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 /dom/html/test/test_bug428135.xhtml | |
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 '')
-rw-r--r-- | dom/html/test/test_bug428135.xhtml | 156 |
1 files changed, 156 insertions, 0 deletions
diff --git a/dom/html/test/test_bug428135.xhtml b/dom/html/test/test_bug428135.xhtml new file mode 100644 index 0000000000..ce269e2f8c --- /dev/null +++ b/dom/html/test/test_bug428135.xhtml @@ -0,0 +1,156 @@ +<?xml version="1.0"?> +<html xmlns="http://www.w3.org/1999/xhtml"> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=428135 +--> +<head> + <title>Test for Bug 428135</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=428135">Mozilla Bug 428135</a> +<p id="display"></p> +<div id="content" style="display: none"> + +</div> +<pre id="test"> +<script class="testbody" type="text/javascript"> +<![CDATA[ + +/** Test for Bug 428135 **/ + +var expectedCurrentTargets = new Array(); + +function d(el, ename) { + var e = document.createEvent("Events"); + e.initEvent(ename, true, true); + el.dispatchEvent(e); +} + +function testListener(e) { + e.preventDefault(); + var expected = expectedCurrentTargets.shift(); + ok(expected == e.currentTarget, + "Unexpected current target [" + e.currentTarget + "], event=" + e.type + + ", phase=" + e.eventPhase + ", target should have been " + expected); +} + +function getAndAddListeners(elname) { + var el = document; + if (elname) { + el = document.getElementById(elname); + } + el.addEventListener("submit", testListener, true); + el.addEventListener("submit", testListener); + el.addEventListener("reset", testListener, true); + el.addEventListener("reset", testListener); + el.addEventListener("fooEvent", testListener, true); + el.addEventListener("fooEvent", testListener); + return el; +} + +function testSubmitResetEvents() { + getAndAddListeners(null); + var outerForm = getAndAddListeners("outerForm"); + var outerSubmit = getAndAddListeners("outerSubmit"); + var outerReset = getAndAddListeners("outerReset"); + var outerSubmitDispatcher = getAndAddListeners("outerSubmitDispatcher"); + var outerResetDispatcher = getAndAddListeners("outerResetDispatcher"); + var outerChild = getAndAddListeners("outerChild"); + var innerForm = getAndAddListeners("innerForm"); + var innerSubmit = getAndAddListeners("innerSubmit"); + var innerReset = getAndAddListeners("innerReset"); + var innerSubmitDispatcher = getAndAddListeners("innerSubmitDispatcher"); + var innerResetDispatcher = getAndAddListeners("innerResetDispatcher"); + + expectedCurrentTargets = new Array(document, outerForm, outerForm, document); + outerSubmit.click(); + ok(!expectedCurrentTargets.length, + "(1) expectedCurrentTargets isn't empty!"); + + expectedCurrentTargets = new Array(document, outerForm, outerForm, document); + outerReset.click(); + ok(!expectedCurrentTargets.length, + "(2) expectedCurrentTargets isn't empty!"); + + // Because of bug 428135, submit shouldn't propagate + // back to outerForm and document! + expectedCurrentTargets = + new Array(document, outerForm, outerSubmitDispatcher, outerSubmitDispatcher); + outerSubmitDispatcher.click(); + ok(!expectedCurrentTargets.length, + "(3) expectedCurrentTargets isn't empty!"); + + // Because of bug 428135, reset shouldn't propagate + // back to outerForm and document! + expectedCurrentTargets = + new Array(document, outerForm, outerResetDispatcher, outerResetDispatcher); + outerResetDispatcher.click(); + ok(!expectedCurrentTargets.length, + "(4) expectedCurrentTargets isn't empty!"); + + // Because of bug 428135, submit shouldn't propagate + // back to outerForm and document! + expectedCurrentTargets = + new Array(document, outerForm, outerChild, innerForm, innerForm, outerChild); + innerSubmit.click(); + ok(!expectedCurrentTargets.length, + "(5) expectedCurrentTargets isn't empty!"); + + // Because of bug 428135, reset shouldn't propagate + // back to outerForm and document! + expectedCurrentTargets = + new Array(document, outerForm, outerChild, innerForm, innerForm, outerChild); + innerReset.click(); + ok(!expectedCurrentTargets.length, + "(6) expectedCurrentTargets isn't empty!"); + + // Because of bug 428135, submit shouldn't propagate + // back to inner/outerForm or document! + expectedCurrentTargets = + new Array(document, outerForm, outerChild, innerForm, innerSubmitDispatcher, + innerSubmitDispatcher); + innerSubmitDispatcher.click(); + ok(!expectedCurrentTargets.length, + "(7) expectedCurrentTargets isn't empty!"); + + // Because of bug 428135, reset shouldn't propagate + // back to inner/outerForm or document! + expectedCurrentTargets = + new Array(document, outerForm, outerChild, innerForm, innerResetDispatcher, + innerResetDispatcher); + innerResetDispatcher.click(); + ok(!expectedCurrentTargets.length, + "(8) expectedCurrentTargets isn't empty!"); +} + +SimpleTest.waitForExplicitFinish(); +addLoadEvent(testSubmitResetEvents); +addLoadEvent(SimpleTest.finish); + + +]]> +</script> +</pre> +<form id="outerForm"> + <input type="submit" value="outer" id="outerSubmit"/> + <input type="reset" value="reset outer" id="outerReset"/> + <input type="button" value="dispatch submit" onclick="d(this, 'submit')" + id="outerSubmitDispatcher"/> + <input type="button" value="dispatch reset" onclick="d(this, 'reset')" + id="outerResetDispatcher"/> + <div id="outerChild"> + <form id="innerForm"> + <input type="submit" value="inner" id="innerSubmit"/> + <input type="reset" value="reset inner" id="innerReset"/> + <input type="button" value="dispatch submit" onclick="d(this, 'submit')" + id="innerSubmitDispatcher"/> + <input type="button" value="dispatch reset" onclick="d(this, 'reset')" + id="innerResetDispatcher"/> + </form> + </div> +</form> +</body> +</html> + |