Bug 1799947 - Update existing tests to put browser_action's into the navbar by default. r=willdurand,extension-reviewers

We had a number of tests that assumed that when adding a browser_action without
specifying the default_area, that the button would enter the navbar. The previous
patch in this series changes that assumption when the Unified Extensions UI is
enabled.

Instead of updating all of these tests to add additional steps to move the
browser_action's out to the navbar after adding them, I've gone ahead and
updated them to default their browser_action's to the navbar instead.

Differential Revision: https://phabricator.services.mozilla.com/D161721
This commit is contained in:
Mike Conley 2022-11-15 18:37:31 +00:00
parent 2b789d1c7f
commit 7f4c164e0d
47 changed files with 167 additions and 42 deletions

View File

@ -92,7 +92,14 @@ async function showBrowserAction(window, extensionId) {
"Expect widget overflow state to match toolbar"
);
} else if (group.areaType == lazy.CustomizableUI.TYPE_PANEL) {
await navbar.overflowable.show();
if (window.gUnifiedExtensions.isEnabled) {
let panel = window.gUnifiedExtensions.panel;
let shown = BrowserTestUtils.waitForPopupEvent(panel, "shown");
window.gUnifiedExtensions.togglePanel();
await shown;
} else {
await navbar.overflowable.show();
}
}
}

View File

@ -45,9 +45,13 @@ async function makeExtension({
};
if (manifest_version === 3) {
manifest.action = {};
manifest.action = {
default_area: "navbar",
};
} else {
manifest.browser_action = {};
manifest.browser_action = {
default_area: "navbar",
};
}
let ext = ExtensionTestUtils.loadExtension({

View File

@ -11,7 +11,9 @@ add_task(async function test_middle_click_with_activeTab() {
let extension = ExtensionTestUtils.loadExtension({
manifest: {
browser_action: {},
browser_action: {
default_area: "navbar",
},
permissions: ["activeTab"],
},
@ -68,6 +70,7 @@ add_task(async function test_middle_click_with_activeTab_and_popup() {
browser_action: {
default_popup: "popup.html",
browser_style: true,
default_area: "navbar",
},
permissions: ["activeTab"],
},
@ -158,7 +161,9 @@ add_task(async function test_middle_click_without_activeTab() {
let extension = ExtensionTestUtils.loadExtension({
manifest: {
browser_action: {},
browser_action: {
default_area: "navbar",
},
},
background() {

View File

@ -127,7 +127,9 @@ async function test_clickData_reset({ manifest_version }) {
let extension = ExtensionTestUtils.loadExtension({
manifest: {
manifest_version,
[action]: {},
[action]: {
default_area: "navbar",
},
page_action: {},
commands: {
[browser_action_command]: {

View File

@ -412,6 +412,7 @@ add_task(async function testTabSwitchContext() {
default_icon: "default.png",
default_popup: "__MSG_popup__",
default_title: "Default __MSG_title__",
default_area: "navbar",
},
default_locale: "en",
@ -434,6 +435,7 @@ add_task(async function testTabSwitchActionContext() {
default_icon: "default.png",
default_popup: "__MSG_popup__",
default_title: "Default __MSG_title__",
default_area: "navbar",
},
default_locale: "en",
permissions: ["tabs"],
@ -449,6 +451,7 @@ add_task(async function testDefaultTitle() {
browser_action: {
default_icon: "icon.png",
default_area: "navbar",
},
permissions: ["tabs"],
@ -528,7 +531,9 @@ add_task(async function testBadgeColorPersistence() {
});
},
manifest: {
browser_action: {},
browser_action: {
default_area: "navbar",
},
},
});
await extension.startup();
@ -580,6 +585,7 @@ add_task(async function testPropertyRemoval() {
default_icon: "default.png",
default_popup: "default.html",
default_title: "Default Title",
default_area: "navbar",
},
},
@ -766,6 +772,7 @@ add_task(async function testMultipleWindows() {
default_icon: "default.png",
default_popup: "default.html",
default_title: "Default Title",
default_area: "navbar",
},
},
@ -936,6 +943,7 @@ add_task(async function testDefaultBadgeTextColor() {
default_icon: "default.png",
default_popup: "default.html",
default_title: "Default Title",
default_area: "navbar",
},
},

View File

@ -24,6 +24,7 @@ let extData = {
permissions: ["contextMenus"],
browser_action: {
default_popup: "popup.html",
default_area: "navbar",
},
},
useAddonManager: "temporary",
@ -203,7 +204,9 @@ async function browseraction_contextmenu_manage_extension_helper(win) {
browser_specific_settings: {
gecko: { id },
},
browser_action: {},
browser_action: {
default_area: "navbar",
},
options_ui: {
page: "options.html",
},
@ -527,7 +530,9 @@ async function browseraction_contextmenu_remove_extension_helper(win) {
browser_specific_settings: {
gecko: { id },
},
browser_action: {},
browser_action: {
default_area: "navbar",
},
},
useAddonManager: "temporary",
});
@ -724,7 +729,9 @@ async function browseraction_contextmenu_report_extension_helper(win) {
browser_specific_settings: {
gecko: { id },
},
browser_action: {},
browser_action: {
default_area: "navbar",
},
},
useAddonManager: "temporary",
});
@ -902,7 +909,9 @@ add_task(async function test_unified_extensions_toolbar_pinning() {
browser_specific_settings: {
gecko: { id },
},
browser_action: {},
browser_action: {
default_area: "navbar",
},
},
useAddonManager: "temporary",
});

View File

@ -5,7 +5,9 @@
add_task(async function testDisabled() {
let extension = ExtensionTestUtils.loadExtension({
manifest: {
browser_action: {},
browser_action: {
default_area: "navbar",
},
},
background: function() {

View File

@ -134,7 +134,9 @@ add_task(async function test_browseraction_with_experiment() {
isPrivileged: true,
manifest: {
browser_action: {},
browser_action: {
default_area: "navbar",
},
experiment_apis: fooExperimentAPIs,
},

View File

@ -26,7 +26,9 @@ async function focusButtonAndPressKeyWithDelay(key, elem, modifiers) {
add_task(async function testKeyBrowserAction() {
let extension = ExtensionTestUtils.loadExtension({
manifest: {
browser_action: {},
browser_action: {
default_area: "navbar",
},
},
async background() {

View File

@ -518,7 +518,9 @@ add_task(async function testDetailsObjects() {
let extension = ExtensionTestUtils.loadExtension({
manifest: {
browser_action: {},
browser_action: {
default_area: "navbar",
},
page_action: {},
background: {
page: "data/background.html",
@ -647,6 +649,7 @@ add_task(async function testPageActionIconLoadingOnBrowserActionThemedIcon() {
default_icon: "common_cached_icon.png",
default_popup: "default_popup.html",
default_title: "BrowserAction title",
default_area: "navbar",
theme_icons: [
{
dark: "1.png",

View File

@ -8,7 +8,9 @@ PromiseTestUtils.allowMatchingRejectionsGlobally(/packaging errors/);
add_task(async function testInvalidIconSizes() {
let extension = ExtensionTestUtils.loadExtension({
manifest: {
browser_action: {},
browser_action: {
default_area: "navbar",
},
page_action: {},
},
@ -91,7 +93,7 @@ add_task(async function testDefaultDetails() {
for (let icon of icons) {
let extension = ExtensionTestUtils.loadExtension({
manifest: {
browser_action: { default_icon: icon },
browser_action: { default_icon: icon, default_area: "navbar" },
page_action: { default_icon: icon },
},
@ -151,7 +153,7 @@ add_task(async function testSecureURLsDenied() {
let extension = ExtensionTestUtils.loadExtension({
manifest: {
browser_action: {},
browser_action: { default_area: "navbar" },
page_action: {},
},
@ -219,6 +221,7 @@ add_task(async function testSecureManifestURLsDenied() {
manifest: {
[api]: {
default_icon: url,
default_area: "navbar",
},
},
});

View File

@ -12,6 +12,7 @@ add_task(async function test_browserActionPort() {
manifest: {
browser_action: {
default_popup: "popup.html",
default_area: "navbar",
browser_style: true,
},
},

View File

@ -23,6 +23,7 @@ add_task(async function testBrowserActionClickCanceled() {
manifest: {
browser_action: {
default_popup: "popup.html",
default_area: "navbar",
browser_style: true,
},
permissions: ["activeTab"],
@ -158,6 +159,7 @@ add_task(async function testBrowserActionDisabled() {
manifest: {
browser_action: {
default_popup: "popup.html",
default_area: "navbar",
browser_style: true,
},
},
@ -265,6 +267,7 @@ add_task(async function testBrowserActionTabPopulation() {
manifest: {
browser_action: {
default_popup: "popup.html",
default_area: "navbar",
browser_style: true,
},
permissions: ["activeTab"],
@ -324,6 +327,7 @@ add_task(async function testClosePopupDuringPreload() {
manifest: {
browser_action: {
default_popup: "popup.html",
default_area: "navbar",
browser_style: true,
},
},

View File

@ -18,6 +18,7 @@ async function installTestAddon(addonId, unpacked = false) {
browser_specific_settings: { gecko: { id: addonId } },
browser_action: {
default_popup: "popup.html",
default_area: "navbar",
},
},
files: {

View File

@ -9,6 +9,7 @@ add_task(async function testBrowserActionPopupResize() {
manifest: {
browser_action: {
default_popup: "popup.html",
default_area: "navbar",
browser_style: true,
},
},

View File

@ -9,6 +9,7 @@ async function testAction(manifest_version) {
manifest_version,
[action]: {
default_popup: "popup.html",
default_area: "navbar",
unrecognized_property: "with-a-random-value",
},
icons: { 32: "icon.png" },

View File

@ -48,6 +48,7 @@ add_task(async function testBrowserActionTelemetryTiming() {
manifest: {
browser_action: {
default_popup: "popup.html",
default_area: "navbar",
browser_style: true,
},
},
@ -213,6 +214,7 @@ add_task(async function testBrowserActionTelemetryResults() {
},
browser_action: {
default_popup: "popup.html",
default_area: "navbar",
browser_style: true,
},
},

View File

@ -65,13 +65,22 @@ async function testStaticTheme(options) {
// Ensure we show the menupanel at least once. This makes sure that the
// elements we're going to query the style of are in the flat tree.
if (defaultArea == "menupanel") {
let overflowButton = document.getElementById("nav-bar-overflow-button");
await waitForElementShown(overflowButton.icon);
info("Open overflow menu");
let menu = document.getElementById("widget-overflow");
let shown = BrowserTestUtils.waitForEvent(menu, "popupshown");
overflowButton.click();
await shown;
if (window.gUnifiedExtensions.isEnabled) {
let shown = BrowserTestUtils.waitForPopupEvent(
window.gUnifiedExtensions.panel,
"shown"
);
window.gUnifiedExtensions.togglePanel();
await shown;
} else {
let overflowButton = document.getElementById("nav-bar-overflow-button");
await waitForElementShown(overflowButton.icon);
info("Open overflow menu");
let menu = document.getElementById("widget-overflow");
let shown = BrowserTestUtils.waitForEvent(menu, "popupshown");
overflowButton.click();
await shown;
}
}
// Confirm that the browser action has the correct default icon before a theme is loaded.
@ -335,6 +344,7 @@ add_task(async function browseraction_theme_icons_dynamic_theme() {
manifest: {
browser_action: {
default_icon: "default.png",
default_area: "navbar",
theme_icons: [
{
light: "light.png",

View File

@ -99,6 +99,7 @@ add_task(async function connect_from_browser_action_popup() {
],
browser_action: {
default_popup: "popup.html",
default_area: "navbar",
},
},
files: {

View File

@ -74,6 +74,7 @@ add_task(async function() {
browser_action: {
default_popup: "popup.html",
default_area: "navbar",
},
},

View File

@ -127,6 +127,7 @@ add_task(async function() {
browser_action: {
default_popup: "page.html?popup",
default_area: "navbar",
},
sidebar_action: {
@ -302,6 +303,7 @@ add_task(async function test_getViews_excludes_blocked_parsing_documents() {
manifest: {
browser_action: {
default_popup: "popup.html",
default_area: "navbar",
},
},
files: {

View File

@ -9,6 +9,7 @@ add_task(async function testIncognitoPopup() {
permissions: ["tabs"],
browser_action: {
default_popup: "popup.html",
default_area: "navbar",
},
page_action: {
default_popup: "popup.html",

View File

@ -16,6 +16,7 @@ add_task(async function testIncognitoViews() {
permissions: ["tabs"],
browser_action: {
default_popup: "popup.html",
default_area: "navbar",
},
},

View File

@ -21,6 +21,7 @@ add_task(async function test_management_install() {
manifest: {
browser_action: {
browser_style: false,
default_area: "navbar",
},
permissions: ["management"],
},

View File

@ -65,7 +65,9 @@ add_task(async function test_permissions() {
add_task(async function test_actionContextMenus() {
const manifest = {
page_action: {},
browser_action: {},
browser_action: {
default_area: "navbar",
},
permissions: ["menus"],
};

View File

@ -10,7 +10,9 @@ function getExtension(background, useAddonManager) {
return ExtensionTestUtils.loadExtension({
useAddonManager,
manifest: {
browser_action: {},
browser_action: {
default_area: "navbar",
},
permissions: ["menus"],
background: { persistent: false },
},
@ -169,6 +171,7 @@ add_task(async function test_actions_context_menu() {
browser_action: {
default_title: "Test BrowserAction",
default_popup: "test.html",
default_area: "navbar",
browser_style: true,
},
background: { persistent: false },

View File

@ -153,6 +153,7 @@ async function testShowHideEvent({
page_action: {},
[action]: {
default_popup: "popup.html",
default_area: "navbar",
},
permissions: ["menus"],
optional_permissions: [PAGE_HOST_PATTERN],

View File

@ -40,7 +40,9 @@ function loadExtensionWithMenusApi() {
let extension = ExtensionTestUtils.loadExtension({
background,
manifest: {
browser_action: {},
browser_action: {
default_area: "navbar",
},
permissions: ["menus"],
},
});

View File

@ -130,6 +130,7 @@ add_task(async function getTargetElement_in_browserAction_popup() {
permissions: ["menus"],
browser_action: {
default_popup: "popup.html",
default_area: "navbar",
},
},
files: {

View File

@ -75,6 +75,7 @@ async function test_mousewheel_zoom(test) {
manifest = {
browser_action: {
default_popup: "panel.html",
default_area: "navbar",
},
};
} else if (test == TESTS.PAGE_ACTION) {

View File

@ -20,6 +20,7 @@ add_task(async function process_switch_in_sidebars_popups() {
},
browser_action: {
default_popup: "page.html?popup",
default_area: "navbar",
},
web_accessible_resources: ["page.html"],
},
@ -90,6 +91,7 @@ add_task(
manifest: {
browser_action: {
default_popup: "popup-1.html",
default_area: "navbar",
},
},
files: {

View File

@ -134,7 +134,9 @@ async function test_clickData(testAsNonPersistent = false) {
async function test_clickData_reset(testAsNonPersistent = false) {
let extension = ExtensionTestUtils.loadExtension({
manifest: {
browser_action: {},
browser_action: {
default_area: "navbar",
},
page_action: {},
background: {
persistent: !testAsNonPersistent,

View File

@ -10,6 +10,7 @@ add_task(async function testPageActionPopup() {
manifest: {
browser_action: {
default_popup: `${BASE}/file_popup_api_injection_a.html`,
default_area: "navbar",
},
page_action: {
default_popup: `${BASE}/file_popup_api_injection_b.html`,

View File

@ -108,6 +108,7 @@ add_task(async function testPopupBackground() {
manifest: {
browser_action: {
default_popup: "popup.html",
default_area: "navbar",
browser_style,
},

View File

@ -27,6 +27,7 @@ add_task(async function testPopupBorderRadius() {
manifest: {
browser_action: {
default_popup: "popup.html",
default_area: "navbar",
browser_style: false,
},

View File

@ -142,7 +142,10 @@ add_task(async function test_new_tab_ignore_settings() {
let extension = ExtensionTestUtils.loadExtension({
manifest: {
browser_specific_settings: { gecko: { id: extensionId } },
browser_action: { default_popup: "ignore.html" },
browser_action: {
default_popup: "ignore.html",
default_area: "navbar",
},
chrome_url_overrides: { newtab: "ignore.html" },
},
files: { "ignore.html": '<h1 id="extension-new-tab">New Tab!</h1>' },

View File

@ -122,7 +122,10 @@ add_task(async function testSources() {
},
manifest: {
browser_action: { default_title: "test" },
browser_action: {
default_title: "test",
default_area: "navbar",
},
page_action: { default_title: "test" },
permissions: ["contextMenus"],
optional_permissions: [

View File

@ -118,6 +118,7 @@ add_task(async function test_window_open_close_from_browserAction_popup() {
manifest: {
browser_action: {
default_popup: "popup.html",
default_area: "navbar",
},
permissions: ["webNavigation", "tabs", "<all_urls>"],
},

View File

@ -118,6 +118,7 @@ add_task(async function test_window_open_close_from_browserAction_popup() {
manifest: {
browser_action: {
default_popup: "popup.html",
default_area: "navbar",
},
permissions: ["webNavigation", "tabs", "<all_urls>"],
},

View File

@ -307,7 +307,9 @@ add_task(async function testWindowTitlePermissions() {
},
manifest: {
permissions: ["activeTab"],
browser_action: {},
browser_action: {
default_area: "navbar",
},
},
});

View File

@ -590,7 +590,9 @@ add_task(async function test_context_menu_without_browserActionFor_global() {
add_task(async function test_browser_action_context_menu() {
const extWithMenuBrowserAction = ExtensionTestUtils.loadExtension({
manifest: {
browser_action: {},
browser_action: {
default_area: "navbar",
},
permissions: ["contextMenus"],
},
background() {
@ -607,7 +609,9 @@ add_task(async function test_browser_action_context_menu() {
});
const extWithSubMenuBrowserAction = ExtensionTestUtils.loadExtension({
manifest: {
browser_action: {},
browser_action: {
default_area: "navbar",
},
permissions: ["contextMenus"],
},
background() {
@ -653,7 +657,9 @@ add_task(async function test_browser_action_context_menu() {
});
const extWithoutMenu2 = ExtensionTestUtils.loadExtension({
manifest: {
browser_action: {},
browser_action: {
default_area: "navbar",
},
name: "extension with a browser action but no menu",
},
useAddonManager: "temporary",

View File

@ -111,7 +111,9 @@ async function withWindowOverflowed(win, taskFn) {
browser_specific_settings: {
gecko: { id: "unified-extensions-overflowable-toolbar@ext-0" },
},
browser_action: {},
browser_action: {
default_area: "navbar",
},
// We pass `activeTab` to have a different permission message when
// hovering the primary/action button.
permissions: ["activeTab", "contextMenus"],
@ -135,7 +137,9 @@ async function withWindowOverflowed(win, taskFn) {
browser_specific_settings: {
gecko: { id: "unified-extensions-overflowable-toolbar@ext-1" },
},
browser_action: {},
browser_action: {
default_area: "navbar",
},
permissions: ["contextMenus"],
},
background() {
@ -161,7 +165,9 @@ async function withWindowOverflowed(win, taskFn) {
for (let i = 2; i < NUM_EXTENSIONS; ++i) {
manifests.push({
name: `Extension #${i}`,
browser_action: {},
browser_action: {
default_area: "navbar",
},
});
}

View File

@ -345,7 +345,9 @@ function getBrowserActionPopup(extension, win = window) {
if (group.areaType == CustomizableUI.TYPE_TOOLBAR) {
return win.document.getElementById("customizationui-widget-panel");
}
return win.PanelUI.overflowPanel;
return win.gUnifiedExtensions.isEnabled
? win.gUnifiedExtensions.panel
: win.PanelUI.overflowPanel;
}
var showBrowserAction = function(extension, win = window) {
@ -372,7 +374,9 @@ async function triggerBrowserActionWithKeyboard(
await focusButtonAndPressKey(key, node, modifiers);
} else if (group.areaType == CustomizableUI.TYPE_PANEL) {
// Use key navigation so that the PanelMultiView doesn't ignore key events
let panel = win.document.getElementById("widget-overflow");
let panel = win.gUnifiedExtensions.isEnabled
? win.gUnifiedExtensions.panel
: win.document.getElementById("widget-overflow");
while (win.document.activeElement != node) {
EventUtils.synthesizeKey("KEY_ArrowDown");
ok(

View File

@ -46,6 +46,7 @@ async function testPopupSize(
manifest: {
browser_action: {
default_popup: "popup.html",
default_area: "navbar",
browser_style: false,
},
},
@ -139,7 +140,9 @@ async function testPopupSize(
let widget = getBrowserActionWidget(extension);
CustomizableUI.addWidgetToArea(widget.id, getCustomizableUIPanelID());
let panel = browserWin.PanelUI.overflowPanel;
let panel = browserWin.gUnifiedExtensions.isEnabled
? browserWin.gUnifiedExtensions.panel
: browserWin.PanelUI.overflowPanel;
panel.setAttribute("animate", "false");
let panelMultiView = panel.firstElementChild;

View File

@ -326,6 +326,7 @@ add_task(async function webextension() {
browser_action: {
default_icon: "default.png",
default_title: "Hello",
default_area: "navbar",
},
page_action: {
default_icon: "default.png",
@ -416,6 +417,7 @@ add_task(async function webextension() {
browser_action: {
default_icon: "default.png",
default_title: "Hello",
default_area: "navbar",
},
page_action: {
default_icon: "default.png",

View File

@ -415,6 +415,7 @@ add_task(async function extensions() {
browser_action: {
default_icon: "default.png",
default_title: "Hello",
default_area: "navbar",
},
page_action: {
default_icon: "default.png",

View File

@ -683,7 +683,9 @@ add_task(async function test_abusereport_from_browserAction_remove() {
const xpiFile = AddonTestUtils.createTempWebExtensionFile({
manifest: {
...BASE_TEST_MANIFEST,
browser_action: {},
browser_action: {
default_area: "navbar",
},
browser_specific_settings: { gecko: { id: EXT_ID } },
},
});