2022-10-15 08:59:11 -05:00
|
|
|
// This test ensures that the settings menu display is working as expected and that
|
|
|
|
// the settings page is also rendered as expected.
|
2022-10-07 13:17:05 -05:00
|
|
|
goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
|
2022-05-30 05:12:29 -05:00
|
|
|
show-text: true // needed when we check for colors below.
|
2022-01-19 16:06:17 -06:00
|
|
|
// First, we check that the settings page doesn't exist.
|
|
|
|
assert-false: "#settings"
|
|
|
|
// We now click on the settings button.
|
|
|
|
click: "#settings-menu"
|
|
|
|
wait-for: "#settings"
|
|
|
|
assert-css: ("#settings", {"display": "block"})
|
|
|
|
// Let's close it by clicking on the same button.
|
|
|
|
click: "#settings-menu"
|
2022-05-11 16:11:31 -05:00
|
|
|
wait-for-css: ("#settings", {"display": "none"})
|
2022-01-19 16:06:17 -06:00
|
|
|
|
|
|
|
// Let's check that pressing "ESCAPE" is closing it.
|
|
|
|
click: "#settings-menu"
|
2022-05-11 16:11:31 -05:00
|
|
|
wait-for-css: ("#settings", {"display": "block"})
|
2022-01-19 16:06:17 -06:00
|
|
|
press-key: "Escape"
|
2022-05-11 16:11:31 -05:00
|
|
|
wait-for-css: ("#settings", {"display": "none"})
|
2022-01-19 16:06:17 -06:00
|
|
|
|
|
|
|
// Let's click on it when the search results are displayed.
|
|
|
|
focus: ".search-input"
|
|
|
|
write: "test"
|
2022-07-16 06:53:43 -05:00
|
|
|
// To be SURE that the search will be run.
|
|
|
|
press-key: 'Enter'
|
2022-01-19 16:06:17 -06:00
|
|
|
wait-for: "#alternative-display #search"
|
|
|
|
click: "#settings-menu"
|
2022-05-11 16:11:31 -05:00
|
|
|
wait-for-css: ("#settings", {"display": "block"})
|
|
|
|
// Ensure that the search is still displayed.
|
|
|
|
wait-for: "#alternative-display #search"
|
2022-01-19 16:06:17 -06:00
|
|
|
assert: "#main-content.hidden"
|
2022-04-29 08:07:47 -05:00
|
|
|
|
|
|
|
// Now let's check the content of the settings menu.
|
|
|
|
local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"}
|
|
|
|
reload:
|
|
|
|
click: "#settings-menu"
|
|
|
|
wait-for: "#settings"
|
|
|
|
|
|
|
|
// We check that the "Use system theme" is disabled.
|
|
|
|
assert-property: ("#use-system-theme", {"checked": "false"})
|
2022-05-23 09:53:44 -05:00
|
|
|
assert: "//*[@class='setting-line']//span[text()='Use system theme']"
|
2022-04-29 08:07:47 -05:00
|
|
|
// Meaning that only the "theme" menu is showing up.
|
|
|
|
assert: ".setting-line:not(.hidden) #theme"
|
|
|
|
assert: ".setting-line.hidden #preferred-dark-theme"
|
|
|
|
assert: ".setting-line.hidden #preferred-light-theme"
|
|
|
|
|
|
|
|
// We check that the correct theme is selected.
|
|
|
|
assert-property: ("#theme .choices #theme-dark", {"checked": "true"})
|
|
|
|
|
2022-05-30 05:12:29 -05:00
|
|
|
// Some style checks...
|
|
|
|
// First we check the "default" display.
|
|
|
|
assert-css: (
|
|
|
|
"#theme-dark",
|
|
|
|
{
|
|
|
|
"border-color": "rgb(221, 221, 221)",
|
|
|
|
"box-shadow": "rgb(53, 53, 53) 0px 0px 0px 3px inset",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
assert-css: ("#theme-light", {"border-color": "rgb(221, 221, 221)", "box-shadow": "none"})
|
|
|
|
// Let's start with the hover.
|
|
|
|
move-cursor-to: "#theme-dark"
|
|
|
|
assert-css: (
|
|
|
|
"#theme-dark",
|
|
|
|
{
|
|
|
|
"border-color": "rgb(33, 150, 243)",
|
|
|
|
"box-shadow": "rgb(53, 53, 53) 0px 0px 0px 3px inset",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
move-cursor-to: "#theme-light"
|
|
|
|
assert-css: ("#theme-light", {"border-color": "rgb(33, 150, 243)", "box-shadow": "none"})
|
|
|
|
move-cursor-to: "#theme-ayu"
|
|
|
|
// Let's now check with the focus.
|
|
|
|
focus: "#theme-dark"
|
|
|
|
assert-css: (
|
|
|
|
"#theme-dark",
|
|
|
|
{
|
|
|
|
"border-color": "rgb(221, 221, 221)",
|
|
|
|
"box-shadow": "rgb(53, 53, 53) 0px 0px 0px 3px inset, rgb(33, 150, 243) 0px 0px 2px 2px",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
focus: "#theme-light"
|
|
|
|
assert-css: (
|
|
|
|
"#theme-light",
|
|
|
|
{
|
|
|
|
"border-color": "rgb(221, 221, 221)",
|
|
|
|
"box-shadow": "rgb(33, 150, 243) 0px 0px 1px 1px",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
// Now we check we both focus and hover.
|
|
|
|
move-cursor-to: "#theme-dark"
|
|
|
|
focus: "#theme-dark"
|
|
|
|
assert-css: (
|
|
|
|
"#theme-dark",
|
|
|
|
{
|
|
|
|
"border-color": "rgb(33, 150, 243)",
|
|
|
|
"box-shadow": "rgb(53, 53, 53) 0px 0px 0px 3px inset, rgb(33, 150, 243) 0px 0px 2px 2px",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
move-cursor-to: "#theme-light"
|
|
|
|
focus: "#theme-light"
|
|
|
|
assert-css: (
|
|
|
|
"#theme-light",
|
|
|
|
{
|
|
|
|
"border-color": "rgb(33, 150, 243)",
|
|
|
|
"box-shadow": "rgb(33, 150, 243) 0px 0px 1px 1px",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
2022-04-29 08:07:47 -05:00
|
|
|
// We now switch the display.
|
|
|
|
click: "#use-system-theme"
|
|
|
|
// Wait for the hidden element to show up.
|
|
|
|
wait-for: ".setting-line:not(.hidden) #preferred-dark-theme"
|
|
|
|
assert: ".setting-line:not(.hidden) #preferred-light-theme"
|
|
|
|
// Check that the theme picking is hidden.
|
|
|
|
assert: ".setting-line.hidden #theme"
|
|
|
|
|
|
|
|
// We check their text as well.
|
|
|
|
assert-text: ("#preferred-dark-theme .setting-name", "Preferred dark theme")
|
|
|
|
assert-text: ("#preferred-light-theme .setting-name", "Preferred light theme")
|
2022-05-11 04:29:21 -05:00
|
|
|
|
2022-05-23 09:53:44 -05:00
|
|
|
// We now check that clicking on the "sliders"' text is like clicking on the slider.
|
|
|
|
// To test it, we use the "Disable keyboard shortcuts".
|
|
|
|
local-storage: {"rustdoc-disable-shortcuts": "false"}
|
|
|
|
click: ".setting-line:last-child .toggle .label"
|
|
|
|
assert-local-storage: {"rustdoc-disable-shortcuts": "true"}
|
|
|
|
|
2022-06-28 16:56:24 -05:00
|
|
|
// Make sure that "Disable keyboard shortcuts" actually took effect.
|
2022-06-28 19:30:58 -05:00
|
|
|
press-key: "Escape"
|
2022-06-28 16:56:24 -05:00
|
|
|
press-key: "?"
|
2022-06-28 19:30:58 -05:00
|
|
|
assert-false: "#help-button .popover"
|
2022-06-28 16:56:24 -05:00
|
|
|
wait-for-css: ("#settings-menu .popover", {"display": "block"})
|
|
|
|
|
|
|
|
// Now turn keyboard shortcuts back on, and see if they work.
|
|
|
|
click: ".setting-line:last-child .toggle .label"
|
|
|
|
assert-local-storage: {"rustdoc-disable-shortcuts": "false"}
|
2022-06-28 19:30:58 -05:00
|
|
|
press-key: "Escape"
|
2022-06-28 16:56:24 -05:00
|
|
|
press-key: "?"
|
|
|
|
wait-for-css: ("#help-button .popover", {"display": "block"})
|
|
|
|
assert-css: ("#settings-menu .popover", {"display": "none"})
|
|
|
|
|
2022-05-11 04:29:21 -05:00
|
|
|
// Now we go to the settings page to check that the CSS is loaded as expected.
|
2022-10-07 13:17:05 -05:00
|
|
|
goto: "file://" + |DOC_PATH| + "/settings.html"
|
2022-05-11 04:29:21 -05:00
|
|
|
wait-for: "#settings"
|
2022-10-15 08:59:11 -05:00
|
|
|
assert-css: (
|
|
|
|
".setting-line .toggle .slider",
|
|
|
|
{"width": "45px", "margin-right": "20px", "border": "0px none rgb(0, 0, 0)"},
|
|
|
|
)
|
|
|
|
|
|
|
|
assert-attribute-false: ("#settings", {"class": "popover"}, CONTAINS)
|
|
|
|
compare-elements-position: (".sub-container", "#settings", ("x"))
|
2022-05-28 11:03:35 -05:00
|
|
|
|
|
|
|
// We now check the display with JS disabled.
|
|
|
|
assert-false: "noscript section"
|
|
|
|
javascript: false
|
|
|
|
reload:
|
|
|
|
assert-css: ("noscript section", {"display": "block"})
|
2022-07-27 07:45:07 -05:00
|
|
|
javascript: true
|
|
|
|
|
|
|
|
// Check for the display on small screen
|
|
|
|
show-text: true
|
|
|
|
reload:
|
|
|
|
size: (300, 1000)
|
|
|
|
click: "#settings-menu"
|
|
|
|
wait-for: "#settings"
|
|
|
|
assert-css: ("#settings .slider", {"width": "45px"}, ALL)
|