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 /layout/base/tests/bug1078327_inner.html | |
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 'layout/base/tests/bug1078327_inner.html')
-rw-r--r-- | layout/base/tests/bug1078327_inner.html | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/layout/base/tests/bug1078327_inner.html b/layout/base/tests/bug1078327_inner.html new file mode 100644 index 0000000000..41fe05a099 --- /dev/null +++ b/layout/base/tests/bug1078327_inner.html @@ -0,0 +1,107 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=1078327 +--> +<head> + <meta charset="utf-8"> + <title>Test for Bug 1078327</title> + <meta name="author" content="Maksim Lebedev" /> + <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"/> + <style> + #target, #listener { background: yellow; padding: 10px; } + #mediator { background: red; padding: 20px; } + </style> + <script type="application/javascript"> + var target = undefined; + var mediator = undefined; + var listener = undefined; + var test_target = false; + var test_capture = false; + var test_mediator_over = false; + var test_mediator_move = false; + var test_mediator_out = false; + var test_listener = false; + var test_lost_capture = false; + + function TargetHandler(event) { + logger("Target receive event: " + event.type + ". Mediator.setPointerCapture()"); + mediator.setPointerCapture(event.pointerId); + test_target = true; + test_capture = true; + } + function MediatorHandler(event) { + logger("Mediator receive event: " + event.type); + if(!test_capture) + return; + if(event.type == "pointermove") + test_mediator_move++; + if(event.type == "pointerover") + test_mediator_over++; + if(event.type == "pointerout") + test_mediator_out++; + if(event.type == "lostpointercapture") + test_lost_capture = true; + } + function ListenerHandler(event) { + logger("Listener receive event: " + event.type); + test_listener = true; + } + function logger(message) { + console.log(message); + var log = document.getElementById('log'); + log.innerHTML = message + "<br>" + log.innerHTML; + } + + function prepareTest() { + SimpleTest.executeSoon(executeTest); + } + function executeTest() + { + logger("executeTest"); + target = document.getElementById("target"); + mediator = document.getElementById("mediator"); + listener = document.getElementById("listener"); + target.addEventListener("pointerdown", TargetHandler); + mediator.addEventListener("gotpointercapture", MediatorHandler); + mediator.addEventListener("pointerover", MediatorHandler); + mediator.addEventListener("pointermove", MediatorHandler); + mediator.addEventListener("pointerout", MediatorHandler); + mediator.addEventListener("lostpointercapture", MediatorHandler); + listener.addEventListener("pointermove", ListenerHandler); + var rect_t = target.getBoundingClientRect(); + var rect_m = mediator.getBoundingClientRect(); + var rect_l = listener.getBoundingClientRect(); + synthesizeMouse(target, rect_t.width/2, rect_t.height/20, {type: "mousedown"}); + synthesizeMouse(target, rect_t.width/2, rect_t.height/20, {type: "mousemove"}); + synthesizeMouse(mediator, rect_m.width/2, rect_m.height/20, {type: "mousemove"}); + synthesizeMouse(listener, rect_l.width/2, rect_l.height/20, {type: "mousemove"}); + synthesizeMouse(mediator, rect_m.width/2, rect_m.height/20, {type: "mousemove"}); + synthesizeMouse(target, rect_t.width/2, rect_t.height/20, {type: "mousemove"}); + synthesizeMouse(target, rect_t.width/2, rect_t.height/20, {type: "mouseup"}); + synthesizeMouse(target, rect_t.width/2, rect_t.height/20, {type: "mousemove"}); + finishTest(); + } + function finishTest() { + parent.is(test_target, true, "pointerdown event should be received by target"); + parent.is(test_lost_capture, true, "mediator should receive lostpointercapture"); + parent.is(test_mediator_over, 1, "mediator should receive pointerover event only once"); + parent.is(test_mediator_move, 5, "mediator should receive pointermove event five times"); + parent.is(test_mediator_out, 1, "mediator should receive pointerout event only once"); + parent.is(test_listener, false, "listener should not receive any events"); + logger("finishTest"); + parent.finishTest(); + } + </script> +</head> +<body onload="prepareTest()"> + <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1078327">Mozilla Bug 1078327</a> + <div id="mediator"> + <div id="listener">div id=listener</div> + </div> + <div id="target">div id=target</div> + <pre id="log"></pre> +</body> +</html> |