]> git.proxmox.com Git - rustc.git/blob - tests/rustdoc-gui/docblock-code-block-line-number.goml
New upstream version 1.70.0+dfsg1
[rustc.git] / tests / rustdoc-gui / docblock-code-block-line-number.goml
1 // Checks that the setting "line numbers" is working as expected.
2 go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
3
4 // Otherwise, we can't check text color
5 show-text: true
6
7 // We check that without this setting, there is no line number displayed.
8 assert-false: "pre.example-line-numbers"
9
10 // Let's now check some CSS properties...
11 define-function: (
12 "check-colors",
13 (theme, color),
14 block {
15 // We now set the setting to show the line numbers on code examples.
16 set-local-storage: {
17 "rustdoc-theme": |theme|,
18 "rustdoc-use-system-theme": "false",
19 "rustdoc-line-numbers": "true"
20 }
21 // We reload to make the line numbers appear and change theme.
22 reload:
23 // We wait for them to be added into the DOM by the JS...
24 wait-for: "pre.example-line-numbers"
25 // If the test didn't fail, it means that it was found!
26 assert-css: (
27 "pre.example-line-numbers",
28 {
29 "color": |color|,
30 "margin": "0px",
31 "padding": "14px 8px",
32 "text-align": "right",
33 },
34 ALL,
35 )
36 },
37 )
38 call-function: ("check-colors", {
39 "theme": "ayu",
40 "color": "rgb(92, 103, 115)",
41 })
42 call-function: ("check-colors", {
43 "theme": "dark",
44 "color": "rgb(59, 145, 226)",
45 })
46 call-function: ("check-colors", {
47 "theme": "light",
48 "color": "rgb(198, 126, 45)",
49 })
50
51 // The first code block has two lines so let's check its `<pre>` elements lists both of them.
52 assert-text: ("pre.example-line-numbers", "1\n2")
53
54 // Now, try changing the setting dynamically. We'll turn it off, using the settings menu,
55 // and make sure it goes away.
56
57 // First, open the settings menu.
58 click: "#settings-menu"
59 wait-for: "#settings"
60 assert-css: ("#settings", {"display": "block"})
61
62 // Then, click the toggle button.
63 click: "input#line-numbers"
64 wait-for: 100 // wait-for-false does not exist
65 assert-false: "pre.example-line-numbers"
66 assert-local-storage: {"rustdoc-line-numbers": "false" }
67
68 // Finally, turn it on again.
69 click: "input#line-numbers"
70 wait-for: "pre.example-line-numbers"
71 assert-local-storage: {"rustdoc-line-numbers": "true" }