diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/dom/events/Event-dispatch-detached-input-and-change.html | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/dom/events/Event-dispatch-detached-input-and-change.html')
-rw-r--r-- | testing/web-platform/tests/dom/events/Event-dispatch-detached-input-and-change.html | 190 |
1 files changed, 190 insertions, 0 deletions
diff --git a/testing/web-platform/tests/dom/events/Event-dispatch-detached-input-and-change.html b/testing/web-platform/tests/dom/events/Event-dispatch-detached-input-and-change.html new file mode 100644 index 0000000000..a53ae71ac2 --- /dev/null +++ b/testing/web-platform/tests/dom/events/Event-dispatch-detached-input-and-change.html @@ -0,0 +1,190 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<link rel="author" title="Joey Arhar" href="mailto:jarhar@chromium.org"> +<title>input and change events for detached checkbox and radio elements</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<body> +<script> + +test(() => { + const input = document.createElement('input'); + input.type = 'checkbox'; + + let inputEventFired = false; + input.addEventListener('input', () => inputEventFired = true); + let changeEventFired = false; + input.addEventListener('change', () => changeEventFired = true); + input.click(); + assert_false(inputEventFired); + assert_false(changeEventFired); +}, 'detached checkbox should not emit input or change events on click().'); + +test(() => { + const input = document.createElement('input'); + input.type = 'radio'; + + let inputEventFired = false; + input.addEventListener('input', () => inputEventFired = true); + let changeEventFired = false; + input.addEventListener('change', () => changeEventFired = true); + input.click(); + assert_false(inputEventFired); + assert_false(changeEventFired); +}, 'detached radio should not emit input or change events on click().'); + +test(() => { + const input = document.createElement('input'); + input.type = 'checkbox'; + + let inputEventFired = false; + input.addEventListener('input', () => inputEventFired = true); + let changeEventFired = false; + input.addEventListener('change', () => changeEventFired = true); + input.dispatchEvent(new MouseEvent('click')); + assert_false(inputEventFired); + assert_false(changeEventFired); +}, `detached checkbox should not emit input or change events on dispatchEvent(new MouseEvent('click')).`); + +test(() => { + const input = document.createElement('input'); + input.type = 'radio'; + + let inputEventFired = false; + input.addEventListener('input', () => inputEventFired = true); + let changeEventFired = false; + input.addEventListener('change', () => changeEventFired = true); + input.dispatchEvent(new MouseEvent('click')); + assert_false(inputEventFired); + assert_false(changeEventFired); +}, `detached radio should not emit input or change events on dispatchEvent(new MouseEvent('click')).`); + + +test(() => { + const input = document.createElement('input'); + input.type = 'checkbox'; + document.body.appendChild(input); + + let inputEventFired = false; + input.addEventListener('input', () => inputEventFired = true); + let changeEventFired = false; + input.addEventListener('change', () => changeEventFired = true); + input.click(); + assert_true(inputEventFired); + assert_true(changeEventFired); +}, 'attached checkbox should emit input and change events on click().'); + +test(() => { + const input = document.createElement('input'); + input.type = 'radio'; + document.body.appendChild(input); + + let inputEventFired = false; + input.addEventListener('input', () => inputEventFired = true); + let changeEventFired = false; + input.addEventListener('change', () => changeEventFired = true); + input.click(); + assert_true(inputEventFired); + assert_true(changeEventFired); +}, 'attached radio should emit input and change events on click().'); + +test(() => { + const input = document.createElement('input'); + input.type = 'checkbox'; + document.body.appendChild(input); + + let inputEventFired = false; + input.addEventListener('input', () => inputEventFired = true); + let changeEventFired = false; + input.addEventListener('change', () => changeEventFired = true); + input.dispatchEvent(new MouseEvent('click')); + assert_true(inputEventFired); + assert_true(changeEventFired); +}, `attached checkbox should emit input and change events on dispatchEvent(new MouseEvent('click')).`); + +test(() => { + const input = document.createElement('input'); + input.type = 'radio'; + document.body.appendChild(input); + + let inputEventFired = false; + input.addEventListener('input', () => inputEventFired = true); + let changeEventFired = false; + input.addEventListener('change', () => changeEventFired = true); + input.dispatchEvent(new MouseEvent('click')); + assert_true(inputEventFired); + assert_true(changeEventFired); +}, `attached radio should emit input and change events on dispatchEvent(new MouseEvent('click')).`); + + +test(() => { + const input = document.createElement('input'); + input.type = 'checkbox'; + const shadowHost = document.createElement('div'); + document.body.appendChild(shadowHost); + const shadowRoot = shadowHost.attachShadow({mode: 'open'}); + shadowRoot.appendChild(input); + + let inputEventFired = false; + input.addEventListener('input', () => inputEventFired = true); + let changeEventFired = false; + input.addEventListener('change', () => changeEventFired = true); + input.click(); + assert_true(inputEventFired); + assert_true(changeEventFired); +}, 'attached to shadow dom checkbox should emit input and change events on click().'); + +test(() => { + const input = document.createElement('input'); + input.type = 'radio'; + const shadowHost = document.createElement('div'); + document.body.appendChild(shadowHost); + const shadowRoot = shadowHost.attachShadow({mode: 'open'}); + shadowRoot.appendChild(input); + + let inputEventFired = false; + input.addEventListener('input', () => inputEventFired = true); + let changeEventFired = false; + input.addEventListener('change', () => changeEventFired = true); + input.click(); + assert_true(inputEventFired); + assert_true(changeEventFired); +}, 'attached to shadow dom radio should emit input and change events on click().'); + +test(() => { + const input = document.createElement('input'); + input.type = 'checkbox'; + const shadowHost = document.createElement('div'); + document.body.appendChild(shadowHost); + const shadowRoot = shadowHost.attachShadow({mode: 'open'}); + shadowRoot.appendChild(input); + + let inputEventFired = false; + input.addEventListener('input', () => inputEventFired = true); + let changeEventFired = false; + input.addEventListener('change', () => changeEventFired = true); + input.dispatchEvent(new MouseEvent('click')); + assert_true(inputEventFired); + assert_true(changeEventFired); +}, `attached to shadow dom checkbox should emit input and change events on dispatchEvent(new MouseEvent('click')).`); + +test(() => { + const input = document.createElement('input'); + input.type = 'radio'; + const shadowHost = document.createElement('div'); + document.body.appendChild(shadowHost); + const shadowRoot = shadowHost.attachShadow({mode: 'open'}); + shadowRoot.appendChild(input); + + let inputEventFired = false; + input.addEventListener('input', () => inputEventFired = true); + let changeEventFired = false; + input.addEventListener('change', () => changeEventFired = true); + input.dispatchEvent(new MouseEvent('click')); + assert_true(inputEventFired); + assert_true(changeEventFired); +}, `attached to shadow dom radio should emit input and change events on dispatchEvent(new MouseEvent('click')).`); + +</script> +</body> |