"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 hasContainers = Services.prefs.getBoolPref("privacy.userContext.enabled") && ContextualIdentityService.getPublicIdentities().length; const example_base = "http://example.com/browser/browser/base/content/test/contextMenu/"; 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, "---", 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