22goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
33show-text: true
44// Check that we can click on the line number.
5- click: ".src-line-numbers > span :nth-child(4)" // This is the span for line 4.
5+ click: ".src-line-numbers > a :nth-child(4)" // This is the anchor for line 4.
66// Ensure that the page URL was updated.
77assert-document-property: ({"URL": "lib.rs.html#4"}, ENDS_WITH)
88assert-attribute: ("//*[@id='4']", {"class": "line-highlighted"})
9- // We now check that the good spans are highlighted
9+ // Ensure that the default style, with the right border, isn't used.
10+ assert-css: ("//*[@id='4']", {"border-right-width": "0px"})
11+ reload:
12+ assert-attribute: ("//*[@id='4']", {"class": "line-highlighted"})
13+ assert-css: ("//*[@id='4']", {"border-right-width": "0px"})
14+ // We now check that the good anchors are highlighted
1015goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#4-6"
11- assert-attribute-false: (".src-line-numbers > span :nth-child(3)", {"class": "line-highlighted"})
12- assert-attribute: (".src-line-numbers > span :nth-child(4)", {"class": "line-highlighted"})
13- assert-attribute: (".src-line-numbers > span :nth-child(5)", {"class": "line-highlighted"})
14- assert-attribute: (".src-line-numbers > span :nth-child(6)", {"class": "line-highlighted"})
15- assert-attribute-false: (".src-line-numbers > span :nth-child(7)", {"class": "line-highlighted"})
16+ assert-attribute-false: (".src-line-numbers > a :nth-child(3)", {"class": "line-highlighted"})
17+ assert-attribute: (".src-line-numbers > a :nth-child(4)", {"class": "line-highlighted"})
18+ assert-attribute: (".src-line-numbers > a :nth-child(5)", {"class": "line-highlighted"})
19+ assert-attribute: (".src-line-numbers > a :nth-child(6)", {"class": "line-highlighted"})
20+ assert-attribute-false: (".src-line-numbers > a :nth-child(7)", {"class": "line-highlighted"})
1621
1722define-function: (
1823 "check-colors",
@@ -21,12 +26,12 @@ define-function: (
2126 ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
2227 ("reload"),
2328 ("assert-css", (
24- ".src-line-numbers > span :not(.line-highlighted)",
29+ ".src-line-numbers > a :not(.line-highlighted)",
2530 {"color": |color|, "background-color": |background_color|},
2631 ALL,
2732 )),
2833 ("assert-css", (
29- ".src-line-numbers > span .line-highlighted",
34+ ".src-line-numbers > a .line-highlighted",
3035 {"color": |highlight_color|, "background-color": |highlight_background_color|},
3136 ALL,
3237 )),
@@ -57,6 +62,25 @@ call-function: ("check-colors", {
5762
5863// This is to ensure that the content is correctly align with the line numbers.
5964compare-elements-position: ("//*[@id='1']", ".rust > code > span", ("y"))
65+ // Check the `href` property so that users can treat anchors as links.
66+ assert-property: (".src-line-numbers > a:nth-child(1)", {
67+ "href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#1"
68+ })
69+ assert-property: (".src-line-numbers > a:nth-child(2)", {
70+ "href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#2"
71+ })
72+ assert-property: (".src-line-numbers > a:nth-child(3)", {
73+ "href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#3"
74+ })
75+ assert-property: (".src-line-numbers > a:nth-child(4)", {
76+ "href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#4"
77+ })
78+ assert-property: (".src-line-numbers > a:nth-child(5)", {
79+ "href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#5"
80+ })
81+ assert-property: (".src-line-numbers > a:nth-child(6)", {
82+ "href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#6"
83+ })
6084
6185// Assert that the line numbers text is aligned to the right.
6286assert-css: (".src-line-numbers", {"text-align": "right"})
@@ -66,7 +90,7 @@ assert-css: (".src-line-numbers", {"text-align": "right"})
6690goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
6791// We use this assert-position to know where we will click.
6892assert-position: ("//*[@id='1']", {"x": 104, "y": 112})
69- // We click on the left of the "1" span but still in the "src-line-number" `<pre>`.
93+ // We click on the left of the "1" anchor but still in the "src-line-number" `<pre>`.
7094click: (103, 103)
7195assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH)
7296
0 commit comments