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-bubbles-false.html | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.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-bubbles-false.html')
-rw-r--r-- | testing/web-platform/tests/dom/events/Event-dispatch-bubbles-false.html | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/testing/web-platform/tests/dom/events/Event-dispatch-bubbles-false.html b/testing/web-platform/tests/dom/events/Event-dispatch-bubbles-false.html new file mode 100644 index 0000000000..0f43cb0275 --- /dev/null +++ b/testing/web-platform/tests/dom/events/Event-dispatch-bubbles-false.html @@ -0,0 +1,98 @@ +<!DOCTYPE html> +<meta charset=utf-8> +<title> Event.bubbles attribute is set to false </title> +<link rel="help" href="https://dom.spec.whatwg.org/#dom-event-initevent"> +<link rel="help" href="https://dom.spec.whatwg.org/#concept-event-dispatch"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<table id="table" border="1" style="display: none"> + <tbody id="table-body"> + <tr id="table-row"> + <td id="table-cell">Shady Grove</td> + <td>Aeolian</td> + </tr> + <tr id="parent"> + <td id="target">Over the river, Charlie</td> + <td>Dorian</td> + </tr> + </tbody> +</table> +<script> +function targetsForDocumentChain(document) { + return [ + document, + document.documentElement, + document.getElementsByTagName("body")[0], + document.getElementById("table"), + document.getElementById("table-body"), + document.getElementById("parent") + ]; +} + +function testChain(document, targetParents, phases, event_type) { + var target = document.getElementById("target"); + var targets = targetParents.concat(target); + var expected_targets = targets.concat(target); + + var actual_targets = [], actual_phases = []; + var test_event = function(evt) { + actual_targets.push(evt.currentTarget); + actual_phases.push(evt.eventPhase); + } + + for (var i = 0; i < targets.length; i++) { + targets[i].addEventListener(event_type, test_event, true); + targets[i].addEventListener(event_type, test_event, false); + } + + var evt = document.createEvent("Event"); + evt.initEvent(event_type, false, true); + + target.dispatchEvent(evt); + + assert_array_equals(actual_targets, expected_targets, "targets"); + assert_array_equals(actual_phases, phases, "phases"); +} + +var phasesForDocumentChain = [ + Event.CAPTURING_PHASE, + Event.CAPTURING_PHASE, + Event.CAPTURING_PHASE, + Event.CAPTURING_PHASE, + Event.CAPTURING_PHASE, + Event.CAPTURING_PHASE, + Event.AT_TARGET, + Event.AT_TARGET, +]; + +test(function () { + var chainWithWindow = [window].concat(targetsForDocumentChain(document)); + testChain( + document, chainWithWindow, [Event.CAPTURING_PHASE].concat(phasesForDocumentChain), "click"); +}, "In window.document with click event"); + +test(function () { + testChain(document, targetsForDocumentChain(document), phasesForDocumentChain, "load"); +}, "In window.document with load event") + +test(function () { + var documentClone = document.cloneNode(true); + testChain( + documentClone, targetsForDocumentChain(documentClone), phasesForDocumentChain, "click"); +}, "In window.document.cloneNode(true)"); + +test(function () { + var newDocument = new Document(); + newDocument.appendChild(document.documentElement.cloneNode(true)); + testChain( + newDocument, targetsForDocumentChain(newDocument), phasesForDocumentChain, "click"); +}, "In new Document()"); + +test(function () { + var HTMLDocument = document.implementation.createHTMLDocument(); + HTMLDocument.body.appendChild(document.getElementById("table").cloneNode(true)); + testChain( + HTMLDocument, targetsForDocumentChain(HTMLDocument), phasesForDocumentChain, "click"); +}, "In DOMImplementation.createHTMLDocument()"); +</script> |