diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /dom/events/test/file_bug1484371.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/events/test/file_bug1484371.html')
-rw-r--r-- | dom/events/test/file_bug1484371.html | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/dom/events/test/file_bug1484371.html b/dom/events/test/file_bug1484371.html new file mode 100644 index 0000000000..56c284b733 --- /dev/null +++ b/dom/events/test/file_bug1484371.html @@ -0,0 +1,94 @@ +<html> + <head> + <script src="/tests/SimpleTest/EventUtils.js"></script> + <script> + var mouseEnterCount = 0; + function mouseEnter() { + ++mouseEnterCount; + } + var mouseLeaveCount = 0; + function mouseLeave() { + ++mouseLeaveCount; + } + + var pointerEnterCount = 0; + function pointerEnter() { + ++pointerEnterCount; + } + var pointerLeaveCount = 0; + function pointerLeave() { + ++pointerLeaveCount; + } + + function pointerEventsEnabled() { + return "onpointerenter" in document.body; + } + + function checkEventCounts(expected, msg) { + parent.is(mouseEnterCount, expected.mouseEnterCount, msg + ": mouseenter event count"); + parent.is(mouseLeaveCount, expected.mouseLeaveCount, msg + ": mouseleave event count"); + if (pointerEventsEnabled()) { + parent.is(pointerEnterCount, expected.pointerEnterCount, msg + ": pointerenter event count"); + parent.is(pointerLeaveCount, expected.pointerLeaveCount, msg + ": pointerleave event count"); + } + } + + function test() { + var lightDiv = document.getElementById("lightDiv"); + var host = document.getElementById("host"); + var sr = host.attachShadow({mode: "closed"}); + sr.innerHTML = "<div>shadow DOM<div>"; + var shadowDiv = sr.firstChild; + + host.addEventListener("mouseenter", mouseEnter, true); + host.addEventListener("mouseleave", mouseLeave, true); + host.addEventListener("pointerenter", pointerEnter, true); + host.addEventListener("pointerleave", pointerLeave, true); + + shadowDiv.addEventListener("mouseenter", mouseEnter, true); + shadowDiv.addEventListener("mouseleave", mouseLeave, true); + shadowDiv.addEventListener("pointerenter", pointerEnter, true); + shadowDiv.addEventListener("pointerleave", pointerLeave, true); + + synthesizeMouseAtCenter(lightDiv, { type: "mousemove" }); + checkEventCounts({ mouseEnterCount: 0, + mouseLeaveCount: 0, + pointerEnterCount: 0, + pointerLeaveCount: 0 + }, + "Entered light DOM" + ); + + synthesizeMouseAtCenter(shadowDiv, { type: "mousemove" }) + checkEventCounts({ mouseEnterCount: 2, + mouseLeaveCount: 0, + pointerEnterCount: 2, + pointerLeaveCount: 0 + }, + "Entered shadow DOM"); + + synthesizeMouseAtCenter(lightDiv, { type: "mousemove" }) + checkEventCounts({ mouseEnterCount: 2, + mouseLeaveCount: 2, + pointerEnterCount: 2, + pointerLeaveCount: 2 + }, + "Left shadow DOM" + ); + + parent.SimpleTest.finish(); + } + + function lazyRequestAnimationFrame(fn) { + requestAnimationFrame( + function() { + setTimeout(fn); + }); + } + </script> + </head> + <body onload="lazyRequestAnimationFrame(test)"> + <div id="lightDiv">light DOM</div> + <div id="host"></div> + </body> +</html> |