2021-10-19 11:42:59 +02:00
|
|
|
// Checks that the setting "line numbers" is working as expected.
|
2022-10-07 20:17:05 +02:00
|
|
|
goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
|
2021-10-19 11:42:59 +02:00
|
|
|
|
|
|
|
// We check that without this setting, there is no line number displayed.
|
2022-09-26 10:50:51 -07:00
|
|
|
assert-false: "pre.example-line-numbers"
|
2021-10-19 11:42:59 +02:00
|
|
|
|
|
|
|
// We now set the setting to show the line numbers on code examples.
|
|
|
|
local-storage: {"rustdoc-line-numbers": "true" }
|
|
|
|
// We reload to make the line numbers appear.
|
|
|
|
reload:
|
|
|
|
|
|
|
|
// We wait for them to be added into the DOM by the JS...
|
2022-09-26 10:50:51 -07:00
|
|
|
wait-for: "pre.example-line-numbers"
|
2021-10-19 11:42:59 +02:00
|
|
|
// If the test didn't fail, it means that it was found!
|
|
|
|
// Let's now check some CSS properties...
|
2022-09-26 10:50:51 -07:00
|
|
|
assert-css: ("pre.example-line-numbers", {
|
2021-10-19 11:42:59 +02:00
|
|
|
"margin": "0px",
|
|
|
|
"padding": "13px 8px",
|
2021-12-12 18:28:58 +01:00
|
|
|
"text-align": "right",
|
2021-10-19 11:42:59 +02:00
|
|
|
})
|
|
|
|
// The first code block has two lines so let's check its `<pre>` elements lists both of them.
|
2022-09-26 10:50:51 -07:00
|
|
|
assert-text: ("pre.example-line-numbers", "1\n2")
|
2022-09-21 15:43:38 -07:00
|
|
|
|
|
|
|
// Now, try changing the setting dynamically. We'll turn it off, using the settings menu,
|
|
|
|
// and make sure it goes away.
|
|
|
|
|
|
|
|
// First, open the settings menu.
|
|
|
|
click: "#settings-menu"
|
|
|
|
wait-for: "#settings"
|
|
|
|
assert-css: ("#settings", {"display": "block"})
|
|
|
|
|
|
|
|
// Then, click the toggle button.
|
|
|
|
click: "input#line-numbers + .slider"
|
|
|
|
wait-for: 100 // wait-for-false does not exist
|
2022-09-26 10:50:51 -07:00
|
|
|
assert-false: "pre.example-line-numbers"
|
2022-09-21 15:43:38 -07:00
|
|
|
|
|
|
|
// Finally, turn it on again.
|
|
|
|
click: "input#line-numbers + .slider"
|
2022-09-26 10:50:51 -07:00
|
|
|
wait-for: "pre.example-line-numbers"
|