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/browser_dragimage.js | |
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/browser_dragimage.js')
-rw-r--r-- | dom/events/test/browser_dragimage.js | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/dom/events/test/browser_dragimage.js b/dom/events/test/browser_dragimage.js new file mode 100644 index 0000000000..503c0ac449 --- /dev/null +++ b/dom/events/test/browser_dragimage.js @@ -0,0 +1,65 @@ +const TEST_URI = "dragimage.html"; + +// This test checks that dragging an image onto the same document +// does not drop it, even when the page cancels the dragover event. +add_task(async function dragimage_remote_tab() { + var tab = await BrowserTestUtils.openNewForegroundTab( + gBrowser, + "http://www.example.com/browser/dom/events/test/" + TEST_URI + ); + + let dropHappened = false; + let oldHandler = tab.linkedBrowser.droppedLinkHandler; + tab.linkedBrowser.droppedLinkHandler = () => { + dropHappened = true; + }; + + await SpecialPowers.spawn(tab.linkedBrowser, [], async () => { + let image = content.document.body.firstElementChild; + let target = content.document.body.lastElementChild; + + await EventUtils.synthesizePlainDragAndDrop({ + srcElement: image, + destElement: target, + srcWindow: content, + destWindow: content, + id: content.windowUtils.DEFAULT_MOUSE_POINTER_ID, + }); + }); + + tab.linkedBrowser.droppedLinkHandler = oldHandler; + + ok(!dropHappened, "drop did not occur"); + + BrowserTestUtils.removeTab(tab); +}); + +// This test checks the same but with an in-process page. +add_task(async function dragimage_local_tab() { + var tab = await BrowserTestUtils.openNewForegroundTab( + gBrowser, + getRootDirectory(gTestPath) + TEST_URI + ); + + let dropHappened = false; + let oldHandler = tab.linkedBrowser.droppedLinkHandler; + tab.linkedBrowser.droppedLinkHandler = () => { + dropHappened = true; + }; + + let image = tab.linkedBrowser.contentDocument.body.firstElementChild; + let target = tab.linkedBrowser.contentDocument.body.lastElementChild; + + await EventUtils.synthesizePlainDragAndDrop({ + srcElement: image, + destElement: target, + srcWindow: tab.linkedBrowser.contentWindow, + destWindow: tab.linkedBrowser.contentWindow, + }); + + tab.linkedBrowser.droppedLinkHandler = oldHandler; + + ok(!dropHappened, "drop did not occur"); + + BrowserTestUtils.removeTab(tab); +}); |