2022-10-15 13:59:11 +00: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 18:17:05 +00:00
|
|
|
goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
|
2022-05-30 10:12:29 +00:00
|
|
|
show-text: true // needed when we check for colors below.
|
2022-01-19 22:06:17 +00: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"})
|
2023-01-18 19:48:24 +00:00
|
|
|
|
|
|
|
// Store the line margin to compare with the settings.html later.
|
|
|
|
store-css: (setting_line_margin, ".setting-line", "margin")
|
|
|
|
|
2022-01-19 22:06:17 +00:00
|
|
|
// Let's close it by clicking on the same button.
|
|
|
|
click: "#settings-menu"
|
2022-05-11 21:11:31 +00:00
|
|
|
wait-for-css: ("#settings", {"display": "none"})
|
2022-01-19 22:06:17 +00:00
|
|
|
|
|
|
|
// Let's check that pressing "ESCAPE" is closing it.
|
|
|
|
click: "#settings-menu"
|
2022-05-11 21:11:31 +00:00
|
|
|
wait-for-css: ("#settings", {"display": "block"})
|
2022-01-19 22:06:17 +00:00
|
|
|
press-key: "Escape"
|
2022-05-11 21:11:31 +00:00
|
|
|
wait-for-css: ("#settings", {"display": "none"})
|
2022-01-19 22:06:17 +00:00
|
|
|
|
|
|
|
// Let's click on it when the search results are displayed.
|
|
|
|
focus: ".search-input"
|
|
|
|
write: "test"
|
2022-07-16 11:53:43 +00:00
|
|
|
// To be SURE that the search will be run.
|
|
|
|
press-key: 'Enter'
|
2022-01-19 22:06:17 +00:00
|
|
|
wait-for: "#alternative-display #search"
|
|
|
|
click: "#settings-menu"
|
2022-05-11 21:11:31 +00:00
|
|
|
wait-for-css: ("#settings", {"display": "block"})
|
|
|
|
// Ensure that the search is still displayed.
|
|
|
|
wait-for: "#alternative-display #search"
|
2022-01-19 22:06:17 +00:00
|
|
|
assert: "#main-content.hidden"
|
2022-04-29 13:07:47 +00: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.
|
2022-11-13 14:50:02 +00:00
|
|
|
assert-property: ("#theme-system-preference", {"checked": "false"})
|
2022-04-29 13:07:47 +00:00
|
|
|
// Meaning that only the "theme" menu is showing up.
|
2023-01-23 17:44:01 +00:00
|
|
|
assert: "#theme.setting-line:not(.hidden)"
|
|
|
|
assert: "#preferred-dark-theme.setting-line.hidden"
|
|
|
|
assert: "#preferred-light-theme.setting-line.hidden"
|
2022-04-29 13:07:47 +00:00
|
|
|
|
|
|
|
// We check that the correct theme is selected.
|
2023-01-23 17:44:01 +00:00
|
|
|
assert-property: ("#theme .setting-radio-choices #theme-dark", {"checked": "true"})
|
2022-04-29 13:07:47 +00:00
|
|
|
|
2022-05-30 10:12:29 +00:00
|
|
|
// Some style checks...
|
2022-11-11 16:57:58 +00:00
|
|
|
move-cursor-to: "#settings-menu > a"
|
|
|
|
// First we check the "default" display for radio buttons.
|
2022-05-30 10:12:29 +00:00
|
|
|
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"})
|
2022-11-11 16:57:58 +00:00
|
|
|
// Let's start with the hover for radio buttons.
|
2022-05-30 10:12:29 +00:00
|
|
|
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"
|
2022-11-11 16:57:58 +00:00
|
|
|
// Let's now check with the focus for radio buttons.
|
2022-05-30 10:12:29 +00:00
|
|
|
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",
|
|
|
|
},
|
|
|
|
)
|
2022-11-11 16:57:58 +00:00
|
|
|
// Now we check we both focus and hover for radio buttons.
|
2022-05-30 10:12:29 +00:00
|
|
|
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-11-11 16:57:58 +00:00
|
|
|
},
|
|
|
|
)
|
2023-01-23 17:44:01 +00:00
|
|
|
// Now we check the setting-radio-name is on a different line than the label.
|
2023-01-17 19:09:38 +00:00
|
|
|
compare-elements-position-near: (
|
2023-01-23 17:44:01 +00:00
|
|
|
"#theme .setting-radio-name",
|
|
|
|
"#theme .setting-radio-choices",
|
2023-01-17 19:09:38 +00:00
|
|
|
{"x": 1}
|
|
|
|
)
|
|
|
|
compare-elements-position-near-false: (
|
2023-01-23 17:44:01 +00:00
|
|
|
"#theme .setting-radio-name",
|
|
|
|
"#theme .setting-radio-choices",
|
2023-01-17 19:09:38 +00:00
|
|
|
{"y": 1}
|
|
|
|
)
|
|
|
|
// Now we check that the label positions are all on the same line.
|
|
|
|
compare-elements-position-near: (
|
2023-01-23 17:44:01 +00:00
|
|
|
"#theme .setting-radio-choices #theme-light",
|
|
|
|
"#theme .setting-radio-choices #theme-dark",
|
2023-01-17 19:09:38 +00:00
|
|
|
{"y": 1}
|
|
|
|
)
|
|
|
|
compare-elements-position-near: (
|
2023-01-23 17:44:01 +00:00
|
|
|
"#theme .setting-radio-choices #theme-dark",
|
|
|
|
"#theme .setting-radio-choices #theme-ayu",
|
2023-01-17 19:09:38 +00:00
|
|
|
{"y": 1}
|
|
|
|
)
|
|
|
|
compare-elements-position-near: (
|
2023-01-23 17:44:01 +00:00
|
|
|
"#theme .setting-radio-choices #theme-ayu",
|
|
|
|
"#theme .setting-radio-choices #theme-system-preference",
|
2023-01-17 19:09:38 +00:00
|
|
|
{"y": 1}
|
|
|
|
)
|
2022-11-11 16:57:58 +00:00
|
|
|
|
|
|
|
// First we check the "default" display for toggles.
|
|
|
|
assert-css: (
|
|
|
|
"#auto-hide-large-items",
|
|
|
|
{
|
|
|
|
"background-color": "rgb(33, 150, 243)",
|
|
|
|
"border-color": "rgb(221, 221, 221)",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
// Let's start with the hover for toggles.
|
|
|
|
move-cursor-to: "#auto-hide-large-items"
|
|
|
|
assert-css: (
|
|
|
|
"#auto-hide-large-items",
|
|
|
|
{
|
|
|
|
"background-color": "rgb(33, 150, 243)",
|
|
|
|
"border-color": "rgb(33, 150, 243)",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
move-cursor-to: "#settings-menu > a"
|
|
|
|
// Let's now check with the focus for toggles.
|
|
|
|
focus: "#auto-hide-large-items"
|
|
|
|
assert-css: (
|
|
|
|
"#auto-hide-large-items",
|
|
|
|
{
|
|
|
|
"background-color": "rgb(33, 150, 243)",
|
|
|
|
"border-color": "rgb(221, 221, 221)",
|
|
|
|
"box-shadow": "rgb(33, 150, 243) 0px 0px 1px 1px",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
// Now we check we both focus and hover for toggles.
|
|
|
|
move-cursor-to: "#auto-hide-large-items"
|
|
|
|
focus: "#auto-hide-large-items"
|
|
|
|
assert-css: (
|
|
|
|
"#auto-hide-large-items",
|
|
|
|
{
|
|
|
|
"background-color": "rgb(33, 150, 243)",
|
|
|
|
"border-color": "rgb(33, 150, 243)",
|
|
|
|
"box-shadow": "rgb(33, 150, 243) 0px 0px 1px 1px",
|
|
|
|
},
|
|
|
|
)
|
2022-05-30 10:12:29 +00:00
|
|
|
|
2022-04-29 13:07:47 +00:00
|
|
|
// We now switch the display.
|
2022-11-13 14:50:02 +00:00
|
|
|
click: "#theme-system-preference"
|
2022-04-29 13:07:47 +00:00
|
|
|
// Wait for the hidden element to show up.
|
2023-01-23 17:44:01 +00:00
|
|
|
wait-for: "#preferred-dark-theme.setting-line:not(.hidden)"
|
|
|
|
assert: "#preferred-light-theme.setting-line:not(.hidden)"
|
2022-04-29 13:07:47 +00:00
|
|
|
|
|
|
|
// We check their text as well.
|
2023-01-23 17:44:01 +00:00
|
|
|
assert-text: ("#preferred-dark-theme .setting-radio-name", "Preferred dark theme")
|
|
|
|
assert-text: ("#preferred-light-theme .setting-radio-name", "Preferred light theme")
|
2022-05-11 09:29:21 +00:00
|
|
|
|
2022-11-10 23:51:14 +00:00
|
|
|
// We now check that clicking on the toggles' text is like clicking on the checkbox.
|
2022-05-23 14:53:44 +00:00
|
|
|
// To test it, we use the "Disable keyboard shortcuts".
|
|
|
|
local-storage: {"rustdoc-disable-shortcuts": "false"}
|
2023-01-23 17:44:01 +00:00
|
|
|
click: ".setting-line:last-child .setting-check span"
|
2022-05-23 14:53:44 +00:00
|
|
|
assert-local-storage: {"rustdoc-disable-shortcuts": "true"}
|
|
|
|
|
2022-06-28 21:56:24 +00:00
|
|
|
// Make sure that "Disable keyboard shortcuts" actually took effect.
|
2022-06-29 00:30:58 +00:00
|
|
|
press-key: "Escape"
|
2022-06-28 21:56:24 +00:00
|
|
|
press-key: "?"
|
2022-06-29 00:30:58 +00:00
|
|
|
assert-false: "#help-button .popover"
|
2022-06-28 21:56:24 +00:00
|
|
|
wait-for-css: ("#settings-menu .popover", {"display": "block"})
|
|
|
|
|
|
|
|
// Now turn keyboard shortcuts back on, and see if they work.
|
2023-01-23 17:44:01 +00:00
|
|
|
click: ".setting-line:last-child .setting-check span"
|
2022-06-28 21:56:24 +00:00
|
|
|
assert-local-storage: {"rustdoc-disable-shortcuts": "false"}
|
2022-06-29 00:30:58 +00:00
|
|
|
press-key: "Escape"
|
2022-06-28 21:56:24 +00:00
|
|
|
press-key: "?"
|
|
|
|
wait-for-css: ("#help-button .popover", {"display": "block"})
|
|
|
|
assert-css: ("#settings-menu .popover", {"display": "none"})
|
|
|
|
|
2023-01-18 18:41:34 +00:00
|
|
|
// Now switch back to the settings popover, and make sure the keyboard
|
|
|
|
// shortcut works when a check box is selected.
|
|
|
|
click: "#settings-menu > a"
|
|
|
|
wait-for-css: ("#settings-menu .popover", {"display": "block"})
|
|
|
|
focus: "#auto-hide-large-items"
|
|
|
|
press-key: "?"
|
|
|
|
wait-for-css: ("#settings-menu .popover", {"display": "none"})
|
|
|
|
wait-for-css: ("#help-button .popover", {"display": "block"})
|
|
|
|
|
2023-01-18 18:52:31 +00:00
|
|
|
// Now switch back to the settings popover, and make sure the keyboard
|
|
|
|
// shortcut works when a check box is selected.
|
|
|
|
click: "#settings-menu > a"
|
|
|
|
wait-for-css: ("#settings-menu .popover", {"display": "block"})
|
|
|
|
wait-for-css: ("#help-button .popover", {"display": "none"})
|
|
|
|
focus: "#theme-system-preference"
|
|
|
|
press-key: "?"
|
|
|
|
wait-for-css: ("#settings-menu .popover", {"display": "none"})
|
|
|
|
wait-for-css: ("#help-button .popover", {"display": "block"})
|
|
|
|
|
2022-05-11 09:29:21 +00:00
|
|
|
// Now we go to the settings page to check that the CSS is loaded as expected.
|
2022-10-07 18:17:05 +00:00
|
|
|
goto: "file://" + |DOC_PATH| + "/settings.html"
|
2022-05-11 09:29:21 +00:00
|
|
|
wait-for: "#settings"
|
2022-11-10 23:51:14 +00:00
|
|
|
assert-css: (".setting-line", {"position": "relative"})
|
2022-10-15 13:59:11 +00:00
|
|
|
|
|
|
|
assert-attribute-false: ("#settings", {"class": "popover"}, CONTAINS)
|
2022-10-20 20:22:36 +00:00
|
|
|
compare-elements-position: (".sub form", "#settings", ("x"))
|
2022-05-28 16:03:35 +00:00
|
|
|
|
2023-01-18 19:48:24 +00:00
|
|
|
// Check that setting-line has the same margin in this mode as in the popover.
|
|
|
|
assert-css: (".setting-line", {"margin": |setting_line_margin|})
|
|
|
|
|
2022-05-28 16:03:35 +00: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 12:45:07 +00:00
|
|
|
javascript: true
|
|
|
|
|
|
|
|
// Check for the display on small screen
|
|
|
|
show-text: true
|
|
|
|
reload:
|
|
|
|
size: (300, 1000)
|
|
|
|
click: "#settings-menu"
|
|
|
|
wait-for: "#settings"
|
2022-11-10 23:51:14 +00:00
|
|
|
assert-css: (".setting-line", {"position": "relative"})
|