]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc-gui/source-code-page.goml
Rollup merge of #103408 - compiler-errors:rpitit-rustdoc, r=GuillaumeGomez
[rust.git] / src / test / rustdoc-gui / source-code-page.goml
1 // Checks that the interactions with the source code pages are working as expected.
2 goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
3 // Check that we can click on the line number.
4 click: ".src-line-numbers > span:nth-child(4)" // This is the span for line 4.
5 // Ensure that the page URL was updated.
6 assert-document-property: ({"URL": "lib.rs.html#4"}, ENDS_WITH)
7 assert-attribute: ("//*[@id='4']", {"class": "line-highlighted"})
8 // We now check that the good spans are highlighted
9 goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#4-6"
10 assert-attribute-false: (".src-line-numbers > span:nth-child(3)", {"class": "line-highlighted"})
11 assert-attribute: (".src-line-numbers > span:nth-child(4)", {"class": "line-highlighted"})
12 assert-attribute: (".src-line-numbers > span:nth-child(5)", {"class": "line-highlighted"})
13 assert-attribute: (".src-line-numbers > span:nth-child(6)", {"class": "line-highlighted"})
14 assert-attribute-false: (".src-line-numbers > span:nth-child(7)", {"class": "line-highlighted"})
15 // This is to ensure that the content is correctly align with the line numbers.
16 compare-elements-position: ("//*[@id='1']", ".rust > code > span", ("y"))
17
18 // Assert that the line numbers text is aligned to the right.
19 assert-css: (".src-line-numbers", {"text-align": "right"})
20
21 // Now let's check that clicking on something else than the line number doesn't
22 // do anything (and certainly not add a `#NaN` to the URL!).
23 show-text: true
24 goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
25 // We use this assert-position to know where we will click.
26 assert-position: ("//*[@id='1']", {"x": 104, "y": 112})
27 // We click on the left of the "1" span but still in the "src-line-number" `<pre>`.
28 click: (103, 103)
29 assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH)
30
31 // Checking the source code sidebar.
32
33 // First we "open" it.
34 click: "#sidebar-toggle"
35 assert: ".source-sidebar-expanded"
36
37 // We check that the first entry of the sidebar is collapsed
38 assert-property: ("#source-sidebar details:first-of-type", {"open": "false"})
39 assert-text: ("#source-sidebar details:first-of-type > summary", "implementors")
40 // We now click on it.
41 click: "#source-sidebar details:first-of-type > summary"
42 assert-property: ("#source-sidebar details:first-of-type", {"open": "true"})
43
44 // And now we collapse it again.
45 click: "#source-sidebar details:first-of-type > summary"
46 assert-property: ("#source-sidebar details:first-of-type", {"open": "false"})
47
48 // Check the spacing.
49 assert-css: ("#source-sidebar > details.dir-entry", {"padding-left": "4px"})
50
51 // Check the search form
52 assert-css: ("nav.sub", {"flex-direction": "row"})
53 // The goal of this test is to ensure the search input is perfectly centered
54 // between the top of the page and the top of the gray code block.
55 // To check this, we maintain the invariant:
56 //
57 // offsetTop[nav.sub form] = offsetTop[#main-content] - offsetHeight[nav.sub form] - offsetTop[nav.sub form]
58 assert-property: ("nav.sub form", {"offsetTop": 28, "offsetHeight": 34})
59 assert-property: ("#main-content", {"offsetTop": 90})
60 // 28 = 90 - 34 - 28
61
62 // Now do the same check on moderately-sized mobile.
63 size: (700, 700)
64 assert-css: ("nav.sub", {"flex-direction": "row"})
65 assert-property: ("nav.sub form", {"offsetTop": 21, "offsetHeight": 34})
66 assert-property: ("#main-content", {"offsetTop": 76})
67 // 21 = 76 - 34 - 21
68
69 // Tiny mobile gets a different display where the logo is stacked on top.
70 size: (450, 700)
71 assert-css: ("nav.sub", {"flex-direction": "column"})