1 // This test checks the position of the `i` for the notable traits.
2 goto: "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html"
4 // We start with a wide screen.
6 // Checking they have the same y position.
7 compare-elements-position: (
8 "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
9 "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
12 // Checking they don't have the same x position.
13 compare-elements-position-false: (
14 "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
15 "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
18 // The `i` should be *after* the type.
20 "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
24 "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
27 // The tooltip should be below the `i`
28 // Also, clicking the tooltip should bring its text into the DOM
29 assert-count: ("//*[@class='notable popover']", 0)
30 click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
31 assert-count: ("//*[@class='notable popover']", 1)
32 compare-elements-position-near: (
33 "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
34 "//*[@class='notable popover']",
37 compare-elements-position-false: (
38 "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
39 "//*[@class='notable popover']",
42 click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
43 move-cursor-to: "//h1"
44 assert-count: ("//*[@class='notable popover']", 0)
46 // Now only the `i` should be on the next line.
48 compare-elements-position-false: (
49 "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
50 "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
54 // Now both the `i` and the struct name should be on the next line.
56 // Checking they have the same y position.
57 compare-elements-position: (
58 "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
59 "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
62 // Checking they don't have the same x position.
63 compare-elements-position-false: (
64 "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
65 "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
68 // The `i` should be *after* the type.
70 "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
74 "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
78 // Checking on mobile now.
80 // Checking they have the same y position.
81 compare-elements-position: (
82 "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
83 "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
86 // Checking they don't have the same x position.
87 compare-elements-position-false: (
88 "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
89 "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
92 // The `i` should be *after* the type.
94 "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
98 "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
101 // The tooltip should STILL be below `i`
102 click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
103 assert-count: ("//*[@class='notable popover']", 1)
104 compare-elements-position-near: (
105 "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
106 "//*[@class='notable popover']",
109 compare-elements-position-false: (
110 "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
111 "//*[@class='notable popover']",
115 "//*[@class='notable popover']",
118 click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
119 move-cursor-to: "//h1"
120 assert-count: ("//*[@class='notable popover']", 0)
122 // Now check the colors.
125 (theme, header_color, content_color, type_color, trait_color),
127 ("goto", "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html"),
128 // This is needed to ensure that the text color is computed.
131 // Setting the theme.
132 ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
133 // We reload the page so the local storage settings are being used.
136 ("move-cursor-to", "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"),
137 ("assert-count", (".notable.popover", 1)),
140 ".notable.popover h3",
141 {"color": |header_color|},
145 ".notable.popover pre",
146 {"color": |content_color|},
150 ".notable.popover pre a.struct",
151 {"color": |type_color|},
155 ".notable.popover pre a.trait",
156 {"color": |trait_color|},
166 "content_color": "rgb(230, 225, 207)",
167 "header_color": "rgb(255, 255, 255)",
168 "type_color": "rgb(255, 160, 165)",
169 "trait_color": "rgb(57, 175, 215)",
177 "content_color": "rgb(221, 221, 221)",
178 "header_color": "rgb(221, 221, 221)",
179 "type_color": "rgb(45, 191, 184)",
180 "trait_color": "rgb(183, 140, 242)",
188 "content_color": "rgb(0, 0, 0)",
189 "header_color": "rgb(0, 0, 0)",
190 "type_color": "rgb(173, 55, 138)",
191 "trait_color": "rgb(110, 79, 201)",
197 // Check that pressing escape works
198 click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
199 move-cursor-to: "//*[@class='notable popover']"
200 assert-count: ("//*[@class='notable popover']", 1)
202 assert-count: ("//*[@class='notable popover']", 0)
203 assert: "#method\.create_an_iterator_from_read .notable-traits:focus"
205 // Check that clicking outside works.
206 click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
207 assert-count: ("//*[@class='notable popover']", 1)
208 click: ".search-input"
209 assert-count: ("//*[@class='notable popover']", 0)
210 assert-false: "#method\.create_an_iterator_from_read .notable-traits:focus"
212 // Check that pressing tab over and over works.
213 click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
214 move-cursor-to: "//*[@class='notable popover']"
215 assert-count: ("//*[@class='notable popover']", 1)
223 assert-count: ("//*[@class='notable popover']", 0)
224 assert: "#method\.create_an_iterator_from_read .notable-traits:focus"
226 // Now we check that the focus isn't given back to the wrong item when opening
228 store-window-property: (scroll, "scrollY")
229 click: "#method\.create_an_iterator_from_read .fn"
230 // We ensure that the scroll position changed.
231 assert-window-property-false: {"scrollY": |scroll|}
232 // Store the new position.
233 store-window-property: (scroll, "scrollY")
234 click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
235 wait-for: "//*[@class='notable popover']"
236 click: "#settings-menu a"
237 click: ".search-input"
238 // We ensure we didn't come back to the previous focused item.
239 assert-window-property-false: {"scrollY": |scroll|}
241 // Same but with Escape handling.
242 store-window-property: (scroll, "scrollY")
243 click: "#method\.create_an_iterator_from_read .fn"
244 // We ensure that the scroll position changed.
245 assert-window-property-false: {"scrollY": |scroll|}
246 // Store the new position.
247 store-window-property: (scroll, "scrollY")
248 click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
249 wait-for: "//*[@class='notable popover']"
250 click: "#settings-menu a"
252 // We ensure we didn't come back to the previous focused item.
253 assert-window-property-false: {"scrollY": |scroll|}
255 // Opening the mobile sidebar should close the popover.
257 click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
258 assert-count: ("//*[@class='notable popover']", 1)
259 click: ".sidebar-menu-toggle"
260 assert: "//*[@class='sidebar shown']"
261 assert-count: ("//*[@class='notable popover']", 0)
262 assert-false: "#method\.create_an_iterator_from_read .notable-traits:focus"
263 // Clicking a notable popover should close the sidebar.
264 click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
265 assert-count: ("//*[@class='notable popover']", 1)
266 assert-false: "//*[@class='sidebar shown']"
268 // Also check the focus handling for the help button.
271 assert-count: ("//*[@class='notable popover']", 0)
272 click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
273 assert-count: ("//*[@class='notable popover']", 1)
274 click: "#help-button a"
275 assert-count: ("//*[@class='notable popover']", 0)
276 assert-false: "#method\.create_an_iterator_from_read .notable-traits:focus"