1 // This test ensures that the settings menu display is working as expected and that
2 // the settings page is also rendered as expected.
3 goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
4 show-text: true // needed when we check for colors below.
5 // First, we check that the settings page doesn't exist.
6 assert-false: "#settings"
7 // We now click on the settings button.
8 click: "#settings-menu"
10 assert-css: ("#settings", {"display": "block"})
11 // Let's close it by clicking on the same button.
12 click: "#settings-menu"
13 wait-for-css: ("#settings", {"display": "none"})
15 // Let's check that pressing "ESCAPE" is closing it.
16 click: "#settings-menu"
17 wait-for-css: ("#settings", {"display": "block"})
19 wait-for-css: ("#settings", {"display": "none"})
21 // Let's click on it when the search results are displayed.
22 focus: ".search-input"
24 // To be SURE that the search will be run.
26 wait-for: "#alternative-display #search"
27 click: "#settings-menu"
28 wait-for-css: ("#settings", {"display": "block"})
29 // Ensure that the search is still displayed.
30 wait-for: "#alternative-display #search"
31 assert: "#main-content.hidden"
33 // Now let's check the content of the settings menu.
34 local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"}
36 click: "#settings-menu"
39 // We check that the "Use system theme" is disabled.
40 assert-property: ("#use-system-theme", {"checked": "false"})
41 assert: "//*[@class='setting-line']//span[text()='Use system theme']"
42 // Meaning that only the "theme" menu is showing up.
43 assert: ".setting-line:not(.hidden) #theme"
44 assert: ".setting-line.hidden #preferred-dark-theme"
45 assert: ".setting-line.hidden #preferred-light-theme"
47 // We check that the correct theme is selected.
48 assert-property: ("#theme .choices #theme-dark", {"checked": "true"})
50 // Some style checks...
51 // First we check the "default" display.
55 "border-color": "rgb(221, 221, 221)",
56 "box-shadow": "rgb(53, 53, 53) 0px 0px 0px 3px inset",
59 assert-css: ("#theme-light", {"border-color": "rgb(221, 221, 221)", "box-shadow": "none"})
60 // Let's start with the hover.
61 move-cursor-to: "#theme-dark"
65 "border-color": "rgb(33, 150, 243)",
66 "box-shadow": "rgb(53, 53, 53) 0px 0px 0px 3px inset",
69 move-cursor-to: "#theme-light"
70 assert-css: ("#theme-light", {"border-color": "rgb(33, 150, 243)", "box-shadow": "none"})
71 move-cursor-to: "#theme-ayu"
72 // Let's now check with the focus.
77 "border-color": "rgb(221, 221, 221)",
78 "box-shadow": "rgb(53, 53, 53) 0px 0px 0px 3px inset, rgb(33, 150, 243) 0px 0px 2px 2px",
85 "border-color": "rgb(221, 221, 221)",
86 "box-shadow": "rgb(33, 150, 243) 0px 0px 1px 1px",
89 // Now we check we both focus and hover.
90 move-cursor-to: "#theme-dark"
95 "border-color": "rgb(33, 150, 243)",
96 "box-shadow": "rgb(53, 53, 53) 0px 0px 0px 3px inset, rgb(33, 150, 243) 0px 0px 2px 2px",
99 move-cursor-to: "#theme-light"
100 focus: "#theme-light"
104 "border-color": "rgb(33, 150, 243)",
105 "box-shadow": "rgb(33, 150, 243) 0px 0px 1px 1px",
109 // We now switch the display.
110 click: "#use-system-theme"
111 // Wait for the hidden element to show up.
112 wait-for: ".setting-line:not(.hidden) #preferred-dark-theme"
113 assert: ".setting-line:not(.hidden) #preferred-light-theme"
114 // Check that the theme picking is hidden.
115 assert: ".setting-line.hidden #theme"
117 // We check their text as well.
118 assert-text: ("#preferred-dark-theme .setting-name", "Preferred dark theme")
119 assert-text: ("#preferred-light-theme .setting-name", "Preferred light theme")
121 // We now check that clicking on the "sliders"' text is like clicking on the slider.
122 // To test it, we use the "Disable keyboard shortcuts".
123 local-storage: {"rustdoc-disable-shortcuts": "false"}
124 click: ".setting-line:last-child .toggle .label"
125 assert-local-storage: {"rustdoc-disable-shortcuts": "true"}
127 // Make sure that "Disable keyboard shortcuts" actually took effect.
130 assert-false: "#help-button .popover"
131 wait-for-css: ("#settings-menu .popover", {"display": "block"})
133 // Now turn keyboard shortcuts back on, and see if they work.
134 click: ".setting-line:last-child .toggle .label"
135 assert-local-storage: {"rustdoc-disable-shortcuts": "false"}
138 wait-for-css: ("#help-button .popover", {"display": "block"})
139 assert-css: ("#settings-menu .popover", {"display": "none"})
141 // Now we go to the settings page to check that the CSS is loaded as expected.
142 goto: "file://" + |DOC_PATH| + "/settings.html"
143 wait-for: "#settings"
145 ".setting-line .toggle .slider",
146 {"width": "45px", "margin-right": "20px", "border": "0px none rgb(0, 0, 0)"},
149 assert-attribute-false: ("#settings", {"class": "popover"}, CONTAINS)
150 compare-elements-position: (".sub form", "#settings", ("x"))
152 // We now check the display with JS disabled.
153 assert-false: "noscript section"
156 assert-css: ("noscript section", {"display": "block"})
159 // Check for the display on small screen
163 click: "#settings-menu"
164 wait-for: "#settings"
165 assert-css: ("#settings .slider", {"width": "45px"}, ALL)