mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +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);
|
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);
|
let policy = WebExtensionPolicy.getByID(this.addon.id);
|
||||||
this.toggleAttribute(
|
this.toggleAttribute(
|
||||||
"attention",
|
"attention",
|
||||||
@ -1384,9 +1380,7 @@ customElements.define(
|
|||||||
|
|
||||||
this._actionButton.disabled = !this._hasAction();
|
this._actionButton.disabled = !this._hasAction();
|
||||||
|
|
||||||
// Note that the data-extensionid attribute is used by context menu handlers
|
this._openMenuButton.dataset.extensionId = this.addon.id;
|
||||||
// to identify the extension being manipulated by the context menu.
|
|
||||||
this._openMenuButton.dataset.extensionid = this.addon.id;
|
|
||||||
this._openMenuButton.setAttribute(
|
this._openMenuButton.setAttribute(
|
||||||
"data-l10n-args",
|
"data-l10n-args",
|
||||||
JSON.stringify({ extensionName: this.addon.name })
|
JSON.stringify({ extensionName: this.addon.name })
|
||||||
@ -1622,30 +1616,13 @@ var gUnifiedExtensions = {
|
|||||||
|
|
||||||
const id = this._getExtensionId(menu);
|
const id = this._getExtensionId(menu);
|
||||||
const addon = await AddonManager.getAddonByID(id);
|
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(
|
const removeButton = menu.querySelector(
|
||||||
".unified-extensions-context-menu-remove-extension"
|
".unified-extensions-context-menu-remove-extension"
|
||||||
);
|
);
|
||||||
const reportButton = menu.querySelector(
|
const reportButton = menu.querySelector(
|
||||||
".unified-extensions-context-menu-report-extension"
|
".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;
|
reportButton.hidden = !gAddonAbuseReportEnabled;
|
||||||
removeButton.disabled = !(
|
removeButton.disabled = !(
|
||||||
@ -1691,36 +1668,6 @@ var gUnifiedExtensions = {
|
|||||||
|
|
||||||
_getExtensionId(menu) {
|
_getExtensionId(menu) {
|
||||||
const { triggerNode } = menu;
|
const { triggerNode } = menu;
|
||||||
return triggerNode.dataset.extensionid;
|
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);
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -7416,11 +7416,6 @@ var ToolbarContextMenu = {
|
|||||||
return node && node.getAttribute("data-extensionid");
|
return node && node.getAttribute("data-extensionid");
|
||||||
},
|
},
|
||||||
|
|
||||||
_getWidgetId(popup) {
|
|
||||||
let node = this._getUnwrappedTriggerNode(popup);
|
|
||||||
return node?.closest(".unified-extensions-item")?.id;
|
|
||||||
},
|
|
||||||
|
|
||||||
async updateExtension(popup) {
|
async updateExtension(popup) {
|
||||||
let removeExtension = popup.querySelector(
|
let removeExtension = popup.querySelector(
|
||||||
".customize-context-removeExtension"
|
".customize-context-removeExtension"
|
||||||
@ -7431,7 +7426,6 @@ var ToolbarContextMenu = {
|
|||||||
let reportExtension = popup.querySelector(
|
let reportExtension = popup.querySelector(
|
||||||
".customize-context-reportExtension"
|
".customize-context-reportExtension"
|
||||||
);
|
);
|
||||||
let pinToToolbar = popup.querySelector(".customize-context-pinToToolbar");
|
|
||||||
let separator = reportExtension.nextElementSibling;
|
let separator = reportExtension.nextElementSibling;
|
||||||
let id = this._getExtensionId(popup);
|
let id = this._getExtensionId(popup);
|
||||||
let addon = id && (await AddonManager.getAddonByID(id));
|
let addon = id && (await AddonManager.getAddonByID(id));
|
||||||
@ -7440,32 +7434,9 @@ var ToolbarContextMenu = {
|
|||||||
element.hidden = !addon;
|
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;
|
reportExtension.hidden = !addon || !gAddonAbuseReportEnabled;
|
||||||
|
|
||||||
if (addon) {
|
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 = !(
|
removeExtension.disabled = !(
|
||||||
addon.permissions & AddonManager.PERM_CAN_UNINSTALL
|
addon.permissions & AddonManager.PERM_CAN_UNINSTALL
|
||||||
);
|
);
|
||||||
|
@ -346,11 +346,6 @@
|
|||||||
data-lazy-l10n-id="toolbar-context-menu-remove-from-toolbar"
|
data-lazy-l10n-id="toolbar-context-menu-remove-from-toolbar"
|
||||||
contexttype="toolbaritem"
|
contexttype="toolbaritem"
|
||||||
class="customize-context-removeFromToolbar"/>
|
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"/>
|
<menuseparator id="toolbarDownloadsAnchorMenuSeparator"/>
|
||||||
<menuitem id="toolbar-context-always-open-downloads-panel"
|
<menuitem id="toolbar-context-always-open-downloads-panel"
|
||||||
oncommand="ToolbarContextMenu.onDownloadsAlwaysOpenPanelChange(event);"
|
oncommand="ToolbarContextMenu.onDownloadsAlwaysOpenPanelChange(event);"
|
||||||
@ -638,11 +633,6 @@
|
|||||||
|
|
||||||
<menupopup id="unified-extensions-context-menu"
|
<menupopup id="unified-extensions-context-menu"
|
||||||
onpopupshowing="gUnifiedExtensions.updateContextMenu(this, event)">
|
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"
|
<menuitem data-lazy-l10n-id="unified-extensions-context-menu-manage-extension"
|
||||||
class="unified-extensions-context-menu-manage-extension"
|
class="unified-extensions-context-menu-manage-extension"
|
||||||
oncommand="gUnifiedExtensions.manageExtension(this.parentElement)" />
|
oncommand="gUnifiedExtensions.manageExtension(this.parentElement)" />
|
||||||
|
@ -1234,21 +1234,10 @@ var CustomizableUIInternal = {
|
|||||||
|
|
||||||
let currentContextMenu =
|
let currentContextMenu =
|
||||||
aNode.getAttribute("context") || aNode.getAttribute("contextmenu");
|
aNode.getAttribute("context") || aNode.getAttribute("contextmenu");
|
||||||
let contextMenuForPlace;
|
let contextMenuForPlace =
|
||||||
|
forcePanel || "panel" == CustomizableUI.getPlaceForItem(aAreaNode)
|
||||||
if (
|
? kPanelItemContextMenu
|
||||||
lazy.gUnifiedExtensionsEnabled &&
|
: null;
|
||||||
CustomizableUI.isWebExtensionWidget(aNode.id) &&
|
|
||||||
(aAreaNode?.id == CustomizableUI.AREA_ADDONS ||
|
|
||||||
aNode.getAttribute("overflowedItem") == "true")
|
|
||||||
) {
|
|
||||||
contextMenuForPlace = null;
|
|
||||||
} else {
|
|
||||||
contextMenuForPlace =
|
|
||||||
forcePanel || "panel" == CustomizableUI.getPlaceForItem(aAreaNode)
|
|
||||||
? kPanelItemContextMenu
|
|
||||||
: null;
|
|
||||||
}
|
|
||||||
if (contextMenuForPlace && !currentContextMenu) {
|
if (contextMenuForPlace && !currentContextMenu) {
|
||||||
aNode.setAttribute("context", contextMenuForPlace);
|
aNode.setAttribute("context", contextMenuForPlace);
|
||||||
} else if (
|
} else if (
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
|
|
||||||
<toolbarseparator />
|
<toolbarseparator />
|
||||||
|
|
||||||
<vbox class="panel-subview-body" context="unified-extensions-context-menu">
|
<vbox class="panel-subview-body">
|
||||||
<vbox id="overflowed-extensions-list">
|
<vbox id="overflowed-extensions-list">
|
||||||
<!-- overflowed extension buttons from the nav-bar will go here -->
|
<!-- overflowed extension buttons from the nav-bar will go here -->
|
||||||
</vbox>
|
</vbox>
|
||||||
|
@ -270,6 +270,9 @@ this.browserAction = class extends ExtensionAPIPersistent {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (gUnifiedExtensionsEnabled) {
|
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(
|
menuButton.setAttribute(
|
||||||
"data-l10n-id",
|
"data-l10n-id",
|
||||||
"unified-extensions-item-open-menu"
|
"unified-extensions-item-open-menu"
|
||||||
|
@ -69,9 +69,6 @@ if (AppConstants.platform == "macosx") {
|
|||||||
|
|
||||||
const type = "extension";
|
const type = "extension";
|
||||||
|
|
||||||
const TOOLBAR_CONTEXT_MENU = "toolbar-context-menu";
|
|
||||||
const UNIFIED_CONTEXT_MENU = "unified-extensions-context-menu";
|
|
||||||
|
|
||||||
async function assertTelemetryMatches(events) {
|
async function assertTelemetryMatches(events) {
|
||||||
events = events.map(([method, object, value, extra]) => {
|
events = events.map(([method, object, value, extra]) => {
|
||||||
return { 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");
|
info("Test toolbar context menu in browserAction");
|
||||||
let toolbarCtxMenu = await testContextMenu(
|
let toolbarCtxMenu = await testContextMenu(
|
||||||
TOOLBAR_CONTEXT_MENU,
|
"toolbar-context-menu",
|
||||||
customizing
|
customizing
|
||||||
);
|
);
|
||||||
|
|
||||||
info("Check toolbar context menu in another button");
|
info("Check toolbar context menu in another button");
|
||||||
let otherButtonId = "home-button";
|
let otherButtonId = "home-button";
|
||||||
await openContextMenu(TOOLBAR_CONTEXT_MENU, otherButtonId, win);
|
await openContextMenu(toolbarCtxMenu.id, otherButtonId, win);
|
||||||
checkVisibility(toolbarCtxMenu, false);
|
checkVisibility(toolbarCtxMenu, false);
|
||||||
toolbarCtxMenu.hidePopup();
|
toolbarCtxMenu.hidePopup();
|
||||||
|
|
||||||
@ -325,16 +322,11 @@ async function browseraction_contextmenu_manage_extension_helper(win) {
|
|||||||
checkVisibility(toolbarCtxMenu, false);
|
checkVisibility(toolbarCtxMenu, false);
|
||||||
toolbarCtxMenu.hidePopup();
|
toolbarCtxMenu.hidePopup();
|
||||||
|
|
||||||
// Pinning browser actions to the overflow panel isn't going to be possible
|
info("Pin the browserAction and another button to the overflow menu");
|
||||||
// after bug 1798896.
|
CustomizableUI.addWidgetToArea(
|
||||||
if (!win.gUnifiedExtensions.isEnabled) {
|
nodeId,
|
||||||
info("Pin a browserAction to the overflow menu");
|
CustomizableUI.AREA_FIXED_OVERFLOW_PANEL
|
||||||
CustomizableUI.addWidgetToArea(
|
);
|
||||||
nodeId,
|
|
||||||
CustomizableUI.AREA_FIXED_OVERFLOW_PANEL
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
CustomizableUI.addWidgetToArea(
|
CustomizableUI.addWidgetToArea(
|
||||||
otherButtonId,
|
otherButtonId,
|
||||||
CustomizableUI.AREA_FIXED_OVERFLOW_PANEL
|
CustomizableUI.AREA_FIXED_OVERFLOW_PANEL
|
||||||
@ -362,13 +354,11 @@ async function browseraction_contextmenu_manage_extension_helper(win) {
|
|||||||
checkVisibility(overflowMenuCtxMenu, false);
|
checkVisibility(overflowMenuCtxMenu, false);
|
||||||
overflowMenuCtxMenu.hidePopup();
|
overflowMenuCtxMenu.hidePopup();
|
||||||
|
|
||||||
if (!win.gUnifiedExtensions.isEnabled) {
|
info("Test overflow menu context menu in browserAction");
|
||||||
info("Test overflow menu context menu in browserAction");
|
await testContextMenu(overflowMenuCtxMenu.id, customizing);
|
||||||
await testContextMenu(overflowMenuCtxMenu.id, customizing);
|
|
||||||
info("Put browser action back in nav-bar");
|
info("Restore initial state");
|
||||||
CustomizableUI.addWidgetToArea(nodeId, CustomizableUI.AREA_NAVBAR);
|
CustomizableUI.addWidgetToArea(nodeId, CustomizableUI.AREA_NAVBAR);
|
||||||
}
|
|
||||||
info("Put other button action back in nav-bar");
|
|
||||||
CustomizableUI.addWidgetToArea(otherButtonId, CustomizableUI.AREA_NAVBAR);
|
CustomizableUI.addWidgetToArea(otherButtonId, CustomizableUI.AREA_NAVBAR);
|
||||||
|
|
||||||
if (customizing) {
|
if (customizing) {
|
||||||
@ -396,37 +386,21 @@ async function browseraction_contextmenu_manage_extension_helper(win) {
|
|||||||
|
|
||||||
info("Run tests in normal mode");
|
info("Run tests in normal mode");
|
||||||
await main(false);
|
await main(false);
|
||||||
|
await assertTelemetryMatches([
|
||||||
if (win.gUnifiedExtensions.isEnabled) {
|
["action", "browserAction", null, { action: "manage", addonId: id }],
|
||||||
await assertTelemetryMatches([
|
["view", "aboutAddons", "detail", { addonId: id, type }],
|
||||||
["action", "browserAction", null, { action: "manage", addonId: id }],
|
["action", "browserAction", null, { action: "manage", addonId: id }],
|
||||||
["view", "aboutAddons", "detail", { addonId: id, type }],
|
["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 }],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
info("Run tests in customize mode");
|
info("Run tests in customize mode");
|
||||||
await main(true);
|
await main(true);
|
||||||
|
await assertTelemetryMatches([
|
||||||
if (win.gUnifiedExtensions.isEnabled) {
|
["action", "browserAction", null, { action: "manage", addonId: id }],
|
||||||
await assertTelemetryMatches([
|
["view", "aboutAddons", "detail", { addonId: id, type }],
|
||||||
["action", "browserAction", null, { action: "manage", addonId: id }],
|
["action", "browserAction", null, { action: "manage", addonId: id }],
|
||||||
["view", "aboutAddons", "detail", { addonId: id, type }],
|
["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 }],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
info("Close the dummy tab and finish");
|
info("Close the dummy tab and finish");
|
||||||
win.gBrowser.removeTab(dummyTab);
|
win.gBrowser.removeTab(dummyTab);
|
||||||
@ -451,51 +425,30 @@ async function runTestContextMenu({ id, customizing, testContextMenu, win }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
info("Test toolbar context menu in browserAction");
|
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 and another button to the overflow menu");
|
||||||
info("Pin the browserAction to the addons panel");
|
CustomizableUI.addWidgetToArea(
|
||||||
CustomizableUI.addWidgetToArea(nodeId, CustomizableUI.AREA_ADDONS);
|
nodeId,
|
||||||
|
CustomizableUI.AREA_FIXED_OVERFLOW_PANEL
|
||||||
|
);
|
||||||
|
|
||||||
if (!customizing) {
|
info("Wait until the overflow menu is ready");
|
||||||
info("Open addons panel");
|
let overflowButton = win.document.getElementById("nav-bar-overflow-button");
|
||||||
win.gUnifiedExtensions.togglePanel();
|
let icon = overflowButton.icon;
|
||||||
await BrowserTestUtils.waitForEvent(
|
await waitForElementShown(icon);
|
||||||
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");
|
if (!customizing) {
|
||||||
let overflowButton = win.document.getElementById("nav-bar-overflow-button");
|
info("Open overflow menu");
|
||||||
let icon = overflowButton.icon;
|
let menu = win.document.getElementById("widget-overflow");
|
||||||
await waitForElementShown(icon);
|
let shown = BrowserTestUtils.waitForEvent(menu, "popupshown");
|
||||||
|
overflowButton.click();
|
||||||
if (!customizing) {
|
await shown;
|
||||||
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("Test overflow menu context menu in browserAction");
|
||||||
|
await testContextMenu("customizationPanelItemContextMenu", customizing);
|
||||||
|
|
||||||
info("Restore initial state");
|
info("Restore initial state");
|
||||||
CustomizableUI.addWidgetToArea(nodeId, CustomizableUI.AREA_NAVBAR);
|
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);
|
let menu = await openContextMenu(menuId, buttonId, win);
|
||||||
|
|
||||||
info(`Choosing 'Remove Extension' in ${menuId} should show confirm dialog`);
|
info(`Choosing 'Remove Extension' in ${menuId} should show confirm dialog`);
|
||||||
let removeItemQuery =
|
let removeExtension = menu.querySelector(
|
||||||
menuId == "unified-extensions-context-menu"
|
".customize-context-removeExtension"
|
||||||
? ".unified-extensions-context-menu-remove-extension"
|
);
|
||||||
: ".customize-context-removeExtension";
|
|
||||||
let removeExtension = menu.querySelector(removeItemQuery);
|
|
||||||
await closeChromeContextMenu(menuId, removeExtension, win);
|
await closeChromeContextMenu(menuId, removeExtension, win);
|
||||||
let args = await confirmArgs;
|
let args = await confirmArgs;
|
||||||
is(args[1], `Remove ${name}?`);
|
is(args[1], `Remove ${name}?`);
|
||||||
@ -584,39 +535,20 @@ async function browseraction_contextmenu_remove_extension_helper(win) {
|
|||||||
win,
|
win,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (win.gUnifiedExtensions.isEnabled) {
|
await assertTelemetryMatches([
|
||||||
// The first uninstall event comes from the toolbar context menu, and the
|
[
|
||||||
// next via the unified extension context menu.
|
"action",
|
||||||
await assertTelemetryMatches([
|
"browserAction",
|
||||||
[
|
"cancelled",
|
||||||
"action",
|
{ action: "uninstall", addonId: id },
|
||||||
"browserAction",
|
],
|
||||||
"cancelled",
|
[
|
||||||
{ action: "uninstall", addonId: id },
|
"action",
|
||||||
],
|
"browserAction",
|
||||||
[
|
"cancelled",
|
||||||
"action",
|
{ action: "uninstall", addonId: id },
|
||||||
"unifiedExtensions",
|
],
|
||||||
"cancelled",
|
]);
|
||||||
{ action: "uninstall", addonId: id },
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
await assertTelemetryMatches([
|
|
||||||
[
|
|
||||||
"action",
|
|
||||||
"browserAction",
|
|
||||||
"cancelled",
|
|
||||||
{ action: "uninstall", addonId: id },
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"action",
|
|
||||||
"browserAction",
|
|
||||||
"cancelled",
|
|
||||||
{ action: "uninstall", addonId: id },
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
info("Run tests in customize mode");
|
info("Run tests in customize mode");
|
||||||
await runTestContextMenu({
|
await runTestContextMenu({
|
||||||
@ -626,38 +558,20 @@ async function browseraction_contextmenu_remove_extension_helper(win) {
|
|||||||
win,
|
win,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (win.gUnifiedExtensions.isEnabled) {
|
await assertTelemetryMatches([
|
||||||
// We'll only get one of these because in customize mode, the browserAction
|
[
|
||||||
// is not accessible when in the addons panel.
|
"action",
|
||||||
todo(
|
"browserAction",
|
||||||
false,
|
"cancelled",
|
||||||
"Should record a second removal event when browserAction " +
|
{ action: "uninstall", addonId: id },
|
||||||
"becomes available in customize mode."
|
],
|
||||||
);
|
[
|
||||||
await assertTelemetryMatches([
|
"action",
|
||||||
[
|
"browserAction",
|
||||||
"action",
|
"cancelled",
|
||||||
"browserAction",
|
{ action: "uninstall", addonId: id },
|
||||||
"cancelled",
|
],
|
||||||
{ action: "uninstall", addonId: id },
|
]);
|
||||||
],
|
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
await assertTelemetryMatches([
|
|
||||||
[
|
|
||||||
"action",
|
|
||||||
"browserAction",
|
|
||||||
"cancelled",
|
|
||||||
{ action: "uninstall", addonId: id },
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"action",
|
|
||||||
"browserAction",
|
|
||||||
"cancelled",
|
|
||||||
{ action: "uninstall", addonId: id },
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
let addon = await AddonManager.getAddonByID(id);
|
let addon = await AddonManager.getAddonByID(id);
|
||||||
ok(addon, "Addon is still installed");
|
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 uninstalled;
|
||||||
|
|
||||||
await assertTelemetryMatches([
|
await assertTelemetryMatches([
|
||||||
@ -729,7 +643,7 @@ async function browseraction_contextmenu_report_extension_helper(win) {
|
|||||||
useAddonManager: "temporary",
|
useAddonManager: "temporary",
|
||||||
});
|
});
|
||||||
|
|
||||||
async function testReportDialog(viaUnifiedContextMenu) {
|
async function testReportDialog() {
|
||||||
const reportDialogWindow = await BrowserTestUtils.waitForCondition(
|
const reportDialogWindow = await BrowserTestUtils.waitForCondition(
|
||||||
() => AbuseReporter.getOpenDialog(),
|
() => AbuseReporter.getOpenDialog(),
|
||||||
"Wait for the abuse report dialog to have been opened"
|
"Wait for the abuse report dialog to have been opened"
|
||||||
@ -743,7 +657,7 @@ async function browseraction_contextmenu_report_extension_helper(win) {
|
|||||||
);
|
);
|
||||||
is(
|
is(
|
||||||
reportDialogParams.report.reportEntryPoint,
|
reportDialogParams.report.reportEntryPoint,
|
||||||
viaUnifiedContextMenu ? "unified_context_menu" : "toolbar_context_menu",
|
"toolbar_context_menu",
|
||||||
"Abuse report dialog has the expected reportEntryPoint"
|
"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);
|
let menu = await openContextMenu(menuId, buttonId, win);
|
||||||
|
|
||||||
info(`Choosing 'Report Extension' in ${menuId} should show confirm dialog`);
|
info(`Choosing 'Report Extension' in ${menuId} should show confirm dialog`);
|
||||||
|
let reportExtension = menu.querySelector(
|
||||||
let usingUnifiedContextMenu = menuId == "unified-extensions-context-menu";
|
".customize-context-reportExtension"
|
||||||
let reportItemQuery = usingUnifiedContextMenu
|
);
|
||||||
? ".unified-extensions-context-menu-report-extension"
|
|
||||||
: ".customize-context-reportExtension";
|
|
||||||
let reportExtension = menu.querySelector(reportItemQuery);
|
|
||||||
|
|
||||||
ok(!reportExtension.hidden, "Report extension should be visibile");
|
ok(!reportExtension.hidden, "Report extension should be visibile");
|
||||||
|
|
||||||
// When running in customizing mode "about:addons" will load in a new tab,
|
// 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") {
|
if (browser.contentDocument?.readyState != "complete") {
|
||||||
await BrowserTestUtils.browserLoaded(browser);
|
await BrowserTestUtils.browserLoaded(browser);
|
||||||
}
|
}
|
||||||
await testReportDialog(usingUnifiedContextMenu);
|
await testReportDialog();
|
||||||
|
|
||||||
// Close the new about:addons tab when running in customize mode,
|
// Close the new about:addons tab when running in customize mode,
|
||||||
// or cancel the abuse report if the about:addons page has been
|
// 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();
|
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() {
|
add_task(async function test_unified_extensions_ui() {
|
||||||
Services.telemetry.clearEvents();
|
Services.telemetry.clearEvents();
|
||||||
let win = await promiseEnableUnifiedExtensions();
|
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_manage_extension_helper(win);
|
||||||
await browseraction_contextmenu_remove_extension_helper(win);
|
await browseraction_contextmenu_remove_extension_helper(win);
|
||||||
await browseraction_contextmenu_report_extension_helper(win);
|
await browseraction_contextmenu_report_extension_helper(win);
|
||||||
await test_no_toolbar_pinning_on_builtin_helper(win);
|
|
||||||
|
|
||||||
await BrowserTestUtils.closeWindow(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() {
|
add_task(async function test_non_unified_extensions_ui() {
|
||||||
Services.telemetry.clearEvents();
|
Services.telemetry.clearEvents();
|
||||||
let win = await promiseDisableUnifiedExtensions();
|
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_manage_extension_helper(win);
|
||||||
await browseraction_contextmenu_remove_extension_helper(win);
|
await browseraction_contextmenu_remove_extension_helper(win);
|
||||||
await browseraction_contextmenu_report_extension_helper(win);
|
await browseraction_contextmenu_report_extension_helper(win);
|
||||||
await test_no_toolbar_pinning_on_builtin_helper(win);
|
|
||||||
|
|
||||||
await BrowserTestUtils.closeWindow(win);
|
await BrowserTestUtils.closeWindow(win);
|
||||||
});
|
});
|
||||||
|
@ -102,31 +102,24 @@ async function testOriginControls(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let doc = menu.ownerDocument;
|
let doc = menu.ownerDocument;
|
||||||
let visibleItems = menu.querySelectorAll(
|
|
||||||
":is(menuitem, menuseparator):not([hidden])"
|
|
||||||
);
|
|
||||||
|
|
||||||
info("Check expected menu items.");
|
info("Check expected menu items.");
|
||||||
for (let i = 0; i < items.length; i++) {
|
for (let i = 0; i < items.length; i++) {
|
||||||
let l10n = doc.l10n.getAttributes(visibleItems[i]);
|
let l10n = doc.l10n.getAttributes(menu.children[i]);
|
||||||
Assert.deepEqual(
|
Assert.deepEqual(l10n, items[i], `Menu item ${i} has correct l10n attrs.`);
|
||||||
l10n,
|
|
||||||
items[i],
|
|
||||||
`Visible 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}.`);
|
is(i === selected, checked, `Expected checked value for item ${i}.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (items.length) {
|
if (items.length) {
|
||||||
is(
|
is(
|
||||||
visibleItems[items.length].nodeName,
|
menu.children[items.length].nodeName,
|
||||||
"menuseparator",
|
"menuseparator",
|
||||||
"Found separator."
|
"Found separator."
|
||||||
);
|
);
|
||||||
is(
|
is(
|
||||||
visibleItems[items.length + 1].className,
|
menu.children[items.length + 1].className,
|
||||||
manageExtensionClassName,
|
manageExtensionClassName,
|
||||||
"All items accounted for."
|
"All items accounted for."
|
||||||
);
|
);
|
||||||
@ -140,7 +133,7 @@ async function testOriginControls(
|
|||||||
|
|
||||||
let itemToClick;
|
let itemToClick;
|
||||||
if (click) {
|
if (click) {
|
||||||
itemToClick = visibleItems[click];
|
itemToClick = menu.children[click];
|
||||||
}
|
}
|
||||||
await closeChromeContextMenu(contextMenuId, itemToClick, win);
|
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;
|
let win;
|
||||||
|
|
||||||
add_setup(async function() {
|
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
|
// This promise rejects with an error if the implementation does not handle
|
||||||
// the case where `global.browserActionFor()` is undefined.
|
// the case where `global.browserActionFor()` is undefined.
|
||||||
const contextMenu = await openUnifiedExtensionsContextMenu(win, extension.id);
|
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 closeChromeContextMenu(contextMenu.id, null, win);
|
||||||
await closeExtensionsPanel(win);
|
await closeExtensionsPanel(win);
|
||||||
@ -683,8 +676,7 @@ add_task(async function test_browser_action_context_menu() {
|
|||||||
win,
|
win,
|
||||||
extWithMenuBrowserAction.id
|
extWithMenuBrowserAction.id
|
||||||
);
|
);
|
||||||
assertVisibleContextMenuItems(contextMenu, 5);
|
is(contextMenu.childElementCount, 5, "expected 5 menu items");
|
||||||
|
|
||||||
const [item, separator] = contextMenu.children;
|
const [item, separator] = contextMenu.children;
|
||||||
is(
|
is(
|
||||||
item.getAttribute("label"),
|
item.getAttribute("label"),
|
||||||
@ -705,21 +697,21 @@ add_task(async function test_browser_action_context_menu() {
|
|||||||
win,
|
win,
|
||||||
extWithMenuPageAction.id
|
extWithMenuPageAction.id
|
||||||
);
|
);
|
||||||
assertVisibleContextMenuItems(contextMenu, 3);
|
is(contextMenu.childElementCount, 3, "expected 3 menu items");
|
||||||
await closeChromeContextMenu(contextMenu.id, null, win);
|
await closeChromeContextMenu(contextMenu.id, null, win);
|
||||||
|
|
||||||
info("extension with no browser action and no menu");
|
info("extension with no browser action and no menu");
|
||||||
// There is no context menu created by this extension, so there should only
|
// 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.
|
// be 3 menu items corresponding to the default manage/remove/report items.
|
||||||
contextMenu = await openUnifiedExtensionsContextMenu(win, extWithoutMenu1.id);
|
contextMenu = await openUnifiedExtensionsContextMenu(win, extWithoutMenu1.id);
|
||||||
assertVisibleContextMenuItems(contextMenu, 3);
|
is(contextMenu.childElementCount, 3, "expected 3 menu items");
|
||||||
await closeChromeContextMenu(contextMenu.id, null, win);
|
await closeChromeContextMenu(contextMenu.id, null, win);
|
||||||
|
|
||||||
info("extension with browser action and no menu");
|
info("extension with browser action and no menu");
|
||||||
// There is no context menu created by this extension, so there should only
|
// 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.
|
// be 3 menu items corresponding to the default manage/remove/report items.
|
||||||
contextMenu = await openUnifiedExtensionsContextMenu(win, extWithoutMenu2.id);
|
contextMenu = await openUnifiedExtensionsContextMenu(win, extWithoutMenu2.id);
|
||||||
assertVisibleContextMenuItems(contextMenu, 3);
|
is(contextMenu.childElementCount, 3, "expected 3 menu items");
|
||||||
await closeChromeContextMenu(contextMenu.id, null, win);
|
await closeChromeContextMenu(contextMenu.id, null, win);
|
||||||
|
|
||||||
info("extension with browser action and menu + sub-menu");
|
info("extension with browser action and menu + sub-menu");
|
||||||
@ -729,7 +721,7 @@ add_task(async function test_browser_action_context_menu() {
|
|||||||
win,
|
win,
|
||||||
extWithSubMenuBrowserAction.id
|
extWithSubMenuBrowserAction.id
|
||||||
);
|
);
|
||||||
assertVisibleContextMenuItems(contextMenu, 5);
|
is(contextMenu.childElementCount, 5, "expected 5 menu items");
|
||||||
const popup = await openSubmenu(contextMenu.children[0]);
|
const popup = await openSubmenu(contextMenu.children[0]);
|
||||||
is(popup.children.length, 1, "expected 1 submenu item");
|
is(popup.children.length, 1, "expected 1 submenu item");
|
||||||
is(
|
is(
|
||||||
@ -738,7 +730,7 @@ add_task(async function test_browser_action_context_menu() {
|
|||||||
"expected menu item"
|
"expected menu item"
|
||||||
);
|
);
|
||||||
// The number of items in the (main) context menu should remain the same.
|
// 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 closeChromeContextMenu(contextMenu.id, null, win);
|
||||||
|
|
||||||
await closeExtensionsPanel(win);
|
await closeExtensionsPanel(win);
|
||||||
|
@ -51,19 +51,6 @@ function getChildrenIDs(parent) {
|
|||||||
return Array.from(parent.children).map(child => child.id);
|
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.
|
* This helper function does most of the heavy lifting for these tests.
|
||||||
* It does the following in order:
|
* It does the following in order:
|
||||||
@ -107,11 +94,6 @@ async function withWindowOverflowed(win, taskFn) {
|
|||||||
|
|
||||||
const extWithMenuBrowserAction = ExtensionTestUtils.loadExtension({
|
const extWithMenuBrowserAction = ExtensionTestUtils.loadExtension({
|
||||||
manifest: {
|
manifest: {
|
||||||
browser_specific_settings: {
|
|
||||||
gecko: {
|
|
||||||
id: "overflowable-toolbar-addon-with-context-menu@mozilla.org",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
name: "Extension #0",
|
name: "Extension #0",
|
||||||
browser_specific_settings: {
|
browser_specific_settings: {
|
||||||
gecko: { id: "unified-extensions-overflowable-toolbar@ext-0" },
|
gecko: { id: "unified-extensions-overflowable-toolbar@ext-0" },
|
||||||
@ -638,19 +620,15 @@ add_task(async function test_context_menu() {
|
|||||||
firstExtensionWidget.dataset.extensionid
|
firstExtensionWidget.dataset.extensionid
|
||||||
);
|
);
|
||||||
Assert.ok(contextMenu, "expected a context menu");
|
Assert.ok(contextMenu, "expected a context menu");
|
||||||
let visibleItems = getVisibleMenuItems(contextMenu);
|
|
||||||
|
|
||||||
// The context menu for the extension that declares a browser action menu
|
// 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
|
// should have the menu item created by the extension, a menu separator
|
||||||
// for pinning the browser action to the toolbar, a menu separator and the 3 default menu items.
|
// and the 3 default menu items.
|
||||||
is(
|
is(
|
||||||
visibleItems.length,
|
contextMenu.childElementCount,
|
||||||
7,
|
5,
|
||||||
"expected a custom context menu item, a menu separator, the pin to " +
|
"expected a custom context menu item and a menu separator in addition to the 3 default menu items"
|
||||||
"toolbar menu item, a menu separator, and the 3 default menu items"
|
|
||||||
);
|
);
|
||||||
|
const [item, separator] = contextMenu.children;
|
||||||
const [item, separator] = visibleItems;
|
|
||||||
is(
|
is(
|
||||||
item.getAttribute("label"),
|
item.getAttribute("label"),
|
||||||
"Click me!",
|
"Click me!",
|
||||||
@ -661,7 +639,6 @@ add_task(async function test_context_menu() {
|
|||||||
"menuseparator",
|
"menuseparator",
|
||||||
"expected separator after last menu item created by the extension"
|
"expected separator after last menu item created by the extension"
|
||||||
);
|
);
|
||||||
|
|
||||||
await closeChromeContextMenu(contextMenu.id, null, win);
|
await closeChromeContextMenu(contextMenu.id, null, win);
|
||||||
|
|
||||||
info("extension with browser action and a menu with submenu");
|
info("extension with browser action and a menu with submenu");
|
||||||
@ -671,9 +648,8 @@ add_task(async function test_context_menu() {
|
|||||||
win,
|
win,
|
||||||
secondExtensionWidget.dataset.extensionid
|
secondExtensionWidget.dataset.extensionid
|
||||||
);
|
);
|
||||||
visibleItems = getVisibleMenuItems(contextMenu);
|
is(contextMenu.childElementCount, 5, "expected 5 menu items");
|
||||||
is(visibleItems.length, 7, "expected 7 menu items");
|
const popup = await openSubmenu(contextMenu.children[0]);
|
||||||
const popup = await openSubmenu(visibleItems[0]);
|
|
||||||
is(popup.children.length, 1, "expected 1 submenu item");
|
is(popup.children.length, 1, "expected 1 submenu item");
|
||||||
is(
|
is(
|
||||||
popup.children[0].getAttribute("label"),
|
popup.children[0].getAttribute("label"),
|
||||||
@ -681,8 +657,7 @@ add_task(async function test_context_menu() {
|
|||||||
"expected menu item"
|
"expected menu item"
|
||||||
);
|
);
|
||||||
// The number of items in the (main) context menu should remain the same.
|
// The number of items in the (main) context menu should remain the same.
|
||||||
visibleItems = getVisibleMenuItems(contextMenu);
|
is(contextMenu.childElementCount, 5, "expected 5 menu items");
|
||||||
is(visibleItems.length, 7, "expected 7 menu items");
|
|
||||||
await closeChromeContextMenu(contextMenu.id, null, win);
|
await closeChromeContextMenu(contextMenu.id, null, win);
|
||||||
|
|
||||||
info("extension with no browser action and no menu");
|
info("extension with no browser action and no menu");
|
||||||
@ -696,9 +671,7 @@ add_task(async function test_context_menu() {
|
|||||||
thirdExtensionWidget.dataset.extensionid
|
thirdExtensionWidget.dataset.extensionid
|
||||||
);
|
);
|
||||||
Assert.ok(contextMenu, "expected a context menu");
|
Assert.ok(contextMenu, "expected a context menu");
|
||||||
visibleItems = getVisibleMenuItems(contextMenu);
|
is(contextMenu.childElementCount, 3, "expected 3 menu items");
|
||||||
is(visibleItems.length, 5, "expected 5 menu items");
|
|
||||||
|
|
||||||
await closeChromeContextMenu(contextMenu.id, null, win);
|
await closeChromeContextMenu(contextMenu.id, null, win);
|
||||||
|
|
||||||
// We can close the unified extensions panel now.
|
// 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
|
// First try to find a CUI widget, otherwise a custom element when the
|
||||||
// extension does not have a browser action.
|
// extension does not have a browser action.
|
||||||
return (
|
return (
|
||||||
view.querySelector(`toolbaritem[data-extensionid="${extensionId}"]`) ||
|
view.querySelector(`[data-extensionid="${extensionId}"]`) ||
|
||||||
view.querySelector(`unified-extensions-item[extension-id="${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 =
|
toolbar-context-menu-view-customize-toolbar-2 =
|
||||||
.label = Customize Toolbar…
|
.label = Customize Toolbar…
|
||||||
.accesskey = C
|
.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 =
|
toolbar-context-menu-bookmarks-toolbar-always-show-2 =
|
||||||
.label = Always Show
|
.label = Always Show
|
||||||
|
@ -23,9 +23,6 @@ unified-extensions-item-message-manage = Manage extension
|
|||||||
|
|
||||||
## Extension's context menu
|
## Extension's context menu
|
||||||
|
|
||||||
unified-extensions-context-menu-pin-to-toolbar =
|
|
||||||
.label = Pin to Toolbar
|
|
||||||
|
|
||||||
unified-extensions-context-menu-manage-extension =
|
unified-extensions-context-menu-manage-extension =
|
||||||
.label = Manage Extension
|
.label = Manage Extension
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user