File tree 2 files changed +25
-0
lines changed
src/librustdoc/html/static/js
2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -153,6 +153,7 @@ const updateTheme = (function() {
153
153
if ( getSettingValue ( "use-system-theme" ) !== "false" ) {
154
154
const lightTheme = getSettingValue ( "preferred-light-theme" ) || "light" ;
155
155
const darkTheme = getSettingValue ( "preferred-dark-theme" ) || "dark" ;
156
+ updateLocalStorage ( "use-system-theme" , "true" ) ;
156
157
157
158
// use light theme if user prefers it, or has no preference
158
159
switchTheme ( mql . matches ? darkTheme : lightTheme , true ) ;
Original file line number Diff line number Diff line change
1
+ // Ensure that the theme picker always starts with the actual defaults.
2
+ goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
3
+ click: "#settings-menu"
4
+ wait-for: "#theme-system-preference"
5
+ assert: "#theme-system-preference:checked"
6
+ assert: "#preferred-light-theme-light:checked"
7
+ assert: "#preferred-dark-theme-dark:checked"
8
+ assert-false: "#preferred-dark-theme-ayu:checked"
9
+
10
+ // Test legacy migration from old theme setup without system-preference matching.
11
+ // See https://github.com/rust-lang/rust/pull/77809#issuecomment-707875732
12
+ local-storage: {
13
+ "rustdoc-preferred-light-theme": null,
14
+ "rustdoc-preferred-dark-theme": null,
15
+ "rustdoc-use-system-theme": null,
16
+ "rustdoc-theme": "ayu"
17
+ }
18
+ goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
19
+ click: "#settings-menu"
20
+ wait-for: "#theme-system-preference"
21
+ assert: "#theme-system-preference:checked"
22
+ assert: "#preferred-light-theme-light:checked"
23
+ assert-false: "#preferred-dark-theme-dark:checked"
24
+ assert: "#preferred-dark-theme-ayu:checked"
You can’t perform that action at this time.
0 commit comments