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 /dom/html/test/test_bug557087-2.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 'dom/html/test/test_bug557087-2.html')
-rw-r--r-- | dom/html/test/test_bug557087-2.html | 359 |
1 files changed, 359 insertions, 0 deletions
diff --git a/dom/html/test/test_bug557087-2.html b/dom/html/test/test_bug557087-2.html new file mode 100644 index 0000000000..7c4b9e5864 --- /dev/null +++ b/dom/html/test/test_bug557087-2.html @@ -0,0 +1,359 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=557087 +--> +<head> + <title>Test for Bug 557087</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <script src="/tests/SimpleTest/EventUtils.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=557087">Mozilla Bug 557087</a> +<p id="display"></p> +<div id="content" style="display:none;"> +</div> +<pre id="test"> +<script type="application/javascript"> + +/** Test for Bug 557087 **/ + +SimpleTest.waitForExplicitFinish(); + +var elementsPreventingClick = [ "input", "button", "select", "textarea", "fieldset" ]; +var elementsWithClick = [ "option", "optgroup", "output", "label", "object" ]; +var gHandled = 0; + +function clickShouldNotHappenHandler(aEvent) +{ + aEvent.target.removeEventListener("click", clickShouldNotHappenHandler); + ok(false, "click event should be prevented! (test1)"); + if (++gHandled >= elementsWithClick.length) { + test2(); + } +} + +function clickShouldNotHappenHandler2(aEvent) +{ + aEvent.target.removeEventListener("click", clickShouldNotHappenHandler3); + ok(false, "click event should be prevented! (test2)"); + if (++gHandled >= elementsWithClick.length) { + test3(); + } +} + +function clickShouldNotHappenHandler5(aEvent) +{ + aEvent.target.removeEventListener("click", clickShouldNotHappenHandler5); + ok(false, "click event should be prevented! (test5)"); + if (++gHandled >= elementsWithClick.length) { + test6(); + } +} + +function clickShouldNotHappenHandler7(aEvent) +{ + aEvent.target.removeEventListener("click", clickShouldNotHappenHandler7); + ok(false, "click event should be prevented! (test7)"); + if (++gHandled >= elementsWithClick.length) { + test8(); + } +} + +function clickShouldHappenHandler(aEvent) +{ + aEvent.target.removeEventListener("click", clickShouldHappenHandler); + ok(true, "click event has been correctly received (test1)"); + if (++gHandled >= elementsWithClick.length) { + test2(); + } +} + +function clickShouldHappenHandler2(aEvent) +{ + aEvent.target.removeEventListener("click", clickShouldHappenHandler2); + ok(true, "click event has been correctly received (test2)"); + if (++gHandled >= elementsWithClick.length) { + test3(); + } +} + +function clickShouldHappenHandler3(aEvent) +{ + aEvent.target.removeEventListener("click", clickShouldHappenHandler3); + ok(true, "click event has been correctly received (test3)"); + if (++gHandled >= (elementsWithClick.length + + elementsPreventingClick.length)) { + test4(); + } +} + +function clickShouldHappenHandler4(aEvent) +{ + aEvent.target.removeEventListener("click", clickShouldHappenHandler4); + ok(true, "click event has been correctly received (test4)"); + if (++gHandled >= (elementsWithClick.length + + elementsPreventingClick.length)) { + test5(); + } +} + +function clickShouldHappenHandler5(aEvent) +{ + aEvent.target.removeEventListener("click", clickShouldHappenHandler5); + ok(true, "click event has been correctly received (test5)"); + if (++gHandled >= elementsWithClick.length) { + test6(); + } +} + +function clickShouldHappenHandler6(aEvent) +{ + aEvent.target.removeEventListener("click", clickShouldHappenHandler6); + ok(true, "click event has been correctly received (test6)"); + if (++gHandled >= (elementsWithClick.length + + elementsPreventingClick.length)) { + test7(); + } +} + +function clickShouldHappenHandler7(aEvent) +{ + aEvent.target.removeEventListener("click", clickShouldHappenHandler7); + ok(true, "click event has been correctly received (test5)"); + if (++gHandled >= elementsWithClick.length) { + test8(); + } +} + +function clickShouldHappenHandler8(aEvent) +{ + aEvent.target.removeEventListener("click", clickShouldHappenHandler8); + ok(true, "click event has been correctly received (test8)"); + if (++gHandled >= (elementsWithClick.length + + elementsPreventingClick.length)) { + SimpleTest.finish(); + } +} + +var fieldset1 = document.createElement("fieldset"); +var fieldset2 = document.createElement("fieldset"); +var legendA = document.createElement("legend"); +var legendB = document.createElement("legend"); +var content = document.getElementById('content'); +fieldset1.disabled = true; +content.appendChild(fieldset1); +fieldset1.appendChild(fieldset2); + +function clean() +{ + var count = fieldset2.children.length; + for (var i=0; i<count; ++i) { + if (fieldset2.children[i] != legendA && + fieldset2.children[i] != legendB) { + fieldset2.removeChild(fieldset2.children[i]); + } + } +} + +function test1() +{ + gHandled = 0; + + // Initialize children without click expected. + for (var name of elementsPreventingClick) { + var element = document.createElement(name); + fieldset2.appendChild(element); + element.addEventListener("click", clickShouldNotHappenHandler); + sendMouseEvent({type:'click'}, element); + } + + // Initialize children with click expected. + for (var name of elementsWithClick) { + var element = document.createElement(name); + fieldset2.appendChild(element); + element.addEventListener("click", clickShouldHappenHandler); + sendMouseEvent({type:'click'}, element); + } +} + +function test2() +{ + gHandled = 0; + fieldset1.disabled = false; + fieldset2.disabled = true; + + // Initialize children without click expected. + for (var name of elementsPreventingClick) { + var element = document.createElement(name); + fieldset2.appendChild(element); + element.addEventListener("click", clickShouldNotHappenHandler2); + sendMouseEvent({type:'click'}, element); + } + + // Initialize children with click expected. + for (var name of elementsWithClick) { + var element = document.createElement(name); + fieldset2.appendChild(element); + element.addEventListener("click", clickShouldHappenHandler2); + sendMouseEvent({type:'click'}, element); + } +} + +function test3() +{ + gHandled = 0; + fieldset1.disabled = false; + fieldset2.disabled = false; + + // All elements should accept the click. + for (var name of elementsPreventingClick) { + var element = document.createElement(name); + fieldset2.appendChild(element); + element.addEventListener("click", clickShouldHappenHandler3); + sendMouseEvent({type:'click'}, element); + } + + // Initialize children with click expected. + for (var name of elementsWithClick) { + var element = document.createElement(name); + fieldset2.appendChild(element); + element.addEventListener("click", clickShouldHappenHandler3); + sendMouseEvent({type:'click'}, element); + } +} + +function test4() +{ + gHandled = 0; + fieldset1.disabled = false; + fieldset2.disabled = true; + + fieldset2.appendChild(legendA); + + // All elements should accept the click. + for (var name of elementsPreventingClick) { + var element = document.createElement(name); + legendA.appendChild(element); + element.addEventListener("click", clickShouldHappenHandler4); + sendMouseEvent({type:'click'}, element); + } + + // Initialize children with click expected. + for (var name of elementsWithClick) { + var element = document.createElement(name); + legendA.appendChild(element); + element.addEventListener("click", clickShouldHappenHandler4); + sendMouseEvent({type:'click'}, element); + } +} + +function test5() +{ + gHandled = 0; + fieldset2.insertBefore(legendB, legendA); + + // Initialize children without click expected. + for (var name of elementsPreventingClick) { + var element = document.createElement(name); + legendA.appendChild(element); + element.addEventListener("click", clickShouldNotHappenHandler5); + sendMouseEvent({type:'click'}, element); + } + + // Initialize children with click expected. + for (var name of elementsWithClick) { + var element = document.createElement(name); + legendA.appendChild(element); + element.addEventListener("click", clickShouldHappenHandler5); + sendMouseEvent({type:'click'}, element); + } +} + +function test6() +{ + gHandled = 0; + fieldset2.removeChild(legendB); + fieldset1.disabled = true; + fieldset2.disabled = false; + + fieldset1.appendChild(legendA); + legendA.appendChild(fieldset2); + + // All elements should accept the click. + for (var name of elementsPreventingClick) { + var element = document.createElement(name); + fieldset2.appendChild(element); + element.addEventListener("click", clickShouldHappenHandler6); + sendMouseEvent({type:'click'}, element); + } + + // Initialize children with click expected. + for (var name of elementsWithClick) { + var element = document.createElement(name); + fieldset2.appendChild(element); + element.addEventListener("click", clickShouldHappenHandler6); + sendMouseEvent({type:'click'}, element); + } +} + +function test7() +{ + gHandled = 0; + fieldset1.disabled = true; + fieldset2.disabled = false; + + fieldset1.appendChild(fieldset2); + fieldset2.appendChild(legendA); + + // All elements should accept the click. + for (var name of elementsPreventingClick) { + var element = document.createElement(name); + legendA.appendChild(element); + element.addEventListener("click", clickShouldNotHappenHandler7); + sendMouseEvent({type:'click'}, element); + } + + // Initialize children with click expected. + for (var name of elementsWithClick) { + var element = document.createElement(name); + legendA.appendChild(element); + element.addEventListener("click", clickShouldHappenHandler7); + sendMouseEvent({type:'click'}, element); + } +} + +function test8() +{ + gHandled = 0; + fieldset1.disabled = true; + fieldset2.disabled = true; + + fieldset1.appendChild(legendA); + legendA.appendChild(fieldset2); + fieldset2.appendChild(legendB); + + // All elements should accept the click. + for (var name of elementsPreventingClick) { + var element = document.createElement(name); + legendB.appendChild(element); + element.addEventListener("click", clickShouldHappenHandler8); + sendMouseEvent({type:'click'}, element); + } + + // Initialize children with click expected. + for (var name of elementsWithClick) { + var element = document.createElement(name); + legendB.appendChild(element); + element.addEventListener("click", clickShouldHappenHandler8); + sendMouseEvent({type:'click'}, element); + } +} + +test1(); + +</script> +</pre> +</body> +</html> |