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 /dom/html/test/browser_content_contextmenu_userinput.js | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/html/test/browser_content_contextmenu_userinput.js')
-rw-r--r-- | dom/html/test/browser_content_contextmenu_userinput.js | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/dom/html/test/browser_content_contextmenu_userinput.js b/dom/html/test/browser_content_contextmenu_userinput.js new file mode 100644 index 0000000000..04d12b332c --- /dev/null +++ b/dom/html/test/browser_content_contextmenu_userinput.js @@ -0,0 +1,72 @@ +"use strict"; + +const kPage = + "http://example.org/browser/" + "dom/html/test/file_content_contextmenu.html"; + +add_task(async function() { + await SpecialPowers.pushPrefEnv({ + set: [["dom.menuitem.enabled", true]], + }); + await BrowserTestUtils.withNewTab( + { + gBrowser, + url: kPage, + }, + async function(aBrowser) { + let contextMenu = document.getElementById("contentAreaContextMenu"); + ok(contextMenu, "Got context menu"); + + info("Open context menu"); + is(contextMenu.state, "closed", "Should not have opened context menu"); + let popupShownPromise = promiseWaitForEvent(window, "popupshown"); + EventUtils.synthesizeMouse( + aBrowser, + window.innerWidth / 3, + window.innerHeight / 3, + { type: "contextmenu", button: 2 }, + window + ); + await popupShownPromise; + is(contextMenu.state, "open", "Should have opened context menu"); + + let pageMenuSep = document.getElementById("page-menu-separator"); + ok( + pageMenuSep && !pageMenuSep.hidden, + "Page menu separator should be shown" + ); + + let testMenuSep = pageMenuSep.previousElementSibling; + ok( + testMenuSep && !testMenuSep.hidden, + "User-added menu separator should be shown" + ); + + let testMenuItem = testMenuSep.previousElementSibling; + is( + testMenuItem.label, + "Test Context Menu Click", + "Got context menu item" + ); + + let promiseCtxMenuClick = SpecialPowers.spawn( + aBrowser, + [], + async function() { + await new Promise(resolve => { + let windowUtils = content.windowUtils; + let menuitem = content.document.getElementById("menuitem"); + menuitem.addEventListener("click", function() { + Assert.ok( + windowUtils.isHandlingUserInput, + "Content menu click should be a user input" + ); + resolve(); + }); + }); + } + ); + EventUtils.synthesizeMouseAtCenter(testMenuItem, {}, window); + await promiseCtxMenuClick; + } + ); +}); |