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
+ // 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
10
15
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"})
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"})
16
21
17
22
define-function: (
18
23
"check-colors",
@@ -21,12 +26,12 @@ define-function: (
21
26
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
22
27
("reload"),
23
28
("assert-css", (
24
- ".src-line-numbers > span :not(.line-highlighted)",
29
+ ".src-line-numbers > a :not(.line-highlighted)",
25
30
{"color": |color|, "background-color": |background_color|},
26
31
ALL,
27
32
)),
28
33
("assert-css", (
29
- ".src-line-numbers > span .line-highlighted",
34
+ ".src-line-numbers > a .line-highlighted",
30
35
{"color": |highlight_color|, "background-color": |highlight_background_color|},
31
36
ALL,
32
37
)),
@@ -57,6 +62,25 @@ call-function: ("check-colors", {
57
62
58
63
// This is to ensure that the content is correctly align with the line numbers.
59
64
compare-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
+ })
60
84
61
85
// Assert that the line numbers text is aligned to the right.
62
86
assert-css: (".src-line-numbers", {"text-align": "right"})
@@ -66,7 +90,7 @@ assert-css: (".src-line-numbers", {"text-align": "right"})
66
90
goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
67
91
// We use this assert-position to know where we will click.
68
92
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>`.
93
+ // We click on the left of the "1" anchor but still in the "src-line-number" `<pre>`.
70
94
click: (103, 103)
71
95
assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH)
72
96
0 commit comments