diff --git a/browser/base/content/test/webextensions/browser_extension_sideloading.js b/browser/base/content/test/webextensions/browser_extension_sideloading.js
index bac26193f6d1..a482c76beccf 100644
--- a/browser/base/content/test/webextensions/browser_extension_sideloading.js
+++ b/browser/base/content/test/webextensions/browser_extension_sideloading.js
@@ -53,7 +53,7 @@ function assertDisabledSideloadedAddonElement(managerWindow, addonElement) {
const enableBtn = addonElement.querySelector('[action="toggle-disabled"]');
is(
doc.l10n.getAttributes(enableBtn).id,
- "enable-addon-button-label",
+ "enable-addon-button",
"The button has the enable label"
);
}
diff --git a/browser/components/enterprisepolicies/tests/browser/browser_policy_extensions.js b/browser/components/enterprisepolicies/tests/browser/browser_policy_extensions.js
index 2c4f6ae7adaa..45f6bfbd993d 100644
--- a/browser/components/enterprisepolicies/tests/browser/browser_policy_extensions.js
+++ b/browser/components/enterprisepolicies/tests/browser/browser_policy_extensions.js
@@ -12,7 +12,9 @@ async function isExtensionLocked(win, addonID) {
await win.htmlBrowserLoaded;
return doc.querySelector(`addon-card[addon-id="${addonID}"]`);
}, `Get addon-card for "${addonID}"`);
- let disableBtn = addonCard.querySelector('[action="toggle-disabled"]');
+ let disableBtn = addonCard.querySelector(
+ 'panel-item[action="toggle-disabled"]'
+ );
let removeBtn = addonCard.querySelector('panel-item[action="remove"]');
ok(removeBtn.disabled, "Remove button should be disabled");
ok(disableBtn.hidden, "Disable button should be hidden");
diff --git a/python/l10n/fluent_migrations/bug_1570792_aboutaddons_extension_toggle.py b/python/l10n/fluent_migrations/bug_1570792_aboutaddons_extension_toggle.py
deleted file mode 100644
index fd42ac24ba4a..000000000000
--- a/python/l10n/fluent_migrations/bug_1570792_aboutaddons_extension_toggle.py
+++ /dev/null
@@ -1,29 +0,0 @@
-# coding=utf8
-
-# Any copyright is dedicated to the Public Domain.
-# http://creativecommons.org/publicdomain/zero/1.0/
-
-from __future__ import absolute_import
-import fluent.syntax.ast as FTL
-from fluent.migrate.helpers import transforms_from
-from fluent.migrate import COPY_PATTERN
-
-TARGET_FILE = "toolkit/toolkit/about/aboutAddons.ftl"
-SOURCE_FILE = TARGET_FILE
-
-
-def migrate(ctx):
- """Bug 1570792 - Add a toggle to extension cards, part {index}"""
-
- ctx.add_transforms(
- TARGET_FILE,
- SOURCE_FILE,
- transforms_from(
-"""
-disable-addon-button-label =
- .aria-label = {COPY_PATTERN(from_path, "disable-addon-button")}
-enable-addon-button-label =
- .aria-label = {COPY_PATTERN(from_path, "enable-addon-button")}
-""",
- from_path=SOURCE_FILE),
- )
diff --git a/toolkit/locales/en-US/toolkit/about/aboutAddons.ftl b/toolkit/locales/en-US/toolkit/about/aboutAddons.ftl
index 74821f16b939..7e72f6e6b70c 100644
--- a/toolkit/locales/en-US/toolkit/about/aboutAddons.ftl
+++ b/toolkit/locales/en-US/toolkit/about/aboutAddons.ftl
@@ -367,10 +367,6 @@ remove-addon-button = Remove
remove-addon-disabled-button = Can’t Be Removed Why?
disable-addon-button = Disable
enable-addon-button = Enable
-disable-addon-button-label =
- .aria-label = Disable
-enable-addon-button-label =
- .aria-label = Enable
preferences-addon-button =
{ PLATFORM() ->
[windows] Options
diff --git a/toolkit/mozapps/extensions/content/aboutaddons.css b/toolkit/mozapps/extensions/content/aboutaddons.css
index ea47722b2cf2..df874edec2e2 100644
--- a/toolkit/mozapps/extensions/content/aboutaddons.css
+++ b/toolkit/mozapps/extensions/content/aboutaddons.css
@@ -176,7 +176,6 @@ addon-card[expanded] .addon-card-message {
/* Adjust height so that the image preserves the aspect ratio from AMO.
* For details, see https://bugzilla.mozilla.org/show_bug.cgi?id=1546123 */
height: calc(var(--section-width) * 92 / 680);
- object-fit: cover;
}
.card-heading-icon {
@@ -195,6 +194,10 @@ addon-card[expanded] .addon-card-message {
flex-direction: column;
}
+.card-actions {
+ flex-shrink: 0;
+}
+
.addon-name-container {
/* Subtract the top line-height so the text and icon align at the top. */
margin-top: -3px;
@@ -240,15 +243,6 @@ addon-card[expanded] .addon-card-message {
-moz-context-properties: fill;
}
-.theme-enable-button {
- min-width: auto;
- height: auto;
- font-size: 13px;
- min-height: auto;
- height: 24px;
- margin: 0;
-}
-
.addon-description {
font-size: 14px;
line-height: 20px;
@@ -281,6 +275,12 @@ addon-card:not([expanded]) .addon-description {
height: 32px;
}
+.more-options-menu {
+ /* Add some negative margin to account for the button's padding */
+ margin-top: -10px;
+ margin-inline-end: -8px;
+}
+
/* Recommended add-ons on list views */
.recommended-heading {
margin-top: 48px;
@@ -437,7 +437,6 @@ addon-details {
width: 24px;
height: 24px;
margin: 0;
- margin-inline-start: 8px;
-moz-context-properties: fill;
fill: currentColor;
background-image: url("chrome://global/skin/icons/more.svg");
diff --git a/toolkit/mozapps/extensions/content/aboutaddons.html b/toolkit/mozapps/extensions/content/aboutaddons.html
index 873efb67d510..9a8b4dcfc3db 100644
--- a/toolkit/mozapps/extensions/content/aboutaddons.html
+++ b/toolkit/mozapps/extensions/content/aboutaddons.html
@@ -14,7 +14,6 @@
-
@@ -78,6 +77,7 @@
+
@@ -119,19 +119,18 @@
data-l10n-id="addon-badge-private-browsing-allowed2"
hidden>
-
-
-
-
+
diff --git a/toolkit/mozapps/extensions/content/aboutaddons.js b/toolkit/mozapps/extensions/content/aboutaddons.js
index 86ac2c0afdf7..b48e5f64ad36 100644
--- a/toolkit/mozapps/extensions/content/aboutaddons.js
+++ b/toolkit/mozapps/extensions/content/aboutaddons.js
@@ -84,21 +84,6 @@ XPCOMUtils.defineLazyPreferenceGetter(
const PLUGIN_ICON_URL = "chrome://global/skin/plugins/pluginGeneric.svg";
const EXTENSION_ICON_URL =
"chrome://mozapps/skin/extensions/extensionGeneric.svg";
-const BUILTIN_THEME_PREVIEWS = new Map([
- [
- "default-theme@mozilla.org",
- "chrome://mozapps/content/extensions/default-theme.svg",
- ],
- [
- "firefox-compact-light@mozilla.org",
- "chrome://mozapps/content/extensions/firefox-compact-light.svg",
- ],
- [
- "firefox-compact-dark@mozilla.org",
- "chrome://mozapps/content/extensions/firefox-compact-dark.svg",
- ],
-]);
-
const PERMISSION_MASKS = {
"ask-to-activate": AddonManager.PERM_CAN_ASK_TO_ACTIVATE,
enable: AddonManager.PERM_CAN_ENABLE,
@@ -122,13 +107,6 @@ const PRIVATE_BROWSING_PERMS = {
origins: [],
};
-function shouldSkipAnimations() {
- return (
- document.body.hasAttribute("skip-animations") ||
- window.matchMedia("(prefers-reduced-motion: reduce)").matches
- );
-}
-
const AddonCardListenerHandler = {
ADDON_EVENTS: new Set([
"onDisabled",
@@ -441,10 +419,6 @@ function nl2br(text) {
* The URL of the best fitting screenshot, if any.
*/
function getScreenshotUrlForAddon(addon) {
- if (BUILTIN_THEME_PREVIEWS.has(addon.id)) {
- return BUILTIN_THEME_PREVIEWS.get(addon.id);
- }
-
let { screenshots } = addon;
if (!screenshots || !screenshots.length) {
return null;
@@ -1646,6 +1620,12 @@ class AddonOptions extends HTMLElement {
case "report":
el.hidden = !isAbuseReportSupported(addon);
break;
+ case "toggle-disabled": {
+ let toggleDisabledAction = addon.userDisabled ? "enable" : "disable";
+ document.l10n.setAttributes(el, `${toggleDisabledAction}-addon-button`);
+ el.hidden = !hasPermission(addon, toggleDisabledAction);
+ break;
+ }
case "install-update":
el.hidden = !updateInstall;
break;
@@ -2437,8 +2417,6 @@ class AddonCard extends HTMLElement {
switch (action) {
case "toggle-disabled":
this.recordActionEvent(addon.userDisabled ? "enable" : "disable");
- // Keep the checked state the same until the add-on's state changes.
- e.target.checked = !addon.userDisabled;
if (addon.userDisabled) {
if (shouldShowPermissionsPrompt(addon)) {
await showPermissionsPrompt(addon);
@@ -2448,6 +2426,10 @@ class AddonCard extends HTMLElement {
} else {
await addon.disable();
}
+ if (e.mozInputSource == MouseEvent.MOZ_SOURCE_KEYBOARD) {
+ // Refocus the open menu button so it's clear where the focus is.
+ this.querySelector('[action="more-options"]').focus();
+ }
break;
case "ask-to-activate":
if (hasPermission(addon, "ask-to-activate")) {
@@ -2696,25 +2678,25 @@ class AddonCard extends HTMLElement {
card.setAttribute("active", addon.isActive);
- // Set the icon or theme preview.
- let iconEl = card.querySelector(".addon-icon");
+ // Update the icon.
+ let icon;
+ if (addon.type == "plugin") {
+ icon = PLUGIN_ICON_URL;
+ } else {
+ icon =
+ AddonManager.getPreferredIconURL(addon, 32, window) ||
+ EXTENSION_ICON_URL;
+ }
+ card.querySelector(".addon-icon").src = icon;
+
+ // Update the theme preview.
let preview = card.querySelector(".card-heading-image");
+ preview.hidden = true;
if (addon.type == "theme") {
- iconEl.hidden = true;
let screenshotUrl = getScreenshotUrlForAddon(addon);
if (screenshotUrl) {
preview.src = screenshotUrl;
- }
- preview.hidden = !screenshotUrl;
- } else {
- preview.hidden = true;
- iconEl.hidden = false;
- if (addon.type == "plugin") {
- iconEl.src = PLUGIN_ICON_URL;
- } else {
- iconEl.src =
- AddonManager.getPreferredIconURL(addon, 32, window) ||
- EXTENSION_ICON_URL;
+ preview.hidden = false;
}
}
@@ -2730,25 +2712,6 @@ class AddonCard extends HTMLElement {
}
name.title = `${addon.name} ${addon.version}`;
- let toggleDisabledAction = addon.userDisabled ? "enable" : "disable";
- let canToggleDisabled = hasPermission(addon, toggleDisabledAction);
- let toggleDisabledButton = card.querySelector('[action="toggle-disabled"]');
- if (toggleDisabledButton) {
- toggleDisabledButton.hidden = !canToggleDisabled;
- if (addon.type === "theme") {
- document.l10n.setAttributes(
- toggleDisabledButton,
- `${toggleDisabledAction}-addon-button`
- );
- } else if (addon.type === "extension") {
- toggleDisabledButton.checked = !addon.userDisabled;
- document.l10n.setAttributes(
- toggleDisabledButton,
- `${toggleDisabledAction}-addon-button-label`
- );
- }
- }
-
// Set the items in the more options menu.
this.options.update(this, addon, this.updateInstall);
@@ -2842,14 +2805,6 @@ class AddonCard extends HTMLElement {
this.card = importTemplate("card").firstElementChild;
- // Remove the toggle-disabled button(s) based on type.
- if (addon.type != "theme") {
- this.card.querySelector(".theme-enable-button").remove();
- }
- if (addon.type != "extension") {
- this.card.querySelector(".extension-enable-button").remove();
- }
-
let nameContainer = this.card.querySelector(".addon-name-container");
let headingLevel = this.expanded ? "h1" : "h3";
let nameHeading = document.createElement(headingLevel);
@@ -2868,7 +2823,7 @@ class AddonCard extends HTMLElement {
let panelType = addon.type == "plugin" ? "plugin-options" : "addon-options";
this.options = document.createElement(panelType);
this.options.render();
- this.card.appendChild(this.options);
+ this.card.querySelector(".more-options-menu").appendChild(this.options);
this.optionsButton = this.card.querySelector(".more-options-button");
// Set the contents.
@@ -2941,6 +2896,7 @@ class RecommendedAddonCard extends HTMLElement {
let heading = card.querySelector(".addon-name-container");
heading.textContent = "";
heading.append(importTemplate("addon-name-container-in-disco-card"));
+ card.querySelector(".more-options-menu").remove();
this.setCardContent(card, addon);
if (addon.type != "theme") {
@@ -2979,14 +2935,13 @@ class RecommendedAddonCard extends HTMLElement {
// Set the theme preview.
let preview = card.querySelector(".card-heading-image");
+ preview.hidden = true;
if (addon.type == "theme") {
let screenshotUrl = getScreenshotUrlForAddon(addon);
if (screenshotUrl) {
preview.src = screenshotUrl;
preview.hidden = false;
}
- } else {
- preview.hidden = true;
}
// Set the name.
@@ -3134,8 +3089,6 @@ class AddonList extends HTMLElement {
super();
this.sections = [];
this.pendingUninstallAddons = new Set();
- this._addonsToUpdate = new Set();
- this._userFocusListenersAdded = false;
}
async connectedCallback() {
@@ -3328,7 +3281,9 @@ class AddonList extends HTMLElement {
return;
}
- let insertSection = this._addonSectionIndex(addon);
+ let insertSection = this.sections.findIndex(({ filterFn }) =>
+ filterFn(addon)
+ );
// Don't add the add-on if it doesn't go in a section.
if (insertSection == -1) {
@@ -3357,144 +3312,24 @@ class AddonList extends HTMLElement {
}
updateAddon(addon) {
- if (!this.getCard(addon)) {
- // Try to add the add-on right away.
- this.addAddon(addon);
- } else if (this._addonSectionIndex(addon) == -1) {
- // Try to remove the add-on right away.
- this._updateAddon(addon);
- } else if (this.isUserFocused) {
- // Queue up a change for when the focus is cleared.
- this.updateLater(addon);
- } else {
- // Not currently focused, make the change now.
- this.withCardAnimation(() => this._updateAddon(addon));
- }
- }
-
- updateLater(addon) {
- this._addonsToUpdate.add(addon);
- this._addUserFocusListeners();
- }
-
- _addUserFocusListeners() {
- if (this._userFocusListenersAdded) {
- return;
- }
-
- this._userFocusListenersAdded = true;
- this.addEventListener("mouseleave", this);
- this.addEventListener("hidden", this, true);
- this.addEventListener("focusout", this);
- }
-
- _removeUserFocusListeners() {
- if (!this._userFocusListenersAdded) {
- return;
- }
-
- this.removeEventListener("mouseleave", this);
- this.removeEventListener("hidden", this, true);
- this.removeEventListener("focusout", this);
- this._userFocusListenersAdded = false;
- }
-
- get hasMenuOpen() {
- return !!this.querySelector("panel-list[open]");
- }
-
- get isUserFocused() {
- return this.matches(":hover, :focus-within") || this.hasMenuOpen;
- }
-
- update() {
- if (this._addonsToUpdate.size) {
- this.withCardAnimation(() => {
- for (let addon of this._addonsToUpdate) {
- this._updateAddon(addon);
- }
- this._addonsToUpdate = new Set();
- });
- }
- }
-
- _getChildCoords() {
- let results = new Map();
- for (let child of this.querySelectorAll("addon-card")) {
- results.set(child, child.getBoundingClientRect());
- }
- return results;
- }
-
- withCardAnimation(changeFn) {
- if (shouldSkipAnimations()) {
- changeFn();
- return;
- }
-
- let origChildCoords = this._getChildCoords();
-
- changeFn();
-
- let newChildCoords = this._getChildCoords();
- let cards = this.querySelectorAll("addon-card");
- let transitionCards = [];
- for (let card of cards) {
- let orig = origChildCoords.get(card);
- let moved = newChildCoords.get(card);
- let changeY = moved.y - (orig || moved).y;
- let cardEl = card.firstElementChild;
-
- if (changeY != 0) {
- cardEl.style.transform = `translateY(${changeY * -1}px)`;
- transitionCards.push(card);
- }
- }
- requestAnimationFrame(() => {
- for (let card of transitionCards) {
- card.firstElementChild.style.transition = "transform 125ms";
- }
-
- requestAnimationFrame(() => {
- for (let card of transitionCards) {
- let cardEl = card.firstElementChild;
- cardEl.style.transform = "";
- cardEl.addEventListener("transitionend", function handler(e) {
- if (e.target == cardEl && e.propertyName == "transform") {
- cardEl.style.transition = "";
- cardEl.removeEventListener("transitionend", handler);
- }
- });
- }
- });
- });
- }
-
- _addonSectionIndex(addon) {
- return this.sections.findIndex(s => s.filterFn(addon));
- }
-
- _updateAddon(addon) {
let card = this.getCard(addon);
if (card) {
- let sectionIndex = this._addonSectionIndex(addon);
+ let sectionIndex = this.sections.findIndex(s => s.filterFn(addon));
if (sectionIndex != -1) {
// Move the card, if needed. This will allow an animation between
// page sections and provides clearer events for testing.
if (card.parentNode.getAttribute("section") != sectionIndex) {
- let { activeElement } = document;
- let refocus = card.contains(activeElement);
let oldSection = card.parentNode;
this.insertCardInto(card, sectionIndex);
this.updateSectionIfEmpty(oldSection);
- if (refocus) {
- activeElement.focus();
- }
this.sendEvent("move", { id: addon.id });
}
} else {
this.removeAddon(addon);
}
+ } else {
+ // Add the add-on, this will do nothing if it shouldn't be in the list.
+ this.addAddon(addon);
}
}
@@ -3593,13 +3428,6 @@ class AddonList extends HTMLElement {
this.removePendingUninstallBar(addon);
this.removeAddon(addon);
}
-
- handleEvent(e) {
- if (!this.isUserFocused || (e.type == "mouseleave" && !this.hasMenuOpen)) {
- this._removeUserFocusListeners();
- this.update();
- }
- }
}
customElements.define("addon-list", AddonList);
diff --git a/toolkit/mozapps/extensions/content/default-theme.svg b/toolkit/mozapps/extensions/content/default-theme.svg
deleted file mode 100644
index b8b6ef29b279..000000000000
--- a/toolkit/mozapps/extensions/content/default-theme.svg
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
diff --git a/toolkit/mozapps/extensions/content/firefox-compact-dark.svg b/toolkit/mozapps/extensions/content/firefox-compact-dark.svg
deleted file mode 100644
index 86ee5c3fdee2..000000000000
--- a/toolkit/mozapps/extensions/content/firefox-compact-dark.svg
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
diff --git a/toolkit/mozapps/extensions/content/firefox-compact-light.svg b/toolkit/mozapps/extensions/content/firefox-compact-light.svg
deleted file mode 100644
index 3e13c787d40e..000000000000
--- a/toolkit/mozapps/extensions/content/firefox-compact-light.svg
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
diff --git a/toolkit/mozapps/extensions/content/toggle-button.css b/toolkit/mozapps/extensions/content/toggle-button.css
deleted file mode 100644
index 2319bc645183..000000000000
--- a/toolkit/mozapps/extensions/content/toggle-button.css
+++ /dev/null
@@ -1,72 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-input[type="checkbox"].toggle-button {
- --button-height: 16px;
- --button-half-height: 8px;
- --button-width: 26px;
- --button-border-width: 1px;
- /* dot-size = button-height - 2*dot-margin - 2*button-border-width */
- --dot-size: 10px;
- --dot-margin: 2px;
- /* --dot-transform-x = button-width - 2*dot-margin - dot-size - 2*button-border-width */
- --dot-transform-x: 10px;
- --border-color: hsla(210,4%,10%,.14);
-}
-
-input[type="checkbox"].toggle-button {
- -moz-appearance: none;
- padding: 0;
- margin: 0;
- outline: 0;
- border: var(--button-border-width) solid var(--border-color);
- height: var(--button-height);
- width: var(--button-width);
- border-radius: var(--button-half-height);
- background: var(--in-content-button-background);
- box-sizing: border-box;
-}
-input[type="checkbox"].toggle-button:hover {
- background: var(--in-content-button-background-hover);
- border-color: var(--border-color);
-}
-input[type="checkbox"].toggle-button:active {
- background: var(--in-content-button-background-active);
- border-color: var(--border-color);
-}
-input[type="checkbox"].toggle-button:focus {
- box-shadow: 0 0 0 1px var(--border-color), 0 0 0 4px rgba(10, 132, 255, 0.3);
-}
-input[type="checkbox"].toggle-button:checked:focus {
- box-shadow: 0 0 0 1px var(--in-content-border-active), 0 0 0 4px rgba(10, 132, 255, 0.3);
-}
-
-input[type="checkbox"].toggle-button:checked {
- background: var(--in-content-primary-button-background);
- border-color: var(--in-content-primary-button-background-hover);
-}
-input[type="checkbox"].toggle-button:checked:hover {
- background: var(--in-content-primary-button-background-hover);
- border-color: var(--in-content-primary-button-background-active);
-}
-input[type="checkbox"].toggle-button:checked:active {
- background: var(--in-content-primary-button-background-active);
- border-color: var(--in-content-primary-button-background-active);
-}
-
-input[type="checkbox"].toggle-button::before {
- display: block;
- content: "";
- background: #fff;
- height: var(--dot-size);
- width: var(--dot-size);
- margin: var(--dot-margin);
- border-radius: 50%;
- outline: 1px solid var(--border-color);
- -moz-outline-radius: 50%;
- transition: transform 100ms;
-}
-input[type="checkbox"].toggle-button:checked::before {
- transform: translateX(var(--dot-transform-x));
-}
diff --git a/toolkit/mozapps/extensions/jar.mn b/toolkit/mozapps/extensions/jar.mn
index e56c61eb4bc0..231ca55528b7 100644
--- a/toolkit/mozapps/extensions/jar.mn
+++ b/toolkit/mozapps/extensions/jar.mn
@@ -22,9 +22,6 @@ toolkit.jar:
content/mozapps/extensions/abuse-report-frame.js (content/abuse-report-frame.js)
content/mozapps/extensions/abuse-report-panel.css (content/abuse-report-panel.css)
content/mozapps/extensions/abuse-report-panel.js (content/abuse-report-panel.js)
- content/mozapps/extensions/default-theme.svg (content/default-theme.svg)
- content/mozapps/extensions/firefox-compact-dark.svg (content/firefox-compact-dark.svg)
- content/mozapps/extensions/firefox-compact-light.svg (content/firefox-compact-light.svg)
content/mozapps/extensions/message-bar.css (content/message-bar.css)
content/mozapps/extensions/message-bar.js (content/message-bar.js)
content/mozapps/extensions/named-deck.js (content/named-deck.js)
@@ -33,5 +30,4 @@ toolkit.jar:
content/mozapps/extensions/rating-star.css (content/rating-star.css)
content/mozapps/extensions/shortcuts.css (content/shortcuts.css)
content/mozapps/extensions/shortcuts.js (content/shortcuts.js)
- content/mozapps/extensions/toggle-button.css (content/toggle-button.css)
#endif
diff --git a/toolkit/mozapps/extensions/test/browser/browser.ini b/toolkit/mozapps/extensions/test/browser/browser.ini
index 15374034143a..575238e9274f 100644
--- a/toolkit/mozapps/extensions/test/browser/browser.ini
+++ b/toolkit/mozapps/extensions/test/browser/browser.ini
@@ -47,7 +47,6 @@ generated-files =
[browser_CTP_plugins.js]
tags = blocklist
[browser_about_debugging_link.js]
-[browser_addon_list_reordering.js]
[browser_bug523784.js]
skip-if = (!debug && os == 'win') #Bug 1489496
[browser_bug567137.js]
diff --git a/toolkit/mozapps/extensions/test/browser/browser_addon_list_reordering.js b/toolkit/mozapps/extensions/test/browser/browser_addon_list_reordering.js
deleted file mode 100644
index 0ef0db4a1946..000000000000
--- a/toolkit/mozapps/extensions/test/browser/browser_addon_list_reordering.js
+++ /dev/null
@@ -1,189 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-const { AddonTestUtils } = ChromeUtils.import(
- "resource://testing-common/AddonTestUtils.jsm"
-);
-
-AddonTestUtils.initMochitest(this);
-
-function assertInSection(card, sectionName, msg) {
- let section = card.closest("section");
- let heading = section.querySelector(".list-section-heading");
- is(
- card.ownerDocument.l10n.getAttributes(heading).id,
- `extension-${sectionName}-heading`,
- msg
- );
-}
-
-function waitForAnimationFrame(win) {
- return new Promise(resolve => win.requestAnimationFrame(resolve));
-}
-
-async function clickEnableToggle(card) {
- let isDisabled = card.addon.userDisabled;
- let addonEvent = isDisabled ? "onEnabled" : "onDisabled";
- let addonStateChanged = AddonTestUtils.promiseAddonEvent(addonEvent);
- let win = card.ownerGlobal;
- let button = card.querySelector(".extension-enable-button");
-
- // Centre the button since "start" could be behind the sticky header.
- button.scrollIntoView({ block: "center" });
- EventUtils.synthesizeMouseAtCenter(button, { type: "mousemove" }, win);
- EventUtils.synthesizeMouseAtCenter(button, {}, win);
-
- await addonStateChanged;
- await waitForAnimationFrame(win);
-}
-
-function mouseOver(el) {
- let win = el.ownerGlobal;
- el.scrollIntoView({ block: "center" });
- EventUtils.synthesizeMouseAtCenter(el, { type: "mousemove" }, win);
- return waitForAnimationFrame(win);
-}
-
-function mouseOutOfList(win) {
- return mouseOver(win.document.querySelector(".header-name"));
-}
-
-function pressKey(win, key) {
- EventUtils.synthesizeKey(key, {}, win);
- return waitForAnimationFrame(win);
-}
-
-function waitForTransitionEnd(...els) {
- return Promise.all(
- els.map(el =>
- BrowserTestUtils.waitForEvent(el, "transitionend", false, e => {
- let cardEl = el.firstElementChild;
- return e.target == cardEl && e.propertyName == "transform";
- })
- )
- );
-}
-
-add_task(async function testReordering() {
- let addonIds = [
- "one@mochi.test",
- "two@mochi.test",
- "three@mochi.test",
- "four@mochi.test",
- "five@mochi.test",
- ];
- let extensions = addonIds.map(id =>
- ExtensionTestUtils.loadExtension({
- manifest: {
- name: id,
- applications: { gecko: { id } },
- },
- useAddonManager: "temporary",
- })
- );
-
- await Promise.all(extensions.map(ext => ext.startup()));
-
- let win = await loadInitialView("extension", { withAnimations: true });
-
- let cardOne = getAddonCard(win, "one@mochi.test");
- ok(!cardOne.addon.userDisabled, "extension one is enabled");
- assertInSection(cardOne, "enabled", "cardOne is initially in Enabled");
-
- await clickEnableToggle(cardOne);
-
- ok(cardOne.addon.userDisabled, "extension one is now disabled");
- assertInSection(cardOne, "enabled", "cardOne is still in Enabled");
-
- let cardThree = getAddonCard(win, "three@mochi.test");
- ok(!cardThree.addon.userDisabled, "extension three is enabled");
- assertInSection(cardThree, "enabled", "cardThree is initially in Enabled");
-
- await clickEnableToggle(cardThree);
-
- ok(cardThree.addon.userDisabled, "extension three is now disabled");
- assertInSection(cardThree, "enabled", "cardThree is still in Enabled");
-
- let transitionsEnded = waitForTransitionEnd(cardOne, cardThree);
- await mouseOutOfList(win);
- await transitionsEnded;
-
- assertInSection(cardOne, "disabled", "cardOne has moved to disabled");
- assertInSection(cardThree, "disabled", "cardThree has moved to disabled");
-
- await clickEnableToggle(cardThree);
- await clickEnableToggle(cardOne);
-
- assertInSection(cardOne, "disabled", "cardOne is still in disabled");
- assertInSection(cardThree, "disabled", "cardThree is still in disabled");
-
- info("Opening a more options menu");
- let panel = cardThree.querySelector("panel-list");
- EventUtils.synthesizeMouseAtCenter(
- cardThree.querySelector('[action="more-options"]'),
- {},
- win
- );
-
- await BrowserTestUtils.waitForEvent(panel, "shown");
- await mouseOutOfList(win);
-
- assertInSection(cardOne, "disabled", "cardOne stays in disabled, menu open");
- assertInSection(cardThree, "disabled", "cardThree stays in disabled");
-
- transitionsEnded = waitForTransitionEnd(cardOne, cardThree);
- EventUtils.synthesizeMouseAtCenter(
- win.document.querySelector(".header-name"),
- {},
- win
- );
- await transitionsEnded;
-
- assertInSection(cardOne, "enabled", "cardOne is now in enabled");
- assertInSection(cardThree, "enabled", "cardThree is now in enabled");
-
- let cardOneToggle = cardOne.querySelector(".extension-enable-button");
- cardOneToggle.scrollIntoView({ block: "center" });
- cardOneToggle.focus();
- await pressKey(win, " ");
- await waitForAnimationFrame(win);
-
- let cardThreeToggle = cardThree.querySelector(".extension-enable-button");
- let addonList = win.document.querySelector("addon-list");
- // Tab down to cardThreeToggle.
- while (
- addonList.contains(win.document.activeElement) &&
- win.document.activeElement !== cardThreeToggle
- ) {
- await pressKey(win, "VK_TAB");
- }
- await pressKey(win, " ");
-
- assertInSection(cardOne, "enabled", "cardOne is still in enabled");
- assertInSection(cardThree, "enabled", "cardThree is still in enabled");
-
- transitionsEnded = waitForTransitionEnd(cardOne, cardThree);
- win.document.querySelector('[action="page-options"]').focus();
- await transitionsEnded;
- assertInSection(
- cardOne,
- "disabled",
- "cardOne is now in the disabled section"
- );
- assertInSection(
- cardThree,
- "disabled",
- "cardThree is now in the disabled section"
- );
-
- // Ensure an uninstalled extension is removed right away.
- // Hover a card in the middle of the list.
- await mouseOver(getAddonCard(win, "two@mochi.test"));
- await cardOne.addon.uninstall(true);
- ok(!cardOne.parentNode, "cardOne has been removed from the document");
-
- await closeView(win);
- await Promise.all(extensions.map(ext => ext.unload()));
-});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_extension_sideloading_permission.js b/toolkit/mozapps/extensions/test/browser/browser_extension_sideloading_permission.js
index 9c0781d184cb..07a49197682a 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_extension_sideloading_permission.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_extension_sideloading_permission.js
@@ -19,7 +19,7 @@ function assertDisabledSideloadedExtensionElement(managerWindow, addonElement) {
);
is(
doc.l10n.getAttributes(toggleDisabled).id,
- "enable-addon-button-label",
+ "enable-addon-button",
"Addon toggle-disabled action has the enable label"
);
}
@@ -31,7 +31,7 @@ function assertEnabledSideloadedExtensionElement(managerWindow, addonElement) {
);
is(
doc.l10n.getAttributes(toggleDisabled).id,
- "enable-addon-button-label",
+ "enable-addon-button",
"Addon toggle-disabled action has the enable label"
);
}
diff --git a/toolkit/mozapps/extensions/test/browser/browser_gmpProvider.js b/toolkit/mozapps/extensions/test/browser/browser_gmpProvider.js
index 4a74266e998b..acd977d4fc70 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_gmpProvider.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_gmpProvider.js
@@ -15,6 +15,9 @@ var GMPScope = ChromeUtils.import(
const TEST_DATE = new Date(2013, 0, 1, 12);
+var gManagerWindow;
+var gCategoryUtilities;
+
var gMockAddons = [];
for (let plugin of GMPScope.GMP_PLUGINS) {
@@ -50,20 +53,35 @@ MockGMPInstallManager.prototype = {
},
};
-function openDetailsView(win, id) {
- let item = getAddonCard(win, id);
+function openDetailsView(aId) {
+ let view = get_current_view(gManagerWindow);
+ Assert.equal(
+ view.id,
+ "html-view",
+ "Should be in the list view to use this function"
+ );
+
+ let item = get_addon_element(gManagerWindow, aId);
Assert.ok(item, "Should have got add-on element.");
is_element_visible(item, "Add-on element should be visible.");
- let loaded = waitForViewLoad(win);
- EventUtils.synthesizeMouseAtCenter(item, {}, item.ownerGlobal);
- return loaded;
+ item.scrollIntoView();
+ EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, item.ownerGlobal);
+ EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, item.ownerGlobal);
+
+ return new Promise(resolve => {
+ wait_for_view_load(gManagerWindow, resolve);
+ });
}
-add_task(async function initializeState() {
+async function initializeState() {
gPrefs.setBoolPref(GMPScope.GMPPrefs.KEY_LOGGING_DUMP, true);
gPrefs.setIntPref(GMPScope.GMPPrefs.KEY_LOGGING_LEVEL, 0);
+ gManagerWindow = await open_manager();
+
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+
registerCleanupFunction(async function() {
for (let addon of gMockAddons) {
gPrefs.clearUserPref(
@@ -124,16 +142,14 @@ add_task(async function initializeState() {
}
await GMPScope.GMPProvider.shutdown();
GMPScope.GMPProvider.startup();
-});
+}
-add_task(async function testNotInstalledDisabled() {
- let win = await loadInitialView("extension");
-
- Assert.ok(isCategoryVisible(win, "plugin"), "Plugin tab visible.");
- await switchView(win, "plugin");
+async function testNotInstalledDisabled() {
+ Assert.ok(gCategoryUtilities.isTypeVisible("plugin"), "Plugin tab visible.");
+ await gCategoryUtilities.openType("plugin");
for (let addon of gMockAddons) {
- let addonCard = getAddonCard(win, addon.id);
+ let addonCard = get_addon_element(gManagerWindow, addon.id);
Assert.ok(addonCard, "Got add-on element:" + addon.id);
is(
@@ -145,20 +161,18 @@ add_task(async function testNotInstalledDisabled() {
let cardMessage = addonCard.querySelector("message-bar.addon-card-message");
is_element_hidden(cardMessage, "Warning notification is hidden");
}
+}
- await closeView(win);
-});
-
-add_task(async function testNotInstalledDisabledDetails() {
- let win = await loadInitialView("plugin");
-
+async function testNotInstalledDisabledDetails() {
for (let addon of gMockAddons) {
- await openDetailsView(win, addon.id);
- let addonCard = getAddonCard(win, addon.id);
+ await openDetailsView(addon.id);
+ let doc = gManagerWindow.document;
+
+ let addonCard = get_addon_element(gManagerWindow, addon.id);
ok(addonCard, "Got add-on element: " + addon.id);
is(
- win.document.l10n.getAttributes(addonCard.addonNameEl).id,
+ doc.l10n.getAttributes(addonCard.addonNameEl).id,
"addon-name-disabled",
"The addon name should include a disabled postfix"
);
@@ -168,21 +182,17 @@ add_task(async function testNotInstalledDisabledDetails() {
let cardMessage = addonCard.querySelector("message-bar.addon-card-message");
is_element_hidden(cardMessage, "Warning notification is hidden");
- await switchView(win, "plugin");
+ await gCategoryUtilities.openType("plugin");
}
+}
- await closeView(win);
-});
-
-add_task(async function testNotInstalled() {
- let win = await loadInitialView("plugin");
-
+async function testNotInstalled() {
for (let addon of gMockAddons) {
gPrefs.setBoolPref(
getKey(GMPScope.GMPPrefs.KEY_PLUGIN_ENABLED, addon.id),
true
);
- let item = getAddonCard(win, addon.id);
+ let item = get_addon_element(gManagerWindow, addon.id);
Assert.ok(item, "Got add-on element:" + addon.id);
let warningMessageBar = await BrowserTestUtils.waitForCondition(() => {
@@ -204,17 +214,13 @@ add_task(async function testNotInstalled() {
);
pluginOptions.querySelector("panel-list").open = false;
}
+}
- await closeView(win);
-});
-
-add_task(async function testNotInstalledDetails() {
- let win = await loadInitialView("plugin");
-
+async function testNotInstalledDetails() {
for (let addon of gMockAddons) {
- await openDetailsView(win, addon.id);
+ await openDetailsView(addon.id);
- const addonCard = getAddonCard(win, addon.id);
+ const addonCard = get_addon_element(gManagerWindow, addon.id);
let el = addonCard.querySelector("[action=update-check]");
is_element_visible(el, "Check for Updates action is visible");
@@ -225,15 +231,11 @@ add_task(async function testNotInstalledDetails() {
}, "Wait for the addon card message to be updated");
is_element_visible(warningMessageBar, "Warning notification is visible");
- await switchView(win, "plugin");
+ await gCategoryUtilities.openType("plugin");
}
+}
- await closeView(win);
-});
-
-add_task(async function testInstalled() {
- let win = await loadInitialView("plugin");
-
+async function testInstalled() {
for (let addon of gMockAddons) {
gPrefs.setIntPref(
getKey(GMPScope.GMPPrefs.KEY_PLUGIN_LAST_UPDATE, addon.id),
@@ -248,7 +250,7 @@ add_task(async function testInstalled() {
"1.2.3.4"
);
- let item = getAddonCard(win, addon.id);
+ let item = get_addon_element(gManagerWindow, addon.id);
Assert.ok(item, "Got add-on element.");
is(item.parentNode.getAttribute("section"), "0", "Should be enabled");
@@ -264,17 +266,13 @@ add_task(async function testInstalled() {
);
pluginOptions.querySelector("panel-list").open = false;
}
+}
- await closeView(win);
-});
-
-add_task(async function testInstalledDetails() {
- let win = await loadInitialView("plugin");
-
+async function testInstalledDetails() {
for (let addon of gMockAddons) {
- await openDetailsView(win, addon.id);
+ await openDetailsView(addon.id);
- let card = getAddonCard(win, addon.id);
+ let card = get_addon_element(gManagerWindow, addon.id);
ok(card, "Got add-on element:" + addon.id);
is_element_visible(
@@ -282,18 +280,14 @@ add_task(async function testInstalledDetails() {
"Find updates link is visible"
);
- await switchView(win, "plugin");
+ await gCategoryUtilities.openType("plugin");
}
+}
- await closeView(win);
-});
-
-add_task(async function testInstalledGlobalEmeDisabled() {
- let win = await loadInitialView("plugin");
+async function testInstalledGlobalEmeDisabled() {
gPrefs.setBoolPref(GMPScope.GMPPrefs.KEY_EME_ENABLED, false);
-
for (let addon of gMockAddons) {
- let item = getAddonCard(win, addon.id);
+ let item = get_addon_element(gManagerWindow, addon.id);
if (addon.isEME) {
is(item.parentNode.getAttribute("section"), "1", "Should be disabled");
// Open the options menu (needed to check the disabled buttons).
@@ -311,12 +305,10 @@ add_task(async function testInstalledGlobalEmeDisabled() {
Assert.ok(item, "Got add-on element.");
}
}
-
gPrefs.setBoolPref(GMPScope.GMPPrefs.KEY_EME_ENABLED, true);
- await closeView(win);
-});
+}
-add_task(async function testPreferencesButton() {
+async function testPreferencesButton() {
let prefValues = [
{ enabled: false, version: "" },
{ enabled: false, version: "1.2.3.4" },
@@ -325,12 +317,15 @@ add_task(async function testPreferencesButton() {
];
for (let preferences of prefValues) {
- info(
+ dump(
"Testing preferences button with pref settings: " +
- JSON.stringify(preferences)
+ JSON.stringify(preferences) +
+ "\n"
);
for (let addon of gMockAddons) {
- let win = await loadInitialView("plugin");
+ await close_manager(gManagerWindow);
+ gManagerWindow = await open_manager();
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
gPrefs.setCharPref(
getKey(GMPScope.GMPPrefs.KEY_PLUGIN_VERSION, addon.id),
preferences.version
@@ -340,7 +335,8 @@ add_task(async function testPreferencesButton() {
preferences.enabled
);
- let item = getAddonCard(win, addon.id);
+ await gCategoryUtilities.openType("plugin");
+ let item = get_addon_element(gManagerWindow, addon.id);
// Open the options menu (needed to check the more options action is enabled).
const pluginOptions = item.querySelector("plugin-options");
@@ -354,17 +350,12 @@ add_task(async function testPreferencesButton() {
);
moreOptions.click();
- await waitForViewLoad(win);
-
- item = getAddonCard(win, addon.id);
- ok(item, "The right view is loaded");
-
- await closeView(win);
+ await wait_for_view_load(gManagerWindow);
}
}
-});
+}
-add_task(async function testUpdateButton() {
+async function testUpdateButton() {
gPrefs.clearUserPref(GMPScope.GMPPrefs.KEY_UPDATE_LAST_CHECK);
let originalInstallManager = GMPScope.GMPInstallManager;
@@ -375,24 +366,20 @@ add_task(async function testUpdateButton() {
configurable: true,
});
- let win = await loadInitialView("plugin");
-
for (let addon of gMockAddons) {
- let item = getAddonCard(win, addon.id);
+ await gCategoryUtilities.openType("plugin");
+ let item = get_addon_element(gManagerWindow, addon.id);
gInstalledAddonId = "";
gInstallDeferred = Promise.defer();
- let loaded = waitForViewLoad(win);
item.querySelector("[action=expand]").click();
- await loaded;
- let detail = getAddonCard(win, addon.id);
+ await wait_for_view_load(gManagerWindow);
+ let detail = get_addon_element(gManagerWindow, addon.id);
detail.querySelector("[action=update-check]").click();
await gInstallDeferred.promise;
Assert.equal(gInstalledAddonId, addon.id);
-
- await switchView(win, "plugin");
}
Object.defineProperty(GMPScope, "GMPInstallManager", {
value: originalInstallManager,
@@ -400,11 +387,9 @@ add_task(async function testUpdateButton() {
enumerable: true,
configurable: true,
});
+}
- await closeView(win);
-});
-
-add_task(async function testEmeSupport() {
+async function testEmeSupport() {
for (let addon of gMockAddons) {
gPrefs.clearUserPref(
getKey(GMPScope.GMPPrefs.KEY_PLUGIN_FORCE_SUPPORTED, addon.id)
@@ -413,10 +398,9 @@ add_task(async function testEmeSupport() {
await GMPScope.GMPProvider.shutdown();
GMPScope.GMPProvider.startup();
- let win = await loadInitialView("plugin");
-
for (let addon of gMockAddons) {
- let item = getAddonCard(win, addon.id);
+ await gCategoryUtilities.openType("plugin");
+ let item = get_addon_element(gManagerWindow, addon.id);
if (addon.id == GMPScope.EME_ADOBE_ID) {
if (AppConstants.isPlatformAndVersionAtLeast("win", "6")) {
Assert.ok(item, "Adobe EME supported, found add-on element.");
@@ -444,8 +428,6 @@ add_task(async function testEmeSupport() {
}
}
- await closeView(win);
-
for (let addon of gMockAddons) {
gPrefs.setBoolPref(
getKey(GMPScope.GMPPrefs.KEY_PLUGIN_VISIBLE, addon.id),
@@ -458,4 +440,27 @@ add_task(async function testEmeSupport() {
}
await GMPScope.GMPProvider.shutdown();
GMPScope.GMPProvider.startup();
+}
+
+async function testCleanupState() {
+ await SpecialPowers.popPrefEnv();
+ await close_manager(gManagerWindow);
+}
+
+// This function run the sequence of all the gmpProvider tests
+// under the same initializeStateOptions (which will enable or disable
+// the HTML about:addons views).
+add_task(async function test_gmpProvider(initializeStateOptions) {
+ await initializeState();
+ await testNotInstalledDisabled();
+ await testNotInstalledDisabledDetails();
+ await testNotInstalled();
+ await testNotInstalledDetails();
+ await testInstalled();
+ await testInstalledDetails();
+ await testInstalledGlobalEmeDisabled();
+ await testPreferencesButton();
+ await testUpdateButton();
+ await testEmeSupport();
+ await testCleanupState();
});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_html_detail_view.js b/toolkit/mozapps/extensions/test/browser/browser_html_detail_view.js
index 0a8d284566fa..6db5b7e5940c 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_html_detail_view.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_html_detail_view.js
@@ -293,7 +293,7 @@ add_task(async function testDetailOperations() {
let panel = card.querySelector("panel-list");
// Check button visibility.
- let disableButton = card.querySelector('[action="toggle-disabled"]');
+ let disableButton = panel.querySelector('[action="toggle-disabled"]');
ok(!disableButton.hidden, "The disable button is visible");
let removeButton = panel.querySelector('[action="remove"]');
@@ -650,19 +650,20 @@ add_task(async function testDefaultTheme() {
let card = getAddonCard(doc, DEFAULT_THEME_ID);
ok(!card.hasAttribute("expanded"), "The list card is not expanded");
+ // Make sure the preview is hidden.
let preview = card.querySelector(".card-heading-image");
ok(preview, "There is a preview");
- ok(!preview.hidden, "The preview is visible");
-
+ is(preview.hidden, true, "The preview is hidden");
let loaded = waitForViewLoad(win);
card.querySelector('[action="expand"]').click();
await loaded;
card = getAddonCard(doc, DEFAULT_THEME_ID);
+ // Make sure the preview is hidden.
preview = card.querySelector(".card-heading-image");
ok(preview, "There is a preview");
- ok(!preview.hidden, "The preview is visible");
+ is(preview.hidden, true, "The preview is hidden");
// Check all the deck buttons are hidden.
assertDeckHeadingHidden(card.details.tabGroup);
@@ -1146,28 +1147,33 @@ add_task(async function testEmptyMoreOptionsMenu() {
await loaded;
card = getAddonCard(doc, DEFAULT_THEME_ID);
- let toggleDisabledButton = card.querySelector('[action="toggle-disabled"]');
enabledItems = card.options.visibleItems;
is(enabledItems.length, 0, "There are no enabled items");
moreOptionsButton = card.querySelector(".more-options-button");
ok(moreOptionsButton.hidden, "The more options button is now hidden");
- ok(toggleDisabledButton.hidden, "The disable button is hidden");
- // Switch themes, the menu should be hidden, but enable button should appear.
+ // Switch themes, this should show the menu again.
let darkTheme = await AddonManager.getAddonByID(DARK_THEME_ID);
let updated = BrowserTestUtils.waitForEvent(card, "update");
await darkTheme.enable();
await updated;
- ok(moreOptionsButton.hidden, "The more options button is still hidden");
- ok(!toggleDisabledButton.hidden, "The enable button is visible");
+ enabledItems = card.options.visibleItems;
+ is(enabledItems.length, 1, "There is one item visible");
+ is(
+ enabledItems[0].getAttribute("action"),
+ "toggle-disabled",
+ "Enable is the item"
+ );
+ ok(!moreOptionsButton.hidden, "The more options button is now visible");
updated = BrowserTestUtils.waitForEvent(card, "update");
- await toggleDisabledButton.click();
+ await enabledItems[0].click();
await updated;
- ok(moreOptionsButton.hidden, "The more options button is hidden");
- ok(toggleDisabledButton.hidden, "The disable button is hidden");
+ enabledItems = card.options.visibleItems;
+ is(enabledItems.length, 0, "There are no items visible");
+ ok(moreOptionsButton.hidden, "The more options button is hidden again");
await closeView(win);
});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_html_list_view.js b/toolkit/mozapps/extensions/test/browser/browser_html_list_view.js
index bc7a9aa560a6..6bb09459b4f9 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_html_list_view.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_html_list_view.js
@@ -106,18 +106,15 @@ add_task(async function testExtensionList() {
ok(icon.src.endsWith("/test-icon.png"), "The icon is set");
// Disable the extension.
- let disableToggle = card.querySelector('[action="toggle-disabled"]');
- ok(disableToggle.checked, "The disable toggle is checked");
+ let disableButton = card.querySelector('[action="toggle-disabled"]');
is(
- doc.l10n.getAttributes(disableToggle).id,
- "disable-addon-button-label",
- "The toggle has the disable label"
+ doc.l10n.getAttributes(disableButton).id,
+ "disable-addon-button",
+ "The button has the disable label"
);
- ok(disableToggle.getAttribute("aria-label"), "There's an aria-label");
- ok(!disableToggle.hidden, "The toggle is visible");
let disabled = BrowserTestUtils.waitForEvent(list, "move");
- disableToggle.click();
+ disableButton.click();
await disabled;
is(
card.parentNode,
@@ -126,13 +123,11 @@ add_task(async function testExtensionList() {
);
// The disable button is now enable.
- ok(!disableToggle.checked, "The disable toggle is unchecked");
is(
- doc.l10n.getAttributes(disableToggle).id,
- "enable-addon-button-label",
+ doc.l10n.getAttributes(disableButton).id,
+ "enable-addon-button",
"The button has the enable label"
);
- ok(disableToggle.getAttribute("aria-label"), "There's an aria-label");
// Remove the add-on.
let removeButton = card.querySelector('[action="remove"]');
@@ -366,11 +361,10 @@ add_task(async function testMouseSupport() {
});
add_task(async function testKeyboardSupport() {
- let id = "test@mochi.test";
let extension = ExtensionTestUtils.loadExtension({
manifest: {
name: "Test extension",
- applications: { gecko: { id } },
+ applications: { gecko: { id: "test@mochi.test" } },
},
useAddonManager: "temporary",
});
@@ -401,60 +395,63 @@ add_task(async function testKeyboardSupport() {
// Test opening and closing the menu.
let moreOptionsMenu = card.querySelector("panel-list");
let expandButton = moreOptionsMenu.querySelector('[action="expand"]');
- let removeButton = card.querySelector('[action="remove"]');
+ let toggleDisableButton = card.querySelector('[action="toggle-disabled"]');
is(moreOptionsMenu.open, false, "The menu is closed");
let shown = BrowserTestUtils.waitForEvent(moreOptionsMenu, "shown");
space();
await shown;
is(moreOptionsMenu.open, true, "The menu is open");
- isFocused(removeButton, "The remove button is now focused");
+ isFocused(toggleDisableButton, "The disable button is now focused");
+ EventUtils.synthesizeKey("Escape", {});
+ is(moreOptionsMenu.open, false, "The menu is closed");
+ isFocused(moreOptionsButton, "The more options button is focused");
+
+ // Test tabbing out of the menu.
+ space();
+ shown = BrowserTestUtils.waitForEvent(moreOptionsMenu, "shown");
+ is(moreOptionsMenu.open, true, "The menu is open");
+ await shown;
tab({ shiftKey: true });
is(moreOptionsMenu.open, true, "The menu stays open");
isFocused(expandButton, "The focus has looped to the bottom");
tab();
is(moreOptionsMenu.open, true, "The menu stays open");
- isFocused(removeButton, "The focus has looped to the top");
+ isFocused(toggleDisableButton, "The focus has looped to the top");
let hidden = BrowserTestUtils.waitForEvent(moreOptionsMenu, "hidden");
EventUtils.synthesizeKey("Escape", {});
await hidden;
isFocused(moreOptionsButton, "Escape closed the menu");
- // Disable the add-on.
- let disableButton = card.querySelector('[action="toggle-disabled"]');
- tab({ shiftKey: true });
- isFocused(disableButton, "The disable toggle is focused");
- is(card.parentNode, enabledSection, "The card is in the enabled section");
- space();
- // Wait for the add-on state to change.
- let [disabledAddon] = await AddonTestUtils.promiseAddonEvent("onDisabled");
- is(disabledAddon.id, id, "The right add-on was disabled");
- is(
- card.parentNode,
- enabledSection,
- "The card is still in the enabled section"
- );
- isFocused(disableButton, "The disable button is still focused");
- let moved = BrowserTestUtils.waitForEvent(list, "move");
- // Click outside the list to clear any focus.
- EventUtils.synthesizeMouseAtCenter(
- doc.querySelector(".header-name"),
- {},
- win
- );
- await moved;
- is(
- card.parentNode,
- disabledSection,
- "The card moved when keyboard focus left the list"
- );
-
- // Remove the add-on.
- moreOptionsButton.focus();
+ // Open the menu to test contents.
shown = BrowserTestUtils.waitForEvent(moreOptionsMenu, "shown");
space();
is(moreOptionsMenu.open, true, "The menu is open");
+ // Wait for the panel to be shown.
await shown;
+
+ // Disable the add-on.
+ isFocused(toggleDisableButton, "The disable button is focused");
+ is(card.parentNode, enabledSection, "The card is in the enabled section");
+ let disabled = BrowserTestUtils.waitForEvent(list, "move");
+ space();
+ await disabled;
+ is(moreOptionsMenu.open, false, "The menu is closed");
+ is(
+ card.parentNode,
+ disabledSection,
+ "The card is now in the disabled section"
+ );
+
+ // Open the menu again.
+ shown = BrowserTestUtils.waitForEvent(moreOptionsMenu, "shown");
+ isFocused(moreOptionsButton, "The more options button is focused");
+ space();
+ await shown;
+
+ // Remove the add-on.
+ tab();
+ let removeButton = card.querySelector('[action="remove"]');
isFocused(removeButton, "The remove button is focused");
let removed = BrowserTestUtils.waitForEvent(list, "remove");
space();
@@ -766,9 +763,8 @@ add_task(async function testSideloadRemoveButton() {
let card = getCardByAddonId(doc, id);
let moreOptionsPanel = card.querySelector("panel-list");
- let moreOptionsButton = card.querySelector('[action="more-options"]');
let panelOpened = BrowserTestUtils.waitForEvent(moreOptionsPanel, "shown");
- EventUtils.synthesizeMouseAtCenter(moreOptionsButton, {}, win);
+ moreOptionsPanel.show();
await panelOpened;
// Verify the remove button is visible with a SUMO link.
@@ -942,10 +938,6 @@ add_task(async function testDisabledDimming() {
let win = await loadInitialView("extension");
let doc = win.document;
- let pageHeader = doc.querySelector("addon-page-header");
-
- // Ensure there's no focus on the list.
- EventUtils.synthesizeMouseAtCenter(pageHeader, {}, win);
const checkOpacity = (card, expected, msg) => {
let { opacity } = card.ownerGlobal.getComputedStyle(card.firstElementChild);
@@ -962,25 +954,18 @@ add_task(async function testDisabledDimming() {
checkOpacity(card, "1", "The opacity is 1 when enabled");
// Disable the add-on, check again.
- let list = doc.querySelector("addon-list");
- let moved = BrowserTestUtils.waitForEvent(list, "move");
await addon.disable();
- await moved;
-
- let disabledSection = getSection(doc, "disabled");
- is(card.parentNode, disabledSection, "The card is in the disabled section");
checkOpacity(card, "0.6", "The opacity is dimmed when disabled");
// Click on the menu button, this should un-dim the card.
let transitionEnded = waitForTransition(card);
- let moreOptionsButton = card.querySelector(".more-options-button");
- EventUtils.synthesizeMouseAtCenter(moreOptionsButton, {}, win);
+ card.panel.open = true;
await transitionEnded;
checkOpacity(card, "1", "The opacity is 1 when the menu is open");
// Close the menu, opacity should return.
transitionEnded = waitForTransition(card);
- EventUtils.synthesizeMouseAtCenter(pageHeader, {}, win);
+ card.panel.open = false;
await transitionEnded;
checkOpacity(card, "0.6", "The card is dimmed again");
diff --git a/toolkit/mozapps/extensions/test/browser/browser_updateid.js b/toolkit/mozapps/extensions/test/browser/browser_updateid.js
index 87e92b92d3af..52b6cd1f51e3 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_updateid.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_updateid.js
@@ -16,8 +16,7 @@ async function getUpdateButton(item) {
let button = item.querySelector('[action="install-update"]');
let panel = button.closest("panel-list");
let shown = BrowserTestUtils.waitForEvent(panel, "shown");
- let moreOptionsButton = item.querySelector('[action="more-options"]');
- EventUtils.synthesizeMouseAtCenter(moreOptionsButton, {}, item.ownerGlobal);
+ panel.show();
await shown;
return button;
}
diff --git a/toolkit/mozapps/extensions/test/browser/head.js b/toolkit/mozapps/extensions/test/browser/head.js
index 7f4850ecfde5..999f7e7f6dfc 100644
--- a/toolkit/mozapps/extensions/test/browser/head.js
+++ b/toolkit/mozapps/extensions/test/browser/head.js
@@ -1637,7 +1637,7 @@ function assertAboutAddonsTelemetryEvents(events, filters = {}) {
}
/* HTML view helpers */
-async function loadInitialView(type, opts) {
+async function loadInitialView(type) {
// Force the first page load to be the view we want.
let viewId = type == "discover" ? "discover/" : `list/${type}`;
Services.prefs.setCharPref(PREF_UI_LASTCATEGORY, `addons://${viewId}`);
@@ -1646,9 +1646,6 @@ async function loadInitialView(type, opts) {
let browser = managerWindow.document.getElementById("html-view-browser");
let win = browser.contentWindow;
- if (!opts || !opts.withAnimations) {
- win.document.body.setAttribute("skip-animations", "");
- }
win.managerWindow = managerWindow;
return win;
}
@@ -1665,10 +1662,6 @@ function switchView(win, type) {
return new CategoryUtilities(win.managerWindow).openType(type);
}
-function isCategoryVisible(win, type) {
- return new CategoryUtilities(win.managerWindow).isTypeVisible(type);
-}
-
function mockPromptService() {
let { prompt } = Services;
let promptService = {