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-reenter.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-reenter.html')
-rw-r--r-- | testing/web-platform/tests/dom/events/Event-dispatch-reenter.html | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/testing/web-platform/tests/dom/events/Event-dispatch-reenter.html b/testing/web-platform/tests/dom/events/Event-dispatch-reenter.html new file mode 100644 index 0000000000..71f8517bdd --- /dev/null +++ b/testing/web-platform/tests/dom/events/Event-dispatch-reenter.html @@ -0,0 +1,66 @@ +<!DOCTYPE html> +<meta charset=utf-8> +<title> Dispatch additional events inside an event listener </title> +<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> +test(function() { + var event_type = "foo"; + var target = document.getElementById("target"); + var parent = document.getElementById("parent"); + var tbody = document.getElementById("table-body"); + var table = document.getElementById("table"); + var body = document.body; + var html = document.documentElement; + var targets = [window, document, html, body, table, tbody, parent, target]; + var expected_targets = [ + window, document, html, body, table, + target, parent, tbody, + table, body, html, document, window, + tbody, parent, target]; + var actual_targets = []; + var expected_types = [ + "foo", "foo", "foo", "foo", "foo", + "bar", "bar", "bar", + "bar", "bar", "bar", "bar", "bar", + "foo", "foo", "foo" + ]; + + var actual_targets = [], actual_types = []; + var test_event = this.step_func(function(evt) { + actual_targets.push(evt.currentTarget); + actual_types.push(evt.type); + + if (table == evt.currentTarget && event_type == evt.type) { + var e = document.createEvent("Event"); + e.initEvent("bar", true, true); + target.dispatchEvent(e); + } + }); + + for (var i = 0; i < targets.length; ++i) { + targets[i].addEventListener(event_type, test_event, true); + targets[i].addEventListener("bar", test_event, false); + } + + var evt = document.createEvent("Event"); + evt.initEvent(event_type, false, true); + target.dispatchEvent(evt); + + assert_array_equals(actual_targets, expected_targets, "actual_targets"); + assert_array_equals(actual_types, expected_types, "actual_types"); +}); +</script> |