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
|
<!DOCTYPE html>
<meta name="timeout" content="long">
<link rel=author href="mailto:jarhar@chromium.org">
<link rel=help href="https://github.com/whatwg/html/issues/2368">
<link rel=help href="https://github.com/whatwg/html/issues/5886">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<div id=targetparent>
<button disabled>
hello world
<span style="border: 1px solid black">child</span>
</button>
<my-control disabled>
hello world
<span style="border: 1px solid black">child</span>
</my-control>
</div>
<script>
customElements.define('my-control', class extends HTMLElement {
static get formAssociated() { return true; }
});
['mousedown', 'mouseup', 'pointerdown', 'pointerup', 'click'].forEach(eventName => {
[true, false].forEach(clickChildElement => {
for (const target of targetparent.children) {
promise_test(async () => {
let parentReceivedEvent = false;
targetparent.addEventListener(eventName, () => parentReceivedEvent = true);
let targetReceivedEvent = false;
target.addEventListener(eventName, () => targetReceivedEvent = true);
let childReceivedEvent = false;
let targetchild = target.firstElementChild;
targetchild.addEventListener(eventName, () => childReceivedEvent = true);
await test_driver.click(clickChildElement ? targetchild : target);
const parentShouldReceiveEvents = eventName.startsWith('pointer');
assert_equals(parentReceivedEvent, parentShouldReceiveEvents,
`parent element received ${eventName} events`);
const targetShouldReceiveEvents = eventName.startsWith('pointer');
assert_equals(targetReceivedEvent, targetShouldReceiveEvents,
`target element received ${eventName} events`);
assert_equals(childReceivedEvent, clickChildElement,
`child element received ${eventName} events`);
}, `Testing ${eventName} events when clicking ${clickChildElement ? 'child of ' : ''}disabled ${target.localName}.`);
}
});
});
</script>
|