diff --git a/browser/components/extensions/test/browser/browser-common.ini b/browser/components/extensions/test/browser/browser-common.ini index 3d22c692412d..e99d40e1e494 100644 --- a/browser/components/extensions/test/browser/browser-common.ini +++ b/browser/components/extensions/test/browser/browser-common.ini @@ -56,7 +56,6 @@ skip-if = (os == 'win' && !debug) # bug 1352668 [browser_ext_contextMenus_checkboxes.js] [browser_ext_contextMenus_commands.js] [browser_ext_contextMenus_icons.js] -skip-if = os == 'win' && !debug # Bug 1351638 [browser_ext_contextMenus_onclick.js] [browser_ext_contextMenus_radioGroups.js] [browser_ext_contextMenus_uninstall.js] diff --git a/browser/components/extensions/test/browser/browser_ext_contextMenus_commands.js b/browser/components/extensions/test/browser/browser_ext_contextMenus_commands.js index 39587c11fb84..355be93c43bf 100644 --- a/browser/components/extensions/test/browser/browser_ext_contextMenus_commands.js +++ b/browser/components/extensions/test/browser/browser_ext_contextMenus_commands.js @@ -33,6 +33,7 @@ add_task(async function() { let extension = ExtensionTestUtils.loadExtension({ manifest: { + "name": "contextMenus commands", "permissions": ["contextMenus", "activeTab", "tabs"], "browser_action": { "default_title": "Test BrowserAction", @@ -59,6 +60,7 @@ add_task(async function() { async function testContext(id) { const menu = await openExtensionContextMenu(); const items = menu.getElementsByAttribute("label", id); + is(items.length, 1, `exactly one menu item found`); await closeExtensionContextMenu(items[0]); return extension.awaitMessage("test-opened"); } diff --git a/browser/components/extensions/test/browser/browser_ext_contextMenus_icons.js b/browser/components/extensions/test/browser/browser_ext_contextMenus_icons.js index 0f963160a5ab..a659336f8d94 100644 --- a/browser/components/extensions/test/browser/browser_ext_contextMenus_icons.js +++ b/browser/components/extensions/test/browser/browser_ext_contextMenus_icons.js @@ -11,6 +11,7 @@ add_task(async function() { let extension = ExtensionTestUtils.loadExtension({ manifest: { + "name": "contextMenus icons", "permissions": ["contextMenus"], "icons": { "18": "extension.png", @@ -38,9 +39,10 @@ add_task(async function() { }, }); - let confirmContextMenuIcon = (rootElement) => { + let confirmContextMenuIcon = (rootElements) => { let expectedURL = new RegExp(String.raw`^moz-extension://[^/]+/extension\.png$`); - let imageUrl = rootElement.getAttribute("image"); + is(rootElements.length, 1, "Found exactly one menu item"); + let imageUrl = rootElements[0].getAttribute("image"); ok(expectedURL.test(imageUrl), "The context menu should display the extension icon next to the root element"); }; @@ -50,17 +52,18 @@ add_task(async function() { let extensionMenu = await openExtensionContextMenu(); let contextMenu = document.getElementById("contentAreaContextMenu"); - let topLevelMenuItem = contextMenu.getElementsByAttribute("ext-type", "top-level-menu")[0]; + let topLevelMenuItem = contextMenu.getElementsByAttribute("ext-type", "top-level-menu"); confirmContextMenuIcon(topLevelMenuItem); - let childToDelete = extensionMenu.getElementsByAttribute("label", "child-to-delete")[0]; - await closeExtensionContextMenu(childToDelete); + let childToDelete = extensionMenu.getElementsByAttribute("label", "child-to-delete"); + is(childToDelete.length, 1, "Found exactly one child to delete"); + await closeExtensionContextMenu(childToDelete[0]); await extension.awaitMessage("child-deleted"); await openExtensionContextMenu(); contextMenu = document.getElementById("contentAreaContextMenu"); - topLevelMenuItem = contextMenu.getElementsByAttribute("label", "child")[0]; + topLevelMenuItem = contextMenu.getElementsByAttribute("label", "child"); confirmContextMenuIcon(topLevelMenuItem); await closeContextMenu(); diff --git a/browser/components/extensions/test/browser/browser_ext_contextMenus_onclick.js b/browser/components/extensions/test/browser/browser_ext_contextMenus_onclick.js index 0ca896f5c8aa..6c432de83e07 100644 --- a/browser/components/extensions/test/browser/browser_ext_contextMenus_onclick.js +++ b/browser/components/extensions/test/browser/browser_ext_contextMenus_onclick.js @@ -218,6 +218,7 @@ add_task(async function test_onclick_modifiers() { async function click(modifiers = {}) { const menu = await openContextMenu(); const items = menu.getElementsByAttribute("label", "modify"); + is(items.length, 1, "Got exactly one context menu item"); await closeExtensionContextMenu(items[0], modifiers); return extension.awaitMessage("click"); } diff --git a/browser/components/extensions/test/browser/head.js b/browser/components/extensions/test/browser/head.js index 8f835b63e39d..36b1889d4b5f 100644 --- a/browser/components/extensions/test/browser/head.js +++ b/browser/components/extensions/test/browser/head.js @@ -320,7 +320,7 @@ async function openExtensionContextMenu(selector = "#img1") { return null; } - let extensionMenu = topLevelMenu[0].childNodes[0]; + let extensionMenu = topLevelMenu[0]; let popupShownPromise = BrowserTestUtils.waitForEvent(contextMenu, "popupshown"); EventUtils.synthesizeMouseAtCenter(extensionMenu, {}); await popupShownPromise; @@ -331,7 +331,10 @@ async function closeExtensionContextMenu(itemToSelect, modifiers = {}) { let contentAreaContextMenu = document.getElementById("contentAreaContextMenu"); let popupHiddenPromise = BrowserTestUtils.waitForEvent(contentAreaContextMenu, "popuphidden"); EventUtils.synthesizeMouseAtCenter(itemToSelect, modifiers); - return popupHiddenPromise; + await popupHiddenPromise; + + // Bug 1351638: parent menu fails to close intermittently, make sure it does. + contentAreaContextMenu.hidePopup(); } async function openChromeContextMenu(menuId, target, win = window) {