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+ // We now check that the good anchors are highlighted
1010goto: "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"})
11+ assert-attribute-false: (".src-line-numbers > a :nth-child(3)", {"class": "line-highlighted"})
12+ assert-attribute: (".src-line-numbers > a :nth-child(4)", {"class": "line-highlighted"})
13+ assert-attribute: (".src-line-numbers > a :nth-child(5)", {"class": "line-highlighted"})
14+ assert-attribute: (".src-line-numbers > a :nth-child(6)", {"class": "line-highlighted"})
15+ assert-attribute-false: (".src-line-numbers > a :nth-child(7)", {"class": "line-highlighted"})
1616
1717define-function: (
1818 "check-colors",
@@ -21,12 +21,12 @@ define-function: (
2121 ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
2222 ("reload"),
2323 ("assert-css", (
24- ".src-line-numbers > span :not(.line-highlighted)",
24+ ".src-line-numbers > a :not(.line-highlighted)",
2525 {"color": |color|, "background-color": |background_color|},
2626 ALL,
2727 )),
2828 ("assert-css", (
29- ".src-line-numbers > span .line-highlighted",
29+ ".src-line-numbers > a .line-highlighted",
3030 {"color": |highlight_color|, "background-color": |highlight_background_color|},
3131 ALL,
3232 )),
@@ -57,6 +57,25 @@ call-function: ("check-colors", {
5757
5858// This is to ensure that the content is correctly align with the line numbers.
5959compare-elements-position: ("//*[@id='1']", ".rust > code > span", ("y"))
60+ // Check the `href` property so that users can treat anchors as links.
61+ assert-property: (".src-line-numbers > a:nth-child(1)", {
62+ "href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#1"
63+ })
64+ assert-property: (".src-line-numbers > a:nth-child(2)", {
65+ "href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#2"
66+ })
67+ assert-property: (".src-line-numbers > a:nth-child(3)", {
68+ "href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#3"
69+ })
70+ assert-property: (".src-line-numbers > a:nth-child(4)", {
71+ "href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#4"
72+ })
73+ assert-property: (".src-line-numbers > a:nth-child(5)", {
74+ "href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#5"
75+ })
76+ assert-property: (".src-line-numbers > a:nth-child(6)", {
77+ "href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#6"
78+ })
6079
6180// Assert that the line numbers text is aligned to the right.
6281assert-css: (".src-line-numbers", {"text-align": "right"})
@@ -66,7 +85,7 @@ assert-css: (".src-line-numbers", {"text-align": "right"})
6685goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
6786// We use this assert-position to know where we will click.
6887assert-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>`.
88+ // We click on the left of the "1" anchor but still in the "src-line-number" `<pre>`.
7089click: (103, 103)
7190assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH)
7291
0 commit comments