mirror of https://github.com/rust-lang/rust.git
rustdoc: add test and bug fix for theme defaults
This commit is contained in:
parent
de74dab880
commit
5cad51c0c5
|
@ -158,6 +158,7 @@ const updateTheme = (function() {
|
|||
if (getSettingValue("use-system-theme") !== "false") {
|
||||
const lightTheme = getSettingValue("preferred-light-theme") || "light";
|
||||
const darkTheme = getSettingValue("preferred-dark-theme") || "dark";
|
||||
updateLocalStorage("use-system-theme", "true");
|
||||
|
||||
if (mql.matches) {
|
||||
use(darkTheme, true);
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
// Ensure that the theme picker always starts with the actual defaults.
|
||||
goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
|
||||
click: "#settings-menu"
|
||||
wait-for: "#theme-system-preference"
|
||||
assert: "#theme-system-preference:checked"
|
||||
assert: "#preferred-light-theme-light:checked"
|
||||
assert: "#preferred-dark-theme-dark:checked"
|
||||
assert-false: "#preferred-dark-theme-ayu:checked"
|
||||
|
||||
// Test legacy migration from old theme setup without system-preference matching.
|
||||
// See https://github.com/rust-lang/rust/pull/77809#issuecomment-707875732
|
||||
local-storage: {
|
||||
"rustdoc-preferred-light-theme": null,
|
||||
"rustdoc-preferred-dark-theme": null,
|
||||
"rustdoc-use-system-theme": null,
|
||||
"rustdoc-theme": "ayu"
|
||||
}
|
||||
goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
|
||||
click: "#settings-menu"
|
||||
wait-for: "#theme-system-preference"
|
||||
assert: "#theme-system-preference:checked"
|
||||
assert: "#preferred-light-theme-light:checked"
|
||||
assert-false: "#preferred-dark-theme-dark:checked"
|
||||
assert: "#preferred-dark-theme-ayu:checked"
|
Loading…
Reference in New Issue