fork/rust

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

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

master
7.8 KiB205 linesraw
1// This test ensures that the elements in the sidebar are displayed correctly.
2javascript: false
3go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
4// Since the javascript is disabled, there shouldn't be a toggle.
5assert-false: "#src-sidebar-toggle"
6wait-for-css: (".sidebar", {"display": "none"})
7
8// Let's retry with javascript enabled.
9javascript: true
10reload:
11wait-for: "#src-sidebar-toggle"
12assert-css: ("#src-sidebar-toggle", {"visibility": "visible"})
13assert-css: (".sidebar > *:not(#src-sidebar-toggle)", {"visibility": "hidden"})
14// Let's expand the sidebar now.
15click: "#src-sidebar-toggle"
16wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"})
17
18// We now check that opening the sidebar and clicking a link will leave it open.
19// The behavior here on desktop is different than the behavior on mobile,
20// but since the sidebar doesn't fill the entire screen here, it makes sense to have the
21// sidebar stay resident.
22wait-for-css: (".sidebar", {"width": "300px"})
23assert-local-storage: {"rustdoc-source-sidebar-show": "true"}
24click: ".sidebar a.selected"
25go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
26wait-for-css: (".sidebar", {"width": "300px"})
27assert-local-storage: {"rustdoc-source-sidebar-show": "true"}
28
29// Now we check the display of the sidebar items.
30show-text: true
31
32define-function: (
33    "check-colors",
34    (
35        theme, color, color_hover, background, background_hover, background_toggle,
36        background_toggle_hover,
37    ),
38    block {
39        set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
40        reload:
41        wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"})
42        assert-css: (
43            "#src-sidebar details[open] > .files a.selected",
44            {"color": |color_hover|, "background-color": |background|},
45        )
46
47        // Without hover or focus.
48        assert-css: ("#src-sidebar-toggle > button", {"background-color": |background_toggle|})
49        // With focus.
50        focus: "#src-sidebar-toggle > button"
51        assert-css: (
52            "#src-sidebar-toggle > button:focus",
53            {"background-color": |background_toggle_hover|},
54        )
55        focus: ".search-input"
56        // With hover.
57        move-cursor-to: "#src-sidebar-toggle > button"
58        assert-css: (
59            "#src-sidebar-toggle > button:hover",
60            {"background-color": |background_toggle_hover|},
61        )
62
63        // Without hover or focus.
64        assert-css: (
65            "#src-sidebar details[open] > .files a:not(.selected)",
66            {"color": |color|, "background-color": |background_toggle|},
67        )
68        // With focus.
69        focus: "#src-sidebar details[open] > .files a:not(.selected)"
70        wait-for-css: (
71            "#src-sidebar details[open] > .files a:not(.selected):focus",
72            {"color": |color_hover|, "background-color": |background_hover|},
73        )
74        focus: ".search-input"
75        // With hover.
76        move-cursor-to: "#src-sidebar details[open] > .files a:not(.selected)"
77        assert-css: (
78            "#src-sidebar details[open] > .files a:not(.selected):hover",
79            {"color": |color_hover|, "background-color": |background_hover|},
80        )
81
82        // Without hover or focus.
83        assert-css: (
84            "#src-sidebar .dir-entry summary",
85            {"color": |color|, "background-color": |background_toggle|},
86        )
87        // With focus.
88        focus: "#src-sidebar .dir-entry summary"
89        wait-for-css: (
90            "#src-sidebar .dir-entry summary:focus",
91            {"color": |color_hover|, "background-color": |background_hover|},
92        )
93        focus: ".search-input"
94        // With hover.
95        move-cursor-to: "#src-sidebar .dir-entry summary"
96        assert-css: (
97            "#src-sidebar .dir-entry summary:hover",
98            {"color": |color_hover|, "background-color": |background_hover|},
99        )
100
101        // Without hover or focus.
102        assert-css: (
103            "#src-sidebar details[open] > .folders > details > summary",
104            {"color": |color|, "background-color": |background_toggle|},
105        )
106        // With focus.
107        focus: "#src-sidebar details[open] > .folders > details > summary"
108        wait-for-css: (
109            "#src-sidebar details[open] > .folders > details > summary:focus",
110            {"color": |color_hover|, "background-color": |background_hover|},
111        )
112        focus: ".search-input"
113        // With hover.
114        move-cursor-to: "#src-sidebar details[open] > .folders > details > summary"
115        assert-css: (
116            "#src-sidebar details[open] > .folders > details > summary:hover",
117            {"color": |color_hover|, "background-color": |background_hover|},
118        )
119    },
120)
121
122call-function: ("check-colors", {
123    "theme": "light",
124    "color": "black",
125    "color_hover": "#000",
126    "background": "#fff",
127    "background_hover": "#e0e0e0",
128    "background_toggle": "rgba(0, 0, 0, 0)",
129    "background_toggle_hover": "#e0e0e0",
130})
131call-function: ("check-colors", {
132    "theme": "dark",
133    "color": "#ddd",
134    "color_hover": "#ddd",
135    "background": "#333",
136    "background_hover": "#444",
137    "background_toggle": "rgba(0, 0, 0, 0)",
138    "background_toggle_hover": "#676767",
139})
140call-function: ("check-colors", {
141    "theme": "ayu",
142    "color": "#c5c5c5",
143    "color_hover": "#ffb44c",
144    "background": "#14191f",
145    "background_hover": "#14191f",
146    "background_toggle": "rgba(0, 0, 0, 0)",
147    "background_toggle_hover": "rgba(70, 70, 70, 0.33)",
148})
149
150// Now checking on mobile devices.
151set-window-size: (500, 700)
152reload:
153// Waiting for the sidebar to be displayed...
154wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"})
155
156// We now check it takes the full size of the display.
157assert-property: ("body", {"clientWidth": "500", "clientHeight": "700"})
158assert-property: (".sidebar", {"clientWidth": "500", "clientHeight": "700"})
159
160// We now check the display of the toggle once the sidebar is expanded.
161assert-property: ("#src-sidebar-toggle", {"clientWidth": "500", "clientHeight": "39"})
162assert-css: (
163    "#src-sidebar-toggle",
164    {
165        "border-top-width": "0px",
166        "border-right-width": "0px",
167        "border-left-width": "0px",
168        "border-bottom-width": "1px",
169    },
170)
171
172// We now check that the scroll position is kept when opening the sidebar.
173click: "#src-sidebar-toggle"
174wait-for-css: (".sidebar", {"left": "-1000px"})
175// We scroll to line 117 to change the scroll position.
176scroll-to: '//*[@id="117"]'
177assert-window-property: {"pageYOffset": "2542"}
178// Expanding the sidebar...
179click: "#src-sidebar-toggle"
180wait-for-css: (".sidebar", {"left": "0px"})
181click: "#src-sidebar-toggle"
182wait-for-css: (".sidebar", {"left": "-1000px"})
183// The "scrollTop" property should be the same.
184assert-window-property: {"pageYOffset": "2542"}
185
186// We now check that opening the sidebar and clicking a link will close it.
187// The behavior here on mobile is different than the behavior on desktop,
188// but common sense dictates that if you have a list of files that fills the entire screen, and
189// you click one of them, you probably want to actually see the file's contents, and not just
190// make it the current selection.
191set-window-size: (500, 700)
192click: "#src-sidebar-toggle"
193wait-for-css: ("#src-sidebar", {"visibility": "visible"})
194assert-local-storage: {"rustdoc-source-sidebar-show": "true"}
195click: ".sidebar a.selected"
196go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
197wait-for-css: ("#src-sidebar", {"visibility": "hidden"})
198assert-local-storage: {"rustdoc-source-sidebar-show": "false"}
199// Resize back to desktop size, to check that the sidebar doesn't spontaneously open.
200set-window-size: (1000, 1000)
201wait-for-css: ("#src-sidebar", {"visibility": "hidden"})
202assert-local-storage: {"rustdoc-source-sidebar-show": "false"}
203click: "#src-sidebar-toggle"
204wait-for-css: ("#src-sidebar", {"visibility": "visible"})
205assert-local-storage: {"rustdoc-source-sidebar-show": "true"}