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.
|
2023-04-11 12:11:34 -05:00
|
|
|
go-to: "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"})
|
2023-01-18 13:48:24 -06:00
|
|
|
|
|
|
|
// Store the line margin to compare with the settings.html later.
|
2023-05-10 03:56:59 -05:00
|
|
|
store-css: (".setting-line", {"margin": setting_line_margin})
|
2023-01-18 13:48:24 -06:00
|
|
|
|
2022-01-19 16:06:17 -06:00
|
|
|
// 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.
|
2024-04-08 05:14:41 -05:00
|
|
|
// If we are on the settings page, the menu doesn't work the same so we set
|
|
|
|
// the theme manually.
|
|
|
|
set-local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"}
|
|
|
|
// We reload the page so the local storage settings are being used.
|
|
|
|
reload:
|
|
|
|
|
2022-04-29 08:07:47 -05:00
|
|
|
click: "#settings-menu"
|
|
|
|
wait-for: "#settings"
|
|
|
|
|
|
|
|
// We check that the "Use system theme" is disabled.
|
2022-11-13 08:50:02 -06:00
|
|
|
assert-property: ("#theme-system-preference", {"checked": "false"})
|
2022-04-29 08:07:47 -05:00
|
|
|
// Meaning that only the "theme" menu is showing up.
|
2023-01-23 11:44:01 -06:00
|
|
|
assert: "#theme.setting-line:not(.hidden)"
|
|
|
|
assert: "#preferred-dark-theme.setting-line.hidden"
|
|
|
|
assert: "#preferred-light-theme.setting-line.hidden"
|
2022-04-29 08:07:47 -05:00
|
|
|
|
|
|
|
// We check that the correct theme is selected.
|
2023-01-23 11:44:01 -06:00
|
|
|
assert-property: ("#theme .setting-radio-choices #theme-dark", {"checked": "true"})
|
2022-04-29 08:07:47 -05:00
|
|
|
|
2022-05-30 05:12:29 -05:00
|
|
|
// Some style checks...
|
2022-11-11 10:57:58 -06:00
|
|
|
move-cursor-to: "#settings-menu > a"
|
|
|
|
// First we check the "default" display for radio buttons.
|
2022-05-30 05:12:29 -05:00
|
|
|
assert-css: (
|
|
|
|
"#theme-dark",
|
|
|
|
{
|
2023-06-24 07:47:16 -05:00
|
|
|
"border-color": "#999",
|
|
|
|
"box-shadow": "#353535 0px 0px 0px 3px inset",
|
2023-04-11 14:25:36 -05:00
|
|
|
"border-width": "2px",
|
2022-05-30 05:12:29 -05:00
|
|
|
},
|
|
|
|
)
|
2023-06-24 07:47:16 -05:00
|
|
|
assert-css: ("#theme-light", {"border-color": "#999", "box-shadow": "none"})
|
2022-11-11 10:57:58 -06:00
|
|
|
// Let's start with the hover for radio buttons.
|
2022-05-30 05:12:29 -05:00
|
|
|
move-cursor-to: "#theme-dark"
|
|
|
|
assert-css: (
|
|
|
|
"#theme-dark",
|
|
|
|
{
|
2023-06-24 07:47:16 -05:00
|
|
|
"border-color": "#2196f3",
|
|
|
|
"box-shadow": "#353535 0px 0px 0px 3px inset",
|
2023-04-11 14:25:36 -05:00
|
|
|
"border-width": "2px",
|
2022-05-30 05:12:29 -05:00
|
|
|
},
|
|
|
|
)
|
|
|
|
move-cursor-to: "#theme-light"
|
2023-04-11 14:25:36 -05:00
|
|
|
assert-css: (
|
|
|
|
"#theme-light",
|
|
|
|
{
|
2023-06-24 07:47:16 -05:00
|
|
|
"border-color": "#2196f3",
|
2023-04-11 14:25:36 -05:00
|
|
|
"box-shadow": "none",
|
|
|
|
"border-width": "2px",
|
|
|
|
}
|
|
|
|
)
|
2022-05-30 05:12:29 -05:00
|
|
|
move-cursor-to: "#theme-ayu"
|
2022-11-11 10:57:58 -06:00
|
|
|
// Let's now check with the focus for radio buttons.
|
2022-05-30 05:12:29 -05:00
|
|
|
focus: "#theme-dark"
|
|
|
|
assert-css: (
|
|
|
|
"#theme-dark",
|
|
|
|
{
|
2023-06-24 07:47:16 -05:00
|
|
|
"border-color": "#999",
|
|
|
|
"box-shadow": "#353535 0px 0px 0px 3px inset, #2196f3 0px 0px 2px 2px",
|
2023-04-11 14:25:36 -05:00
|
|
|
"border-width": "2px",
|
2022-05-30 05:12:29 -05:00
|
|
|
},
|
|
|
|
)
|
|
|
|
focus: "#theme-light"
|
|
|
|
assert-css: (
|
|
|
|
"#theme-light",
|
|
|
|
{
|
2023-06-24 07:47:16 -05:00
|
|
|
"border-color": "#999",
|
|
|
|
"box-shadow": "#2196f3 0px 0px 1px 1px",
|
2023-04-11 14:25:36 -05:00
|
|
|
"border-width": "2px",
|
2022-05-30 05:12:29 -05:00
|
|
|
},
|
|
|
|
)
|
2022-11-11 10:57:58 -06:00
|
|
|
// Now we check we both focus and hover for radio buttons.
|
2022-05-30 05:12:29 -05:00
|
|
|
move-cursor-to: "#theme-dark"
|
|
|
|
focus: "#theme-dark"
|
|
|
|
assert-css: (
|
|
|
|
"#theme-dark",
|
|
|
|
{
|
2023-06-24 07:47:16 -05:00
|
|
|
"border-color": "#2196f3",
|
|
|
|
"box-shadow": "#353535 0px 0px 0px 3px inset, #2196f3 0px 0px 2px 2px",
|
2023-04-11 14:25:36 -05:00
|
|
|
"border-width": "2px",
|
2022-05-30 05:12:29 -05:00
|
|
|
},
|
|
|
|
)
|
|
|
|
move-cursor-to: "#theme-light"
|
|
|
|
focus: "#theme-light"
|
|
|
|
assert-css: (
|
|
|
|
"#theme-light",
|
|
|
|
{
|
2023-06-24 07:47:16 -05:00
|
|
|
"border-color": "#2196f3",
|
|
|
|
"box-shadow": "#2196f3 0px 0px 1px 1px",
|
2023-04-11 14:25:36 -05:00
|
|
|
"border-width": "2px",
|
2022-11-11 10:57:58 -06:00
|
|
|
},
|
|
|
|
)
|
2023-01-23 11:44:01 -06:00
|
|
|
// Now we check the setting-radio-name is on a different line than the label.
|
2023-01-17 13:09:38 -06:00
|
|
|
compare-elements-position-near: (
|
2023-01-23 11:44:01 -06:00
|
|
|
"#theme .setting-radio-name",
|
|
|
|
"#theme .setting-radio-choices",
|
2023-01-17 13:09:38 -06:00
|
|
|
{"x": 1}
|
|
|
|
)
|
|
|
|
compare-elements-position-near-false: (
|
2023-01-23 11:44:01 -06:00
|
|
|
"#theme .setting-radio-name",
|
|
|
|
"#theme .setting-radio-choices",
|
2023-01-17 13:09:38 -06:00
|
|
|
{"y": 1}
|
|
|
|
)
|
|
|
|
// Now we check that the label positions are all on the same line.
|
|
|
|
compare-elements-position-near: (
|
2023-01-23 11:44:01 -06:00
|
|
|
"#theme .setting-radio-choices #theme-light",
|
|
|
|
"#theme .setting-radio-choices #theme-dark",
|
2023-01-17 13:09:38 -06:00
|
|
|
{"y": 1}
|
|
|
|
)
|
|
|
|
compare-elements-position-near: (
|
2023-01-23 11:44:01 -06:00
|
|
|
"#theme .setting-radio-choices #theme-dark",
|
|
|
|
"#theme .setting-radio-choices #theme-ayu",
|
2023-01-17 13:09:38 -06:00
|
|
|
{"y": 1}
|
|
|
|
)
|
|
|
|
compare-elements-position-near: (
|
2023-01-23 11:44:01 -06:00
|
|
|
"#theme .setting-radio-choices #theme-ayu",
|
|
|
|
"#theme .setting-radio-choices #theme-system-preference",
|
2023-01-17 13:09:38 -06:00
|
|
|
{"y": 1}
|
|
|
|
)
|
2022-11-11 10:57:58 -06:00
|
|
|
|
|
|
|
// First we check the "default" display for toggles.
|
|
|
|
assert-css: (
|
|
|
|
"#auto-hide-large-items",
|
|
|
|
{
|
2023-06-24 07:47:16 -05:00
|
|
|
"background-color": "#2196f3",
|
|
|
|
"border-color": "#999",
|
2023-04-11 14:25:36 -05:00
|
|
|
// 1px border when checked
|
|
|
|
"border-width": "1px",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
assert-css: (
|
|
|
|
"#auto-hide-method-docs",
|
|
|
|
{
|
|
|
|
"background-color": "rgba(0, 0, 0, 0)",
|
2023-06-24 07:47:16 -05:00
|
|
|
"border-color": "#999",
|
2023-04-11 14:25:36 -05:00
|
|
|
// 2px border when unchecked
|
|
|
|
"border-width": "2px",
|
2022-11-11 10:57:58 -06:00
|
|
|
},
|
|
|
|
)
|
|
|
|
// Let's start with the hover for toggles.
|
|
|
|
move-cursor-to: "#auto-hide-large-items"
|
|
|
|
assert-css: (
|
|
|
|
"#auto-hide-large-items",
|
|
|
|
{
|
2023-06-24 07:47:16 -05:00
|
|
|
"background-color": "#2196f3",
|
|
|
|
"border-color": "#2196f3",
|
2023-04-11 14:25:36 -05:00
|
|
|
// 1px border when checked
|
|
|
|
"border-width": "1px",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
move-cursor-to: "#auto-hide-method-docs"
|
|
|
|
assert-css: (
|
|
|
|
"#auto-hide-method-docs",
|
|
|
|
{
|
|
|
|
"background-color": "rgba(0, 0, 0, 0)",
|
2023-06-24 07:47:16 -05:00
|
|
|
"border-color": "#2196f3",
|
2023-04-11 14:25:36 -05:00
|
|
|
// 2px border when unchecked
|
|
|
|
"border-width": "2px",
|
2022-11-11 10:57:58 -06:00
|
|
|
},
|
|
|
|
)
|
|
|
|
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",
|
|
|
|
{
|
2023-06-24 07:47:16 -05:00
|
|
|
"background-color": "#2196f3",
|
|
|
|
"border-color": "#999",
|
|
|
|
"box-shadow": "#2196f3 0px 0px 1px 1px",
|
2023-04-11 14:25:36 -05:00
|
|
|
// 1px border when checked
|
|
|
|
"border-width": "1px",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
focus: "#auto-hide-method-docs"
|
|
|
|
assert-css: (
|
|
|
|
"#auto-hide-method-docs",
|
|
|
|
{
|
|
|
|
"background-color": "rgba(0, 0, 0, 0)",
|
2023-06-24 07:47:16 -05:00
|
|
|
"border-color": "#999",
|
|
|
|
"box-shadow": "#2196f3 0px 0px 1px 1px",
|
2023-04-11 14:25:36 -05:00
|
|
|
// 2px border when unchecked
|
|
|
|
"border-width": "2px",
|
2022-11-11 10:57:58 -06:00
|
|
|
},
|
|
|
|
)
|
|
|
|
// 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",
|
|
|
|
{
|
2023-06-24 07:47:16 -05:00
|
|
|
"background-color": "#2196f3",
|
|
|
|
"border-color": "#2196f3",
|
|
|
|
"box-shadow": "#2196f3 0px 0px 1px 1px",
|
2023-04-11 14:25:36 -05:00
|
|
|
// 1px border when checked
|
|
|
|
"border-width": "1px",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
move-cursor-to: "#auto-hide-method-docs"
|
|
|
|
focus: "#auto-hide-method-docs"
|
|
|
|
assert-css: (
|
|
|
|
"#auto-hide-method-docs",
|
|
|
|
{
|
|
|
|
"background-color": "rgba(0, 0, 0, 0)",
|
2023-06-24 07:47:16 -05:00
|
|
|
"border-color": "#2196f3",
|
|
|
|
"box-shadow": "#2196f3 0px 0px 1px 1px",
|
2023-04-11 14:25:36 -05:00
|
|
|
// 2px border when unchecked
|
|
|
|
"border-width": "2px",
|
2022-11-11 10:57:58 -06:00
|
|
|
},
|
|
|
|
)
|
2022-05-30 05:12:29 -05:00
|
|
|
|
2022-04-29 08:07:47 -05:00
|
|
|
// We now switch the display.
|
2022-11-13 08:50:02 -06:00
|
|
|
click: "#theme-system-preference"
|
2022-04-29 08:07:47 -05:00
|
|
|
// Wait for the hidden element to show up.
|
2023-01-23 11:44:01 -06:00
|
|
|
wait-for: "#preferred-dark-theme.setting-line:not(.hidden)"
|
|
|
|
assert: "#preferred-light-theme.setting-line:not(.hidden)"
|
2022-04-29 08:07:47 -05:00
|
|
|
|
|
|
|
// We check their text as well.
|
2023-01-23 11:44:01 -06: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 04:29:21 -05:00
|
|
|
|
2022-11-10 17:51:14 -06:00
|
|
|
// We now check that clicking on the toggles' text is like clicking on the checkbox.
|
2022-05-23 09:53:44 -05:00
|
|
|
// To test it, we use the "Disable keyboard shortcuts".
|
2023-04-11 12:11:34 -05:00
|
|
|
set-local-storage: {"rustdoc-disable-shortcuts": "false"}
|
2023-01-23 11:44:01 -06:00
|
|
|
click: ".setting-line:last-child .setting-check span"
|
2022-05-23 09:53:44 -05:00
|
|
|
assert-local-storage: {"rustdoc-disable-shortcuts": "true"}
|
|
|
|
|
2023-04-21 18:28:05 -05:00
|
|
|
// We now check that focusing a toggle and pressing Space is like clicking on it.
|
|
|
|
assert-local-storage: {"rustdoc-disable-shortcuts": "true"}
|
|
|
|
focus: ".setting-line:last-child .setting-check input"
|
|
|
|
press-key: "Space"
|
|
|
|
assert-local-storage: {"rustdoc-disable-shortcuts": "false"}
|
|
|
|
focus: ".setting-line:last-child .setting-check input"
|
|
|
|
press-key: "Space"
|
|
|
|
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.
|
2023-01-23 11:44:01 -06:00
|
|
|
click: ".setting-line:last-child .setting-check span"
|
2022-06-28 16:56:24 -05:00
|
|
|
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"})
|
|
|
|
|
2023-01-18 12:41:34 -06: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 12:52:31 -06: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 04:29:21 -05:00
|
|
|
// Now we go to the settings page to check that the CSS is loaded as expected.
|
2023-04-11 12:11:34 -05:00
|
|
|
go-to: "file://" + |DOC_PATH| + "/settings.html"
|
2022-05-11 04:29:21 -05:00
|
|
|
wait-for: "#settings"
|
rustdoc: redesign toolbar and disclosure widgets
This adds labels to the icons and moves them away from the search box.
These changes are made together, because they work together, but are based on
several complaints:
* The [+/-] thing are a Reddit-ism. They don't look like buttons, but look
like syntax
<https://rust-lang.zulipchat.com/#narrow/stream/266220-t-rustdoc/topic/More.20visual.20difference.20for.20the.20.2B.2F-.20.20Icons>,
<https://github.com/rust-lang/rust/issues/59851>
(some of these are laundry lists with more suggestions, but they all
mention [+/-] looking wrong)
* The settings, help, and summary buttons are also too hard to recognize
<https://lwn.net/Articles/987070/>,
<https://github.com/rust-lang/rust/issues/90310>,
<https://github.com/rust-lang/rust/issues/14475#issuecomment-274241997>,
<https://internals.rust-lang.org/t/improve-rustdoc-design/12758>
("Not all functionality is self-explanatory, for example the [+] button in
the top right corner, the theme picker or the settings button.")
The toggle-all and toggle-individual buttons both need done at once, since we
want them to look like they go together. This changes them from both being
[+/-] to both being arrows.
Settings and Help are also migrated, so that the whole group can benefit from
being described using actual words.
Additionally, the Help button is only shown on SERPs, not all the time.
This is done for two major reasons:
* Most of what's in there is search-related. The things that aren't are
keyboard commands, and the search box tells you about that anyway.
Pressing <kbd>?</kbd> will temporarily show the button and its popover.
* I'm trading it off by showing the help button, even on mobile.
It's useful since you can use the search engine suggestions there.
* The three buttons were causing line wrapping on too many desktop layouts.
2024-08-25 01:11:30 -05:00
|
|
|
assert-false: "#settings-menu"
|
2023-05-22 18:41:52 -05:00
|
|
|
assert-css: (".setting-radio", {"cursor": "pointer"})
|
2022-10-15 08:59:11 -05:00
|
|
|
|
|
|
|
assert-attribute-false: ("#settings", {"class": "popover"}, CONTAINS)
|
2024-04-01 14:11:22 -05:00
|
|
|
compare-elements-position: (".sub form", "#settings", ["x"])
|
2022-05-28 11:03:35 -05:00
|
|
|
|
2023-01-18 13:48:24 -06: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 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:
|
2023-04-11 12:11:34 -05:00
|
|
|
set-window-size: (300, 1000)
|
2022-07-27 07:45:07 -05:00
|
|
|
wait-for: "#settings"
|
2023-05-22 18:41:52 -05:00
|
|
|
assert-css: (".setting-radio", {"cursor": "pointer"})
|