From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../test/contextMenu/browser_contextmenu.js | 2034 ++++++++++++++++++++ 1 file changed, 2034 insertions(+) create mode 100644 browser/base/content/test/contextMenu/browser_contextmenu.js (limited to 'browser/base/content/test/contextMenu/browser_contextmenu.js') diff --git a/browser/base/content/test/contextMenu/browser_contextmenu.js b/browser/base/content/test/contextMenu/browser_contextmenu.js new file mode 100644 index 0000000000..ebeb4bdb04 --- /dev/null +++ b/browser/base/content/test/contextMenu/browser_contextmenu.js @@ -0,0 +1,2034 @@ +"use strict"; + +let contextMenu; +let LOGIN_FILL_ITEMS = ["---", null, "manage-saved-logins", true]; +let NAVIGATION_ITEMS = + AppConstants.platform == "macosx" + ? [ + "context-back", + false, + "context-forward", + false, + "context-reload", + true, + "---", + null, + "context-bookmarkpage", + true, + ] + : [ + "context-navigation", + null, + [ + "context-back", + false, + "context-forward", + false, + "context-reload", + true, + "context-bookmarkpage", + true, + ], + null, + "---", + null, + ]; +let hasPocket = Services.prefs.getBoolPref("extensions.pocket.enabled"); +let hasStripOnShare = Services.prefs.getBoolPref( + "privacy.query_stripping.strip_on_share.enabled" +); +let hasContainers = + Services.prefs.getBoolPref("privacy.userContext.enabled") && + ContextualIdentityService.getPublicIdentities().length; + +const example_base = + // eslint-disable-next-line @microsoft/sdl/no-insecure-url + "http://example.com/browser/browser/base/content/test/contextMenu/"; +const about_preferences_base = "about:preferences"; +const chrome_base = + "chrome://mochitests/content/browser/browser/base/content/test/contextMenu/"; +const head_base = + "chrome://mochitests/content/browser/browser/base/content/test/contextMenu/"; + +/* import-globals-from contextmenu_common.js */ +Services.scriptloader.loadSubScript( + chrome_base + "contextmenu_common.js", + this +); + +function getThisFrameSubMenu(base_menu) { + if (AppConstants.NIGHTLY_BUILD) { + let osPidItem = ["context-frameOsPid", false]; + base_menu = base_menu.concat(osPidItem); + } + return base_menu; +} + +add_setup(async function () { + await SpecialPowers.pushPrefEnv({ + set: [ + ["browser.search.separatePrivateDefault.ui.enabled", true], + ["extensions.screenshots.disabled", false], + ["layout.forms.reveal-password-context-menu.enabled", true], + ], + }); +}); + +// Below are test cases for XUL element +add_task(async function test_xul_text_link_label() { + let url = chrome_base + "subtst_contextmenu_xul.xhtml"; + + await BrowserTestUtils.openNewForegroundTab({ + gBrowser, + url, + waitForLoad: true, + waitForStateStop: true, + }); + + await test_contextmenu("#test-xul-text-link-label", [ + "context-openlinkintab", + true, + ...(hasContainers ? ["context-openlinkinusercontext-menu", true] : []), + // We need a blank entry here because the containers submenu is + // dynamically generated with no ids. + ...(hasContainers ? ["", null] : []), + "context-openlink", + true, + "context-openlinkprivate", + true, + "---", + null, + "context-bookmarklink", + true, + "context-savelink", + true, + ...(hasPocket ? ["context-savelinktopocket", true] : []), + "context-copylink", + true, + ...(hasStripOnShare ? ["context-stripOnShareLink", true] : []), + "---", + null, + "context-searchselect", + true, + "context-searchselect-private", + true, + ]); + + // Clean up so won't affect HTML element test cases. + lastElementSelector = null; + gBrowser.removeCurrentTab(); +}); + +// Below are test cases for HTML element. + +add_task(async function test_setup_html() { + let url = example_base + "subtst_contextmenu.html"; + + await BrowserTestUtils.openNewForegroundTab(gBrowser, url); + + await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function () { + let doc = content.document; + let audioIframe = doc.querySelector("#test-audio-in-iframe"); + // media documents always use a