diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/dom/events/Event-propagation.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/dom/events/Event-propagation.html')
-rw-r--r-- | testing/web-platform/tests/dom/events/Event-propagation.html | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/testing/web-platform/tests/dom/events/Event-propagation.html b/testing/web-platform/tests/dom/events/Event-propagation.html new file mode 100644 index 0000000000..33989eb4bf --- /dev/null +++ b/testing/web-platform/tests/dom/events/Event-propagation.html @@ -0,0 +1,48 @@ +<!doctype html> +<title>Event propagation tests</title> +<link rel=author title="Aryeh Gregor" href=ayg@aryeh.name> +<div id=log></div> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script> +"use strict"; + +function testPropagationFlag(ev, expected, desc) { + test(function() { + var called = false; + var callback = function() { called = true }; + this.add_cleanup(function() { + document.head.removeEventListener("foo", callback) + }); + document.head.addEventListener("foo", callback); + document.head.dispatchEvent(ev); + assert_equals(called, expected, "Propagation flag"); + // dispatchEvent resets the propagation flags so it will happily dispatch + // the event the second time around. + document.head.dispatchEvent(ev); + assert_equals(called, true, "Propagation flag after first dispatch"); + }, desc); +} + +var ev = document.createEvent("Event"); +ev.initEvent("foo", true, false); +testPropagationFlag(ev, true, "Newly-created Event"); +ev.stopPropagation(); +testPropagationFlag(ev, false, "After stopPropagation()"); +ev.initEvent("foo", true, false); +testPropagationFlag(ev, true, "Reinitialized after stopPropagation()"); + +var ev = document.createEvent("Event"); +ev.initEvent("foo", true, false); +ev.stopImmediatePropagation(); +testPropagationFlag(ev, false, "After stopImmediatePropagation()"); +ev.initEvent("foo", true, false); +testPropagationFlag(ev, true, "Reinitialized after stopImmediatePropagation()"); + +var ev = document.createEvent("Event"); +ev.initEvent("foo", true, false); +ev.cancelBubble = true; +testPropagationFlag(ev, false, "After cancelBubble=true"); +ev.initEvent("foo", true, false); +testPropagationFlag(ev, true, "Reinitialized after cancelBubble=true"); +</script> |