mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Backed out 3 changesets (bug 1782203) for causing lint failures on browser_unified_extensions_overflowable_toolbar.js. CLOSED TREE
Backed out changeset 50e57afebed3 (bug 1782203) Backed out changeset d17ea376ed45 (bug 1782203) Backed out changeset e91d51f1ce90 (bug 1782203)
This commit is contained in:
parent
705b1388fe
commit
d7d2cc6477
@ -1360,10 +1360,6 @@ customElements.define(
|
||||
|
||||
this.setAttribute("extension-id", this.addon.id);
|
||||
|
||||
// Note that the data-extensionid attribute is used by context menu handlers
|
||||
// to identify the extension being manipulated by the context menu.
|
||||
this._actionButton.dataset.extensionid = this.addon.id;
|
||||
|
||||
let policy = WebExtensionPolicy.getByID(this.addon.id);
|
||||
this.toggleAttribute(
|
||||
"attention",
|
||||
@ -1384,9 +1380,7 @@ customElements.define(
|
||||
|
||||
this._actionButton.disabled = !this._hasAction();
|
||||
|
||||
// Note that the data-extensionid attribute is used by context menu handlers
|
||||
// to identify the extension being manipulated by the context menu.
|
||||
this._openMenuButton.dataset.extensionid = this.addon.id;
|
||||
this._openMenuButton.dataset.extensionId = this.addon.id;
|
||||
this._openMenuButton.setAttribute(
|
||||
"data-l10n-args",
|
||||
JSON.stringify({ extensionName: this.addon.name })
|
||||
@ -1622,30 +1616,13 @@ var gUnifiedExtensions = {
|
||||
|
||||
const id = this._getExtensionId(menu);
|
||||
const addon = await AddonManager.getAddonByID(id);
|
||||
const widgetId = this._getWidgetId(menu);
|
||||
const forBrowserAction = !!widgetId;
|
||||
|
||||
const pinButton = menu.querySelector(
|
||||
".unified-extensions-context-menu-pin-to-toolbar"
|
||||
);
|
||||
const removeButton = menu.querySelector(
|
||||
".unified-extensions-context-menu-remove-extension"
|
||||
);
|
||||
const reportButton = menu.querySelector(
|
||||
".unified-extensions-context-menu-report-extension"
|
||||
);
|
||||
const menuSeparator = menu.querySelector(
|
||||
".unified-extensions-context-menu-management-separator"
|
||||
);
|
||||
|
||||
menuSeparator.hidden = !forBrowserAction;
|
||||
pinButton.hidden = !forBrowserAction;
|
||||
|
||||
if (forBrowserAction) {
|
||||
let area = CustomizableUI.getPlacementOfWidget(widgetId).area;
|
||||
let inToolbar = area != CustomizableUI.AREA_ADDONS;
|
||||
pinButton.setAttribute("checked", inToolbar);
|
||||
}
|
||||
|
||||
reportButton.hidden = !gAddonAbuseReportEnabled;
|
||||
removeButton.disabled = !(
|
||||
@ -1691,36 +1668,6 @@ var gUnifiedExtensions = {
|
||||
|
||||
_getExtensionId(menu) {
|
||||
const { triggerNode } = menu;
|
||||
return triggerNode.dataset.extensionid;
|
||||
},
|
||||
|
||||
_getWidgetId(menu) {
|
||||
const { triggerNode } = menu;
|
||||
return triggerNode.closest(".unified-extensions-item")?.id;
|
||||
},
|
||||
|
||||
onPinToToolbarChange(menu, event) {
|
||||
let shouldPinToToolbar = event.target.getAttribute("checked") == "true";
|
||||
// Revert the checkbox back to its original state. This is because the
|
||||
// addon context menu handlers are asynchronous, and there seems to be
|
||||
// a race where the checkbox state won't get set in time to show the
|
||||
// right state. So we err on the side of caution, and presume that future
|
||||
// attempts to open this context menu on an extension button will show
|
||||
// the same checked state that we started in.
|
||||
event.target.setAttribute("checked", !shouldPinToToolbar);
|
||||
|
||||
let widgetId = this._getWidgetId(menu);
|
||||
if (!widgetId) {
|
||||
return;
|
||||
}
|
||||
this.pinToToolbar(widgetId, shouldPinToToolbar);
|
||||
},
|
||||
|
||||
pinToToolbar(widgetId, shouldPinToToolbar) {
|
||||
let newArea = shouldPinToToolbar
|
||||
? CustomizableUI.AREA_NAVBAR
|
||||
: CustomizableUI.AREA_ADDONS;
|
||||
let newPosition = shouldPinToToolbar ? undefined : 0;
|
||||
CustomizableUI.addWidgetToArea(widgetId, newArea, newPosition);
|
||||
return triggerNode.dataset.extensionId;
|
||||
},
|
||||
};
|
||||
|
@ -7416,11 +7416,6 @@ var ToolbarContextMenu = {
|
||||
return node && node.getAttribute("data-extensionid");
|
||||
},
|
||||
|
||||
_getWidgetId(popup) {
|
||||
let node = this._getUnwrappedTriggerNode(popup);
|
||||
return node?.closest(".unified-extensions-item")?.id;
|
||||
},
|
||||
|
||||
async updateExtension(popup) {
|
||||
let removeExtension = popup.querySelector(
|
||||
".customize-context-removeExtension"
|
||||
@ -7431,7 +7426,6 @@ var ToolbarContextMenu = {
|
||||
let reportExtension = popup.querySelector(
|
||||
".customize-context-reportExtension"
|
||||
);
|
||||
let pinToToolbar = popup.querySelector(".customize-context-pinToToolbar");
|
||||
let separator = reportExtension.nextElementSibling;
|
||||
let id = this._getExtensionId(popup);
|
||||
let addon = id && (await AddonManager.getAddonByID(id));
|
||||
@ -7440,32 +7434,9 @@ var ToolbarContextMenu = {
|
||||
element.hidden = !addon;
|
||||
}
|
||||
|
||||
// The pinToToolbar item is only available in the toolbar context menu popup,
|
||||
// and not in the overflow panel context menu, and should only be made visible
|
||||
// for addons when the Unified Extensions UI is enabled.
|
||||
if (pinToToolbar) {
|
||||
pinToToolbar.hidden = !addon || !gUnifiedExtensions.isEnabled;
|
||||
}
|
||||
|
||||
reportExtension.hidden = !addon || !gAddonAbuseReportEnabled;
|
||||
|
||||
if (addon) {
|
||||
if (gUnifiedExtensions.isEnabled) {
|
||||
popup.querySelector(".customize-context-moveToPanel").hidden = true;
|
||||
popup.querySelector(
|
||||
".customize-context-removeFromToolbar"
|
||||
).hidden = true;
|
||||
|
||||
if (pinToToolbar) {
|
||||
let widgetId = this._getWidgetId(popup);
|
||||
if (widgetId) {
|
||||
let area = CustomizableUI.getPlacementOfWidget(widgetId).area;
|
||||
let inToolbar = area != CustomizableUI.AREA_ADDONS;
|
||||
pinToToolbar.setAttribute("checked", inToolbar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
removeExtension.disabled = !(
|
||||
addon.permissions & AddonManager.PERM_CAN_UNINSTALL
|
||||
);
|
||||
|
@ -346,11 +346,6 @@
|
||||
data-lazy-l10n-id="toolbar-context-menu-remove-from-toolbar"
|
||||
contexttype="toolbaritem"
|
||||
class="customize-context-removeFromToolbar"/>
|
||||
<menuitem oncommand="gUnifiedExtensions.onPinToToolbarChange(this.parentElement, event);"
|
||||
data-lazy-l10n-id="toolbar-context-menu-pin-to-toolbar"
|
||||
type="checkbox"
|
||||
contexttype="toolbaritem"
|
||||
class="customize-context-pinToToolbar"/>
|
||||
<menuseparator id="toolbarDownloadsAnchorMenuSeparator"/>
|
||||
<menuitem id="toolbar-context-always-open-downloads-panel"
|
||||
oncommand="ToolbarContextMenu.onDownloadsAlwaysOpenPanelChange(event);"
|
||||
@ -638,11 +633,6 @@
|
||||
|
||||
<menupopup id="unified-extensions-context-menu"
|
||||
onpopupshowing="gUnifiedExtensions.updateContextMenu(this, event)">
|
||||
<menuitem oncommand="gUnifiedExtensions.onPinToToolbarChange(this.parentElement, event);"
|
||||
data-lazy-l10n-id="unified-extensions-context-menu-pin-to-toolbar"
|
||||
type="checkbox"
|
||||
class="unified-extensions-context-menu-pin-to-toolbar"/>
|
||||
<menuseparator class="unified-extensions-context-menu-management-separator"/>
|
||||
<menuitem data-lazy-l10n-id="unified-extensions-context-menu-manage-extension"
|
||||
class="unified-extensions-context-menu-manage-extension"
|
||||
oncommand="gUnifiedExtensions.manageExtension(this.parentElement)" />
|
||||
|
@ -1234,21 +1234,10 @@ var CustomizableUIInternal = {
|
||||
|
||||
let currentContextMenu =
|
||||
aNode.getAttribute("context") || aNode.getAttribute("contextmenu");
|
||||
let contextMenuForPlace;
|
||||
|
||||
if (
|
||||
lazy.gUnifiedExtensionsEnabled &&
|
||||
CustomizableUI.isWebExtensionWidget(aNode.id) &&
|
||||
(aAreaNode?.id == CustomizableUI.AREA_ADDONS ||
|
||||
aNode.getAttribute("overflowedItem") == "true")
|
||||
) {
|
||||
contextMenuForPlace = null;
|
||||
} else {
|
||||
contextMenuForPlace =
|
||||
forcePanel || "panel" == CustomizableUI.getPlaceForItem(aAreaNode)
|
||||
? kPanelItemContextMenu
|
||||
: null;
|
||||
}
|
||||
let contextMenuForPlace =
|
||||
forcePanel || "panel" == CustomizableUI.getPlaceForItem(aAreaNode)
|
||||
? kPanelItemContextMenu
|
||||
: null;
|
||||
if (contextMenuForPlace && !currentContextMenu) {
|
||||
aNode.setAttribute("context", contextMenuForPlace);
|
||||
} else if (
|
||||
|
@ -81,7 +81,7 @@
|
||||
|
||||
<toolbarseparator />
|
||||
|
||||
<vbox class="panel-subview-body" context="unified-extensions-context-menu">
|
||||
<vbox class="panel-subview-body">
|
||||
<vbox id="overflowed-extensions-list">
|
||||
<!-- overflowed extension buttons from the nav-bar will go here -->
|
||||
</vbox>
|
||||
|
@ -270,6 +270,9 @@ this.browserAction = class extends ExtensionAPIPersistent {
|
||||
);
|
||||
|
||||
if (gUnifiedExtensionsEnabled) {
|
||||
// Open the unified context menu when context-clicking the menu button.
|
||||
menuButton.setAttribute("context", "unified-extensions-context-menu");
|
||||
menuButton.setAttribute("data-extension-id", extension.id);
|
||||
menuButton.setAttribute(
|
||||
"data-l10n-id",
|
||||
"unified-extensions-item-open-menu"
|
||||
|
@ -69,9 +69,6 @@ if (AppConstants.platform == "macosx") {
|
||||
|
||||
const type = "extension";
|
||||
|
||||
const TOOLBAR_CONTEXT_MENU = "toolbar-context-menu";
|
||||
const UNIFIED_CONTEXT_MENU = "unified-extensions-context-menu";
|
||||
|
||||
async function assertTelemetryMatches(events) {
|
||||
events = events.map(([method, object, value, extra]) => {
|
||||
return { method, object, value, extra };
|
||||
@ -310,13 +307,13 @@ async function browseraction_contextmenu_manage_extension_helper(win) {
|
||||
|
||||
info("Test toolbar context menu in browserAction");
|
||||
let toolbarCtxMenu = await testContextMenu(
|
||||
TOOLBAR_CONTEXT_MENU,
|
||||
"toolbar-context-menu",
|
||||
customizing
|
||||
);
|
||||
|
||||
info("Check toolbar context menu in another button");
|
||||
let otherButtonId = "home-button";
|
||||
await openContextMenu(TOOLBAR_CONTEXT_MENU, otherButtonId, win);
|
||||
await openContextMenu(toolbarCtxMenu.id, otherButtonId, win);
|
||||
checkVisibility(toolbarCtxMenu, false);
|
||||
toolbarCtxMenu.hidePopup();
|
||||
|
||||
@ -325,16 +322,11 @@ async function browseraction_contextmenu_manage_extension_helper(win) {
|
||||
checkVisibility(toolbarCtxMenu, false);
|
||||
toolbarCtxMenu.hidePopup();
|
||||
|
||||
// Pinning browser actions to the overflow panel isn't going to be possible
|
||||
// after bug 1798896.
|
||||
if (!win.gUnifiedExtensions.isEnabled) {
|
||||
info("Pin a browserAction to the overflow menu");
|
||||
CustomizableUI.addWidgetToArea(
|
||||
nodeId,
|
||||
CustomizableUI.AREA_FIXED_OVERFLOW_PANEL
|
||||
);
|
||||
}
|
||||
|
||||
info("Pin the browserAction and another button to the overflow menu");
|
||||
CustomizableUI.addWidgetToArea(
|
||||
nodeId,
|
||||
CustomizableUI.AREA_FIXED_OVERFLOW_PANEL
|
||||
);
|
||||
CustomizableUI.addWidgetToArea(
|
||||
otherButtonId,
|
||||
CustomizableUI.AREA_FIXED_OVERFLOW_PANEL
|
||||
@ -362,13 +354,11 @@ async function browseraction_contextmenu_manage_extension_helper(win) {
|
||||
checkVisibility(overflowMenuCtxMenu, false);
|
||||
overflowMenuCtxMenu.hidePopup();
|
||||
|
||||
if (!win.gUnifiedExtensions.isEnabled) {
|
||||
info("Test overflow menu context menu in browserAction");
|
||||
await testContextMenu(overflowMenuCtxMenu.id, customizing);
|
||||
info("Put browser action back in nav-bar");
|
||||
CustomizableUI.addWidgetToArea(nodeId, CustomizableUI.AREA_NAVBAR);
|
||||
}
|
||||
info("Put other button action back in nav-bar");
|
||||
info("Test overflow menu context menu in browserAction");
|
||||
await testContextMenu(overflowMenuCtxMenu.id, customizing);
|
||||
|
||||
info("Restore initial state");
|
||||
CustomizableUI.addWidgetToArea(nodeId, CustomizableUI.AREA_NAVBAR);
|
||||
CustomizableUI.addWidgetToArea(otherButtonId, CustomizableUI.AREA_NAVBAR);
|
||||
|
||||
if (customizing) {
|
||||
@ -396,37 +386,21 @@ async function browseraction_contextmenu_manage_extension_helper(win) {
|
||||
|
||||
info("Run tests in normal mode");
|
||||
await main(false);
|
||||
|
||||
if (win.gUnifiedExtensions.isEnabled) {
|
||||
await assertTelemetryMatches([
|
||||
["action", "browserAction", null, { action: "manage", addonId: id }],
|
||||
["view", "aboutAddons", "detail", { addonId: id, type }],
|
||||
]);
|
||||
} else {
|
||||
await assertTelemetryMatches([
|
||||
["action", "browserAction", null, { action: "manage", addonId: id }],
|
||||
["view", "aboutAddons", "detail", { addonId: id, type }],
|
||||
["action", "browserAction", null, { action: "manage", addonId: id }],
|
||||
["view", "aboutAddons", "detail", { addonId: id, type }],
|
||||
]);
|
||||
}
|
||||
await assertTelemetryMatches([
|
||||
["action", "browserAction", null, { action: "manage", addonId: id }],
|
||||
["view", "aboutAddons", "detail", { addonId: id, type }],
|
||||
["action", "browserAction", null, { action: "manage", addonId: id }],
|
||||
["view", "aboutAddons", "detail", { addonId: id, type }],
|
||||
]);
|
||||
|
||||
info("Run tests in customize mode");
|
||||
await main(true);
|
||||
|
||||
if (win.gUnifiedExtensions.isEnabled) {
|
||||
await assertTelemetryMatches([
|
||||
["action", "browserAction", null, { action: "manage", addonId: id }],
|
||||
["view", "aboutAddons", "detail", { addonId: id, type }],
|
||||
]);
|
||||
} else {
|
||||
await assertTelemetryMatches([
|
||||
["action", "browserAction", null, { action: "manage", addonId: id }],
|
||||
["view", "aboutAddons", "detail", { addonId: id, type }],
|
||||
["action", "browserAction", null, { action: "manage", addonId: id }],
|
||||
["view", "aboutAddons", "detail", { addonId: id, type }],
|
||||
]);
|
||||
}
|
||||
await assertTelemetryMatches([
|
||||
["action", "browserAction", null, { action: "manage", addonId: id }],
|
||||
["view", "aboutAddons", "detail", { addonId: id, type }],
|
||||
["action", "browserAction", null, { action: "manage", addonId: id }],
|
||||
["view", "aboutAddons", "detail", { addonId: id, type }],
|
||||
]);
|
||||
|
||||
info("Close the dummy tab and finish");
|
||||
win.gBrowser.removeTab(dummyTab);
|
||||
@ -451,51 +425,30 @@ async function runTestContextMenu({ id, customizing, testContextMenu, win }) {
|
||||
}
|
||||
|
||||
info("Test toolbar context menu in browserAction");
|
||||
await testContextMenu(TOOLBAR_CONTEXT_MENU, customizing);
|
||||
await testContextMenu("toolbar-context-menu", customizing);
|
||||
|
||||
if (win.gUnifiedExtensions.isEnabled) {
|
||||
info("Pin the browserAction to the addons panel");
|
||||
CustomizableUI.addWidgetToArea(nodeId, CustomizableUI.AREA_ADDONS);
|
||||
info("Pin the browserAction and another button to the overflow menu");
|
||||
CustomizableUI.addWidgetToArea(
|
||||
nodeId,
|
||||
CustomizableUI.AREA_FIXED_OVERFLOW_PANEL
|
||||
);
|
||||
|
||||
if (!customizing) {
|
||||
info("Open addons panel");
|
||||
win.gUnifiedExtensions.togglePanel();
|
||||
await BrowserTestUtils.waitForEvent(
|
||||
win.gUnifiedExtensions.panel,
|
||||
"popupshown"
|
||||
);
|
||||
info("Test browserAction in addons panel");
|
||||
await testContextMenu("unified-extensions-context-menu", customizing);
|
||||
} else {
|
||||
todo(
|
||||
false,
|
||||
"The browserAction cannot be accessed from customize " +
|
||||
"mode when in the addons panel."
|
||||
);
|
||||
}
|
||||
} else {
|
||||
info("Pin the browserAction to the overflow panel");
|
||||
CustomizableUI.addWidgetToArea(
|
||||
nodeId,
|
||||
CustomizableUI.AREA_FIXED_OVERFLOW_PANEL
|
||||
);
|
||||
info("Wait until the overflow menu is ready");
|
||||
let overflowButton = win.document.getElementById("nav-bar-overflow-button");
|
||||
let icon = overflowButton.icon;
|
||||
await waitForElementShown(icon);
|
||||
|
||||
info("Wait until the overflow menu is ready");
|
||||
let overflowButton = win.document.getElementById("nav-bar-overflow-button");
|
||||
let icon = overflowButton.icon;
|
||||
await waitForElementShown(icon);
|
||||
|
||||
if (!customizing) {
|
||||
info("Open overflow menu");
|
||||
let menu = win.document.getElementById("widget-overflow");
|
||||
let shown = BrowserTestUtils.waitForEvent(menu, "popupshown");
|
||||
overflowButton.click();
|
||||
await shown;
|
||||
}
|
||||
info("Test overflow menu context menu in browserAction");
|
||||
await testContextMenu("customizationPanelItemContextMenu", customizing);
|
||||
if (!customizing) {
|
||||
info("Open overflow menu");
|
||||
let menu = win.document.getElementById("widget-overflow");
|
||||
let shown = BrowserTestUtils.waitForEvent(menu, "popupshown");
|
||||
overflowButton.click();
|
||||
await shown;
|
||||
}
|
||||
|
||||
info("Test overflow menu context menu in browserAction");
|
||||
await testContextMenu("customizationPanelItemContextMenu", customizing);
|
||||
|
||||
info("Restore initial state");
|
||||
CustomizableUI.addWidgetToArea(nodeId, CustomizableUI.AREA_NAVBAR);
|
||||
|
||||
@ -559,11 +512,9 @@ async function browseraction_contextmenu_remove_extension_helper(win) {
|
||||
let menu = await openContextMenu(menuId, buttonId, win);
|
||||
|
||||
info(`Choosing 'Remove Extension' in ${menuId} should show confirm dialog`);
|
||||
let removeItemQuery =
|
||||
menuId == "unified-extensions-context-menu"
|
||||
? ".unified-extensions-context-menu-remove-extension"
|
||||
: ".customize-context-removeExtension";
|
||||
let removeExtension = menu.querySelector(removeItemQuery);
|
||||
let removeExtension = menu.querySelector(
|
||||
".customize-context-removeExtension"
|
||||
);
|
||||
await closeChromeContextMenu(menuId, removeExtension, win);
|
||||
let args = await confirmArgs;
|
||||
is(args[1], `Remove ${name}?`);
|
||||
@ -584,39 +535,20 @@ async function browseraction_contextmenu_remove_extension_helper(win) {
|
||||
win,
|
||||
});
|
||||
|
||||
if (win.gUnifiedExtensions.isEnabled) {
|
||||
// The first uninstall event comes from the toolbar context menu, and the
|
||||
// next via the unified extension context menu.
|
||||
await assertTelemetryMatches([
|
||||
[
|
||||
"action",
|
||||
"browserAction",
|
||||
"cancelled",
|
||||
{ action: "uninstall", addonId: id },
|
||||
],
|
||||
[
|
||||
"action",
|
||||
"unifiedExtensions",
|
||||
"cancelled",
|
||||
{ action: "uninstall", addonId: id },
|
||||
],
|
||||
]);
|
||||
} else {
|
||||
await assertTelemetryMatches([
|
||||
[
|
||||
"action",
|
||||
"browserAction",
|
||||
"cancelled",
|
||||
{ action: "uninstall", addonId: id },
|
||||
],
|
||||
[
|
||||
"action",
|
||||
"browserAction",
|
||||
"cancelled",
|
||||
{ action: "uninstall", addonId: id },
|
||||
],
|
||||
]);
|
||||
}
|
||||
await assertTelemetryMatches([
|
||||
[
|
||||
"action",
|
||||
"browserAction",
|
||||
"cancelled",
|
||||
{ action: "uninstall", addonId: id },
|
||||
],
|
||||
[
|
||||
"action",
|
||||
"browserAction",
|
||||
"cancelled",
|
||||
{ action: "uninstall", addonId: id },
|
||||
],
|
||||
]);
|
||||
|
||||
info("Run tests in customize mode");
|
||||
await runTestContextMenu({
|
||||
@ -626,38 +558,20 @@ async function browseraction_contextmenu_remove_extension_helper(win) {
|
||||
win,
|
||||
});
|
||||
|
||||
if (win.gUnifiedExtensions.isEnabled) {
|
||||
// We'll only get one of these because in customize mode, the browserAction
|
||||
// is not accessible when in the addons panel.
|
||||
todo(
|
||||
false,
|
||||
"Should record a second removal event when browserAction " +
|
||||
"becomes available in customize mode."
|
||||
);
|
||||
await assertTelemetryMatches([
|
||||
[
|
||||
"action",
|
||||
"browserAction",
|
||||
"cancelled",
|
||||
{ action: "uninstall", addonId: id },
|
||||
],
|
||||
]);
|
||||
} else {
|
||||
await assertTelemetryMatches([
|
||||
[
|
||||
"action",
|
||||
"browserAction",
|
||||
"cancelled",
|
||||
{ action: "uninstall", addonId: id },
|
||||
],
|
||||
[
|
||||
"action",
|
||||
"browserAction",
|
||||
"cancelled",
|
||||
{ action: "uninstall", addonId: id },
|
||||
],
|
||||
]);
|
||||
}
|
||||
await assertTelemetryMatches([
|
||||
[
|
||||
"action",
|
||||
"browserAction",
|
||||
"cancelled",
|
||||
{ action: "uninstall", addonId: id },
|
||||
],
|
||||
[
|
||||
"action",
|
||||
"browserAction",
|
||||
"cancelled",
|
||||
{ action: "uninstall", addonId: id },
|
||||
],
|
||||
]);
|
||||
|
||||
let addon = await AddonManager.getAddonByID(id);
|
||||
ok(addon, "Addon is still installed");
|
||||
@ -672,7 +586,7 @@ async function browseraction_contextmenu_remove_extension_helper(win) {
|
||||
},
|
||||
});
|
||||
});
|
||||
await testContextMenu(TOOLBAR_CONTEXT_MENU, false);
|
||||
await testContextMenu("toolbar-context-menu", false);
|
||||
await uninstalled;
|
||||
|
||||
await assertTelemetryMatches([
|
||||
@ -729,7 +643,7 @@ async function browseraction_contextmenu_report_extension_helper(win) {
|
||||
useAddonManager: "temporary",
|
||||
});
|
||||
|
||||
async function testReportDialog(viaUnifiedContextMenu) {
|
||||
async function testReportDialog() {
|
||||
const reportDialogWindow = await BrowserTestUtils.waitForCondition(
|
||||
() => AbuseReporter.getOpenDialog(),
|
||||
"Wait for the abuse report dialog to have been opened"
|
||||
@ -743,7 +657,7 @@ async function browseraction_contextmenu_report_extension_helper(win) {
|
||||
);
|
||||
is(
|
||||
reportDialogParams.report.reportEntryPoint,
|
||||
viaUnifiedContextMenu ? "unified_context_menu" : "toolbar_context_menu",
|
||||
"toolbar_context_menu",
|
||||
"Abuse report dialog has the expected reportEntryPoint"
|
||||
);
|
||||
|
||||
@ -763,13 +677,9 @@ async function browseraction_contextmenu_report_extension_helper(win) {
|
||||
let menu = await openContextMenu(menuId, buttonId, win);
|
||||
|
||||
info(`Choosing 'Report Extension' in ${menuId} should show confirm dialog`);
|
||||
|
||||
let usingUnifiedContextMenu = menuId == "unified-extensions-context-menu";
|
||||
let reportItemQuery = usingUnifiedContextMenu
|
||||
? ".unified-extensions-context-menu-report-extension"
|
||||
: ".customize-context-reportExtension";
|
||||
let reportExtension = menu.querySelector(reportItemQuery);
|
||||
|
||||
let reportExtension = menu.querySelector(
|
||||
".customize-context-reportExtension"
|
||||
);
|
||||
ok(!reportExtension.hidden, "Report extension should be visibile");
|
||||
|
||||
// When running in customizing mode "about:addons" will load in a new tab,
|
||||
@ -797,7 +707,7 @@ async function browseraction_contextmenu_report_extension_helper(win) {
|
||||
if (browser.contentDocument?.readyState != "complete") {
|
||||
await BrowserTestUtils.browserLoaded(browser);
|
||||
}
|
||||
await testReportDialog(usingUnifiedContextMenu);
|
||||
await testReportDialog();
|
||||
|
||||
// Close the new about:addons tab when running in customize mode,
|
||||
// or cancel the abuse report if the about:addons page has been
|
||||
@ -849,30 +759,6 @@ async function browseraction_contextmenu_report_extension_helper(win) {
|
||||
await extension.unload();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that built-in buttons see the Pin to Overflow and Remove items in
|
||||
* the toolbar context menu and don't see the Pin to Toolbar item, since
|
||||
* that's reserved for extension widgets.
|
||||
*
|
||||
* @param {DOMWindow} win A browser window that may or may not have the
|
||||
* Unified Extensions UI enabled.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async function test_no_toolbar_pinning_on_builtin_helper(win) {
|
||||
let menu = await openContextMenu(TOOLBAR_CONTEXT_MENU, "home-button", win);
|
||||
info(`Pin to Overflow and Remove from Toolbar should be visible.`);
|
||||
let pinToOverflow = menu.querySelector(".customize-context-moveToPanel");
|
||||
let removeFromToolbar = menu.querySelector(
|
||||
".customize-context-removeFromToolbar"
|
||||
);
|
||||
Assert.ok(!pinToOverflow.hidden, "Pin to Overflow is visible.");
|
||||
Assert.ok(!removeFromToolbar.hidden, "Remove from Toolbar is visible.");
|
||||
info(`This button should have "Pin to Toolbar" hidden`);
|
||||
let pinToToolbar = menu.querySelector(".customize-context-pinToToolbar");
|
||||
Assert.ok(pinToToolbar.hidden, "Pin to Overflow is hidden.");
|
||||
menu.hidePopup();
|
||||
}
|
||||
|
||||
add_task(async function test_unified_extensions_ui() {
|
||||
Services.telemetry.clearEvents();
|
||||
let win = await promiseEnableUnifiedExtensions();
|
||||
@ -883,143 +769,10 @@ add_task(async function test_unified_extensions_ui() {
|
||||
await browseraction_contextmenu_manage_extension_helper(win);
|
||||
await browseraction_contextmenu_remove_extension_helper(win);
|
||||
await browseraction_contextmenu_report_extension_helper(win);
|
||||
await test_no_toolbar_pinning_on_builtin_helper(win);
|
||||
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
});
|
||||
|
||||
/**
|
||||
* Tests that if Unified Extensions is enabled, that browser actions can
|
||||
* be unpinned from the toolbar to the addons panel and back again, via
|
||||
* a context menu item.
|
||||
*/
|
||||
add_task(async function test_unified_extensions_toolbar_pinning() {
|
||||
let win = await promiseEnableUnifiedExtensions();
|
||||
let id = "addon_id@example.com";
|
||||
let nodeId = `${makeWidgetId(id)}-browser-action`;
|
||||
let extension = ExtensionTestUtils.loadExtension({
|
||||
manifest: {
|
||||
browser_specific_settings: {
|
||||
gecko: { id },
|
||||
},
|
||||
browser_action: {},
|
||||
},
|
||||
useAddonManager: "temporary",
|
||||
});
|
||||
await extension.startup();
|
||||
|
||||
Assert.equal(
|
||||
CustomizableUI.getPlacementOfWidget(nodeId).area,
|
||||
CustomizableUI.AREA_NAVBAR,
|
||||
"Should start placed in the nav-bar."
|
||||
);
|
||||
|
||||
let menu = await openContextMenu(TOOLBAR_CONTEXT_MENU, nodeId, win);
|
||||
|
||||
info(`Pin to Overflow and Remove from Toolbar should be hidden.`);
|
||||
let pinToOverflow = menu.querySelector(".customize-context-moveToPanel");
|
||||
let removeFromToolbar = menu.querySelector(
|
||||
".customize-context-removeFromToolbar"
|
||||
);
|
||||
Assert.ok(pinToOverflow.hidden, "Pin to Overflow is hidden.");
|
||||
Assert.ok(removeFromToolbar.hidden, "Remove from Toolbar is hidden.");
|
||||
|
||||
info(
|
||||
`This button should have "Pin to Toolbar" visible and checked by default.`
|
||||
);
|
||||
let pinToToolbar = menu.querySelector(".customize-context-pinToToolbar");
|
||||
Assert.ok(!pinToToolbar.hidden, "Pin to Toolbar is visible.");
|
||||
Assert.equal(
|
||||
pinToToolbar.getAttribute("checked"),
|
||||
"true",
|
||||
"Pin to Toolbar is checked."
|
||||
);
|
||||
|
||||
info("Pinning addon to the addons panel.");
|
||||
await closeChromeContextMenu(TOOLBAR_CONTEXT_MENU, pinToToolbar, win);
|
||||
|
||||
Assert.equal(
|
||||
CustomizableUI.getPlacementOfWidget(nodeId).area,
|
||||
CustomizableUI.AREA_ADDONS,
|
||||
"Should have moved the button to the addons panel."
|
||||
);
|
||||
|
||||
info("Opening addons panel");
|
||||
win.gUnifiedExtensions.togglePanel();
|
||||
await BrowserTestUtils.waitForEvent(
|
||||
win.gUnifiedExtensions.panel,
|
||||
"popupshown"
|
||||
);
|
||||
info("Testing unpinning in the addons panel");
|
||||
|
||||
menu = await openContextMenu(UNIFIED_CONTEXT_MENU, nodeId, win);
|
||||
|
||||
// The UNIFIED_CONTEXT_MENU has a different node for pinToToolbar, so
|
||||
// we have to requery for it.
|
||||
pinToToolbar = menu.querySelector(
|
||||
".unified-extensions-context-menu-pin-to-toolbar"
|
||||
);
|
||||
|
||||
Assert.ok(!pinToToolbar.hidden, "Pin to Toolbar is visible.");
|
||||
Assert.equal(
|
||||
pinToToolbar.getAttribute("checked"),
|
||||
"false",
|
||||
"Pin to Toolbar is not checked."
|
||||
);
|
||||
await closeChromeContextMenu(UNIFIED_CONTEXT_MENU, pinToToolbar, win);
|
||||
|
||||
Assert.equal(
|
||||
CustomizableUI.getPlacementOfWidget(nodeId).area,
|
||||
CustomizableUI.AREA_NAVBAR,
|
||||
"Should have moved the button back to the nav-bar."
|
||||
);
|
||||
|
||||
await extension.unload();
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
});
|
||||
|
||||
/**
|
||||
* Tests that there's no Pin to Toolbar option for unified-extensions-item's
|
||||
* in the add-ons panel, since these do not represent browser action buttons.
|
||||
*/
|
||||
add_task(async function test_unified_extensions_item_no_pinning() {
|
||||
let win = await promiseEnableUnifiedExtensions();
|
||||
let id = "addon_id@example.com";
|
||||
let extension = ExtensionTestUtils.loadExtension({
|
||||
manifest: {
|
||||
browser_specific_settings: {
|
||||
gecko: { id },
|
||||
},
|
||||
},
|
||||
useAddonManager: "temporary",
|
||||
});
|
||||
await extension.startup();
|
||||
|
||||
info("Opening addons panel");
|
||||
let panel = win.gUnifiedExtensions.panel;
|
||||
await openExtensionsPanel(win);
|
||||
|
||||
let items = panel.querySelectorAll("unified-extensions-item");
|
||||
Assert.ok(
|
||||
!!items.length,
|
||||
"There should be at least one unified-extensions-item."
|
||||
);
|
||||
|
||||
let menu = await openChromeContextMenu(
|
||||
UNIFIED_CONTEXT_MENU,
|
||||
`unified-extensions-item[extension-id='${id}']`,
|
||||
win
|
||||
);
|
||||
let pinToToolbar = menu.querySelector(
|
||||
".unified-extensions-context-menu-pin-to-toolbar"
|
||||
);
|
||||
Assert.ok(pinToToolbar.hidden, "Pin to Toolbar is hidden.");
|
||||
menu.hidePopup();
|
||||
|
||||
await extension.unload();
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
});
|
||||
|
||||
add_task(async function test_non_unified_extensions_ui() {
|
||||
Services.telemetry.clearEvents();
|
||||
let win = await promiseDisableUnifiedExtensions();
|
||||
@ -1030,7 +783,6 @@ add_task(async function test_non_unified_extensions_ui() {
|
||||
await browseraction_contextmenu_manage_extension_helper(win);
|
||||
await browseraction_contextmenu_remove_extension_helper(win);
|
||||
await browseraction_contextmenu_report_extension_helper(win);
|
||||
await test_no_toolbar_pinning_on_builtin_helper(win);
|
||||
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
});
|
||||
|
@ -102,31 +102,24 @@ async function testOriginControls(
|
||||
}
|
||||
|
||||
let doc = menu.ownerDocument;
|
||||
let visibleItems = menu.querySelectorAll(
|
||||
":is(menuitem, menuseparator):not([hidden])"
|
||||
);
|
||||
|
||||
info("Check expected menu items.");
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
let l10n = doc.l10n.getAttributes(visibleItems[i]);
|
||||
Assert.deepEqual(
|
||||
l10n,
|
||||
items[i],
|
||||
`Visible menu item ${i} has correct l10n attrs.`
|
||||
);
|
||||
let l10n = doc.l10n.getAttributes(menu.children[i]);
|
||||
Assert.deepEqual(l10n, items[i], `Menu item ${i} has correct l10n attrs.`);
|
||||
|
||||
let checked = visibleItems[i].getAttribute("checked") === "true";
|
||||
let checked = menu.children[i].getAttribute("checked") === "true";
|
||||
is(i === selected, checked, `Expected checked value for item ${i}.`);
|
||||
}
|
||||
|
||||
if (items.length) {
|
||||
is(
|
||||
visibleItems[items.length].nodeName,
|
||||
menu.children[items.length].nodeName,
|
||||
"menuseparator",
|
||||
"Found separator."
|
||||
);
|
||||
is(
|
||||
visibleItems[items.length + 1].className,
|
||||
menu.children[items.length + 1].className,
|
||||
manageExtensionClassName,
|
||||
"All items accounted for."
|
||||
);
|
||||
@ -140,7 +133,7 @@ async function testOriginControls(
|
||||
|
||||
let itemToClick;
|
||||
if (click) {
|
||||
itemToClick = visibleItems[click];
|
||||
itemToClick = menu.children[click];
|
||||
}
|
||||
await closeChromeContextMenu(contextMenuId, itemToClick, win);
|
||||
|
||||
|
@ -57,13 +57,6 @@ function waitClosedWindow(win) {
|
||||
});
|
||||
}
|
||||
|
||||
function assertVisibleContextMenuItems(contextMenu, expected) {
|
||||
let visibleItems = contextMenu.querySelectorAll(
|
||||
":is(menuitem, menuseparator):not([hidden])"
|
||||
);
|
||||
is(visibleItems.length, expected, `expected ${expected} visible menu items`);
|
||||
}
|
||||
|
||||
let win;
|
||||
|
||||
add_setup(async function() {
|
||||
@ -577,7 +570,7 @@ add_task(async function test_context_menu_without_browserActionFor_global() {
|
||||
// This promise rejects with an error if the implementation does not handle
|
||||
// the case where `global.browserActionFor()` is undefined.
|
||||
const contextMenu = await openUnifiedExtensionsContextMenu(win, extension.id);
|
||||
assertVisibleContextMenuItems(contextMenu, 3);
|
||||
is(contextMenu.childElementCount, 3, "expected 3 menu items");
|
||||
|
||||
await closeChromeContextMenu(contextMenu.id, null, win);
|
||||
await closeExtensionsPanel(win);
|
||||
@ -683,8 +676,7 @@ add_task(async function test_browser_action_context_menu() {
|
||||
win,
|
||||
extWithMenuBrowserAction.id
|
||||
);
|
||||
assertVisibleContextMenuItems(contextMenu, 5);
|
||||
|
||||
is(contextMenu.childElementCount, 5, "expected 5 menu items");
|
||||
const [item, separator] = contextMenu.children;
|
||||
is(
|
||||
item.getAttribute("label"),
|
||||
@ -705,21 +697,21 @@ add_task(async function test_browser_action_context_menu() {
|
||||
win,
|
||||
extWithMenuPageAction.id
|
||||
);
|
||||
assertVisibleContextMenuItems(contextMenu, 3);
|
||||
is(contextMenu.childElementCount, 3, "expected 3 menu items");
|
||||
await closeChromeContextMenu(contextMenu.id, null, win);
|
||||
|
||||
info("extension with no browser action and no menu");
|
||||
// There is no context menu created by this extension, so there should only
|
||||
// be 3 menu items corresponding to the default manage/remove/report items.
|
||||
contextMenu = await openUnifiedExtensionsContextMenu(win, extWithoutMenu1.id);
|
||||
assertVisibleContextMenuItems(contextMenu, 3);
|
||||
is(contextMenu.childElementCount, 3, "expected 3 menu items");
|
||||
await closeChromeContextMenu(contextMenu.id, null, win);
|
||||
|
||||
info("extension with browser action and no menu");
|
||||
// There is no context menu created by this extension, so there should only
|
||||
// be 3 menu items corresponding to the default manage/remove/report items.
|
||||
contextMenu = await openUnifiedExtensionsContextMenu(win, extWithoutMenu2.id);
|
||||
assertVisibleContextMenuItems(contextMenu, 3);
|
||||
is(contextMenu.childElementCount, 3, "expected 3 menu items");
|
||||
await closeChromeContextMenu(contextMenu.id, null, win);
|
||||
|
||||
info("extension with browser action and menu + sub-menu");
|
||||
@ -729,7 +721,7 @@ add_task(async function test_browser_action_context_menu() {
|
||||
win,
|
||||
extWithSubMenuBrowserAction.id
|
||||
);
|
||||
assertVisibleContextMenuItems(contextMenu, 5);
|
||||
is(contextMenu.childElementCount, 5, "expected 5 menu items");
|
||||
const popup = await openSubmenu(contextMenu.children[0]);
|
||||
is(popup.children.length, 1, "expected 1 submenu item");
|
||||
is(
|
||||
@ -738,7 +730,7 @@ add_task(async function test_browser_action_context_menu() {
|
||||
"expected menu item"
|
||||
);
|
||||
// The number of items in the (main) context menu should remain the same.
|
||||
assertVisibleContextMenuItems(contextMenu, 5);
|
||||
is(contextMenu.childElementCount, 5, "expected 5 menu items");
|
||||
await closeChromeContextMenu(contextMenu.id, null, win);
|
||||
|
||||
await closeExtensionsPanel(win);
|
||||
|
@ -51,19 +51,6 @@ function getChildrenIDs(parent) {
|
||||
return Array.from(parent.children).map(child => child.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a NodeList of all non-hidden menu, menuitem and menuseparators
|
||||
* that are direct descendants of popup.
|
||||
*
|
||||
* @param {Element} popup
|
||||
* @returns {NodeList} the visible items.
|
||||
*/
|
||||
function getVisibleMenuItems(popup) {
|
||||
return popup.querySelectorAll(
|
||||
":scope > :is(menu, menuitem, menuseparator):not([hidden])"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This helper function does most of the heavy lifting for these tests.
|
||||
* It does the following in order:
|
||||
@ -107,11 +94,6 @@ async function withWindowOverflowed(win, taskFn) {
|
||||
|
||||
const extWithMenuBrowserAction = ExtensionTestUtils.loadExtension({
|
||||
manifest: {
|
||||
browser_specific_settings: {
|
||||
gecko: {
|
||||
id: "overflowable-toolbar-addon-with-context-menu@mozilla.org",
|
||||
},
|
||||
},
|
||||
name: "Extension #0",
|
||||
browser_specific_settings: {
|
||||
gecko: { id: "unified-extensions-overflowable-toolbar@ext-0" },
|
||||
@ -638,19 +620,15 @@ add_task(async function test_context_menu() {
|
||||
firstExtensionWidget.dataset.extensionid
|
||||
);
|
||||
Assert.ok(contextMenu, "expected a context menu");
|
||||
let visibleItems = getVisibleMenuItems(contextMenu);
|
||||
|
||||
// The context menu for the extension that declares a browser action menu
|
||||
// should have the menu item created by the extension, a menu separator, the control
|
||||
// for pinning the browser action to the toolbar, a menu separator and the 3 default menu items.
|
||||
// should have the menu item created by the extension, a menu separator
|
||||
// and the 3 default menu items.
|
||||
is(
|
||||
visibleItems.length,
|
||||
7,
|
||||
"expected a custom context menu item, a menu separator, the pin to " +
|
||||
"toolbar menu item, a menu separator, and the 3 default menu items"
|
||||
contextMenu.childElementCount,
|
||||
5,
|
||||
"expected a custom context menu item and a menu separator in addition to the 3 default menu items"
|
||||
);
|
||||
|
||||
const [item, separator] = visibleItems;
|
||||
const [item, separator] = contextMenu.children;
|
||||
is(
|
||||
item.getAttribute("label"),
|
||||
"Click me!",
|
||||
@ -661,7 +639,6 @@ add_task(async function test_context_menu() {
|
||||
"menuseparator",
|
||||
"expected separator after last menu item created by the extension"
|
||||
);
|
||||
|
||||
await closeChromeContextMenu(contextMenu.id, null, win);
|
||||
|
||||
info("extension with browser action and a menu with submenu");
|
||||
@ -671,9 +648,8 @@ add_task(async function test_context_menu() {
|
||||
win,
|
||||
secondExtensionWidget.dataset.extensionid
|
||||
);
|
||||
visibleItems = getVisibleMenuItems(contextMenu);
|
||||
is(visibleItems.length, 7, "expected 7 menu items");
|
||||
const popup = await openSubmenu(visibleItems[0]);
|
||||
is(contextMenu.childElementCount, 5, "expected 5 menu items");
|
||||
const popup = await openSubmenu(contextMenu.children[0]);
|
||||
is(popup.children.length, 1, "expected 1 submenu item");
|
||||
is(
|
||||
popup.children[0].getAttribute("label"),
|
||||
@ -681,8 +657,7 @@ add_task(async function test_context_menu() {
|
||||
"expected menu item"
|
||||
);
|
||||
// The number of items in the (main) context menu should remain the same.
|
||||
visibleItems = getVisibleMenuItems(contextMenu);
|
||||
is(visibleItems.length, 7, "expected 7 menu items");
|
||||
is(contextMenu.childElementCount, 5, "expected 5 menu items");
|
||||
await closeChromeContextMenu(contextMenu.id, null, win);
|
||||
|
||||
info("extension with no browser action and no menu");
|
||||
@ -696,9 +671,7 @@ add_task(async function test_context_menu() {
|
||||
thirdExtensionWidget.dataset.extensionid
|
||||
);
|
||||
Assert.ok(contextMenu, "expected a context menu");
|
||||
visibleItems = getVisibleMenuItems(contextMenu);
|
||||
is(visibleItems.length, 5, "expected 5 menu items");
|
||||
|
||||
is(contextMenu.childElementCount, 3, "expected 3 menu items");
|
||||
await closeChromeContextMenu(contextMenu.id, null, win);
|
||||
|
||||
// We can close the unified extensions panel now.
|
||||
|
@ -66,7 +66,7 @@ const getUnifiedExtensionsItem = (win, extensionId) => {
|
||||
// First try to find a CUI widget, otherwise a custom element when the
|
||||
// extension does not have a browser action.
|
||||
return (
|
||||
view.querySelector(`toolbaritem[data-extensionid="${extensionId}"]`) ||
|
||||
view.querySelector(`[data-extensionid="${extensionId}"]`) ||
|
||||
view.querySelector(`unified-extensions-item[extension-id="${extensionId}"]`)
|
||||
);
|
||||
};
|
||||
|
@ -63,11 +63,6 @@ toolbar-context-menu-view-customize-toolbar =
|
||||
toolbar-context-menu-view-customize-toolbar-2 =
|
||||
.label = Customize Toolbar…
|
||||
.accesskey = C
|
||||
# This is only ever shown when toolbar-context-menu-pin-to-overflow-menu
|
||||
# is hidden, so they can share access keys.
|
||||
toolbar-context-menu-pin-to-toolbar =
|
||||
.label = Pin to Toolbar
|
||||
.accesskey = P
|
||||
|
||||
toolbar-context-menu-bookmarks-toolbar-always-show-2 =
|
||||
.label = Always Show
|
||||
|
@ -23,9 +23,6 @@ unified-extensions-item-message-manage = Manage extension
|
||||
|
||||
## Extension's context menu
|
||||
|
||||
unified-extensions-context-menu-pin-to-toolbar =
|
||||
.label = Pin to Toolbar
|
||||
|
||||
unified-extensions-context-menu-manage-extension =
|
||||
.label = Manage Extension
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user