diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /remote/test/browser/input/browser_dispatchMouseEvent.js | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | remote/test/browser/input/browser_dispatchMouseEvent.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/remote/test/browser/input/browser_dispatchMouseEvent.js b/remote/test/browser/input/browser_dispatchMouseEvent.js new file mode 100644 index 0000000000..96adcd5a8a --- /dev/null +++ b/remote/test/browser/input/browser_dispatchMouseEvent.js @@ -0,0 +1,60 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +add_task(async function testDispatchMouseEvent({ client }) { + await loadURL(toDataURL("<div>foo</div>")); + + const { Input } = client; + + await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function() { + const div = content.document.querySelector("div"); + content.mouseDownPromise = new Promise(resolve => { + div.addEventListener("mousedown", resolve, { once: true }); + }); + content.mouseUpPromise = new Promise(resolve => { + div.addEventListener("mouseup", resolve, { once: true }); + }); + content.clickPromise = new Promise(resolve => { + div.addEventListener("click", resolve, { once: true }); + }); + }); + + const { x, y } = await SpecialPowers.spawn( + gBrowser.selectedBrowser, + [], + () => { + return content.document.querySelector("div").getBoundingClientRect(); + } + ); + + await Input.dispatchMouseEvent({ + type: "mousePressed", + x, + y, + }); + + info("Waiting for DOM mousedown event on the div"); + await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() { + await content.mouseDownPromise; + }); + + await Input.dispatchMouseEvent({ + type: "mouseReleased", + x, + y, + }); + + info("Waiting for DOM mouseup event on the div"); + await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() { + await content.mouseUpPromise; + }); + + info("Waiting for DOM click event on the div"); + await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() { + await content.clickPromise; + }); + + ok(true, "All events detected"); +}); |