2021-10-19 04:42:59 -05:00
|
|
|
// Checks that the setting "line numbers" is working as expected.
|
2023-04-11 12:11:34 -05:00
|
|
|
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
|
2021-10-19 04:42:59 -05:00
|
|
|
|
2022-12-23 23:55:04 -06:00
|
|
|
// Otherwise, we can't check text color
|
|
|
|
show-text: true
|
|
|
|
|
2021-10-19 04:42:59 -05:00
|
|
|
// We check that without this setting, there is no line number displayed.
|
2022-09-26 12:50:51 -05:00
|
|
|
assert-false: "pre.example-line-numbers"
|
2021-10-19 04:42:59 -05:00
|
|
|
|
|
|
|
// Let's now check some CSS properties...
|
2022-12-23 23:55:04 -06:00
|
|
|
define-function: (
|
|
|
|
"check-colors",
|
|
|
|
(theme, color),
|
2023-01-06 08:18:51 -06:00
|
|
|
block {
|
2022-12-23 23:55:04 -06:00
|
|
|
// We now set the setting to show the line numbers on code examples.
|
2023-04-11 12:11:34 -05:00
|
|
|
set-local-storage: {
|
2022-12-23 23:55:04 -06:00
|
|
|
"rustdoc-theme": |theme|,
|
|
|
|
"rustdoc-use-system-theme": "false",
|
|
|
|
"rustdoc-line-numbers": "true"
|
2023-01-06 08:18:51 -06:00
|
|
|
}
|
2022-12-23 23:55:04 -06:00
|
|
|
// We reload to make the line numbers appear and change theme.
|
2023-01-06 08:18:51 -06:00
|
|
|
reload:
|
2022-12-23 23:55:04 -06:00
|
|
|
// We wait for them to be added into the DOM by the JS...
|
2023-01-06 08:18:51 -06:00
|
|
|
wait-for: "pre.example-line-numbers"
|
2022-12-23 23:55:04 -06:00
|
|
|
// If the test didn't fail, it means that it was found!
|
2023-01-06 08:18:51 -06:00
|
|
|
assert-css: (
|
2022-12-23 23:55:04 -06:00
|
|
|
"pre.example-line-numbers",
|
|
|
|
{
|
|
|
|
"color": |color|,
|
|
|
|
"margin": "0px",
|
|
|
|
"padding": "14px 8px",
|
|
|
|
"text-align": "right",
|
|
|
|
},
|
|
|
|
ALL,
|
2023-01-06 08:18:51 -06:00
|
|
|
)
|
|
|
|
},
|
2022-12-23 23:55:04 -06:00
|
|
|
)
|
|
|
|
call-function: ("check-colors", {
|
|
|
|
"theme": "ayu",
|
|
|
|
"color": "rgb(92, 103, 115)",
|
2021-10-19 04:42:59 -05:00
|
|
|
})
|
2022-12-23 23:55:04 -06:00
|
|
|
call-function: ("check-colors", {
|
|
|
|
"theme": "dark",
|
|
|
|
"color": "rgb(59, 145, 226)",
|
|
|
|
})
|
|
|
|
call-function: ("check-colors", {
|
|
|
|
"theme": "light",
|
|
|
|
"color": "rgb(198, 126, 45)",
|
|
|
|
})
|
|
|
|
|
2021-10-19 04:42:59 -05:00
|
|
|
// The first code block has two lines so let's check its `<pre>` elements lists both of them.
|
2022-09-26 12:50:51 -05:00
|
|
|
assert-text: ("pre.example-line-numbers", "1\n2")
|
2022-09-21 17:43:38 -05: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.
|
2022-11-10 17:51:14 -06:00
|
|
|
click: "input#line-numbers"
|
2022-09-21 17:43:38 -05:00
|
|
|
wait-for: 100 // wait-for-false does not exist
|
2022-09-26 12:50:51 -05:00
|
|
|
assert-false: "pre.example-line-numbers"
|
2022-12-12 15:49:19 -06:00
|
|
|
assert-local-storage: {"rustdoc-line-numbers": "false" }
|
2022-09-21 17:43:38 -05:00
|
|
|
|
|
|
|
// Finally, turn it on again.
|
2022-11-10 17:51:14 -06:00
|
|
|
click: "input#line-numbers"
|
2022-09-26 12:50:51 -05:00
|
|
|
wait-for: "pre.example-line-numbers"
|
2022-12-12 15:49:19 -06:00
|
|
|
assert-local-storage: {"rustdoc-line-numbers": "true" }
|