]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc-gui/docblock-code-block-line-number.goml
Auto merge of #2739 - RalfJung:misc, r=RalfJung
[rust.git] / src / test / rustdoc-gui / docblock-code-block-line-number.goml
1 // Checks that the setting "line numbers" is working as expected.
2 goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
3
4 // We check that without this setting, there is no line number displayed.
5 assert-false: "pre.example-line-numbers"
6
7 // We now set the setting to show the line numbers on code examples.
8 local-storage: {"rustdoc-line-numbers": "true" }
9 // We reload to make the line numbers appear.
10 reload:
11
12 // We wait for them to be added into the DOM by the JS...
13 wait-for: "pre.example-line-numbers"
14 // If the test didn't fail, it means that it was found!
15 // Let's now check some CSS properties...
16 assert-css: ("pre.example-line-numbers", {
17     "margin": "0px",
18     "padding": "13px 8px",
19     "text-align": "right",
20 })
21 // The first code block has two lines so let's check its `<pre>` elements lists both of them.
22 assert-text: ("pre.example-line-numbers", "1\n2")
23
24 // Now, try changing the setting dynamically. We'll turn it off, using the settings menu,
25 // and make sure it goes away.
26
27 // First, open the settings menu.
28 click: "#settings-menu"
29 wait-for: "#settings"
30 assert-css: ("#settings", {"display": "block"})
31
32 // Then, click the toggle button.
33 click: "input#line-numbers"
34 wait-for: 100 // wait-for-false does not exist
35 assert-false: "pre.example-line-numbers"
36 assert-local-storage: {"rustdoc-line-numbers": "false" }
37
38 // Finally, turn it on again.
39 click: "input#line-numbers"
40 wait-for: "pre.example-line-numbers"
41 assert-local-storage: {"rustdoc-line-numbers": "true" }