Skip to content

Commit

Permalink
Tests for ::target-text.
Browse files Browse the repository at this point in the history
These tests were written when ::target-text was implemented, but
changing window.location.hash for target text was not allowed at that
time, and did not allow for automated testing. Submit since that is now
possible.

target-text-004.html fails because currentColor for ::selection does not
fall back to using the text color from ::target-text.

Bug: 1136817, 1147859
Change-Id: Id512caec6ef7df8380f75fe82c79af27975991d1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2521513
Reviewed-by: Manuel Rego <[email protected]>
Commit-Queue: Rune Lillesveen <[email protected]>
Cr-Commit-Position: refs/heads/main@{#933854}
  • Loading branch information
lilles authored and Chromium LUCI CQ committed Oct 21, 2021
1 parent 493215c commit 5cb11c5
Show file tree
Hide file tree
Showing 11 changed files with 150 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ crbug.com/1108830 external/wpt/css/css-pseudo/marker-word-break.html [ Failure ]
crbug.com/1012289 external/wpt/css/css-pseudo/marker-unicode-bidi-default.html [ Failure ]
crbug.com/1012289 external/wpt/css/css-pseudo/marker-unicode-bidi-normal.html [ Failure ]
crbug.com/1147859 external/wpt/css/css-pseudo/selection-decoration-p3.html [ Failure ]
crbug.com/1136817 external/wpt/css/css-pseudo/target-text-001.html [ Failure ]
crbug.com/1136817 external/wpt/css/css-pseudo/target-text-002.html [ Failure ]
crbug.com/1136817 external/wpt/css/css-pseudo/target-text-004.html [ Pass ]
crbug.com/1136817 external/wpt/css/css-pseudo/target-text-005.html [ Failure ]
crbug.com/1035708 wpt_internal/css/css-pseudo/spelling-error-color-001.html [ Failure ]
crbug.com/1035708 wpt_internal/css/css-pseudo/spelling-error-color-002.html [ Failure ]
crbug.com/1035708 wpt_internal/css/css-pseudo/grammar-error-color-001.html [ Failure ]
Expand Down
2 changes: 2 additions & 0 deletions third_party/blink/web_tests/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -1654,6 +1654,8 @@ crbug.com/1035708 wpt_internal/css/css-pseudo/grammar-error-color-dynamic-001.ht
crbug.com/1035708 wpt_internal/css/css-pseudo/grammar-error-color-dynamic-002.html [ Failure ]
crbug.com/1035708 wpt_internal/css/css-pseudo/grammar-error-color-dynamic-003.html [ Failure ]
crbug.com/1035708 wpt_internal/css/css-pseudo/grammar-error-color-dynamic-004.html [ Failure ]
crbug.com/1147859 external/wpt/css/css-pseudo/target-text-004.html [ Failure ]
crbug.com/1179938 external/wpt/css/css-pseudo/target-text-006.html [ Failure ]
crbug.com/1035708 external/wpt/css/css-pseudo/target-text-dynamic-001.html [ Failure ]
crbug.com/1035708 external/wpt/css/css-pseudo/target-text-dynamic-002.html [ Failure ]
crbug.com/1035708 external/wpt/css/css-pseudo/target-text-dynamic-003.html [ Failure ]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!doctype html>
<meta charset="utf-8">
<title>CSS Pseudo-Elements Test: ::target-text color rendering - basic</title>
<link rel="help" href="https://drafts.csswg.org/css-pseudo/#selectordef-target-text">
<link rel="match" href="target-text-lime-green-ref.html">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<style>
.ahem { font-family: Ahem; }
p::target-text {
color: lime;
background-color: green;
}
</style>
<p>PASS if there are two segments of lime squares with a green square between below.</p>
<p class="ahem">match me</p>
<script>
window.location.hash = "#:~:text=match%20me";
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!doctype html>
<meta charset="utf-8">
<title>CSS Pseudo-Elements Test: ::target-text color rendering - match across elements</title>
<link rel="help" href="https://drafts.csswg.org/css-pseudo/#selectordef-target-text">
<link rel="match" href="target-text-lime-green-ref.html">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<style>
.ahem { font-family: Ahem; }
::target-text {
color: lime;
background-color: green;
}
</style>
<p>PASS if there are two segments of lime squares with a green square between below.</p>
<p class="ahem">ma<span>tch </span>me</p>
<script>
window.location.hash = "#:~:text=match%20me";
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!doctype html>
<meta charset="utf-8">
<title>CSS Pseudo-Elements Test: ::target-text color rendering - two matches</title>
<link rel="help" href="https://drafts.csswg.org/css-pseudo/#selectordef-target-text">
<link rel="match" href="target-text-lime-ref.html">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<style>
.ahem { font-family: Ahem; }
p::target-text {
color: lime;
background-color: green;
}
</style>
<p>PASS if there are two segments of lime squares below.</p>
<p class="ahem">match me</p>
<script>
window.location.hash = "#:~:text=match&text=me";
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!doctype html>
<meta charset="utf-8">
<title>CSS Pseudo-Elements Test: ::target-text color rendering - with selection</title>
<link rel="help" href="https://drafts.csswg.org/css-pseudo/#selectordef-target-text">
<link rel="match" href="target-text-lime-green-ref.html">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<style>
p::target-text {
background-color: red;
color: lime;
}
p::selection {
background-color: green;
color: currentColor;
}
#sel {
font-family: Ahem;
}
</style>
<p>PASS if there are two segments of lime squares with a green square between below.</p>
<p id="sel">match me</p>
<script>
window.location.hash = "#:~:text=match%20me";
let range = document.createRange();
range.selectNodeContents(sel);
window.getSelection().addRange(range);
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!doctype html>
<meta charset="utf-8">
<title>CSS Pseudo-Elements Test: ::target-text color rendering - with transparent selection</title>
<link rel="help" href="https://drafts.csswg.org/css-pseudo/#selectordef-target-text">
<link rel="match" href="target-text-lime-green-ref.html">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<style>
p::target-text {
background-color: green;
color: transparent;
}
p::selection {
background-color: transparent;
color: lime;
}
#sel {
font-family: Ahem;
}
</style>
<p>PASS if there are two segments of lime squares with a green square between below.</p>
<p id="sel">match me</p>
<script>
window.location.hash = "#:~:text=match%20me";
let range = document.createRange();
range.selectNodeContents(sel);
window.getSelection().addRange(range);
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!doctype html>
<meta charset="utf-8">
<title>CSS Pseudo-Elements Test: ::target-text color rendering - text rendered once</title>
<link rel="help" href="https://drafts.csswg.org/css-pseudo/#selectordef-target-text">
<link rel="match" href="target-text-two-words-ref.html">
<style>
p.white { color: white; }
p::target-text {
color: black;
background-color: orange;
}
</style>
<p>PASS if the text below is rendered black on an orange background.</p>
<p class="white">match me</p>
<script>
window.location.hash = "#:~:text=match%20me";
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!doctype html>
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<p>PASS if there are two segments of lime squares with a green square between below.</p>
<p style="font-family:Ahem"><span style="color:lime;background:green">match me</span></p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!doctype html>
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<style>
.ahem { font-family: Ahem; }
span {
color: lime;
background-color: green;
}
</style>
<p>PASS if there are two segments of lime squares below.</p>
<p class="ahem"><span>match</span> <span>me</span></p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!doctype html>
<title>CSS Test Reference</title>
<p>PASS if the text below is rendered black on an orange background.</p>
<p><span style="color:black;background:orange">match me<span></p>

0 comments on commit 5cb11c5

Please sign in to comment.