2
2
goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
3
3
show-text: true
4
4
// 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.
6
6
// Ensure that the page URL was updated.
7
7
assert-document-property: ({"URL": "lib.rs.html#4"}, ENDS_WITH)
8
8
assert-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
10
10
goto: "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"})
16
16
17
17
define-function: (
18
18
"check-colors",
@@ -21,12 +21,12 @@ define-function: (
21
21
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
22
22
("reload"),
23
23
("assert-css", (
24
- ".src-line-numbers > span :not(.line-highlighted)",
24
+ ".src-line-numbers > a :not(.line-highlighted)",
25
25
{"color": |color|, "background-color": |background_color|},
26
26
ALL,
27
27
)),
28
28
("assert-css", (
29
- ".src-line-numbers > span .line-highlighted",
29
+ ".src-line-numbers > a .line-highlighted",
30
30
{"color": |highlight_color|, "background-color": |highlight_background_color|},
31
31
ALL,
32
32
)),
@@ -57,6 +57,25 @@ call-function: ("check-colors", {
57
57
58
58
// This is to ensure that the content is correctly align with the line numbers.
59
59
compare-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
+ })
60
79
61
80
// Assert that the line numbers text is aligned to the right.
62
81
assert-css: (".src-line-numbers", {"text-align": "right"})
@@ -66,7 +85,7 @@ assert-css: (".src-line-numbers", {"text-align": "right"})
66
85
goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
67
86
// We use this assert-position to know where we will click.
68
87
assert-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>`.
70
89
click: (103, 103)
71
90
assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH)
72
91
0 commit comments