fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
10.1 KiB325 linesraw
1// This test ensures that the settings menu display is working as expected and that
2// the settings page is also rendered as expected.
3go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
4show-text: true // needed when we check for colors below.
5// First, we check that the settings page doesn't exist.
6assert-false: "#settings"
7// We now click on the settings button.
8click: "#settings-menu"
9wait-for: "#settings"
10assert-css: ("#settings", {"display": "block"})
11
12// Store the line margin to compare with the settings.html later.
13store-css: (".setting-line", {"margin": setting_line_margin})
14
15// Let's close it by clicking on the same button.
16click: "#settings-menu"
17wait-for-css: ("#settings", {"display": "none"})
18
19// Let's check that pressing "ESCAPE" is closing it.
20click: "#settings-menu"
21wait-for-css: ("#settings", {"display": "block"})
22press-key: "Escape"
23wait-for-css: ("#settings", {"display": "none"})
24
25// Let's click on it when the search results are displayed.
26focus: ".search-input"
27write: "test"
28// To be SURE that the search will be run.
29press-key: 'Enter'
30wait-for: "#alternative-display #search"
31click: "#settings-menu"
32wait-for-css: ("#settings", {"display": "block"})
33// Ensure that the search is still displayed.
34wait-for: "#alternative-display #search"
35assert: "#main-content.hidden"
36
37// Now let's check the content of the settings menu.
38set-local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"}
39reload:
40click: "#settings-menu"
41wait-for: "#settings"
42
43// We check that the "Use system theme" is disabled.
44assert-property: ("#theme-system-preference", {"checked": "false"})
45// Meaning that only the "theme" menu is showing up.
46assert: "#theme.setting-line:not(.hidden)"
47assert: "#preferred-dark-theme.setting-line.hidden"
48assert: "#preferred-light-theme.setting-line.hidden"
49
50// We check that the correct theme is selected.
51assert-property: ("#theme .setting-radio-choices #theme-dark", {"checked": "true"})
52
53// Some style checks...
54move-cursor-to: "#settings-menu > a"
55// First we check the "default" display for radio buttons.
56assert-css: (
57    "#theme-dark",
58    {
59        "border-color": "#999",
60        "box-shadow": "#353535 0px 0px 0px 3px inset",
61        "border-width": "2px",
62    },
63)
64assert-css: ("#theme-light", {"border-color": "#999", "box-shadow": "none"})
65// Let's start with the hover for radio buttons.
66move-cursor-to: "#theme-dark"
67assert-css: (
68    "#theme-dark",
69    {
70        "border-color": "#2196f3",
71        "box-shadow": "#353535 0px 0px 0px 3px inset",
72        "border-width": "2px",
73    },
74)
75move-cursor-to: "#theme-light"
76assert-css: (
77    "#theme-light",
78    {
79        "border-color": "#2196f3",
80        "box-shadow": "none",
81        "border-width": "2px",
82    }
83)
84move-cursor-to: "#theme-ayu"
85// Let's now check with the focus for radio buttons.
86focus: "#theme-dark"
87assert-css: (
88    "#theme-dark",
89    {
90        "border-color": "#999",
91        "box-shadow": "#353535 0px 0px 0px 3px inset, #2196f3 0px 0px 2px 2px",
92        "border-width": "2px",
93    },
94)
95focus: "#theme-light"
96assert-css: (
97    "#theme-light",
98    {
99        "border-color": "#999",
100        "box-shadow": "#2196f3 0px 0px 1px 1px",
101        "border-width": "2px",
102    },
103)
104// Now we check we both focus and hover for radio buttons.
105move-cursor-to: "#theme-dark"
106focus: "#theme-dark"
107assert-css: (
108    "#theme-dark",
109    {
110        "border-color": "#2196f3",
111        "box-shadow": "#353535 0px 0px 0px 3px inset, #2196f3 0px 0px 2px 2px",
112        "border-width": "2px",
113    },
114)
115move-cursor-to: "#theme-light"
116focus: "#theme-light"
117assert-css: (
118    "#theme-light",
119    {
120        "border-color": "#2196f3",
121        "box-shadow": "#2196f3 0px 0px 1px 1px",
122        "border-width": "2px",
123    },
124)
125// Now we check the setting-radio-name is on a different line than the label.
126compare-elements-position-near: (
127    "#theme .setting-radio-name",
128    "#theme .setting-radio-choices",
129    {"x": 1}
130)
131compare-elements-position-near-false: (
132    "#theme .setting-radio-name",
133    "#theme .setting-radio-choices",
134    {"y": 1}
135)
136// Now we check that the label positions are all on the same line.
137compare-elements-position-near: (
138    "#theme .setting-radio-choices #theme-light",
139    "#theme .setting-radio-choices #theme-dark",
140    {"y": 1}
141)
142compare-elements-position-near: (
143    "#theme .setting-radio-choices #theme-dark",
144    "#theme .setting-radio-choices #theme-ayu",
145    {"y": 1}
146)
147compare-elements-position-near: (
148    "#theme .setting-radio-choices #theme-ayu",
149    "#theme .setting-radio-choices #theme-system-preference",
150    {"y": 1}
151)
152
153// First we check the "default" display for toggles.
154assert-css: (
155    "#auto-hide-large-items",
156    {
157        "background-color": "#2196f3",
158        "border-color": "#999",
159        // 1px border when checked
160        "border-width": "1px",
161    },
162)
163assert-css: (
164    "#auto-hide-method-docs",
165    {
166        "background-color": "rgba(0, 0, 0, 0)",
167        "border-color": "#999",
168        // 2px border when unchecked
169        "border-width": "2px",
170    },
171)
172// Let's start with the hover for toggles.
173move-cursor-to: "#auto-hide-large-items"
174assert-css: (
175    "#auto-hide-large-items",
176    {
177        "background-color": "#2196f3",
178        "border-color": "#2196f3",
179        // 1px border when checked
180        "border-width": "1px",
181    },
182)
183move-cursor-to: "#auto-hide-method-docs"
184assert-css: (
185    "#auto-hide-method-docs",
186    {
187        "background-color": "rgba(0, 0, 0, 0)",
188        "border-color": "#2196f3",
189        // 2px border when unchecked
190        "border-width": "2px",
191    },
192)
193move-cursor-to: "#settings-menu > a"
194// Let's now check with the focus for toggles.
195focus: "#auto-hide-large-items"
196assert-css: (
197    "#auto-hide-large-items",
198    {
199        "background-color": "#2196f3",
200        "border-color": "#999",
201        "box-shadow": "#2196f3 0px 0px 1px 1px",
202        // 1px border when checked
203        "border-width": "1px",
204    },
205)
206focus: "#auto-hide-method-docs"
207assert-css: (
208    "#auto-hide-method-docs",
209    {
210        "background-color": "rgba(0, 0, 0, 0)",
211        "border-color": "#999",
212        "box-shadow": "#2196f3 0px 0px 1px 1px",
213        // 2px border when unchecked
214        "border-width": "2px",
215    },
216)
217// Now we check we both focus and hover for toggles.
218move-cursor-to: "#auto-hide-large-items"
219focus: "#auto-hide-large-items"
220assert-css: (
221    "#auto-hide-large-items",
222    {
223        "background-color": "#2196f3",
224        "border-color": "#2196f3",
225        "box-shadow": "#2196f3 0px 0px 1px 1px",
226        // 1px border when checked
227        "border-width": "1px",
228    },
229)
230move-cursor-to: "#auto-hide-method-docs"
231focus: "#auto-hide-method-docs"
232assert-css: (
233    "#auto-hide-method-docs",
234    {
235        "background-color": "rgba(0, 0, 0, 0)",
236        "border-color": "#2196f3",
237        "box-shadow": "#2196f3 0px 0px 1px 1px",
238        // 2px border when unchecked
239        "border-width": "2px",
240    },
241)
242
243// We now switch the display.
244click: "#theme-system-preference"
245// Wait for the hidden element to show up.
246wait-for: "#preferred-dark-theme.setting-line:not(.hidden)"
247assert: "#preferred-light-theme.setting-line:not(.hidden)"
248
249// We check their text as well.
250assert-text: ("#preferred-dark-theme .setting-radio-name", "Preferred dark theme")
251assert-text: ("#preferred-light-theme .setting-radio-name", "Preferred light theme")
252
253// We now check that clicking on the toggles' text is like clicking on the checkbox.
254// To test it, we use the "Disable keyboard shortcuts".
255set-local-storage: {"rustdoc-disable-shortcuts": "false"}
256click: ".setting-line:last-child .setting-check span"
257assert-local-storage: {"rustdoc-disable-shortcuts": "true"}
258
259// We now check that focusing a toggle and pressing Space is like clicking on it.
260assert-local-storage: {"rustdoc-disable-shortcuts": "true"}
261focus: ".setting-line:last-child .setting-check input"
262press-key: "Space"
263assert-local-storage: {"rustdoc-disable-shortcuts": "false"}
264focus: ".setting-line:last-child .setting-check input"
265press-key: "Space"
266assert-local-storage: {"rustdoc-disable-shortcuts": "true"}
267
268// Make sure that "Disable keyboard shortcuts" actually took effect.
269press-key: "Escape"
270press-key: "?"
271assert-false: "#help-button .popover"
272wait-for-css: ("#settings-menu .popover", {"display": "block"})
273
274// Now turn keyboard shortcuts back on, and see if they work.
275click: ".setting-line:last-child .setting-check span"
276assert-local-storage: {"rustdoc-disable-shortcuts": "false"}
277press-key: "Escape"
278press-key: "?"
279wait-for-css: ("#help-button .popover", {"display": "block"})
280assert-css: ("#settings-menu .popover", {"display": "none"})
281
282// Now switch back to the settings popover, and make sure the keyboard
283// shortcut works when a check box is selected.
284click: "#settings-menu > a"
285wait-for-css: ("#settings-menu .popover", {"display": "block"})
286focus: "#auto-hide-large-items"
287press-key: "?"
288wait-for-css: ("#settings-menu .popover", {"display": "none"})
289wait-for-css: ("#help-button .popover", {"display": "block"})
290
291// Now switch back to the settings popover, and make sure the keyboard
292// shortcut works when a check box is selected.
293click: "#settings-menu > a"
294wait-for-css: ("#settings-menu .popover", {"display": "block"})
295wait-for-css: ("#help-button .popover", {"display": "none"})
296focus: "#theme-system-preference"
297press-key: "?"
298wait-for-css: ("#settings-menu .popover", {"display": "none"})
299wait-for-css: ("#help-button .popover", {"display": "block"})
300
301// Now we go to the settings page to check that the CSS is loaded as expected.
302go-to: "file://" + |DOC_PATH| + "/settings.html"
303wait-for: "#settings"
304assert-css: (".setting-radio", {"cursor": "pointer"})
305
306assert-attribute-false: ("#settings", {"class": "popover"}, CONTAINS)
307compare-elements-position: (".sub form", "#settings", ("x"))
308
309// Check that setting-line has the same margin in this mode as in the popover.
310assert-css: (".setting-line", {"margin": |setting_line_margin|})
311
312// We now check the display with JS disabled.
313assert-false: "noscript section"
314javascript: false
315reload:
316assert-css: ("noscript section", {"display": "block"})
317javascript: true
318
319// Check for the display on small screen
320show-text: true
321reload:
322set-window-size: (300, 1000)
323click: "#settings-menu"
324wait-for: "#settings"
325assert-css: (".setting-radio", {"cursor": "pointer"})