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