-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
marker-hit-testing.html
96 lines (95 loc) · 3.08 KB
/
marker-hit-testing.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Pseudo-Elements Test: Hit testing ::marker</title>
<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#marker-pseudo">
<meta name="assert" content="This test checks that hit-testing a ::marker, the APIs provide the nearest element ancestor." />
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<style>
ol {
display: inline-block;
padding-left: 100px;
}
li {
font: 50px/100px Ahem;
width: 50px;
}
.inside {
list-style-position: inside;
}
.image {
list-style-image: url("/images/green-100x50.png");
}
.string {
list-style-type: "X";
}
.marker::marker {
content: "X";
}
.nested {
display: block;
}
.nested::before {
content: '';
display: list-item;
}
</style>
<!-- The <li> are 50px wide, and the ::marker are at least 50px wide.
Since they are outside, try to locate them at -40px to the left of
the <li>, i.e. -65px from the center of the <li> -->
<ol class="outside" data-x="-65">
<li class="image"></li>
<li class="string"></li>
<li class="marker"></li>
<li class="nested image"></li>
<li class="nested string"></li>
</ol>
<!-- The <li> are 50px wide, and the inside ::marker are at least 50px,
so locate them at the horizontal center of the <li> -->
<ol class="inside" data-x="0">
<li class="image"></li>
<li class="string"></li>
<li class="marker"></li>
<li class="nested image"></li>
<li class="nested string"></li>
</ol>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script>
function check(event, li) {
assert_equals(event.target, li, "event.target");
if (event.path) {
assert_equals(event.path[0], li, "event.path");
}
const el = document.elementFromPoint(event.clientX, event.clientY);
assert_equals(el, li, "elementFromPoint");
}
setup({ explicit_done: true });
addEventListener("load", async function() {
for (let list of document.querySelectorAll("ol")) {
for (let li of list.querySelectorAll("li")) {
const listener = e => check(e, li);
async_test(function(t) {
document.addEventListener("mousedown", t.step_func_done(listener));
}, list.className + " " + li.className + " ::marker's content");
async_test(function(t) {
document.addEventListener("mouseup", t.step_func_done(listener));
}, list.className + " " + li.className + " ::marker");
await new test_driver.Actions()
// Send an event at the vertical middle of the <li>, this should
// hit the contents of the ::marker
.pointerMove(+list.dataset.x, 0, {origin: li})
.pointerDown()
// The ::marker is 100px tall but its contents only 50px tall.
// Send an event inside the ::marker but above its contents.
.pointerMove(+list.dataset.x, -40, {origin: li})
.pointerUp()
.send();
}
}
done();
});
</script>