Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 4 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /html/semantics/disabled-elements/disabled-event-dispatch-additional.tentative.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta name="timeout" content="long">
<link rel=author href="mailto:jarhar@chromium.org">
<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>
<!-- This test should be merged with disabled-event-dispatch.tentative.html after interop2023 is over. -->
<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; }
});
['dblclick', 'auxclick'].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);
const elementToClick = clickChildElement ? targetchild : target;
if (eventName === 'dblclick') {
await (new test_driver.Actions()
.pointerMove(1, 1, {origin: elementToClick})
.pointerDown()
.pointerUp()
.pointerDown()
.pointerUp())
.send();
} else if (eventName === 'auxclick') {
const actions = new test_driver.Actions();
await actions
.pointerMove(1, 1, {origin: elementToClick})
.pointerDown({button: actions.ButtonType.MIDDLE})
.pointerUp({button: actions.ButtonType.MIDDLE})
.send();
}
const shouldReceiveEvents = eventName.startsWith('pointer') || eventName === 'auxclick';
assert_equals(parentReceivedEvent, shouldReceiveEvents,
`parent element received ${eventName} events`);
assert_equals(targetReceivedEvent, shouldReceiveEvents,
`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>