fork/rust

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

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

master
3.1 KiB88 linesraw
1// This test ensure that the sidebar isn't "hidden" on mobile but instead moved out of the viewport.
2// This is especially important for devices for "text-first" content (like for users with
3// sight issues).
4go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
5// Switching to "mobile view" by reducing the width to 600px.
6set-window-size: (600, 600)
7assert-css: (".sidebar", {"display": "block", "left": "-1000px"})
8// Opening the sidebar menu.
9click: ".sidebar-menu-toggle"
10assert-css: (".sidebar", {"display": "block", "left": "0px"})
11// Closing the sidebar menu.
12click: ".sidebar-menu-toggle"
13assert-css: (".sidebar", {"display": "block", "left": "-1000px"})
14// Force the sidebar open by focusing a link inside it.
15// This makes it easier for keyboard users to get to it.
16focus: ".sidebar-elems h3 a"
17assert-css: (".sidebar", {"display": "block", "left": "0px"})
18// When we tab out of the sidebar, close it.
19focus: ".search-input"
20assert-css: (".sidebar", {"display": "block", "left": "-1000px"})
21
22// Open the sidebar menu.
23click: ".sidebar-menu-toggle"
24assert-css: (".sidebar", {"left": "0px"})
25
26// Make sure the "struct Foo" header is hidden, since the mobile topbar already does it.
27assert-css: ("//nav[contains(@class, 'sidebar')]//h2/a[text()='Foo']/parent::h2", {"display": "none"})
28// Make sure the global navigation is still here.
29assert-css: ("//nav[contains(@class, 'sidebar')]//h2/a[text()='In test_docs']/parent::h2", {"display": "block"})
30
31// Click elsewhere.
32click: "body"
33assert-css: (".sidebar", {"display": "block", "left": "-1000px"})
34
35// Open the sidebar menu, and make sure pressing Escape closes it.
36click: ".sidebar-menu-toggle"
37assert-css: (".sidebar", {"left": "0px"})
38press-key: "Escape"
39assert-css: (".sidebar", {"display": "block", "left": "-1000px"})
40
41// Check that the topbar is visible
42assert-property: (".mobile-topbar", {"clientHeight": "45"})
43
44// Check that clicking an element from the sidebar scrolls to the right place
45// so the target is not obscured by the topbar.
46click: ".sidebar-menu-toggle"
47click: ".sidebar-elems section .block li > a"
48assert-position: ("#method\.must_use", {"y": 46})
49
50// Check that the bottom-most item on the sidebar menu can be scrolled fully into view.
51click: ".sidebar-menu-toggle"
52scroll-to: ".block.keyword li:nth-child(1)"
53compare-elements-position-near: (".block.keyword li:nth-child(1)", ".mobile-topbar", {"y": 543.19})
54
55// Now checking the background color of the sidebar.
56show-text: true
57
58define-function: (
59    "check-colors",
60    (theme, color, background),
61    block {
62        set-local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": |theme|}
63        reload:
64
65        // Open the sidebar menu.
66        click: ".sidebar-menu-toggle"
67        assert-css: (".sidebar", {
68            "background-color": |background|,
69            "color": |color|,
70        })
71    },
72)
73
74call-function: ("check-colors", {
75    "theme": "ayu",
76    "color": "#c5c5c5",
77    "background": "#14191f",
78})
79call-function: ("check-colors", {
80    "theme": "dark",
81    "color": "#ddd",
82    "background": "#505050",
83})
84call-function: ("check-colors", {
85    "theme": "light",
86    "color": "black",
87    "background": "#F5F5F5",
88})