diff --git a/toolkit/actors/PictureInPictureChild.jsm b/toolkit/actors/PictureInPictureChild.jsm
index a8865646d2..0f60d995d4 100644
--- a/toolkit/actors/PictureInPictureChild.jsm
+++ b/toolkit/actors/PictureInPictureChild.jsm
@@ -8,9 +8,6 @@ var EXPORTED_SYMBOLS = ["PictureInPictureChild", "PictureInPictureToggleChild"];
const { ActorChild } = ChromeUtils.import(
"resource://gre/modules/ActorChild.jsm"
);
-const { XPCOMUtils } = ChromeUtils.import(
- "resource://gre/modules/XPCOMUtils.jsm"
-);
ChromeUtils.defineModuleGetter(
this,
@@ -23,8 +20,6 @@ ChromeUtils.defineModuleGetter(
"resource://gre/modules/Services.jsm"
);
-XPCOMUtils.defineLazyGlobalGetters(this, ["InspectorUtils"]);
-
const TOGGLE_ENABLED_PREF =
"media.videocontrols.picture-in-picture.video-toggle.enabled";
const TOGGLE_TESTING_PREF =
@@ -149,6 +144,10 @@ class PictureInPictureToggleChild extends ActorChild {
}
break;
}
+ case "mouseout": {
+ this.onMouseOut(event);
+ break;
+ }
case "mousedown":
case "pointerup":
case "mouseup":
@@ -280,6 +279,9 @@ class PictureInPictureToggleChild extends ActorChild {
capture: true,
});
this.content.windowRoot.addEventListener("click", this, { capture: true });
+ this.content.windowRoot.addEventListener("mouseout", this, {
+ capture: true,
+ });
}
removeMouseButtonListeners() {
@@ -298,6 +300,9 @@ class PictureInPictureToggleChild extends ActorChild {
this.content.windowRoot.removeEventListener("click", this, {
capture: true,
});
+ this.content.windowRoot.removeEventListener("mouseout", this, {
+ capture: true,
+ });
}
/**
@@ -455,6 +460,28 @@ class PictureInPictureToggleChild extends ActorChild {
}
}
+ /**
+ * Called on mouseout events to determine whether or not the mouse has
+ * exited the window.
+ *
+ * @param {Event} event The mouseout event.
+ */
+ onMouseOut(event) {
+ if (!event.relatedTarget) {
+ // For mouseout events, if there's no relatedTarget (which normally
+ // maps to the element that the mouse entered into) then this means that
+ // we left the window.
+ let state = this.docState;
+
+ let video = state.weakOverVideo && state.weakOverVideo.get();
+ if (!video) {
+ return;
+ }
+
+ this.onMouseLeaveVideo(video);
+ }
+ }
+
/**
* Called for each mousemove event when we're tracking those events to
* determine if the cursor is hovering over a
+
+
+ `,
+ "options.js": () => {
+ browser.test.onMessage.addListener(msg => {
+ if (msg === "get-version") {
+ let version = document.querySelector("pre").textContent;
+ browser.test.sendMessage("version", version);
+ }
+ });
+ browser.test.sendMessage("options-loaded");
+ },
+ },
+ useAddonManager: "temporary",
+ });
+ await extension.startup();
+ return extension;
+ }
+
+ let firstExtension = await loadExtension("1");
+ let win = await loadInitialView("extension");
+ let doc = win.document;
+
+ let card = getAddonCard(doc, id);
+ let loaded = waitForViewLoad(win);
+ card.querySelector('[action="expand"]').click();
+ await loaded;
+
+ card = doc.querySelector("addon-card");
+ let browserAdded = waitOptionsBrowserInserted();
+ card.querySelector('named-deck-button[name="preferences"]').click();
+ await browserAdded;
+
+ await firstExtension.awaitMessage("options-loaded");
+ await firstExtension.sendMessage("get-version");
+ let version = await firstExtension.awaitMessage("version");
+ is(version, "1", "Version 1 page is loaded");
+
+ let updated = BrowserTestUtils.waitForEvent(card, "update");
+ browserAdded = waitOptionsBrowserInserted();
+ let secondExtension = await loadExtension("2");
+ await updated;
+ await browserAdded;
+ await secondExtension.awaitMessage("options-loaded");
+
+ await secondExtension.sendMessage("get-version");
+ version = await secondExtension.awaitMessage("version");
+ is(version, "2", "Version 2 page is loaded");
+ let { deck } = card.details;
+ is(deck.selectedViewName, "preferences", "Preferences are still shown");
+
+ await closeView(win);
+ await firstExtension.unload();
+ await secondExtension.unload();
+});
+
+add_task(async function testReloadExtension() {
+ let id = "reload@mochi.test";
+ let xpiFile = AddonTestUtils.createTempWebExtensionFile({
+ manifest: {
+ applications: { gecko: { id } },
+ options_ui: {
+ page: "options.html",
+ },
+ },
+ files: {
+ "options.html": `
+
+
+
+
+ Options
+
+
+ `,
+ },
+ });
+ let addon = await AddonManager.installTemporaryAddon(xpiFile);
+
+ let win = await loadInitialView("extension");
+ let doc = win.document;
+
+ let card = getAddonCard(doc, id);
+ let loaded = waitForViewLoad(win);
+ card.querySelector('[action="expand"]').click();
+ await loaded;
+
+ card = doc.querySelector("addon-card");
+ let { deck } = card.details;
+ is(deck.selectedViewName, "details", "Details load first");
+
+ let browserAdded = waitOptionsBrowserInserted();
+ card.querySelector('named-deck-button[name="preferences"]').click();
+ await browserAdded;
+
+ is(deck.selectedViewName, "preferences", "Preferences are shown");
+
+ let updated = BrowserTestUtils.waitForEvent(card, "update");
+ browserAdded = waitOptionsBrowserInserted();
+ let addonStarted = AddonTestUtils.promiseWebExtensionStartup(id);
+ await addon.reload();
+ await addonStarted;
+ await updated;
+ await browserAdded;
+ is(deck.selectedViewName, "preferences", "Preferences are still shown");
+
+ await closeView(win);
+ await addon.uninstall();
+});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_html_options_ui_in_tab.js b/toolkit/mozapps/extensions/test/browser/browser_html_options_ui_in_tab.js
index b38e1b5a8d..8bf451ce3e 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_html_options_ui_in_tab.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_html_options_ui_in_tab.js
@@ -6,10 +6,7 @@
add_task(async function enableHtmlViews() {
await SpecialPowers.pushPrefEnv({
- set: [
- ["extensions.htmlaboutaddons.enabled", true],
- ["extensions.htmlaboutaddons.inline-options.enabled", true],
- ],
+ set: [["extensions.htmlaboutaddons.inline-options.enabled", true]],
});
});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_html_plugins.js b/toolkit/mozapps/extensions/test/browser/browser_html_plugins.js
index 5824c6c174..9579a86c5a 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_html_plugins.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_html_plugins.js
@@ -7,10 +7,6 @@
const TEST_PLUGIN_DESCRIPTION = "Flash plug-in for testing purposes.";
add_task(async function enableHtmlViews() {
- await SpecialPowers.pushPrefEnv({
- set: [["extensions.htmlaboutaddons.enabled", true]],
- });
-
let gProvider = new MockProvider();
gProvider.createAddons([
{
diff --git a/toolkit/mozapps/extensions/test/browser/browser_html_recent_updates.js b/toolkit/mozapps/extensions/test/browser/browser_html_recent_updates.js
index c64fbc9141..64d5f3d1dd 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_html_recent_updates.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_html_recent_updates.js
@@ -8,10 +8,6 @@ function dateHoursAgo(hours) {
}
add_task(async function enableHtmlViews() {
- await SpecialPowers.pushPrefEnv({
- set: [["extensions.htmlaboutaddons.enabled", true]],
- });
-
gProvider = new MockProvider();
gProvider.createAddons([
{
@@ -78,13 +74,23 @@ add_task(async function testRecentUpdatesList() {
// Load extension view first so we can mock the startOfDay property.
let win = await loadInitialView("extension");
let doc = win.document;
- let managerDoc = win.managerWindow.document;
+ const RECENT_URL = "addons://updates/recent";
+ let recentCat = win.managerWindow.gCategories.get(RECENT_URL);
+
+ ok(recentCat.hidden, "Recent updates category is initially hidden");
// Load the recent updates view.
let loaded = waitForViewLoad(win);
- managerDoc.getElementById("utils-viewUpdates").doCommand();
+ doc.querySelector('#page-options [action="view-recent-updates"]').click();
await loaded;
+ is(
+ win.managerWindow.gCategories.selected,
+ RECENT_URL,
+ "Recent updates is selected"
+ );
+ ok(!recentCat.hidden, "Recent updates category is now shown");
+
// Find all the add-on ids.
let list = doc.querySelector("addon-list");
let addonsInOrder = () =>
@@ -123,7 +129,7 @@ add_task(async function testRecentUpdatesList() {
info("Go back to the recent updates view");
loaded = waitForViewLoad(win);
- managerDoc.getElementById("utils-viewUpdates").doCommand();
+ doc.querySelector('#page-options [action="view-recent-updates"]').click();
await loaded;
// Find the list again.
diff --git a/toolkit/mozapps/extensions/test/browser/browser_html_scroll_restoration.js b/toolkit/mozapps/extensions/test/browser/browser_html_scroll_restoration.js
new file mode 100644
index 0000000000..0a5226d390
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/browser/browser_html_scroll_restoration.js
@@ -0,0 +1,226 @@
+/* eslint max-len: ["error", 80] */
+"use strict";
+
+const { AddonTestUtils } = ChromeUtils.import(
+ "resource://testing-common/AddonTestUtils.jsm"
+);
+
+AddonTestUtils.initMochitest(this);
+const server = AddonTestUtils.createHttpServer();
+const TEST_API_URL = `http://localhost:${server.identity.primaryPort}/discoapi`;
+
+const EXT_ID_EXTENSION = "extension@example.com";
+const EXT_ID_THEME = "theme@example.com";
+
+let requestCount = 0;
+server.registerPathHandler("/discoapi", (request, response) => {
+ // This test is expected to load the results only once, and then cache the
+ // results.
+ is(++requestCount, 1, "Expect only one discoapi request");
+
+ let results = {
+ results: [
+ {
+ addon: {
+ authors: [{ name: "Some author" }],
+ current_version: {
+ files: [{ platform: "all", url: "data:," }],
+ },
+ url: "data:,",
+ guid: "recommendation@example.com",
+ type: "extension",
+ },
+ },
+ ],
+ };
+ response.write(JSON.stringify(results));
+});
+
+add_task(async function setup() {
+ await SpecialPowers.pushPrefEnv({
+ set: [["extensions.getAddons.discovery.api_url", TEST_API_URL]],
+ });
+
+ let mockProvider = new MockProvider();
+ mockProvider.createAddons([
+ {
+ id: EXT_ID_EXTENSION,
+ name: "Mock 1",
+ type: "extension",
+ userPermissions: {
+ origins: [""],
+ permissions: ["tabs"],
+ },
+ },
+ {
+ id: EXT_ID_THEME,
+ name: "Mock 2",
+ type: "theme",
+ },
+ ]);
+});
+
+async function switchToView(win, type, param = "") {
+ let loaded = waitForViewLoad(win);
+ win.managerWindow.gViewController.loadView(`addons://${type}/${param}`);
+ await loaded;
+ await waitForStableLayout(win);
+}
+
+// delta = -1 = go back.
+// delta = +1 = go forwards.
+async function historyGo(win, delta, expectedViewType) {
+ let loaded = waitForViewLoad(win);
+ win.managerWindow.history.go(delta);
+ await loaded;
+ is(
+ win.managerWindow.gViewController.currentViewId,
+ expectedViewType,
+ "Expected view after history navigation"
+ );
+ await waitForStableLayout(win);
+}
+
+async function waitForStableLayout(win) {
+ // In the test, it is important that the layout is fully stable before we
+ // consider the view loaded, because those affect the offset calculations.
+ await TestUtils.waitForCondition(
+ () => isLayoutStable(win),
+ "Waiting for layout to stabilize"
+ );
+}
+
+function isLayoutStable(win) {
+ // elements may affect the layout of a page, and therefore we
+ // should check whether its embedded style sheet has finished loading.
+ for (let bar of win.document.querySelectorAll("message-bar")) {
+ // Check for the existence of a CSS property from message-bar.css.
+ if (!win.getComputedStyle(bar).getPropertyValue("--message-bar-icon-url")) {
+ return false;
+ }
+ }
+ return true;
+}
+
+function getAddonCard(win, addonId) {
+ return win.document.querySelector(`addon-card[addon-id="${addonId}"]`);
+}
+
+function getScrollOffset(win) {
+ let { scrollTop: top, scrollLeft: left } = win.document.documentElement;
+ return { top, left };
+}
+
+// Scroll an element into view. The purpose of this is to simulate a real-world
+// scenario where the user has moved part of the UI is in the viewport.
+function scrollTopLeftIntoView(elem) {
+ elem.scrollIntoView({ block: "start", inline: "start" });
+ // Sanity check: In this test, a large padding has been added to the top and
+ // left of the document. So when an element has been scrolled into view, the
+ // top and left offsets must be non-zero.
+ assertNonZeroScrollOffsets(getScrollOffset(elem.ownerGlobal));
+}
+
+function assertNonZeroScrollOffsets(offsets) {
+ ok(offsets.left, "Should have scrolled to the right");
+ ok(offsets.top, "Should have scrolled down");
+}
+
+function checkScrollOffset(win, expected, msg = "") {
+ let actual = getScrollOffset(win);
+ is(actual.top, expected.top, `Top scroll offset - ${msg}`);
+ is(actual.left, expected.left, `Left scroll offset - ${msg}`);
+}
+
+add_task(async function test_scroll_restoration() {
+ let win = await loadInitialView("discover");
+
+ // Wait until the recommendations have been loaded. These are cached after
+ // the first load, so we only need to wait once, at the start of the test.
+ await win.document.querySelector("recommended-addon-list").cardsReady;
+
+ // Force scrollbar to appear, by adding enough space at the top and left.
+ win.document.body.style.paddingTop = "200vh";
+ win.document.body.style.paddingLeft = "100vw";
+ win.document.body.style.width = "200vw";
+
+ checkScrollOffset(win, { top: 0, left: 0 }, "initial page load");
+
+ scrollTopLeftIntoView(win.document.querySelector("recommended-addon-card"));
+ let discoOffsets = getScrollOffset(win);
+ assertNonZeroScrollOffsets(discoOffsets);
+
+ // Switch from disco pane to extension list
+
+ await switchToView(win, "list", "extension");
+ checkScrollOffset(win, { top: 0, left: 0 }, "initial extension list");
+
+ scrollTopLeftIntoView(getAddonCard(win, EXT_ID_EXTENSION));
+ let extListOffsets = getScrollOffset(win);
+ assertNonZeroScrollOffsets(extListOffsets);
+
+ // Switch from extension list to details view.
+
+ let loaded = waitForViewLoad(win);
+ getAddonCard(win, EXT_ID_EXTENSION).click();
+ await loaded;
+
+ checkScrollOffset(win, { top: 0, left: 0 }, "initial details view");
+ scrollTopLeftIntoView(getAddonCard(win, EXT_ID_EXTENSION));
+ let detailsOffsets = getScrollOffset(win);
+ assertNonZeroScrollOffsets(detailsOffsets);
+
+ // Switch from details view back to extension list.
+
+ await historyGo(win, -1, "addons://list/extension");
+ checkScrollOffset(win, extListOffsets, "back to extension list");
+
+ // Now scroll to the bottom-right corner, so we can check whether the scroll
+ // offset is correctly restored when the extension view is loaded, even when
+ // the recommendations are loaded after the initial render.
+ ok(
+ win.document.querySelector("recommended-addon-card"),
+ "Recommendations have already been loaded"
+ );
+ win.document.body.scrollIntoView({ block: "end", inline: "end" });
+ extListOffsets = getScrollOffset(win);
+ assertNonZeroScrollOffsets(extListOffsets);
+
+ // Switch back from the extension list to the details view.
+
+ await historyGo(win, +1, `addons://detail/${EXT_ID_EXTENSION}`);
+ checkScrollOffset(win, detailsOffsets, "details view with default tab");
+
+ // Switch from the default details tab to the permissions tab.
+ // (this does not change the history).
+ win.document.querySelector("named-deck-button[name='permissions']").click();
+
+ // Switch back from the details view to the extension list.
+
+ await historyGo(win, -1, "addons://list/extension");
+ checkScrollOffset(win, extListOffsets, "bottom-right of extension list");
+ ok(
+ win.document.querySelector("recommended-addon-card"),
+ "Recommendations should have been loaded again"
+ );
+
+ // Switch back from extension list to the details view.
+
+ await historyGo(win, +1, `addons://detail/${EXT_ID_EXTENSION}`);
+ // Scroll offsets are not remembered for the details view, because at the
+ // time of leaving the details view, the non-default tab was selected.
+ checkScrollOffset(win, { top: 0, left: 0 }, "details view, non-default tab");
+
+ // Switch back from the details view to the disco pane.
+
+ await historyGo(win, -2, "addons://discover/");
+ checkScrollOffset(win, discoOffsets, "after switching back to disco pane");
+
+ // Switch from disco pane to theme list.
+
+ // Verifies that the extension list and theme lists are independent.
+ await switchToView(win, "list", "theme");
+ checkScrollOffset(win, { top: 0, left: 0 }, "initial theme list");
+
+ await closeView(win);
+});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_html_updates.js b/toolkit/mozapps/extensions/test/browser/browser_html_updates.js
index dde2bf3edb..06fddb779f 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_html_updates.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_html_updates.js
@@ -6,10 +6,7 @@ const { AddonTestUtils } = ChromeUtils.import(
AddonTestUtils.initMochitest(this);
-add_task(async function enableHtmlViews() {
- await SpecialPowers.pushPrefEnv({
- set: [["extensions.htmlaboutaddons.enabled", true]],
- });
+add_task(async function setup() {
});
function loadDetailView(win, id) {
@@ -67,7 +64,7 @@ add_task(async function testChangeAutoUpdates() {
// Go back to the list view and check the details view again.
let loaded = waitForViewLoad(win);
- win.managerWindow.document.getElementById("go-back").click();
+ doc.querySelector(".back-button").click();
await loaded;
// Load the detail view again.
@@ -492,7 +489,6 @@ add_task(async function testAvailableUpdates() {
let win = await loadInitialView("extension");
let doc = win.document;
- let managerDoc = win.managerWindow.document;
let { gCategories } = win.managerWindow;
let availableCat = gCategories.get("addons://updates/available");
@@ -501,7 +497,7 @@ add_task(async function testAvailableUpdates() {
// Check for all updates.
let updatesFound = TestUtils.topicObserved("EM-update-check-finished");
- managerDoc.getElementById("utils-updateNow").doCommand();
+ doc.querySelector('#page-options [action="check-for-updates"]').click();
await updatesFound;
// Wait for the available updates count to finalize, it's async.
@@ -535,7 +531,7 @@ add_task(async function testAvailableUpdates() {
// Go back to the last view.
loaded = waitForViewLoad(win);
- managerDoc.getElementById("go-back").click();
+ doc.querySelector(".back-button").click();
await loaded;
// We're back on the updates view.
diff --git a/toolkit/mozapps/extensions/test/browser/browser_html_warning_messages.js b/toolkit/mozapps/extensions/test/browser/browser_html_warning_messages.js
index d45805860a..fdb591a387 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_html_warning_messages.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_html_warning_messages.js
@@ -23,9 +23,6 @@ const SUPPORT_URL = Services.urlFormatter.formatURL(
);
add_task(async function setup() {
- await SpecialPowers.pushPrefEnv({
- set: [["extensions.htmlaboutaddons.enabled", true]],
- });
gProvider = new MockProvider();
});
@@ -101,7 +98,6 @@ add_task(async function testNoMessageLangpack() {
appDisabled: true,
id,
name: "Signed Langpack",
- signedState: AddonManager.SIGNEDSTATE_SIGNED,
type: "locale",
},
]);
@@ -148,26 +144,6 @@ add_task(async function testIncompatible() {
});
});
-add_task(async function testUnsignedEnabled() {
- let id = "unsigned-allowed@mochi.test";
- gProvider.createAddons([
- {
- id,
- name: "Unsigned",
- signedState: AddonManager.SIGNEDSTATE_MISSING,
- },
- ]);
- await checkMessageState(id, "extension", {
- linkText: "More Information",
- linkUrl: SUPPORT_URL + "unsigned-addons",
- text:
- "Unsigned could not be verified for use in " +
- appName +
- ". Proceed with caution.",
- type: "warning",
- });
-});
-
add_task(async function testSoftBlocked() {
let id = "softblocked@mochi.test";
let linkUrl = "https://example.com/addon-blocked";
diff --git a/toolkit/mozapps/extensions/test/browser/browser_inlinesettings_browser.js b/toolkit/mozapps/extensions/test/browser/browser_inlinesettings_browser.js
deleted file mode 100644
index 00be2b4743..0000000000
--- a/toolkit/mozapps/extensions/test/browser/browser_inlinesettings_browser.js
+++ /dev/null
@@ -1,274 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-/* eslint-disable mozilla/no-arbitrary-setTimeout */
-
-/* globals TestUtils */
-
-let { ExtensionTestCommon } = ChromeUtils.import(
- "resource://testing-common/ExtensionTestCommon.jsm"
-);
-
-ChromeUtils.import("resource://testing-common/ContentTask.jsm", {});
-
-// This test is testing resizing of the inline options in XUL about:addons. The
-// behavior in HTML about:addons is checked in the testInlineOptions task of
-// browser_html_options_ui.js.
-SpecialPowers.pushPrefEnv({
- set: [["extensions.htmlaboutaddons.enabled", false]],
-});
-
-var gAddon;
-var gOtherAddon;
-var gManagerWindow;
-var gCategoryUtilities;
-
-function installAddon(details) {
- let id = Cc["@mozilla.org/uuid-generator;1"]
- .getService(Ci.nsIUUIDGenerator)
- .generateUUID().number;
- if (!details.manifest) {
- details.manifest = {};
- }
- details.manifest.applications = { gecko: { id } };
- let xpi = ExtensionTestCommon.generateXPI(details);
-
- return AddonManager.installTemporaryAddon(xpi).then(addon => {
- SimpleTest.registerCleanupFunction(function() {
- addon.uninstall();
-
- Services.obs.notifyObservers(xpi, "flush-cache-entry");
- xpi.remove(false);
- });
-
- return addon;
- });
-}
-
-add_task(async function() {
- gAddon = await installAddon({
- manifest: {
- options_ui: {
- page: "options.html",
- },
- },
-
- files: {
- "options.html": `
-
-
-
-
-
-
- The quick mauve fox jumps over the opalescent dog.
-
- `,
- },
- });
-
- // Create another add-on with no inline options, to verify that detail
- // view switches work correctly.
- gOtherAddon = await installAddon({});
-
- gManagerWindow = await open_manager("addons://list/extension");
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
-});
-
-async function openDetailsBrowser(addonId) {
- var addon = get_addon_element(gManagerWindow, addonId);
-
- is(
- addon.mAddon.optionsType,
- AddonManager.OPTIONS_TYPE_INLINE_BROWSER,
- "Options should be inline browser type"
- );
-
- addon.parentNode.ensureElementIsVisible(addon);
-
- var button = gManagerWindow.document.getAnonymousElementByAttribute(
- addon,
- "anonid",
- "preferences-btn"
- );
-
- is_element_visible(button, "Preferences button should be visible");
-
- EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, gManagerWindow);
-
- await TestUtils.topicObserved(
- AddonManager.OPTIONS_NOTIFICATION_DISPLAYED,
- (subject, data) => data == addonId
- );
-
- is(
- gManagerWindow.gViewController.currentViewId,
- `addons://detail/${encodeURIComponent(addonId)}/preferences`,
- "Current view should scroll to preferences"
- );
-
- var browser = gManagerWindow.document.querySelector(
- "#detail-grid > rows > stack > .inline-options-browser"
- );
- var rows = browser.parentNode.parentNode;
-
- let url = await ContentTask.spawn(browser, {}, () => content.location.href);
-
- ok(browser, "Grid should have a browser descendant");
- is(browser.localName, "browser", "Grid should have a browser descendant");
- is(
- url,
- addon.mAddon.optionsURL,
- "Browser has the expected options URL loaded"
- );
-
- is(
- browser.clientWidth,
- browser.parentNode.clientWidth,
- "Browser should be the same width as its direct parent"
- );
- is(
- browser.clientWidth,
- rows.clientWidth,
- "Browser should be the same width as its rows ancestor"
- );
-
- button = gManagerWindow.document.getElementById("detail-prefs-btn");
- is_element_hidden(button, "Preferences button should not be visible");
-
- return browser;
-}
-
-add_task(async function test_inline_browser_addon() {
- let browser = await openDetailsBrowser(gAddon.id);
-
- function checkHeights(expected) {
- let { clientHeight } = browser;
- return ContentTask.spawn(
- browser,
- { expected, clientHeight },
- ({ expected, clientHeight }) => {
- let { body } = content.document;
-
- is(
- body.clientHeight,
- expected,
- `Document body should be ${expected}px tall`
- );
- is(
- body.clientHeight,
- body.scrollHeight,
- "Document body should be tall enough to fit its contents"
- );
-
- let heightDiff = clientHeight - expected;
- ok(
- heightDiff >= 0 && heightDiff < 50,
- `Browser should be slightly taller than the document body (${clientHeight} vs. ${expected})`
- );
- }
- );
- }
-
- // Delay long enough to avoid hitting our resize rate limit.
- let delay = () => new Promise(resolve => setTimeout(resolve, 300));
-
- await delay();
-
- await checkHeights(300);
-
- info(
- "Increase the document height, and expect the browser to grow correspondingly"
- );
- await ContentTask.spawn(browser, null, () => {
- content.document.body.classList.toggle("bigger");
- });
-
- await delay();
-
- await checkHeights(600);
-
- info(
- "Decrease the document height, and expect the browser to shrink correspondingly"
- );
- await ContentTask.spawn(browser, null, () => {
- content.document.body.classList.toggle("bigger");
- });
-
- await delay();
-
- await checkHeights(300);
-
- await new Promise(resolve =>
- gCategoryUtilities.openType("extension", resolve)
- );
-
- browser = gManagerWindow.document.querySelector(".inline-options-browser");
-
- is(browser, null, "Options browser should be removed from the document");
-});
-
-// Test that loading an add-on with no inline browser works as expected
-// after having viewed our main test add-on.
-add_task(async function test_plain_addon() {
- var addon = get_addon_element(gManagerWindow, gOtherAddon.id);
-
- is(addon.mAddon.optionsType, null, "Add-on should have no options");
-
- addon.parentNode.ensureElementIsVisible(addon);
-
- await EventUtils.synthesizeMouseAtCenter(
- addon,
- { clickCount: 1 },
- gManagerWindow
- );
-
- EventUtils.synthesizeMouseAtCenter(addon, { clickCount: 2 }, gManagerWindow);
-
- await BrowserTestUtils.waitForEvent(gManagerWindow, "ViewChanged");
-
- is(
- gManagerWindow.gViewController.currentViewId,
- `addons://detail/${encodeURIComponent(gOtherAddon.id)}`,
- "Detail view should be open"
- );
-
- var browser = gManagerWindow.document.querySelector(
- "#detail-grid > rows > .inline-options-browser"
- );
-
- is(browser, null, "Detail view should have no inline browser");
-
- await new Promise(resolve =>
- gCategoryUtilities.openType("extension", resolve)
- );
-});
-
-// Test that loading the original add-on details successfully creates a
-// browser.
-add_task(async function test_inline_browser_addon_again() {
- let browser = await openDetailsBrowser(gAddon.id);
-
- await new Promise(resolve =>
- gCategoryUtilities.openType("extension", resolve)
- );
-
- browser = gManagerWindow.document.querySelector(".inline-options-browser");
-
- is(browser, null, "Options browser should be removed from the document");
-});
-
-add_task(async function() {
- await close_manager(gManagerWindow);
-
- gManagerWindow = null;
- gCategoryUtilities = null;
-});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_installssl.js b/toolkit/mozapps/extensions/test/browser/browser_installssl.js
index 724ec72615..16091b36f1 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_installssl.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_installssl.js
@@ -67,7 +67,7 @@ function add_install_test(mainURL, redirectURL, expectedStatus) {
function run_install_tests(callback) {
async function run_next_install_test() {
- if (gTests.length == 0) {
+ if (!gTests.length) {
callback();
return;
}
diff --git a/toolkit/mozapps/extensions/test/browser/browser_legacy.js b/toolkit/mozapps/extensions/test/browser/browser_legacy.js
deleted file mode 100644
index 6aacb5a507..0000000000
--- a/toolkit/mozapps/extensions/test/browser/browser_legacy.js
+++ /dev/null
@@ -1,237 +0,0 @@
-// This test is testing the view with legacy add-ons in the XUL about:addons UI.
-// This is not implemented in HTML about:addons, but might be in bug 1525184.
-SpecialPowers.pushPrefEnv({
- set: [["extensions.htmlaboutaddons.enabled", false]],
-});
-
-add_task(async function() {
- const INFO_URL =
- Services.urlFormatter.formatURLPref("app.support.baseURL") +
- "webextensions";
-
- // The mochitest framework installs a bunch of legacy extensions.
- // Fortunately, the extensions.legacy.exceptions preference exists to
- // avoid treating some extensions as legacy for the purposes of the UI.
- const IGNORE = [
- "special-powers@mozilla.org",
- "mochikit@mozilla.org",
- "mozscreenshots@mozilla.org",
- ];
-
- let goodAddons = [
- {
- id: "webextension@tests.mozilla.org",
- name: "WebExtension",
- type: "extension",
- isWebExtension: true,
- },
- {
- id: "mozilla@tests.mozilla.org",
- name: "Mozilla signed extension",
- type: "extension",
- isWebExtension: false,
- signedState: AddonManager.SIGNEDSTATE_PRIVILEGED,
- },
- ];
-
- let disabledAddon = [
- {
- id: "legacy@tests.mozilla.org",
- name: "Legacy extension",
- type: "extension",
- isWebExtension: false,
- appDisabled: true,
- },
- ];
-
- let unsignedAddons = [
- {
- id: "unsigned_webext@tests.mozilla.org",
- name: "Unsigned WebExtension",
- type: "extension",
- isWebExtension: true,
- appDisabled: true,
- signedState: AddonManager.SIGNEDSTATE_MISSING,
- },
- {
- id: "unsigned_legacy@tests.mozilla.org",
- name: "Unsigned legacy extension",
- type: "extension",
- isWebExtension: false,
- appDisabled: true,
- signedState: AddonManager.SIGNEDSTATE_MISSING,
- },
- ];
-
- let provider = new MockProvider();
- provider.createAddons(goodAddons);
-
- let mgrWin = await open_manager(null);
- let catUtils = new CategoryUtilities(mgrWin);
-
- // Check that the test addons in the given list are exactly those
- // in the expected list.
- async function checkList(listId, expectIds) {
- let ids = new Set(expectIds);
- for (let item of mgrWin.document.getElementById(listId).itemChildren) {
- if (!item.mAddon.id.endsWith("@tests.mozilla.org")) {
- continue;
- }
-
- ok(ids.has(item.mAddon.id), `Found ${item.mAddon.id} in addons list`);
- ids.delete(item.mAddon.id);
- }
-
- for (let id of ids) {
- ok(false, `Did not find ${id} in addons list`);
- }
- }
-
- // Initially, we have two good extensions (a webextension and a
- // "Mozilla Extensions"-signed extension).
- await catUtils.openType("extension");
- checkList("addon-list", [
- "webextension@tests.mozilla.org",
- "mozilla@tests.mozilla.org",
- ]);
-
- // Now add a legacy extension
- provider.createAddons(disabledAddon);
-
- // The legacy category does not watch for new installs since new
- // legacy extensions cannot be installed while legacy extensions
- // are disabled, so manually refresh it here.
- await mgrWin.gLegacyView.refreshVisibility();
-
- // Make sure we re-render the extensions list, after that we should
- // still just have the original two entries.
- await catUtils.openType("plugin");
- await catUtils.openType("extension");
-
- checkList("addon-list", [
- "webextension@tests.mozilla.org",
- "mozilla@tests.mozilla.org",
- ]);
-
- // But now the legacy banner and category should be visible
- banner = mgrWin.document.getElementById("legacy-extensions-notice");
- is_element_visible(
- banner,
- "Warning about legacy extensions should be visible"
- );
-
- let catItem = mgrWin.gLegacyView._categoryItem;
- is(catItem.disabled, false, "Legacy category is visible");
- is(
- catItem.getAttribute("name"),
- get_string("type.legacy.name"),
- "Category label with no unsigned extensions is correct"
- );
-
- // Follow the link to the legacy extensions page
- let legacyLink = mgrWin.document.getElementById(
- "legacy-extensions-learnmore-link"
- );
- is_element_visible(legacyLink, "Link to legacy extension is visible");
-
- let loadPromise = new Promise(resolve =>
- wait_for_view_load(mgrWin, resolve, true)
- );
- legacyLink.click();
- await loadPromise;
-
- is(
- mgrWin.gViewController.currentViewId,
- "addons://legacy/",
- "Legacy extensions link leads to the correct view"
- );
-
- let link = mgrWin.document.getElementById("legacy-learnmore");
- is(link.href, INFO_URL, "Learn more link points to the right place");
-
- // The only extension in the list should be the one we just added.
- checkList("legacy-list", ["legacy@tests.mozilla.org"]);
-
- // Now add some unsigned addons and flip the signing preference
- provider.createAddons(unsignedAddons);
-
- // The entry on the left side should now read "Unsupported"
- await mgrWin.gLegacyView.refreshVisibility();
- is(catItem.disabled, false, "Legacy category is visible");
- is(
- catItem.getAttribute("name"),
- get_string("type.unsupported.name"),
- "Category label with unsigned extensions is correct"
- );
-
- // The main extensions list should still have the original two
- // good extensions and the legacy banner.
- await catUtils.openType("extension");
- checkList("addon-list", [
- "webextension@tests.mozilla.org",
- "mozilla@tests.mozilla.org",
- ]);
-
- banner = mgrWin.document.getElementById("legacy-extensions-notice");
- is_element_visible(
- banner,
- "Warning about legacy extensions should be visible"
- );
-
- // And the legacy pane should show both legacy and unsigned extensions
- await catUtils.openType("legacy");
- checkList("legacy-list", [
- "legacy@tests.mozilla.org",
- "unsigned_webext@tests.mozilla.org",
- "unsigned_legacy@tests.mozilla.org",
- ]);
-
- // Disable unsigned extensions
- SpecialPowers.pushPrefEnv({
- set: [["xpinstall.signatures.required", false]],
- });
-
- await new Promise(executeSoon);
-
- // The name of the pane should go back to "Legacy Extensions"
- await mgrWin.gLegacyView.refreshVisibility();
- is(catItem.disabled, false, "Legacy category is visible");
- is(
- catItem.getAttribute("name"),
- get_string("type.legacy.name"),
- "Category label with no unsigned extensions is correct"
- );
-
- // The unsigned extension should be present in the main extensions pane
- await catUtils.openType("extension");
- checkList("addon-list", [
- "webextension@tests.mozilla.org",
- "mozilla@tests.mozilla.org",
- "unsigned_webext@tests.mozilla.org",
- ]);
-
- // And it should not be present in the legacy pane
- await catUtils.openType("legacy");
- checkList("legacy-list", [
- "legacy@tests.mozilla.org",
- "unsigned_legacy@tests.mozilla.org",
- ]);
-
- await close_manager(mgrWin);
-
- // Now enable legacy extensions and open a new addons manager tab.
- // The remembered last view will be the list of legacy extensions but
- // now that legacy extensions are enabled, we should jump to the
- // regular Extensions list.
- await SpecialPowers.pushPrefEnv({
- set: [["extensions.legacy.enabled", true]],
- });
-
- mgrWin = await open_manager(null);
- is(
- mgrWin.gViewController.currentViewId,
- "addons://list/extension",
- "addons manager switched to extensions list"
- );
- await close_manager(mgrWin);
-});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_legacy_pre57.js b/toolkit/mozapps/extensions/test/browser/browser_legacy_pre57.js
deleted file mode 100644
index 5a0bbb1a71..0000000000
--- a/toolkit/mozapps/extensions/test/browser/browser_legacy_pre57.js
+++ /dev/null
@@ -1,104 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-// This test is testing XUL about:addons UI not implemented in the HTML about:addons,
-// it may be adapted or tested in a separate test file in Bug 1525184.
-SpecialPowers.pushPrefEnv({
- set: [["extensions.htmlaboutaddons.enabled", false]],
-});
-
-add_task(async function() {
- const INFO_URL =
- Services.urlFormatter.formatURLPref("app.support.baseURL") +
- "webextensions";
-
- const NAMES = {
- newTheme: "New LWT",
- legacy: "Legacy Extension",
- webextension: "WebExtension",
- dictionary: "Dictionary",
- langpack: "Language Pack",
- };
- let addons = [
- {
- id: "new-theme@tests.mozilla.org",
- name: NAMES.newTheme,
- type: "theme",
- isWebExtension: true,
- },
- {
- id: "legacy@tests.mozilla.org",
- name: NAMES.legacy,
- type: "extension",
- isWebExtension: false,
- },
- {
- id: "webextension@tests.mozilla.org",
- name: NAMES.webextension,
- type: "extension",
- isWebExtension: true,
- },
- {
- id: "dictionary@tests.mozilla.org",
- name: NAMES.dictionary,
- type: "dictionary",
- },
- ];
-
- let provider = new MockProvider();
- provider.createAddons(addons);
-
- let mgrWin = await open_manager(null);
- let catUtils = new CategoryUtilities(mgrWin);
-
- async function check(category, name, isLegacy) {
- await catUtils.openType(category);
-
- let document = mgrWin.document;
- // First find the entry in the list.
- let item = Array.from(
- document.getElementById("addon-list").childNodes
- ).find(i => i.getAttribute("name") == name);
-
- ok(item, `Found ${name} in list`);
- item.parentNode.ensureElementIsVisible(item);
-
- // Check the badge
- let badge = document.getAnonymousElementByAttribute(
- item,
- "anonid",
- "legacy"
- );
-
- if (isLegacy) {
- is_element_visible(badge, `Legacy badge is visible for ${name}`);
- is(badge.href, INFO_URL, "Legacy badge link is correct");
- } else {
- is_element_hidden(badge, `Legacy badge is hidden for ${name}`);
- }
-
- // Click down to the details page.
- EventUtils.synthesizeMouseAtCenter(item, {}, mgrWin);
- await new Promise(resolve => wait_for_view_load(mgrWin, resolve));
-
- // And check the badge
- let elements = document.getElementsByClassName("legacy-warning");
- is(elements.length, 1, "Found the legacy-warning element");
- badge = elements[0];
-
- if (isLegacy) {
- is_element_visible(badge, `Legacy badge is visible for ${name}`);
- is(badge.href, INFO_URL, "Legacy badge link is correct");
- } else {
- is_element_hidden(badge, `Legacy badge is hidden for ${name}`);
- }
- }
-
- await check("theme", NAMES.newTheme, false);
- await check("extension", NAMES.legacy, true);
- await check("extension", NAMES.webextension, false);
- await check("dictionary", NAMES.dictionary, false);
-
- await close_manager(mgrWin);
-});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_list.js b/toolkit/mozapps/extensions/test/browser/browser_list.js
deleted file mode 100644
index e063a5a376..0000000000
--- a/toolkit/mozapps/extensions/test/browser/browser_list.js
+++ /dev/null
@@ -1,1003 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-// Tests the list view
-
-const { AppConstants } = ChromeUtils.import(
- "resource://gre/modules/AppConstants.jsm"
-);
-
-const { PromiseTestUtils } = ChromeUtils.import(
- "resource://testing-common/PromiseTestUtils.jsm"
-);
-
-PromiseTestUtils.whitelistRejectionsGlobally(/this\._errorLink/);
-
-var gProvider;
-var gManagerWindow;
-var gCategoryUtilities;
-
-var gApp = document.getElementById("bundle_brand").getString("brandShortName");
-var gVersion = Services.appinfo.version;
-var gDate = new Date(2010, 7, 16);
-var infoURL =
- Services.urlFormatter.formatURLPref("app.support.baseURL") +
- "unsigned-addons";
-
-const EXPECTED_ADDONS = 11;
-
-// This test is testing XUL about:addons UI (the HTML about:addons has its
-// own test files for these test cases).
-SpecialPowers.pushPrefEnv({
- set: [["extensions.htmlaboutaddons.enabled", false]],
-});
-
-add_task(async function() {
- gProvider = new MockProvider();
-
- gProvider.createAddons([
- {
- id: "addon1@tests.mozilla.org",
- name: "Test add-on",
- version: "1.0",
- description: "A test add-on",
- longDescription: " A longer description",
- updateDate: gDate,
- },
- {
- id: "addon2@tests.mozilla.org",
- name: "Test add-on 2",
- version: "2.0",
- longDescription: " A longer description",
- _userDisabled: true,
- isActive: false,
- },
- {
- id: "addon3@tests.mozilla.org",
- name: "Test add-on 3",
- longDescription: " A longer description",
- isActive: false,
- isCompatible: false,
- appDisabled: true,
- permissions:
- AddonManager.PERM_CAN_ENABLE |
- AddonManager.PERM_CAN_DISABLE |
- AddonManager.PERM_CAN_UPGRADE,
- },
- {
- id: "addon5@tests.mozilla.org",
- blocklistURL: "http://example.com/addon5@tests.mozilla.org",
- name: "Test add-on 5",
- isActive: false,
- blocklistState: Ci.nsIBlocklistService.STATE_BLOCKED,
- appDisabled: true,
- },
- {
- id: "addon6@tests.mozilla.org",
- blocklistURL: "http://example.com/addon6@tests.mozilla.org",
- name: "Test add-on 6",
- operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE,
- },
- {
- id: "addon8@tests.mozilla.org",
- blocklistURL: "http://example.com/addon8@tests.mozilla.org",
- name: "Test add-on 8",
- blocklistState: Ci.nsIBlocklistService.STATE_VULNERABLE_UPDATE_AVAILABLE,
- },
- {
- id: "addon9@tests.mozilla.org",
- blocklistURL: "http://example.com/addon9@tests.mozilla.org",
- name: "Test add-on 9",
- blocklistState: Ci.nsIBlocklistService.STATE_VULNERABLE_NO_UPDATE,
- },
- {
- id: "addon10@tests.mozilla.org",
- name: "Test add-on 10",
- signedState: AddonManager.SIGNEDSTATE_MISSING,
- },
- {
- id: "addon11@tests.mozilla.org",
- name: "Test add-on 11",
- signedState: AddonManager.SIGNEDSTATE_MISSING,
- isActive: false,
- isCompatible: false,
- appDisabled: true,
- },
- {
- id: "addon12@tests.mozilla.org",
- name: "Test add-on 12",
- signedState: AddonManager.SIGNEDSTATE_PRELIMINARY,
- foreignInstall: true,
- },
- {
- id: "addon13@tests.mozilla.org",
- name: "Test add-on 13",
- signedState: AddonManager.SIGNEDSTATE_SIGNED,
- foreignInstall: true,
- },
- {
- id: "addon15@tests.mozilla.org",
- name: "Test add-on 15",
- hidden: true,
- },
- ]);
-
- gManagerWindow = await open_manager(null);
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
-});
-
-function get_test_items() {
- var tests = "@tests.mozilla.org";
-
- var items = {};
- var item = gManagerWindow.document.getElementById("addon-list").firstChild;
-
- while (item) {
- if (
- item.mAddon.id.substring(item.mAddon.id.length - tests.length) == tests &&
- !BrowserTestUtils.is_hidden(item)
- ) {
- items[item.mAddon.name] = item;
- }
- item = item.nextSibling;
- }
-
- return items;
-}
-
-function get_node(parent, anonid) {
- return parent.ownerDocument.getAnonymousElementByAttribute(
- parent,
- "anonid",
- anonid
- );
-}
-
-function get_class_node(parent, cls) {
- return parent.ownerDocument.getAnonymousElementByAttribute(
- parent,
- "class",
- cls
- );
-}
-
-// Check that the list appears to have displayed correctly and trigger some
-// changes
-add_task(async function() {
- await gCategoryUtilities.openType("extension");
- let items = get_test_items();
- is(
- Object.keys(items).length,
- EXPECTED_ADDONS,
- "Should be the right number of add-ons installed"
- );
-
- info("Addon 3");
- let addon = items["Test add-on 3"];
- addon.parentNode.ensureElementIsVisible(addon);
- let { name, version } = await get_tooltip_info(addon);
- is(
- get_node(addon, "name").textContent,
- "Test add-on 3",
- "Name should be correct"
- );
- is(name, "Test add-on 3", "Tooltip name should be correct");
- is(version, undefined, "Tooltip version should be hidden");
-
- is_element_hidden(
- get_node(addon, "preferences-btn"),
- "Preferences button should be hidden"
- );
- is_element_hidden(
- get_node(addon, "enable-btn"),
- "Enable button should be hidden"
- );
- is_element_hidden(
- get_node(addon, "disable-btn"),
- "Disable button should be hidden"
- );
- is_element_hidden(
- get_node(addon, "remove-btn"),
- "Remove button should be hidden"
- );
-
- is_element_visible(
- get_node(addon, "warning"),
- "Warning message should be visible"
- );
- is(
- get_node(addon, "warning").textContent,
- "Test add-on 3 is incompatible with " + gApp + " " + gVersion + ".",
- "Warning message should be correct"
- );
- is_element_hidden(
- get_node(addon, "warning-link"),
- "Warning link should be hidden"
- );
- is_element_hidden(get_node(addon, "error"), "Error message should be hidden");
- is_element_hidden(
- get_node(addon, "error-link"),
- "Error link should be hidden"
- );
- is_element_hidden(
- get_node(addon, "pending"),
- "Pending message should be hidden"
- );
-
- info("Addon 5");
- addon = items["Test add-on 5"];
- addon.parentNode.ensureElementIsVisible(addon);
- await TestUtils.waitForCondition(
- () => !BrowserTestUtils.is_hidden(get_node(addon, "error-link"))
- );
- ({ name, version } = await get_tooltip_info(addon));
- is(
- get_node(addon, "name").textContent,
- "Test add-on 5",
- "Name should be correct"
- );
- is(name, "Test add-on 5", "Tooltip name should be correct");
-
- is_element_hidden(
- get_node(addon, "preferences-btn"),
- "Preferences button should be hidden"
- );
- is_element_hidden(
- get_node(addon, "enable-btn"),
- "Enable button should be hidden"
- );
- is_element_hidden(
- get_node(addon, "disable-btn"),
- "Disable button should be hidden"
- );
- is_element_visible(
- get_node(addon, "remove-btn"),
- "Remove button should be visible"
- );
-
- is_element_hidden(
- get_node(addon, "warning"),
- "Warning message should be hidden"
- );
- is_element_hidden(
- get_node(addon, "warning-link"),
- "Warning link should be hidden"
- );
- is_element_visible(
- get_node(addon, "error"),
- "Error message should be visible"
- );
- is(
- get_node(addon, "error").textContent,
- "Test add-on 5 has been disabled due to security or stability issues.",
- "Error message should be correct"
- );
- is_element_visible(
- get_node(addon, "error-link"),
- "Error link should be visible"
- );
- is(
- get_node(addon, "error-link").value,
- "More Information",
- "Error link text should be correct"
- );
- is(
- get_node(addon, "error-link").href,
- "http://example.com/addon5@tests.mozilla.org",
- "Error link should be correct"
- );
- is_element_hidden(
- get_node(addon, "pending"),
- "Pending message should be hidden"
- );
-
- info("Addon 6");
- addon = items["Test add-on 6"];
- addon.parentNode.ensureElementIsVisible(addon);
- ({ name, version } = await get_tooltip_info(addon));
- is(
- get_node(addon, "name").textContent,
- "Test add-on 6",
- "Name should be correct"
- );
- is(name, "Test add-on 6", "Tooltip name should be correct");
- is_element_hidden(
- get_class_node(addon, "disabled-postfix"),
- "Disabled postfix should be hidden"
- );
-
- is_element_hidden(
- get_node(addon, "preferences-btn"),
- "Preferences button should be hidden"
- );
- is_element_hidden(
- get_node(addon, "enable-btn"),
- "Enable button should be hidden"
- );
- is_element_visible(
- get_node(addon, "disable-btn"),
- "Disable button should be visible"
- );
- is_element_visible(
- get_node(addon, "remove-btn"),
- "Remove button should be visible"
- );
-
- is_element_hidden(
- get_node(addon, "warning"),
- "Warning message should be hidden"
- );
- is_element_hidden(
- get_node(addon, "warning-link"),
- "Warning link should be hidden"
- );
- is_element_hidden(
- get_node(addon, "error"),
- "Error message should be visible"
- );
- is_element_hidden(
- get_node(addon, "error-link"),
- "Error link should be hidden"
- );
- is_element_hidden(
- get_node(addon, "pending"),
- "Pending message should be hidden"
- );
-
- info("Disabling");
- EventUtils.synthesizeMouseAtCenter(
- get_node(addon, "disable-btn"),
- {},
- gManagerWindow
- );
- await new Promise(executeSoon);
- is_element_visible(
- get_class_node(addon, "disabled-postfix"),
- "Disabled postfix should be visible"
- );
-
- is_element_hidden(
- get_node(addon, "preferences-btn"),
- "Preferences button should be hidden"
- );
- is_element_visible(
- get_node(addon, "enable-btn"),
- "Enable button should be visible"
- );
- is_element_hidden(
- get_node(addon, "disable-btn"),
- "Disable button should be hidden"
- );
- is_element_visible(
- get_node(addon, "remove-btn"),
- "Remove button should be visible"
- );
-
- is_element_hidden(
- get_node(addon, "warning"),
- "Warning message should be hidden"
- );
- is_element_hidden(
- get_node(addon, "warning-link"),
- "Warning link should be hidden"
- );
- is_element_hidden(
- get_node(addon, "error"),
- "Error message should be visible"
- );
- is_element_hidden(
- get_node(addon, "error-link"),
- "Error link should be hidden"
- );
- is_element_hidden(
- get_node(addon, "pending"),
- "Pending message should be hidden"
- );
-
- info("Addon 8");
- addon = items["Test add-on 8"];
- addon.parentNode.ensureElementIsVisible(addon);
- await TestUtils.waitForCondition(
- () => !BrowserTestUtils.is_hidden(get_node(addon, "error-link"))
- );
- ({ name, version } = await get_tooltip_info(addon));
- is(
- get_node(addon, "name").textContent,
- "Test add-on 8",
- "Name should be correct"
- );
- is(name, "Test add-on 8", "Tooltip name should be correct");
-
- is_element_hidden(
- get_node(addon, "preferences-btn"),
- "Preferences button should be hidden"
- );
- is_element_hidden(
- get_node(addon, "enable-btn"),
- "Enable button should be hidden"
- );
- is_element_visible(
- get_node(addon, "disable-btn"),
- "Disable button should be visible"
- );
- is_element_visible(
- get_node(addon, "remove-btn"),
- "Remove button should be visible"
- );
-
- is_element_hidden(
- get_node(addon, "warning"),
- "Warning message should be hidden"
- );
- is_element_hidden(
- get_node(addon, "warning-link"),
- "Warning link should be hidden"
- );
- is_element_visible(
- get_node(addon, "error"),
- "Error message should be visible"
- );
- is(
- get_node(addon, "error").textContent,
- "Test add-on 8 is known to be vulnerable and should be updated.",
- "Error message should be correct"
- );
- is_element_visible(
- get_node(addon, "error-link"),
- "Error link should be visible"
- );
- is(
- get_node(addon, "error-link").value,
- "Update Now",
- "Error link text should be correct"
- );
- is(
- get_node(addon, "error-link").href,
- "http://example.com/addon8@tests.mozilla.org",
- "Error link should be correct"
- );
- is_element_hidden(
- get_node(addon, "pending"),
- "Pending message should be hidden"
- );
-
- info("Addon 9");
- addon = items["Test add-on 9"];
- addon.parentNode.ensureElementIsVisible(addon);
- await TestUtils.waitForCondition(
- () => !BrowserTestUtils.is_hidden(get_node(addon, "error-link"))
- );
- ({ name, version } = await get_tooltip_info(addon));
- is(
- get_node(addon, "name").textContent,
- "Test add-on 9",
- "Name should be correct"
- );
- is(name, "Test add-on 9", "Tooltip name should be correct");
-
- is_element_hidden(
- get_node(addon, "preferences-btn"),
- "Preferences button should be hidden"
- );
- is_element_hidden(
- get_node(addon, "enable-btn"),
- "Enable button should be hidden"
- );
- is_element_visible(
- get_node(addon, "disable-btn"),
- "Disable button should be visible"
- );
- is_element_visible(
- get_node(addon, "remove-btn"),
- "Remove button should be visible"
- );
-
- is_element_hidden(
- get_node(addon, "warning"),
- "Warning message should be hidden"
- );
- is_element_hidden(
- get_node(addon, "warning-link"),
- "Warning link should be hidden"
- );
- is_element_visible(
- get_node(addon, "error"),
- "Error message should be visible"
- );
- is(
- get_node(addon, "error").textContent,
- "Test add-on 9 is known to be vulnerable. Use with caution.",
- "Error message should be correct"
- );
- is_element_visible(
- get_node(addon, "error-link"),
- "Error link should be visible"
- );
- is(
- get_node(addon, "error-link").value,
- "More Information",
- "Error link text should be correct"
- );
- is(
- get_node(addon, "error-link").href,
- "http://example.com/addon9@tests.mozilla.org",
- "Error link should be correct"
- );
- is_element_hidden(
- get_node(addon, "pending"),
- "Pending message should be hidden"
- );
-
- info("Addon 10");
- addon = items["Test add-on 10"];
- addon.parentNode.ensureElementIsVisible(addon);
- ({ name, version } = await get_tooltip_info(addon));
- is(
- get_node(addon, "name").textContent,
- "Test add-on 10",
- "Name should be correct"
- );
- is(name, "Test add-on 10", "Tooltip name should be correct");
-
- is_element_hidden(
- get_node(addon, "preferences-btn"),
- "Preferences button should be hidden"
- );
- is_element_hidden(
- get_node(addon, "enable-btn"),
- "Enable button should be hidden"
- );
- is_element_visible(
- get_node(addon, "disable-btn"),
- "Disable button should be visible"
- );
- is_element_visible(
- get_node(addon, "remove-btn"),
- "Remove button should be visible"
- );
-
- is_element_visible(
- get_node(addon, "warning"),
- "Warning message should be visible"
- );
- is(
- get_node(addon, "warning").textContent,
- "Test add-on 10 could not be verified for use in " +
- gApp +
- ". Proceed with caution.",
- "Warning message should be correct"
- );
- is_element_visible(
- get_node(addon, "warning-link"),
- "Warning link should be visible"
- );
- is(
- get_node(addon, "warning-link").value,
- "More Information",
- "Warning link text should be correct"
- );
- is(
- get_node(addon, "warning-link").href,
- infoURL,
- "Warning link should be correct"
- );
- is_element_hidden(
- get_node(addon, "error"),
- "Error message should be hidden"
- );
- is_element_hidden(
- get_node(addon, "error-link"),
- "Error link should be hidden"
- );
- is_element_hidden(
- get_node(addon, "pending"),
- "Pending message should be hidden"
- );
-
- info("Addon 11");
- addon = items["Test add-on 11"];
- addon.parentNode.ensureElementIsVisible(addon);
- ({ name, version } = await get_tooltip_info(addon));
- is(
- get_node(addon, "name").textContent,
- "Test add-on 11",
- "Name should be correct"
- );
- is(name, "Test add-on 11", "Tooltip name should be correct");
-
- is_element_hidden(
- get_node(addon, "preferences-btn"),
- "Preferences button should be hidden"
- );
- is_element_hidden(
- get_node(addon, "enable-btn"),
- "Enable button should be hidden"
- );
- is_element_hidden(
- get_node(addon, "disable-btn"),
- "Disable button should be hidden"
- );
- is_element_visible(
- get_node(addon, "remove-btn"),
- "Remove button should be visible"
- );
-
- is_element_visible(
- get_node(addon, "warning"),
- "Warning message should be visible"
- );
- is(
- get_node(addon, "warning").textContent,
- "Test add-on 11 is incompatible with " + gApp + " " + gVersion + ".",
- "Warning message should be correct"
- );
- is_element_hidden(
- get_node(addon, "warning-link"),
- "Warning link should be hidden"
- );
- is_element_hidden(
- get_node(addon, "error"),
- "Error message should be hidden"
- );
- is_element_hidden(
- get_node(addon, "error-link"),
- "Error link should be hidden"
- );
- is_element_hidden(
- get_node(addon, "pending"),
- "Pending message should be hidden"
- );
-
- let showAllButton = gManagerWindow.document.getElementById(
- "show-all-extensions"
- );
- is_element_hidden(
- showAllButton,
- "Button for showing all extensions should be hidden"
- );
- is_element_hidden(signingInfoUI, "Signing info UI should be hidden");
-});
-
-// Reload the list to make sure the changes are still pending and that undoing
-// works
-add_task(async function() {
- await gCategoryUtilities.openType("plugin");
- await gCategoryUtilities.openType("extension");
-
- let items = get_test_items();
- is(
- Object.keys(items).length,
- EXPECTED_ADDONS,
- "Should be the right number of add-ons installed"
- );
-
- info("Addon 6");
- let addon = items["Test add-on 6"];
- addon.parentNode.ensureElementIsVisible(addon);
- let { name } = await get_tooltip_info(addon);
- is(
- get_node(addon, "name").textContent,
- "Test add-on 6",
- "Name should be correct"
- );
- is(name, "Test add-on 6", "Tooltip name should be correct");
- is_element_visible(
- get_class_node(addon, "disabled-postfix"),
- "Disabled postfix should be visible"
- );
-
- is_element_hidden(
- get_node(addon, "preferences-btn"),
- "Preferences button should be hidden"
- );
- is_element_visible(
- get_node(addon, "enable-btn"),
- "Enable button should be visible"
- );
- is_element_hidden(
- get_node(addon, "disable-btn"),
- "Disable button should be hidden"
- );
- is_element_visible(
- get_node(addon, "remove-btn"),
- "Remove button should be visible"
- );
-
- is_element_hidden(
- get_node(addon, "warning"),
- "Warning message should be hidden"
- );
- is_element_hidden(
- get_node(addon, "warning-link"),
- "Warning link should be hidden"
- );
- is_element_hidden(
- get_node(addon, "error"),
- "Error message should be visible"
- );
- is_element_hidden(
- get_node(addon, "error-link"),
- "Error link should be hidden"
- );
- is_element_hidden(
- get_node(addon, "pending"),
- "Pending message should be hidden"
- );
-
- info("Enabling");
- EventUtils.synthesizeMouseAtCenter(
- get_node(addon, "enable-btn"),
- {},
- gManagerWindow
- );
- await new Promise(executeSoon);
- is_element_hidden(
- get_class_node(addon, "disabled-postfix"),
- "Disabled postfix should be hidden"
- );
-
- is_element_hidden(
- get_node(addon, "preferences-btn"),
- "Preferences button should be hidden"
- );
- is_element_hidden(
- get_node(addon, "enable-btn"),
- "Enable button should be hidden"
- );
- is_element_visible(
- get_node(addon, "disable-btn"),
- "Disable button should be visible"
- );
- is_element_visible(
- get_node(addon, "remove-btn"),
- "Remove button should be visible"
- );
-
- is_element_hidden(
- get_node(addon, "warning"),
- "Warning message should be hidden"
- );
- is_element_hidden(
- get_node(addon, "warning-link"),
- "Warning link should be hidden"
- );
- is_element_hidden(
- get_node(addon, "error"),
- "Error message should be visible"
- );
- is_element_hidden(
- get_node(addon, "error-link"),
- "Error link should be hidden"
- );
- is_element_hidden(
- get_node(addon, "pending"),
- "Pending message should be hidden"
- );
-});
-
-// Check that upgrades with onExternalInstall take effect immediately
-add_task(async function() {
- gProvider.createAddons([
- {
- id: "addon1@tests.mozilla.org",
- name: "Test add-on replacement",
- version: "2.0",
- description: "A test add-on with a new description",
- updateDate: gDate,
- operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE,
- },
- {
- id: "addon14@tests.mozilla.org",
- name: "Test add-on 14",
- hidden: true,
- },
- ]);
-
- let items = get_test_items();
- is(
- Object.keys(items).length,
- EXPECTED_ADDONS,
- "Should be the right number of add-ons installed"
- );
-
- let addon = items["Test add-on replacement"];
- addon.parentNode.ensureElementIsVisible(addon);
- let { name, version } = await get_tooltip_info(addon);
- is(
- get_node(addon, "name").textContent,
- "Test add-on replacement",
- "Name should be correct"
- );
- is(name, "Test add-on replacement", "Tooltip name should be correct");
- is(version, "2.0", "Tooltip version should be correct");
- is_element_hidden(
- get_class_node(addon, "disabled-postfix"),
- "Disabled postfix should be hidden"
- );
- is_element_hidden(
- get_class_node(addon, "update-postfix"),
- "Update postfix should be hidden"
- );
- is(
- get_node(addon, "date-updated").value,
- formatDate(gDate),
- "Update date should be correct"
- );
-
- is_element_hidden(
- get_node(addon, "preferences-btn"),
- "Preferences button should be hidden"
- );
- is_element_hidden(
- get_node(addon, "enable-btn"),
- "Enable button should be hidden"
- );
- is_element_visible(
- get_node(addon, "disable-btn"),
- "Disable button should be visible"
- );
- is_element_visible(
- get_node(addon, "remove-btn"),
- "Remove button should be visible"
- );
-
- is_element_hidden(
- get_node(addon, "warning"),
- "Warning message should be hidden"
- );
- is_element_hidden(
- get_node(addon, "warning-link"),
- "Warning link should be hidden"
- );
- is_element_hidden(get_node(addon, "error"), "Error message should be hidden");
- is_element_hidden(
- get_node(addon, "error-link"),
- "Error link should be hidden"
- );
- is_element_hidden(
- get_node(addon, "pending"),
- "Pending message should be hidden"
- );
-});
-
-// Check that focus changes correctly move around the selected list item
-add_task(async function() {
- function is_node_in_list(aNode) {
- var list = gManagerWindow.document.getElementById("addon-list");
-
- while (aNode && aNode != list) {
- aNode = aNode.parentNode;
- }
-
- if (aNode) {
- return true;
- }
- return false;
- }
-
- // Ignore the OSX full keyboard access setting
- Services.prefs.setBoolPref("accessibility.tabfocus_applies_to_xul", false);
-
- let items = get_test_items();
- is(
- Object.keys(items).length,
- EXPECTED_ADDONS,
- "Should be the right number of add-ons installed"
- );
-
- let addon = items["Test add-on 6"];
- addon.parentNode.ensureElementIsVisible(addon);
- addon.parentNode.focus();
- is(
- Services.focus.focusedElement,
- addon.parentNode,
- "Focus should have moved to the list"
- );
-
- EventUtils.synthesizeKey("VK_TAB", {}, gManagerWindow);
- is(
- Services.focus.focusedElement,
- get_node(addon, "disable-btn"),
- "Focus should have moved to the disable button"
- );
-
- EventUtils.synthesizeKey("VK_TAB", {}, gManagerWindow);
- is(
- Services.focus.focusedElement,
- get_node(addon, "remove-btn"),
- "Focus should have moved to the remove button"
- );
-
- EventUtils.synthesizeKey("VK_TAB", {}, gManagerWindow);
- ok(
- !is_node_in_list(Services.focus.focusedElement),
- "Focus should be outside the list"
- );
-
- EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }, gManagerWindow);
- is(
- Services.focus.focusedElement,
- get_node(addon, "remove-btn"),
- "Focus should have moved to the remove button"
- );
-
- EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }, gManagerWindow);
- is(
- Services.focus.focusedElement,
- get_node(addon, "disable-btn"),
- "Focus should have moved to the disable button"
- );
-
- EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }, gManagerWindow);
- is(
- Services.focus.focusedElement,
- addon.parentNode,
- "Focus should have moved to the list"
- );
-
- EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }, gManagerWindow);
- ok(
- !is_node_in_list(Services.focus.focusedElement),
- "Focus should be outside the list"
- );
-
- try {
- Services.prefs.clearUserPref("accessibility.tabfocus_applies_to_xul");
- } catch (e) {}
-});
-
-// Check that onPropertyChanges for appDisabled updates the UI
-add_task(async function() {
- info("Checking that onPropertyChanges for appDisabled updates the UI");
-
- let [aAddon] = await promiseAddonsByIDs(["addon2@tests.mozilla.org"]);
- await aAddon.disable();
- aAddon.isCompatible = true;
- aAddon.appDisabled = false;
-
- gManagerWindow.loadView("addons://list/extension");
- await new Promise(resolve => wait_for_view_load(gManagerWindow, resolve));
- var el = get_addon_element(gManagerWindow, "addon2@tests.mozilla.org");
-
- is(
- el.getAttribute("active"),
- "false",
- "Addon should not be marked as active"
- );
- is_element_hidden(
- get_node(el, "warning"),
- "Warning message should not be visible"
- );
-
- info("Making addon incompatible and appDisabled");
- aAddon.isCompatible = false;
- aAddon.appDisabled = true;
-
- is(
- el.getAttribute("active"),
- "false",
- "Addon should not be marked as active"
- );
- is_element_visible(
- get_node(el, "warning"),
- "Warning message should be visible"
- );
- is(
- get_node(el, "warning").textContent,
- "Test add-on 2 is incompatible with " + gApp + " " + gVersion + ".",
- "Warning message should be correct"
- );
-});
-
-add_task(async function() {
- is(
- gManagerWindow.document.getElementById("helpButton").href,
- Services.urlFormatter.formatURLPref("app.support.baseURL") + "addons-help",
- "The help link is setup correctly"
- );
-});
-
-add_task(async function() {
- return close_manager(gManagerWindow);
-});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_manage_shortcuts.js b/toolkit/mozapps/extensions/test/browser/browser_manage_shortcuts.js
index c09ed9f82f..8f1fb7ce16 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_manage_shortcuts.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_manage_shortcuts.js
@@ -5,27 +5,41 @@ const { PromiseTestUtils } = ChromeUtils.import(
);
PromiseTestUtils.whitelistRejectionsGlobally(/Message manager disconnected/);
-let gManagerWindow;
-
-async function loadShortcutsView() {
- gManagerWindow = await open_manager(null);
- let categoryUtilities = new CategoryUtilities(gManagerWindow);
- await categoryUtilities.openType("extension");
-
- // There should be a manage shortcuts link.
- let doc = gManagerWindow.document;
- let shortcutsLink = doc.getElementById("manage-shortcuts");
- ok(!shortcutsLink.hidden, "The shortcuts link is visible");
-
- // Open the shortcuts view.
- shortcutsLink.click();
- await wait_for_view_load(gManagerWindow);
-
- return doc.getElementById("shortcuts-view").contentDocument;
+function extensionShortcutsReady(id) {
+ let extension = WebExtensionPolicy.getByID(id).extension;
+ return BrowserTestUtils.waitForCondition(() => {
+ return extension.shortcuts.keysetsMap.has(window);
+ }, "Wait for add-on keyset to be registered");
}
-function closeView() {
- return close_manager(gManagerWindow);
+async function loadShortcutsView() {
+ // Load the theme view initially so we can verify that the category is switched
+ // to "extension" when the shortcuts view is loaded.
+ let win = await loadInitialView("theme");
+ let { managerWindow } = win;
+
+ is(
+ managerWindow.gCategories.node.value,
+ "addons://list/theme",
+ "The theme category is selected"
+ );
+
+ let shortcutsLink = win.document.querySelector(
+ '#page-options [action="manage-shortcuts"]'
+ );
+ ok(!shortcutsLink.hidden, "The shortcuts link is visible");
+
+ let loaded = waitForViewLoad(win);
+ shortcutsLink.click();
+ await loaded;
+
+ is(
+ managerWindow.gCategories.node.value,
+ "addons://list/extension",
+ "The extension category is now selected"
+ );
+
+ return win;
}
add_task(async function testUpdatingCommands() {
@@ -58,6 +72,7 @@ add_task(async function testUpdatingCommands() {
await extension.startup();
await extension.awaitMessage("ready");
+ await extensionShortcutsReady(extension.id);
async function checkShortcut(name, key, modifiers) {
EventUtils.synthesizeKey(key, modifiers);
@@ -73,7 +88,8 @@ add_task(async function testUpdatingCommands() {
await checkShortcut("commandOne", "7", { shiftKey: true, altKey: true });
await checkShortcut("commandTwo", "4", { altKey: true });
- let doc = await loadShortcutsView();
+ let win = await loadShortcutsView();
+ let doc = win.document;
let card = doc.querySelector(`.card[addon-id="${extension.id}"]`);
ok(card, `There is a card for the extension`);
@@ -101,7 +117,8 @@ add_task(async function testUpdatingCommands() {
// Wait for the shortcut attribute to change.
await BrowserTestUtils.waitForCondition(
- () => input.getAttribute("shortcut") == "Alt+Shift+8"
+ () => input.getAttribute("shortcut") == "Alt+Shift+8",
+ "Wait for shortcut to update to Alt+Shift+8"
);
// Check that the change worked (but skip if browserAction).
@@ -119,7 +136,8 @@ add_task(async function testUpdatingCommands() {
altKey: true,
});
await BrowserTestUtils.waitForCondition(
- () => input.getAttribute("shortcut") == `Alt+Shift+${count}`
+ () => input.getAttribute("shortcut") == `Alt+Shift+${count}`,
+ `Wait for shortcut to update to Alt+Shift+${count}`
);
}
@@ -162,7 +180,7 @@ add_task(async function testUpdatingCommands() {
checkLabel("commandTwo", "Command Two!");
checkLabel("_execute_browser_action", "shortcuts-browserAction");
- await closeView();
+ await closeView(win);
await extension.unload();
});
@@ -185,6 +203,7 @@ async function startExtensionWithCommands(numCommands) {
await extension.startup();
await extension.awaitMessage("ready");
+ await extensionShortcutsReady(extension.id);
return extension;
}
@@ -195,7 +214,8 @@ add_task(async function testExpanding() {
let extension = await startExtensionWithCommands(numCommands);
- let doc = await loadShortcutsView();
+ let win = await loadShortcutsView();
+ let doc = win.document;
let card = doc.querySelector(`.card[addon-id="${extension.id}"]`);
ok(!card.hasAttribute("expanded"), "The card is not expanded");
@@ -254,7 +274,7 @@ add_task(async function testExpanding() {
assertCollapsedVisibility({ collapsed: true });
- await closeView();
+ await closeView(win);
await extension.unload();
});
@@ -262,7 +282,8 @@ add_task(async function testOneExtraCommandIsNotCollapsed() {
const numCommands = 6;
let extension = await startExtensionWithCommands(numCommands);
- let doc = await loadShortcutsView();
+ let win = await loadShortcutsView();
+ let doc = win.document;
// The card is not expanded, since it doesn't collapse.
let card = doc.querySelector(`.card[addon-id="${extension.id}"]`);
@@ -281,6 +302,6 @@ add_task(async function testOneExtraCommandIsNotCollapsed() {
ok(getComputedStyle(row).display != "none", "All the rows are visible");
}
- await closeView();
+ await closeView(win);
await extension.unload();
});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_manage_shortcuts_hidden.js b/toolkit/mozapps/extensions/test/browser/browser_manage_shortcuts_hidden.js
index 586eaffa56..d88a9de446 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_manage_shortcuts_hidden.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_manage_shortcuts_hidden.js
@@ -5,7 +5,8 @@ async function loadShortcutsView() {
let managerWin = await open_manager(null);
managerWin.gViewController.loadView("addons://shortcuts/shortcuts");
await wait_for_view_load(managerWin);
- return managerWin.document.getElementById("shortcuts-view").contentDocument;
+ return managerWin.document.getElementById("html-view-browser")
+ .contentDocument;
}
async function closeShortcutsView(doc) {
@@ -32,6 +33,7 @@ async function registerAndStartExtension(mockProvider, ext) {
// We use MockProvider because the "hidden" property cannot
// be set when "useAddonManager" is passed to loadExtension.
hidden: ext.manifest.hidden,
+ isSystem: ext.isSystem,
},
]);
return extension;
@@ -148,3 +150,50 @@ add_task(async function hidden_extension() {
mockProvider.unregister();
});
+
+add_task(async function system_addons_and_shortcuts() {
+ let mockProvider = new MockProvider();
+ let systemExt1 = await registerAndStartExtension(mockProvider, {
+ isSystem: true,
+ manifest: {
+ name: "system with shortcuts",
+ // In practice, all XPIStateLocations with isSystem=true also have
+ // isBuiltin=true, which implies that hidden=true as well.
+ hidden: true,
+ commands: {
+ systemShortcut: {},
+ },
+ },
+ });
+ let systemExt2 = await registerAndStartExtension(mockProvider, {
+ isSystem: true,
+ manifest: {
+ name: "system without shortcuts",
+ hidden: true,
+ },
+ });
+
+ let doc = await loadShortcutsView();
+
+ ok(
+ getShortcutByName(doc, systemExt1, "systemShortcut"),
+ "System add-on with shortcut should have a card"
+ );
+
+ is(
+ getShortcutCard(doc, systemExt2),
+ null,
+ "System add-on without shortcut should not have a card"
+ );
+ is(
+ getNoShortcutListItem(doc, systemExt2),
+ null,
+ "System add-on without shortcuts should not be listed"
+ );
+
+ await closeShortcutsView(doc);
+ await systemExt1.unload();
+ await systemExt2.unload();
+
+ mockProvider.unregister();
+});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_manualupdates.js b/toolkit/mozapps/extensions/test/browser/browser_manualupdates.js
deleted file mode 100644
index 1d7a7397b4..0000000000
--- a/toolkit/mozapps/extensions/test/browser/browser_manualupdates.js
+++ /dev/null
@@ -1,385 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-// Tests manual updates, including the Available Updates pane
-
-var gProvider;
-var gManagerWindow;
-var gCategoryUtilities;
-var gAvailableCategory;
-
-// This test is testing XUL about:addons UI (the HTML about:addons has its
-// own test files for these test cases).
-SpecialPowers.pushPrefEnv({
- set: [["extensions.htmlaboutaddons.enabled", false]],
-});
-
-async function test() {
- waitForExplicitFinish();
-
- gProvider = new MockProvider();
-
- gProvider.createAddons([
- {
- id: "addon1@tests.mozilla.org",
- name: "auto updating addon",
- version: "1.0",
- applyBackgroundUpdates: AddonManager.AUTOUPDATE_ENABLE,
- },
- ]);
-
- let aWindow = await open_manager("addons://list/extension");
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- run_next_test();
-}
-
-async function end_test() {
- await close_manager(gManagerWindow);
- finish();
-}
-
-add_test(function() {
- gAvailableCategory = gManagerWindow.gCategories.get(
- "addons://updates/available"
- );
- is(
- gCategoryUtilities.isVisible(gAvailableCategory),
- false,
- "Available Updates category should initially be hidden"
- );
-
- gProvider.createAddons([
- {
- id: "addon2@tests.mozilla.org",
- name: "manually updating addon",
- version: "1.0",
- isCompatible: false,
- operationsRequiringRestart: 0,
- blocklistState: Ci.nsIBlocklistService.STATE_BLOCKED,
- applyBackgroundUpdates: AddonManager.AUTOUPDATE_DISABLE,
- },
- ]);
-
- is(
- gCategoryUtilities.isVisible(gAvailableCategory),
- false,
- "Available Updates category should still be hidden"
- );
-
- run_next_test();
-});
-
-add_test(async function() {
- let finished = 0;
- function maybeRunNext() {
- if (++finished == 2) {
- run_next_test();
- }
- }
-
- gAvailableCategory.addEventListener(
- "CategoryBadgeUpdated",
- function() {
- is(
- gCategoryUtilities.isVisible(gAvailableCategory),
- true,
- "Available Updates category should now be visible"
- );
- is(
- gAvailableCategory.badgeCount,
- 1,
- "Badge for Available Updates should now be 1"
- );
- maybeRunNext();
- },
- { once: true }
- );
-
- await gCategoryUtilities.openType("extension");
- gProvider.createInstalls([
- {
- name: "manually updating addon (new and improved!)",
- existingAddon: gProvider.addons[1],
- version: "1.1",
- releaseNotesURI: Services.io.newURI(TESTROOT + "thereIsNoFileHere.xhtml"),
- },
- ]);
-
- var item = get_addon_element(gManagerWindow, "addon2@tests.mozilla.org");
- get_tooltip_info(item).then(({ version }) => {
- is(version, "1.0", "Should still show the old version in the tooltip");
- maybeRunNext();
- });
-});
-
-add_test(async function() {
- Promise.resolve().then(() => {
- EventUtils.synthesizeMouseAtCenter(gAvailableCategory, {}, gManagerWindow);
- });
- await wait_for_view_load(gManagerWindow, null, true);
- is(
- gManagerWindow.document.getElementById("categories").selectedItem.value,
- "addons://updates/available",
- "Available Updates category should now be selected"
- );
- is(
- gManagerWindow.gViewController.currentViewId,
- "addons://updates/available",
- "Available Updates view should be the current view"
- );
- run_next_test();
-});
-
-add_test(async function() {
- var list = gManagerWindow.document.getElementById("updates-list");
- is(list.itemCount, 1, "Should be 1 available update listed");
- var item = list.firstChild;
- is(
- item.mAddon.id,
- "addon2@tests.mozilla.org",
- "Update item should be for the manually updating addon"
- );
-
- // The item in the list will be checking for update information asynchronously
- // so we have to wait for it to complete. Doing the same async request should
- // make our callback be called later.
- await AddonManager.getAllInstalls();
- run_next_test();
-});
-
-add_test(function() {
- var list = gManagerWindow.document.getElementById("updates-list");
- var item = list.firstChild;
- get_tooltip_info(item).then(({ version }) => {
- is(version, "1.1", "Update item should have version number of the update");
- var postfix = gManagerWindow.document.getAnonymousElementByAttribute(
- item,
- "class",
- "update-postfix"
- );
- is_element_visible(postfix, "'Update' postfix should be visible");
- is_element_visible(item._updateAvailable, "");
- is_element_visible(
- item._relNotesToggle,
- "Release notes toggle should be visible"
- );
- is_element_hidden(item._warning, "Incompatible warning should be hidden");
- is_element_hidden(item._error, "Blocklist error should be hidden");
-
- info("Opening release notes");
- item.addEventListener(
- "RelNotesToggle",
- function() {
- info("Release notes now open");
-
- is_element_hidden(
- item._relNotesLoading,
- "Release notes loading message should be hidden"
- );
- is_element_visible(
- item._relNotesError,
- "Release notes error message should be visible"
- );
- is(
- item._relNotes.childElementCount,
- 0,
- "Release notes should be empty"
- );
-
- info("Closing release notes");
- item.addEventListener(
- "RelNotesToggle",
- function() {
- info("Release notes now closed");
- info("Setting Release notes URI to something that should load");
- gProvider.installs[0].releaseNotesURI = Services.io.newURI(
- TESTROOT + "releaseNotes.xhtml"
- );
-
- info("Re-opening release notes");
- item.addEventListener(
- "RelNotesToggle",
- function() {
- info("Release notes now open");
-
- is_element_hidden(
- item._relNotesLoading,
- "Release notes loading message should be hidden"
- );
- is_element_hidden(
- item._relNotesError,
- "Release notes error message should be hidden"
- );
- isnot(
- item._relNotes.childElementCount,
- 0,
- "Release notes should have been inserted into container"
- );
-
- run_next_test();
- },
- { once: true }
- );
- EventUtils.synthesizeMouseAtCenter(
- item._relNotesToggle,
- {},
- gManagerWindow
- );
- is_element_visible(
- item._relNotesLoading,
- "Release notes loading message should be visible"
- );
- },
- { once: true }
- );
- EventUtils.synthesizeMouseAtCenter(
- item._relNotesToggle,
- {},
- gManagerWindow
- );
- },
- { once: true }
- );
- EventUtils.synthesizeMouseAtCenter(
- item._relNotesToggle,
- {},
- gManagerWindow
- );
- is_element_visible(
- item._relNotesLoading,
- "Release notes loading message should be visible"
- );
- });
-});
-
-add_test(function() {
- var badgeUpdated = false;
- var installCompleted = false;
-
- gAvailableCategory.addEventListener(
- "CategoryBadgeUpdated",
- function() {
- if (installCompleted) {
- run_next_test();
- } else {
- badgeUpdated = true;
- }
- },
- { once: true }
- );
-
- var list = gManagerWindow.document.getElementById("updates-list");
- var item = list.firstChild;
- var updateBtn = item._updateBtn;
- is_element_visible(updateBtn, "Update button should be visible");
-
- var install = gProvider.installs[0];
- var listener = {
- onInstallStarted() {
- info("Install started");
- is_element_visible(
- item._installStatus,
- "Install progress widget should be visible"
- );
- },
- onInstallEnded(...args) {
- install.removeTestListener(this);
- info("Install ended");
- is_element_hidden(
- item._installStatus,
- "Install progress widget should be hidden"
- );
-
- if (badgeUpdated) {
- run_next_test();
- } else {
- installCompleted = true;
- }
- },
- };
- install.addTestListener(listener);
- EventUtils.synthesizeMouseAtCenter(updateBtn, {}, gManagerWindow);
-});
-
-add_test(async function() {
- is(
- gCategoryUtilities.isVisible(gAvailableCategory),
- true,
- "Available Updates category should still be visible"
- );
- is(
- gAvailableCategory.badgeCount,
- 0,
- "Badge for Available Updates should now be 0"
- );
-
- await gCategoryUtilities.openType("extension");
- is(
- gCategoryUtilities.isVisible(gAvailableCategory),
- false,
- "Available Updates category should be hidden"
- );
-
- await close_manager(gManagerWindow);
- let aWindow = await open_manager(null);
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- gAvailableCategory = gManagerWindow.gCategories.get(
- "addons://updates/available"
- );
-
- is(
- gCategoryUtilities.isVisible(gAvailableCategory),
- false,
- "Available Updates category should be hidden"
- );
-
- run_next_test();
-});
-
-add_test(function() {
- gAvailableCategory.addEventListener(
- "CategoryBadgeUpdated",
- async function() {
- is(
- gCategoryUtilities.isVisible(gAvailableCategory),
- true,
- "Available Updates category should now be visible"
- );
- is(
- gAvailableCategory.badgeCount,
- 1,
- "Badge for Available Updates should now be 1"
- );
-
- gAvailableCategory.addEventListener(
- "CategoryBadgeUpdated",
- function() {
- is(
- gCategoryUtilities.isVisible(gAvailableCategory),
- false,
- "Available Updates category should now be hidden"
- );
-
- run_next_test();
- },
- { once: true }
- );
-
- let aAddon = await AddonManager.getAddonByID("addon2@tests.mozilla.org");
- aAddon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_ENABLE;
- },
- { once: true }
- );
-
- gProvider.createInstalls([
- {
- name: "manually updating addon (new and even more improved!)",
- existingAddon: gProvider.addons[1],
- version: "1.2",
- releaseNotesURI: Services.io.newURI(TESTROOT + "thereIsNoFileHere.xhtml"),
- },
- ]);
-});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_menu_button_accessibility.js b/toolkit/mozapps/extensions/test/browser/browser_menu_button_accessibility.js
new file mode 100644
index 0000000000..5433ddcc77
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/browser/browser_menu_button_accessibility.js
@@ -0,0 +1,81 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+async function testOpenMenu(btn, method) {
+ let shown = BrowserTestUtils.waitForEvent(btn.ownerGlobal, "shown", true);
+ await method();
+ await shown;
+ is(btn.getAttribute("aria-expanded"), "true", "expanded when open");
+}
+
+async function testCloseMenu(btn, method) {
+ let hidden = BrowserTestUtils.waitForEvent(btn.ownerGlobal, "hidden", true);
+ await method();
+ await hidden;
+ is(btn.getAttribute("aria-expanded"), "false", "not expanded when closed");
+}
+
+async function testButton(btn) {
+ let win = btn.ownerGlobal;
+
+ is(btn.getAttribute("aria-haspopup"), "menu", "it has a menu");
+ is(btn.getAttribute("aria-expanded"), "false", "not expanded");
+
+ info("Test open/close with mouse");
+ await testOpenMenu(btn, () => {
+ EventUtils.synthesizeMouseAtCenter(btn, {}, win);
+ });
+ await testCloseMenu(btn, () => {
+ let spacer = win.document.querySelector(".main-heading .spacer");
+ EventUtils.synthesizeMouseAtCenter(spacer, {}, win);
+ });
+
+ info("Test open/close with keyboard");
+ await testOpenMenu(btn, async () => {
+ btn.focus();
+ EventUtils.synthesizeKey(" ", {}, win);
+ });
+ await testCloseMenu(btn, () => {
+ EventUtils.synthesizeKey("Escape", {}, win);
+ });
+}
+
+add_task(async function testPageOptionsMenuButton() {
+ let win = await loadInitialView("extension");
+
+ await testButton(
+ win.document.querySelector(".page-options-menu .more-options-button")
+ );
+
+ await closeView(win);
+});
+
+add_task(async function testCardMoreOptionsButton() {
+ let id = "more-options-button@mochi.test";
+ let extension = ExtensionTestUtils.loadExtension({
+ manifest: {
+ applications: { gecko: { id } },
+ },
+ useAddonManager: "temporary",
+ });
+ await extension.startup();
+
+ let win = await loadInitialView("extension");
+ let card = getAddonCard(win, id);
+
+ info("Check list page");
+ await testButton(card.querySelector(".more-options-button"));
+
+ let viewLoaded = waitForViewLoad(win);
+ EventUtils.synthesizeMouseAtCenter(card, {}, win);
+ await viewLoaded;
+
+ info("Check detail page");
+ card = getAddonCard(win, id);
+ await testButton(card.querySelector(".more-options-button"));
+
+ await closeView(win);
+ await extension.unload();
+});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_page_accessibility.js b/toolkit/mozapps/extensions/test/browser/browser_page_accessibility.js
new file mode 100644
index 0000000000..e049cbd618
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/browser/browser_page_accessibility.js
@@ -0,0 +1,15 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+add_task(async function testPageTitle() {
+ let win = await loadInitialView("extension");
+ let title = win.document.querySelector("title");
+ is(
+ win.document.l10n.getAttributes(title).id,
+ "addons-page-title",
+ "The page title is set"
+ );
+ await closeView(win);
+});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug567127.js b/toolkit/mozapps/extensions/test/browser/browser_page_options_install_addon.js
similarity index 63%
rename from toolkit/mozapps/extensions/test/browser/browser_bug567127.js
rename to toolkit/mozapps/extensions/test/browser/browser_page_options_install_addon.js
index 1f87c1a677..d8e9b08695 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_bug567127.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_page_options_install_addon.js
@@ -7,8 +7,6 @@
var MockFilePicker = SpecialPowers.MockFilePicker;
MockFilePicker.init(window);
-var gManagerWindow;
-
async function checkInstallConfirmation(...names) {
let notificationCount = 0;
let observer = {
@@ -54,7 +52,7 @@ async function checkInstallConfirmation(...names) {
}
add_task(async function test_install_from_file() {
- gManagerWindow = await open_manager("addons://list/extension");
+ let win = await loadInitialView("extension");
var filePaths = [
get_addon_file_url("browser_dragdrop1.xpi"),
@@ -73,10 +71,50 @@ add_task(async function test_install_from_file() {
"Drag Drop test 2"
);
- gManagerWindow.gViewController.doCommand("cmd_installFromFile");
+ win.document
+ .querySelector('#page-options [action="install-from-file"]')
+ .click();
await pInstallURIClosed;
MockFilePicker.cleanup();
- await close_manager(gManagerWindow);
+ await closeView(win);
+});
+
+add_task(async function test_install_disabled() {
+ let win = await loadInitialView("extension");
+ let doc = win.document;
+
+ let pageOptionsMenu = doc.querySelector("addon-page-options panel-list");
+
+ function openPageOptions() {
+ let opened = BrowserTestUtils.waitForEvent(pageOptionsMenu, "shown");
+ pageOptionsMenu.open = true;
+ return opened;
+ }
+
+ function closePageOptions() {
+ let closed = BrowserTestUtils.waitForEvent(pageOptionsMenu, "hidden");
+ pageOptionsMenu.open = false;
+ return closed;
+ }
+
+ await openPageOptions();
+ let installButton = doc.querySelector('[action="install-from-file"]');
+ ok(!installButton.hidden, "The install button is shown");
+ await closePageOptions();
+
+ await SpecialPowers.pushPrefEnv({ set: [[PREF_XPI_ENABLED, false]] });
+
+ await openPageOptions();
+ ok(installButton.hidden, "The install button is now hidden");
+ await closePageOptions();
+
+ await SpecialPowers.popPrefEnv();
+
+ await openPageOptions();
+ ok(!installButton.hidden, "The install button is shown again");
+ await closePageOptions();
+
+ await closeView(win);
});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_page_options_updates.js b/toolkit/mozapps/extensions/test/browser/browser_page_options_updates.js
new file mode 100644
index 0000000000..45a7294713
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/browser/browser_page_options_updates.js
@@ -0,0 +1,122 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Make sure we don't accidentally start a background update while the prefs
+// are enabled.
+disableBackgroundUpdateTimer();
+registerCleanupFunction(() => {
+ enableBackgroundUpdateTimer();
+});
+
+const { AddonTestUtils } = ChromeUtils.import(
+ "resource://testing-common/AddonTestUtils.jsm",
+ {}
+);
+
+const PREF_UPDATE_ENABLED = "extensions.update.enabled";
+const PREF_AUTOUPDATE_DEFAULT = "extensions.update.autoUpdateDefault";
+
+add_task(async function testUpdateAutomaticallyButton() {
+ SpecialPowers.pushPrefEnv({
+ set: [[PREF_UPDATE_ENABLED, true], [PREF_AUTOUPDATE_DEFAULT, true]],
+ });
+
+ let win = await loadInitialView("extension");
+
+ let toggleAutomaticButton = win.document.querySelector(
+ '#page-options [action="set-update-automatically"]'
+ );
+
+ info("Verify the checked state reflects the update state");
+ ok(toggleAutomaticButton.checked, "Automatic updates button is checked");
+
+ AddonManager.autoUpdateDefault = false;
+ ok(!toggleAutomaticButton.checked, "Automatic updates button is unchecked");
+
+ AddonManager.autoUpdateDefault = true;
+ ok(toggleAutomaticButton.checked, "Automatic updates button is re-checked");
+
+ info("Verify that clicking the button changes the update state");
+ ok(AddonManager.autoUpdateDefault, "Auto updates are default");
+ ok(AddonManager.updateEnabled, "Updates are enabled");
+
+ toggleAutomaticButton.click();
+ ok(!AddonManager.autoUpdateDefault, "Auto updates are disabled");
+ ok(AddonManager.updateEnabled, "Updates are enabled");
+
+ toggleAutomaticButton.click();
+ ok(AddonManager.autoUpdateDefault, "Auto updates are enabled again");
+ ok(AddonManager.updateEnabled, "Updates are enabled");
+
+ await closeView(win);
+});
+
+add_task(async function testResetUpdateStates() {
+ let id = "update-state@mochi.test";
+ let extension = ExtensionTestUtils.loadExtension({
+ manifest: {
+ applications: { gecko: { id } },
+ },
+ useAddonManager: "permanent",
+ });
+ await extension.startup();
+
+ let win = await loadInitialView("extension");
+ let resetStateButton = win.document.querySelector(
+ '#page-options [action="reset-update-states"]'
+ );
+
+ info("Changing add-on update state");
+ let addon = await AddonManager.getAddonByID(id);
+
+ let setAddonUpdateState = async updateState => {
+ let changed = AddonTestUtils.promiseAddonEvent("onPropertyChanged");
+ addon.applyBackgroundUpdates = updateState;
+ await changed;
+ let addonState = addon.applyBackgroundUpdates;
+ is(addonState, updateState, `Add-on updates are ${updateState}`);
+ };
+
+ await setAddonUpdateState(AddonManager.AUTOUPDATE_DISABLE);
+
+ let propertyChanged = AddonTestUtils.promiseAddonEvent("onPropertyChanged");
+ resetStateButton.click();
+ await propertyChanged;
+ is(
+ addon.applyBackgroundUpdates,
+ AddonManager.AUTOUPDATE_DEFAULT,
+ "Add-on is reset to default updates"
+ );
+
+ await setAddonUpdateState(AddonManager.AUTOUPDATE_ENABLE);
+
+ propertyChanged = AddonTestUtils.promiseAddonEvent("onPropertyChanged");
+ resetStateButton.click();
+ await propertyChanged;
+ is(
+ addon.applyBackgroundUpdates,
+ AddonManager.AUTOUPDATE_DEFAULT,
+ "Add-on is reset to default updates again"
+ );
+
+ info("Check the label on the button as the global state changes");
+ is(
+ win.document.l10n.getAttributes(resetStateButton).id,
+ "addon-updates-reset-updates-to-automatic",
+ "The reset button label says it resets to automatic"
+ );
+
+ info("Disable auto updating globally");
+ AddonManager.autoUpdateDefault = false;
+
+ is(
+ win.document.l10n.getAttributes(resetStateButton).id,
+ "addon-updates-reset-updates-to-manual",
+ "The reset button label says it resets to manual"
+ );
+
+ await closeView(win);
+ await extension.unload();
+});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_panel_item_accesskey.js b/toolkit/mozapps/extensions/test/browser/browser_panel_item_accesskey.js
new file mode 100644
index 0000000000..72e35f8dee
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/browser/browser_panel_item_accesskey.js
@@ -0,0 +1,100 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+add_task(async function testPanelItemWithAccesskey() {
+ let win = await loadInitialView("extension");
+ let doc = win.document;
+
+ let panelList = doc.createElement("panel-list");
+ let items = [
+ { textContent: "First Item", accessKey: "F" },
+ { textContent: "Second Item", accessKey: "S" },
+ { textContent: "Third Item" },
+ ];
+
+ let panelItems = items.map(details => {
+ let item = doc.createElement("panel-item");
+ for (let [attr, value] of Object.entries(details)) {
+ item[attr] = value;
+ }
+ panelList.appendChild(item);
+ return item;
+ });
+
+ doc.body.appendChild(panelList);
+
+ function assertAccessKeys(items, keys, { checkLabels = false } = {}) {
+ is(items.length, keys.length, "Got the same number of items and keys");
+ for (let i = 0; i < items.length; i++) {
+ is(items[i].accessKey, keys[i], `Item ${i} has the right key`);
+ if (checkLabels) {
+ let label = items[i].shadowRoot.querySelector("label");
+ is(label.accessKey, keys[i] || null, `Label ${i} has the right key`);
+ }
+ }
+ }
+
+ info("Accesskeys should be removed when closed");
+ assertAccessKeys(panelItems, ["", "", ""]);
+
+ info("Accesskeys should be set when open");
+ let panelShown = BrowserTestUtils.waitForEvent(panelList, "shown");
+ panelList.show();
+ await panelShown;
+ assertAccessKeys(panelItems, ["F", "S", ""], { checkLabels: true });
+
+ info("Changing accesskeys should happen right away");
+ panelItems[1].accessKey = "c";
+ panelItems[2].accessKey = "T";
+ assertAccessKeys(panelItems, ["F", "c", "T"], { checkLabels: true });
+
+ info("Accesskeys are removed again on hide");
+ let panelHidden = BrowserTestUtils.waitForEvent(panelList, "hidden");
+ panelList.hide();
+ await panelHidden;
+ assertAccessKeys(panelItems, ["", "", ""]);
+
+ info("Accesskeys are set again on show");
+ panelItems[0].removeAttribute("accesskey");
+ panelShown = BrowserTestUtils.waitForEvent(panelList, "shown");
+ panelList.show();
+ await panelShown;
+ assertAccessKeys(panelItems, ["", "c", "T"], { checkLabels: true });
+
+ info("Check that accesskeys can be used without the modifier when open");
+ let secondClickCount = 0;
+ let thirdClickCount = 0;
+ panelItems[1].addEventListener("click", () => secondClickCount++);
+ panelItems[2].addEventListener("click", () => thirdClickCount++);
+
+ // Make sure the focus is in the window.
+ panelItems[0].focus();
+
+ panelHidden = BrowserTestUtils.waitForEvent(panelList, "hidden");
+ EventUtils.synthesizeKey("c", {}, win);
+ await panelHidden;
+
+ is(secondClickCount, 1, "The accesskey worked unmodified");
+ is(thirdClickCount, 0, "The other listener wasn't fired");
+
+ EventUtils.synthesizeKey("c", {}, win);
+ EventUtils.synthesizeKey("t", {}, win);
+
+ is(secondClickCount, 1, "The key doesn't trigger when closed");
+ is(thirdClickCount, 0, "The key doesn't trigger when closed");
+
+ panelShown = BrowserTestUtils.waitForEvent(panelList, "shown");
+ panelList.show();
+ await panelShown;
+
+ panelHidden = BrowserTestUtils.waitForEvent(panelList, "hidden");
+ EventUtils.synthesizeKey("t", {}, win);
+ await panelHidden;
+
+ is(secondClickCount, 1, "The other listener wasn't fired");
+ is(thirdClickCount, 1, "The accesskey worked unmodified");
+
+ await closeView(win);
+});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_panel_list_accessibility.js b/toolkit/mozapps/extensions/test/browser/browser_panel_list_accessibility.js
new file mode 100644
index 0000000000..b3729442cf
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/browser/browser_panel_list_accessibility.js
@@ -0,0 +1,64 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+function setupPanel(win) {
+ let doc = win.document;
+ let panelList = doc.createElement("panel-list");
+ let items = ["one", "two", "three"];
+ let panelItems = items.map(item => {
+ let panelItem = doc.createElement("panel-item");
+ panelItem.textContent = item;
+ panelList.append(panelItem);
+ return panelItem;
+ });
+
+ let anchorButton = doc.createElement("button");
+ anchorButton.addEventListener("click", e => panelList.toggle(e));
+
+ doc.body.append(anchorButton, panelList);
+
+ return { anchorButton, panelList, panelItems };
+}
+
+add_task(async function testItemFocusOnOpen() {
+ let win = await loadInitialView("extension");
+ let doc = win.document;
+
+ let { anchorButton, panelList, panelItems } = setupPanel(win);
+
+ ok(doc.activeElement, "There is an active element");
+ ok(!doc.activeElement.closest("panel-list"), "Focus isn't in the list");
+
+ let shown = BrowserTestUtils.waitForEvent(panelList, "shown");
+ EventUtils.synthesizeMouseAtCenter(anchorButton, {}, win);
+ await shown;
+
+ is(doc.activeElement, panelItems[0], "The first item is focused");
+
+ let hidden = BrowserTestUtils.waitForEvent(panelList, "hidden");
+ EventUtils.synthesizeKey("Escape", {}, win);
+ await hidden;
+
+ is(doc.activeElement, anchorButton, "The anchor is focused again on close");
+
+ await closeView(win);
+});
+
+add_task(async function testAriaAttributes() {
+ let win = await loadInitialView("extension");
+
+ let { panelList, panelItems } = setupPanel(win);
+
+ is(panelList.getAttribute("role"), "menu", "The panel is a menu");
+
+ is(panelItems.length, 3, "There are 3 items");
+ Assert.deepEqual(
+ panelItems.map(panelItem => panelItem.button.getAttribute("role")),
+ new Array(panelItems.length).fill("menuitem"),
+ "All of the items have a menuitem button"
+ );
+
+ await closeView(win);
+});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_plugin_enabled_state_locked.js b/toolkit/mozapps/extensions/test/browser/browser_plugin_enabled_state_locked.js
deleted file mode 100644
index 876901ee30..0000000000
--- a/toolkit/mozapps/extensions/test/browser/browser_plugin_enabled_state_locked.js
+++ /dev/null
@@ -1,149 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-// Tests that state menu is displayed correctly (enabled or disabled) in the add-on manager
-// when the preference is unlocked / locked
-const gIsWindows = "@mozilla.org/windows-registry-key;1" in Cc;
-const gIsLinux =
- "@mozilla.org/gnome-gconf-service;1" in Cc ||
- "@mozilla.org/gio-service;1" in Cc;
-
-var gManagerWindow;
-var gCategoryUtilities;
-var gPluginElement;
-
-function getTestPluginPref() {
- let prefix = "plugin.state.";
- if (gIsWindows) {
- return `${prefix}nptest`;
- }
- if (gIsLinux) {
- return `${prefix}libnptest`;
- }
- return `${prefix}test`;
-}
-
-// This test is testing XUL about:addons UI (the HTML about:addons tests should verify
-// this in their own test files).
-SpecialPowers.pushPrefEnv({
- set: [["extensions.htmlaboutaddons.enabled", false]],
-});
-
-registerCleanupFunction(() => {
- Services.prefs.unlockPref(getTestPluginPref());
- Services.prefs.clearUserPref(getTestPluginPref());
-});
-
-function getPlugins() {
- return AddonManager.getAddonsByTypes(["plugin"]);
-}
-
-function getTestPlugin(aPlugins) {
- let testPluginId;
-
- for (let plugin of aPlugins) {
- if (plugin.name == "Test Plug-in") {
- testPluginId = plugin.id;
- break;
- }
- }
-
- Assert.ok(testPluginId, "Test Plug-in should exist");
-
- let pluginElement = get_addon_element(gManagerWindow, testPluginId);
- pluginElement.parentNode.ensureElementIsVisible(pluginElement);
-
- return pluginElement;
-}
-
-function checkStateMenu(locked) {
- Assert.equal(
- Services.prefs.prefIsLocked(getTestPluginPref()),
- locked,
- "Preference lock state should be correct."
- );
- let menuList = gManagerWindow.document.getAnonymousElementByAttribute(
- gPluginElement,
- "anonid",
- "state-menulist"
- );
- // State menu should always have a selected item which must be visible
- let selectedMenuItem = menuList.querySelector(
- '.addon-control[selected="true"]'
- );
-
- is_element_visible(menuList, "State menu should be visible.");
- Assert.equal(
- menuList.disabled,
- locked,
- "State menu should" + (locked === true ? "" : " not") + " be disabled."
- );
-
- is_element_visible(
- selectedMenuItem,
- "State menu's selected item should be visible."
- );
-}
-
-function checkStateMenuDetail(locked) {
- Assert.equal(
- Services.prefs.prefIsLocked(getTestPluginPref()),
- locked,
- "Preference should be " + (locked === true ? "" : "un") + "locked."
- );
-
- // open details menu
- EventUtils.synthesizeMouseAtCenter(gPluginElement, {}, gManagerWindow);
-
- return new Promise(async resolve => {
- await wait_for_view_load(gManagerWindow);
- let menuList = gManagerWindow.document.getElementById(
- "detail-state-menulist"
- );
- is_element_visible(menuList, "Details state menu should be visible.");
- Assert.equal(
- menuList.disabled,
- locked,
- "Details state menu enabled state should be correct."
- );
- resolve();
- });
-}
-
-add_task(async function initializeState() {
- Services.prefs.setIntPref(getTestPluginPref(), Ci.nsIPluginTag.STATE_ENABLED);
- Services.prefs.unlockPref(getTestPluginPref());
- gManagerWindow = await open_manager();
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- await gCategoryUtilities.openType("plugin");
-
- let plugins = await getPlugins();
- gPluginElement = getTestPlugin(plugins);
-});
-
-// Tests that plugin state menu is enabled if the preference is unlocked
-add_task(async function taskCheckStateMenuIsEnabled() {
- checkStateMenu(false);
- await checkStateMenuDetail(false);
-});
-
-// Lock the preference and then reload the plugin category
-add_task(async function reinitializeState() {
- // lock the preference
- Services.prefs.lockPref(getTestPluginPref());
- await gCategoryUtilities.openType("plugin");
- // Retrieve the test plugin element
- let plugins = await getPlugins();
- gPluginElement = getTestPlugin(plugins);
-});
-
-// Tests that plugin state menu is disabled if the preference is locked
-add_task(async function taskCheckStateMenuIsDisabled() {
- checkStateMenu(true);
- await checkStateMenuDetail(true);
-});
-
-add_task(async function testCleanup() {
- await close_manager(gManagerWindow);
-});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_pluginprefs.js b/toolkit/mozapps/extensions/test/browser/browser_pluginprefs.js
index c7cca6b802..4055eba591 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_pluginprefs.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_pluginprefs.js
@@ -11,7 +11,7 @@ async function getTestPluginAddon() {
return plugins.find(plugin => plugin.name === "Test Plug-in");
}
-async function test_inline_plugin_prefs() {
+add_task(async function test_inline_plugin_prefs() {
gManagerWindow = await open_manager("addons://list/plugin");
let testPlugin = await getTestPluginAddon();
ok(testPlugin, "Test Plug-in should exist");
@@ -35,26 +35,7 @@ async function test_inline_plugin_prefs() {
}
).then(event => event.target);
- if (gManagerWindow.useHtmlViews) {
- pluginEl.querySelector("panel-item[action='preferences']").click();
- } else {
- pluginEl.parentNode.ensureElementIsVisible(pluginEl);
-
- let button = gManagerWindow.document.getAnonymousElementByAttribute(
- pluginEl,
- "anonid",
- "preferences-btn"
- );
- is_element_visible(button, "Preferences button should be visible");
-
- EventUtils.synthesizeMouseAtCenter(
- pluginEl,
- { clickCount: 1 },
- gManagerWindow
- );
-
- await TestUtils.topicObserved(AddonManager.OPTIONS_NOTIFICATION_DISPLAYED);
- }
+ pluginEl.querySelector("panel-item[action='preferences']").click();
info("Waiting for inline options page to be ready");
let doc = (await optionsBrowserPromise).contentDocument;
@@ -82,20 +63,4 @@ async function test_inline_plugin_prefs() {
);
await close_manager(gManagerWindow);
-}
-
-add_task(async function test_inline_plugin_prefs_on_XUL_aboutaddons() {
- await SpecialPowers.pushPrefEnv({
- set: [["extensions.htmlaboutaddons.enabled", false]],
- });
- await test_inline_plugin_prefs();
- await SpecialPowers.popPrefEnv();
-});
-
-add_task(async function test_inline_plugin_prefs_on_HTML_aboutaddons() {
- await SpecialPowers.pushPrefEnv({
- set: [["extensions.htmlaboutaddons.enabled", true]],
- });
- await test_inline_plugin_prefs();
- await SpecialPowers.popPrefEnv();
});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_pluginprefs_is_not_disabled.js b/toolkit/mozapps/extensions/test/browser/browser_pluginprefs_is_not_disabled.js
deleted file mode 100644
index 9046a4311b..0000000000
--- a/toolkit/mozapps/extensions/test/browser/browser_pluginprefs_is_not_disabled.js
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-// Tests plugin prefs being enabled
-
-function getTestPlugin(aPlugins) {
- let [testPlugin] = aPlugins.filter(plugin => plugin.name === "Test Plug-in");
- Assert.ok(testPlugin, "Test Plug-in should exist");
- return testPlugin;
-}
-
-add_task(async function taskCheckPluginPrefsEnabled() {
- const [gManagerWindow, plugins] = await Promise.all([
- open_manager(),
- AddonManager.getAddonsByTypes(["plugin"]),
- ]);
- const testPlugin = getTestPlugin(plugins);
- const testPluginTag = getTestPluginTag();
- Assert.ok(testPluginTag, "Test Plug-in tag should exist");
- const initialTestPluginState = testPluginTag.enabledState;
-
- Assert.ok(
- gManagerWindow.gViewController.commands.cmd_showItemPreferences.isEnabled(
- testPlugin
- ),
- "Test Plug-in preferences should be enabled"
- );
- testPluginTag.enabledState = Ci.nsIPluginTag.STATE_DISABLED;
- Assert.ok(
- gManagerWindow.gViewController.commands.cmd_showItemPreferences.isEnabled(
- testPlugin
- ),
- "Test Plug-in preferences should be enabled"
- );
-
- testPluginTag.enabledState = initialTestPluginState;
- await close_manager(gManagerWindow);
-});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_recentupdates.js b/toolkit/mozapps/extensions/test/browser/browser_recentupdates.js
deleted file mode 100644
index 716ce51030..0000000000
--- a/toolkit/mozapps/extensions/test/browser/browser_recentupdates.js
+++ /dev/null
@@ -1,105 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-// Tests the recent updates pane
-
-var gProvider;
-var gManagerWindow;
-var gCategoryUtilities;
-
-async function test() {
- waitForExplicitFinish();
-
- gProvider = new MockProvider();
-
- gProvider.createAddons([
- {
- id: "addon1@tests.mozilla.org",
- name: "updated 6 hours ago",
- version: "1.0",
- updateDate: new Date(Date.now() - 1000 * 60 * 60 * 6),
- releaseNotesURI: Services.io.newURI(TESTROOT + "releaseNotes.xhtml"),
- },
- {
- id: "addon2@tests.mozilla.org",
- name: "updated 5 seconds ago",
- version: "1.0",
- updateDate: new Date(Date.now() - 1000 * 5),
- },
- {
- id: "addon3@tests.mozilla.org",
- name: "updated 1 month ago",
- version: "1.0",
- updateDate: new Date(Date.now() - 1000 * 60 * 60 * 25 * 30),
- },
- ]);
-
- let aWindow = await open_manager("addons://list/extension");
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- run_next_test();
-}
-
-async function end_test() {
- await close_manager(gManagerWindow);
- finish();
-}
-
-add_test(function() {
- info("Checking menuitem for Recent Updates opens that pane");
- var recentCat = gManagerWindow.gCategories.get("addons://updates/recent");
- is(
- gCategoryUtilities.isVisible(recentCat),
- false,
- "Recent Updates category should initially be hidden"
- );
-
- var utilsBtn = gManagerWindow.document.getElementById("header-utils-btn");
- utilsBtn.addEventListener(
- "popupshown",
- async function() {
- Promise.resolve().then(() => {
- var menuitem = gManagerWindow.document.getElementById(
- "utils-viewUpdates"
- );
- EventUtils.synthesizeMouse(menuitem, 2, 2, {}, gManagerWindow);
- });
- await wait_for_view_load(gManagerWindow, null, true);
- is(
- gCategoryUtilities.isVisible(recentCat),
- true,
- "Recent Updates category should now be visible"
- );
- is(
- gManagerWindow.document.getElementById("categories").selectedItem.value,
- "addons://updates/recent",
- "Recent Updates category should now be selected"
- );
- is(
- gManagerWindow.gViewController.currentViewId,
- "addons://updates/recent",
- "Recent Updates view should be the current view"
- );
- run_next_test();
- },
- { once: true }
- );
- EventUtils.synthesizeMouse(utilsBtn, 2, 2, {}, gManagerWindow);
-});
-
-add_test(async function() {
- await close_manager(gManagerWindow);
- let aWindow = await open_manager(null);
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
-
- var recentCat = gManagerWindow.gCategories.get("addons://updates/recent");
- is(
- gCategoryUtilities.isVisible(recentCat),
- true,
- "Recent Updates category should still be visible"
- );
-
- run_next_test();
-});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_reinstall.js b/toolkit/mozapps/extensions/test/browser/browser_reinstall.js
index e0f88bc10f..e2ea990473 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_reinstall.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_reinstall.js
@@ -14,78 +14,26 @@ const testIdSuffix = "@tests.mozilla.org";
let gManagerWindow, xpi1, xpi2;
-function get_test_items_in_list(aManager) {
- let item = aManager.document.getElementById("addon-list").firstChild;
- let items = [];
-
- while (item) {
- if (item.localName != "richlistitem") {
- item = item.nextSibling;
- continue;
- }
-
- if (
- !item.mAddon ||
- item.mAddon.id.substring(item.mAddon.id.length - testIdSuffix.length) ==
- testIdSuffix
- ) {
- items.push(item);
- }
- item = item.nextSibling;
- }
-
- return items;
-}
-
function htmlDoc() {
return gManagerWindow.document.getElementById("html-view-browser")
.contentDocument;
}
function get_list_item_count() {
- if (gManagerWindow.useHtmlViews) {
- return htmlDoc().querySelectorAll(`addon-card[addon-id$="${testIdSuffix}"]`)
- .length;
- }
- return get_test_items_in_list(gManagerWindow).length;
-}
-
-function get_node(parent, anonid) {
- return parent.ownerDocument.getAnonymousElementByAttribute(
- parent,
- "anonid",
- anonid
- );
+ return htmlDoc().querySelectorAll(`addon-card[addon-id$="${testIdSuffix}"]`)
+ .length;
}
function removeItem(item) {
- let button;
- if (gManagerWindow.useHtmlViews) {
- button = item.querySelector('[action="remove"]');
- button.click();
- } else {
- button = get_node(item, "remove-btn");
- EventUtils.synthesizeMouseAtCenter(button, {}, button.ownerGlobal);
- }
-}
-
-function get_class_node(parent, cls) {
- return parent.ownerDocument.getAnonymousElementByAttribute(
- parent,
- "class",
- cls
- );
+ let button = item.querySelector('[action="remove"]');
+ button.click();
}
function hasPendingMessage(item, msg) {
- if (gManagerWindow.useHtmlViews) {
- let messageBar = htmlDoc().querySelector(
- `message-bar[addon-id="${item.addon.id}"`
- );
- is_element_visible(messageBar, msg);
- } else {
- is_element_visible(get_class_node(item, "pending"), msg);
- }
+ let messageBar = htmlDoc().querySelector(
+ `message-bar[addon-id="${item.addon.id}"`
+ );
+ is_element_visible(messageBar, msg);
}
async function install_addon(xpi) {
@@ -109,63 +57,47 @@ async function check_addon(aAddon, aVersion) {
let { version } = await get_tooltip_info(item, gManagerWindow);
is(version, aVersion, "Version should be correct");
- if (gManagerWindow.useHtmlViews) {
- const l10nAttrs = item.ownerDocument.l10n.getAttributes(item.addonNameEl);
- if (aAddon.userDisabled) {
- Assert.deepEqual(
- l10nAttrs,
- { id: "addon-name-disabled", args: { name: aAddon.name } },
- "localized addon name is marked as disabled"
- );
- } else {
- ok(!l10nAttrs.id, "localized addon name is not marked as disabled");
- }
-
- return;
- }
-
+ const l10nAttrs = item.ownerDocument.l10n.getAttributes(
+ item.querySelector(".addon-name")
+ );
if (aAddon.userDisabled) {
- is_element_visible(
- get_class_node(item, "disabled-postfix"),
- "Disabled postfix should be hidden"
+ Assert.deepEqual(
+ l10nAttrs,
+ { id: "addon-name-disabled", args: { name: aAddon.name } },
+ "localized addon name is marked as disabled"
);
} else {
- is_element_hidden(
- get_class_node(item, "disabled-postfix"),
- "Disabled postfix should be hidden"
+ Assert.deepEqual(
+ l10nAttrs,
+ { id: null, args: null },
+ "localized addon name is not marked as disabled"
);
}
}
async function wait_for_addon_item_added(addonId) {
- if (gManagerWindow.useHtmlViews) {
- await BrowserTestUtils.waitForEvent(
- htmlDoc().querySelector("addon-list"),
- "add"
- );
- const item = get_addon_element(gManagerWindow, addonId);
- ok(item, `Found addon card for ${addonId}`);
- }
+ await BrowserTestUtils.waitForEvent(
+ htmlDoc().querySelector("addon-list"),
+ "add"
+ );
+ const item = get_addon_element(gManagerWindow, addonId);
+ ok(item, `Found addon card for ${addonId}`);
}
async function wait_for_addon_item_removed(addonId) {
- if (gManagerWindow.useHtmlViews) {
- await BrowserTestUtils.waitForEvent(
- htmlDoc().querySelector("addon-list"),
- "remove"
- );
- const item = get_addon_element(gManagerWindow, addonId);
- ok(!item, `There shouldn't be an addon card for ${addonId}`);
- }
+ await BrowserTestUtils.waitForEvent(
+ htmlDoc().querySelector("addon-list"),
+ "remove"
+ );
+ const item = get_addon_element(gManagerWindow, addonId);
+ ok(!item, `There shouldn't be an addon card for ${addonId}`);
}
-async function wait_for_addon_item_updated(addonId) {
- if (gManagerWindow.useHtmlViews) {
- await BrowserTestUtils.waitForEvent(
- get_addon_element(gManagerWindow, addonId),
- "update"
- );
- }
+function wait_for_addon_item_updated(addonId) {
+ return BrowserTestUtils.waitForEvent(
+ get_addon_element(gManagerWindow, addonId),
+ "update"
+ );
}
// Install version 1 then upgrade to version 2 with the manager open
@@ -310,35 +242,6 @@ async function test_upgrade_pending_uninstall_disabled_v1_to_v2() {
is(get_list_item_count(), 0, "Should be no items in the list");
}
-async function test_upgrades(useHtmlViews) {
- await SpecialPowers.pushPrefEnv({
- set: [["extensions.htmlaboutaddons.enabled", useHtmlViews]],
- });
-
- // Close existing about:addons tab if a test failure has
- // prevented it from being closed.
- if (gManagerWindow) {
- await close_manager(gManagerWindow);
- }
-
- gManagerWindow = await open_manager("addons://list/extension");
- is(
- gManagerWindow.useHtmlViews,
- useHtmlViews,
- "Got about:addons window in the expected mode"
- );
-
- await test_upgrade_v1_to_v2();
- await test_upgrade_disabled_v1_to_v2();
- await test_upgrade_pending_uninstall_v1_to_v2();
- await test_upgrade_pending_uninstall_disabled_v1_to_v2();
-
- await close_manager(gManagerWindow);
- gManagerWindow = null;
-
- // No popPrefEnv because of bug 1557397.
-}
-
add_task(async function setup() {
xpi1 = await AddonTestUtils.createTempWebExtensionFile({
manifest: {
@@ -358,10 +261,20 @@ add_task(async function setup() {
mockPromptService()._response = 0;
});
-add_task(function run_tests_on_XUL_aboutaddons() {
- return test_upgrades(false);
-});
+add_task(async function test_upgrades() {
+ // Close existing about:addons tab if a test failure has
+ // prevented it from being closed.
+ if (gManagerWindow) {
+ await close_manager(gManagerWindow);
+ }
-add_task(function run_tests_on_HTML_aboutaddons() {
- return test_upgrades(true);
+ gManagerWindow = await open_manager("addons://list/extension");
+
+ await test_upgrade_v1_to_v2();
+ await test_upgrade_disabled_v1_to_v2();
+ await test_upgrade_pending_uninstall_v1_to_v2();
+ await test_upgrade_pending_uninstall_disabled_v1_to_v2();
+
+ await close_manager(gManagerWindow);
+ gManagerWindow = null;
});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_shortcuts_duplicate_check.js b/toolkit/mozapps/extensions/test/browser/browser_shortcuts_duplicate_check.js
new file mode 100644
index 0000000000..93cccaf43c
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/browser/browser_shortcuts_duplicate_check.js
@@ -0,0 +1,149 @@
+"use strict";
+
+const { PromiseTestUtils } = ChromeUtils.import(
+ "resource://testing-common/PromiseTestUtils.jsm"
+);
+PromiseTestUtils.whitelistRejectionsGlobally(/Message manager disconnected/);
+
+async function loadShortcutsView() {
+ let win = await loadInitialView("extension");
+
+ // There should be a manage shortcuts link.
+ let shortcutsLink = win.document.querySelector('[action="manage-shortcuts"]');
+
+ // Open the shortcuts view.
+ let loaded = waitForViewLoad(win);
+ shortcutsLink.click();
+ await loaded;
+
+ return win;
+}
+
+add_task(async function testDuplicateShortcutsWarnings() {
+ let duplicateCommands = {
+ commandOne: {
+ suggested_key: { default: "Shift+Alt+1" },
+ },
+ commandTwo: {
+ description: "Command Two!",
+ suggested_key: { default: "Shift+Alt+2" },
+ },
+ };
+ let extension = ExtensionTestUtils.loadExtension({
+ manifest: {
+ commands: duplicateCommands,
+ name: "Extension 1",
+ },
+ background() {
+ browser.test.sendMessage("ready");
+ },
+ useAddonManager: "temporary",
+ });
+
+ await extension.startup();
+ await extension.awaitMessage("ready");
+
+ let extension2 = ExtensionTestUtils.loadExtension({
+ manifest: {
+ commands: {
+ ...duplicateCommands,
+ commandThree: {
+ description: "Command Three!",
+ suggested_key: { default: "Shift+Alt+3" },
+ },
+ },
+ name: "Extension 2",
+ },
+ background() {
+ browser.test.sendMessage("ready");
+ },
+ useAddonManager: "temporary",
+ });
+
+ await extension2.startup();
+ await extension2.awaitMessage("ready");
+
+ let win = await loadShortcutsView();
+ let doc = win.document;
+
+ let warningBars = doc.querySelectorAll("message-bar");
+ // Ensure warning messages are shown for each duplicate shorctut.
+ is(
+ warningBars.length,
+ Object.keys(duplicateCommands).length,
+ "There is a warning message bar for each duplicate shortcut"
+ );
+
+ // Ensure warning messages are correct with correct shortcuts.
+ let count = 1;
+ for (let warning of warningBars) {
+ let warningMsg = warning.querySelector("span");
+ let l10nAttrs = doc.l10n.getAttributes(warningMsg);
+ is(
+ l10nAttrs.id,
+ "shortcuts-duplicate-warning-message",
+ "Warning message is shown"
+ );
+ Assert.deepEqual(
+ l10nAttrs.args,
+ { shortcut: `Shift+Alt+${count}` },
+ "Warning message shortcut is correct"
+ );
+ count++;
+ }
+
+ ["Shift+Alt+1", "Shift+Alt+2"].forEach((shortcut, index) => {
+ // Ensure warning messages are correct with correct shortcuts.
+ let warning = warningBars[index];
+ let warningMsg = warning.querySelector("span");
+ let l10nAttrs = doc.l10n.getAttributes(warningMsg);
+ is(
+ l10nAttrs.id,
+ "shortcuts-duplicate-warning-message",
+ "Warning message is shown"
+ );
+ Assert.deepEqual(
+ l10nAttrs.args,
+ { shortcut },
+ "Warning message shortcut is correct"
+ );
+
+ // Check if all inputs have warning style.
+ let inputs = doc.querySelectorAll(`input[shortcut="${shortcut}"]`);
+ for (let input of inputs) {
+ // Check if warning error message is shown on focus.
+ input.focus();
+ let error = doc.querySelector(".error-message");
+ let label = error.querySelector(".error-message-label");
+ is(error.style.visibility, "visible", "The error element is shown");
+ is(
+ error.getAttribute("type"),
+ "warning",
+ "Duplicate shortcut has warning class"
+ );
+ is(
+ label.dataset.l10nId,
+ "shortcuts-duplicate",
+ "Correct error message is shown"
+ );
+
+ // On keypress events wrning class should be removed.
+ EventUtils.synthesizeKey("A");
+ ok(
+ !error.classList.contains("warning"),
+ "Error element should not have warning class"
+ );
+
+ input.blur();
+ is(
+ error.style.visibility,
+ "hidden",
+ "The error element is hidden on blur"
+ );
+ }
+ });
+
+ await closeView(win);
+ await extension.unload();
+ await extension2.unload();
+});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_sidebar_categories.js b/toolkit/mozapps/extensions/test/browser/browser_sidebar_categories.js
new file mode 100644
index 0000000000..a2d3be0a00
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/browser/browser_sidebar_categories.js
@@ -0,0 +1,74 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const THEME_ID = "default-theme@mozilla.org";
+
+add_task(async function testClickingSidebarEntriesChangesView() {
+ let win = await loadInitialView("extension");
+ let doc = win.document;
+ let { managerWindow } = win;
+ let themeCategory = managerWindow.document.getElementById("category-theme");
+
+ let assertViewHas = (selector, msg) => ok(doc.querySelector(selector), msg);
+ let assertListView = type =>
+ assertViewHas(`addon-list[type="${type}"]`, `On ${type} list`);
+
+ assertListView("extension");
+
+ let loaded = waitForViewLoad(win);
+ themeCategory.click();
+ await loaded;
+
+ assertListView("theme");
+
+ loaded = waitForViewLoad(win);
+ getAddonCard(win, THEME_ID).click();
+ await loaded;
+
+ ok(!doc.querySelector("addon-list"), "No more addon-list");
+ assertViewHas(
+ `addon-card[addon-id="${THEME_ID}"][expanded]`,
+ "Detail view now"
+ );
+
+ loaded = waitForViewLoad(win);
+ EventUtils.synthesizeMouseAtCenter(
+ themeCategory.firstElementChild,
+ {},
+ managerWindow
+ );
+ await loaded;
+
+ assertListView("theme");
+
+ loaded = waitForViewLoad(win);
+ EventUtils.synthesizeKey("VK_UP", {}, managerWindow);
+ await loaded;
+
+ assertListView("extension");
+
+ await closeView(win);
+});
+
+add_task(async function testClickingSidebarPaddingNoChange() {
+ let win = await loadInitialView("theme");
+ let { managerWindow } = win;
+
+ let loaded = waitForViewLoad(win);
+ getAddonCard(win, THEME_ID).click();
+ await loaded;
+
+ ok(
+ managerWindow.gViewController.currentViewId.startsWith("addons://detail/"),
+ "The detail view loaded"
+ );
+
+ let themeCategory = managerWindow.document.getElementById("category-theme");
+ EventUtils.synthesizeMouse(themeCategory, -5, -5, {}, managerWindow);
+
+ ok(!managerWindow.gViewController.isLoading, "No view is loading");
+
+ await closeView(win);
+});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_sorting.js b/toolkit/mozapps/extensions/test/browser/browser_sorting.js
deleted file mode 100644
index 974461b9a9..0000000000
--- a/toolkit/mozapps/extensions/test/browser/browser_sorting.js
+++ /dev/null
@@ -1,385 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-// Tests that sorting of add-ons works correctly
-// (this test uses the list view, even though it no longer has sort buttons - see bug 623207)
-
-var gManagerWindow;
-var gProvider;
-
-// This test is testing XUL about:addons UI features that are not supported in the
-// HTML about:addons.
-SpecialPowers.pushPrefEnv({
- set: [["extensions.htmlaboutaddons.enabled", false]],
-});
-
-async function test() {
- waitForExplicitFinish();
-
- gProvider = new MockProvider();
- gProvider.createAddons([
- {
- // enabledInstalled group
- // * Enabled
- // * Incompatible but enabled because compatibility checking is off
- // * Waiting to be installed
- // * Waiting to be enabled
- id: "test1@tests.mozilla.org",
- name: "Test add-on",
- description: "foo",
- updateDate: new Date(2010, 4, 2, 0, 0, 0),
- pendingOperations: AddonManager.PENDING_NONE,
- },
- {
- id: "test2@tests.mozilla.org",
- name: "a first add-on",
- description: "foo",
- updateDate: new Date(2010, 4, 1, 23, 59, 59),
- pendingOperations: AddonManager.PENDING_UPGRADE,
- isActive: true,
- isCompatible: false,
- },
- {
- id: "test3@tests.mozilla.org",
- name: "\u010Cesk\u00FD slovn\u00EDk", // Český slovník
- description: "foo",
- updateDate: new Date(2010, 4, 2, 0, 0, 1),
- pendingOperations: AddonManager.PENDING_INSTALL,
- isActive: false,
- },
- {
- id: "test4@tests.mozilla.org",
- name: "canadian dictionary",
- updateDate: new Date(1970, 0, 1, 0, 0, 0),
- description: "foo",
- isActive: true,
- },
- {
- id: "test5@tests.mozilla.org",
- name: "croatian dictionary",
- description: "foo",
- updateDate: new Date(2012, 12, 12, 0, 0, 0),
- pendingOperations: AddonManager.PENDING_ENABLE,
- isActive: false,
- },
- {
- // pendingDisable group
- // * Waiting to be disabled
- id: "test6@tests.mozilla.org",
- name: "orange Add-on",
- description: "foo",
- updateDate: new Date(2010, 4, 2, 0, 0, 0),
- isCompatible: false,
- isActive: true,
- pendingOperations: AddonManager.PENDING_DISABLE,
- },
- {
- id: "test7@tests.mozilla.org",
- name: "Blue Add-on",
- description: "foo",
- updateDate: new Date(2010, 4, 1, 23, 59, 59),
- isActive: true,
- pendingOperations: AddonManager.PENDING_DISABLE,
- },
- {
- id: "test8@tests.mozilla.org",
- name: "Green Add-on",
- description: "foo",
- updateDate: new Date(2010, 4, 3, 0, 0, 1),
- pendingOperations: AddonManager.PENDING_DISABLE,
- },
- {
- id: "test9@tests.mozilla.org",
- name: "red Add-on",
- updateDate: new Date(2011, 4, 1, 0, 0, 0),
- description: "foo",
- isCompatible: false,
- pendingOperations: AddonManager.PENDING_DISABLE,
- },
- {
- id: "test10@tests.mozilla.org",
- name: "Purple Add-on",
- description: "foo",
- updateDate: new Date(2012, 12, 12, 0, 0, 0),
- isCompatible: false,
- pendingOperations: AddonManager.PENDING_DISABLE,
- },
- {
- // pendingUninstall group
- // * Waiting to be removed
- id: "test11@tests.mozilla.org",
- name: "amber Add-on",
- description: "foo",
- updateDate: new Date(1978, 4, 2, 0, 0, 0),
- isActive: false,
- appDisabled: true,
- pendingOperations: AddonManager.PENDING_UNINSTALL,
- },
- {
- id: "test12@tests.mozilla.org",
- name: "Salmon Add-on - pending disable",
- description: "foo",
- updateDate: new Date(2054, 4, 1, 23, 59, 59),
- isActive: true,
- pendingOperations: AddonManager.PENDING_UNINSTALL,
- },
- {
- id: "test13@tests.mozilla.org",
- name: "rose Add-on",
- description: "foo",
- updateDate: new Date(2010, 4, 2, 0, 0, 1),
- isActive: false,
- userDisabled: true,
- pendingOperations: AddonManager.PENDING_UNINSTALL,
- },
- {
- id: "test14@tests.mozilla.org",
- name: "Violet Add-on",
- updateDate: new Date(2010, 5, 1, 0, 0, 0),
- description: "foo",
- isActive: false,
- appDisabled: true,
- pendingOperations: AddonManager.PENDING_UNINSTALL,
- },
- {
- id: "test15@tests.mozilla.org",
- name: "white Add-on",
- description: "foo",
- updateDate: new Date(2010, 4, 12, 0, 0, 0),
- isActive: false,
- userDisabled: true,
- pendingOperations: AddonManager.PENDING_UNINSTALL,
- },
- {
- // disabledIncompatibleBlocked group
- // * Disabled
- // * Incompatible
- // * Blocklisted
- id: "test16@tests.mozilla.org",
- name: "grimsby Add-on",
- description: "foo",
- updateDate: new Date(2010, 4, 1, 0, 0, 0),
- isActive: false,
- appDisabled: true,
- },
- {
- id: "test17@tests.mozilla.org",
- name: "beamsville Add-on",
- description: "foo",
- updateDate: new Date(2010, 4, 8, 23, 59, 59),
- isActive: false,
- userDisabled: true,
- },
- {
- id: "test18@tests.mozilla.org",
- name: "smithville Add-on",
- description: "foo",
- updateDate: new Date(2010, 4, 3, 0, 0, 1),
- isActive: false,
- userDisabled: true,
- blocklistState: Ci.nsIBlocklistService.STATE_OUTDATED,
- },
- {
- id: "test19@tests.mozilla.org",
- name: "dunnville Add-on",
- updateDate: new Date(2010, 4, 2, 0, 0, 0),
- description: "foo",
- isActive: false,
- appDisabled: true,
- isCompatible: false,
- blocklistState: Ci.nsIBlocklistService.STATE_NOT_BLOCKED,
- },
- {
- id: "test20@tests.mozilla.org",
- name: "silverdale Add-on",
- description: "foo",
- updateDate: new Date(2010, 4, 12, 0, 0, 0),
- isActive: false,
- appDisabled: true,
- blocklistState: Ci.nsIBlocklistService.STATE_BLOCKED,
- },
- ]);
-
- let aWindow = await open_manager("addons://list/extension");
- gManagerWindow = aWindow;
- run_next_test();
-}
-
-async function end_test() {
- await close_manager(gManagerWindow);
- finish();
-}
-
-function set_order(aSortBy, aAscending) {
- var list = gManagerWindow.document.getElementById("addon-list");
- var elements = [];
- var node = list.firstChild;
- while (node) {
- elements.push(node);
- node = node.nextSibling;
- }
- gManagerWindow.sortElements(elements, ["uiState", aSortBy], aAscending);
- for (let element of elements) {
- list.appendChild(element);
- }
-}
-
-function check_order(aExpectedOrder) {
- var order = [];
- var list = gManagerWindow.document.getElementById("addon-list");
- var node = list.firstChild;
- while (node) {
- var id = node.getAttribute("value");
- if (id && id.endsWith("@tests.mozilla.org")) {
- order.push(node.getAttribute("value"));
- }
- node = node.nextSibling;
- }
-
- is(
- order.toSource(),
- aExpectedOrder.toSource(),
- "Should have seen the right order"
- );
-}
-
-// Tests that ascending name ordering was the default
-add_test(function() {
- check_order([
- "test2@tests.mozilla.org",
- "test4@tests.mozilla.org",
- "test3@tests.mozilla.org",
- "test5@tests.mozilla.org",
- "test1@tests.mozilla.org",
- "test7@tests.mozilla.org",
- "test8@tests.mozilla.org",
- "test6@tests.mozilla.org",
- "test10@tests.mozilla.org",
- "test9@tests.mozilla.org",
- "test11@tests.mozilla.org",
- "test13@tests.mozilla.org",
- "test12@tests.mozilla.org",
- "test14@tests.mozilla.org",
- "test15@tests.mozilla.org",
- "test17@tests.mozilla.org",
- "test19@tests.mozilla.org",
- "test16@tests.mozilla.org",
- "test20@tests.mozilla.org",
- "test18@tests.mozilla.org",
- ]);
- run_next_test();
-});
-
-// Tests that switching to date ordering works
-add_test(function() {
- set_order("updateDate", false);
-
- // When we're ascending with updateDate, it's from newest
- // to oldest.
-
- check_order([
- "test5@tests.mozilla.org",
- "test3@tests.mozilla.org",
- "test1@tests.mozilla.org",
- "test2@tests.mozilla.org",
- "test4@tests.mozilla.org",
- "test10@tests.mozilla.org",
- "test9@tests.mozilla.org",
- "test8@tests.mozilla.org",
- "test6@tests.mozilla.org",
- "test7@tests.mozilla.org",
- "test12@tests.mozilla.org",
- "test14@tests.mozilla.org",
- "test15@tests.mozilla.org",
- "test13@tests.mozilla.org",
- "test11@tests.mozilla.org",
- "test20@tests.mozilla.org",
- "test17@tests.mozilla.org",
- "test18@tests.mozilla.org",
- "test19@tests.mozilla.org",
- "test16@tests.mozilla.org",
- ]);
-
- set_order("updateDate", true);
-
- check_order([
- "test4@tests.mozilla.org",
- "test2@tests.mozilla.org",
- "test1@tests.mozilla.org",
- "test3@tests.mozilla.org",
- "test5@tests.mozilla.org",
- "test7@tests.mozilla.org",
- "test6@tests.mozilla.org",
- "test8@tests.mozilla.org",
- "test9@tests.mozilla.org",
- "test10@tests.mozilla.org",
- "test11@tests.mozilla.org",
- "test13@tests.mozilla.org",
- "test15@tests.mozilla.org",
- "test14@tests.mozilla.org",
- "test12@tests.mozilla.org",
- "test16@tests.mozilla.org",
- "test19@tests.mozilla.org",
- "test18@tests.mozilla.org",
- "test17@tests.mozilla.org",
- "test20@tests.mozilla.org",
- ]);
-
- run_next_test();
-});
-
-// Tests that switching to name ordering works
-add_test(function() {
- set_order("name", true);
-
- check_order([
- "test2@tests.mozilla.org",
- "test4@tests.mozilla.org",
- "test3@tests.mozilla.org",
- "test5@tests.mozilla.org",
- "test1@tests.mozilla.org",
- "test7@tests.mozilla.org",
- "test8@tests.mozilla.org",
- "test6@tests.mozilla.org",
- "test10@tests.mozilla.org",
- "test9@tests.mozilla.org",
- "test11@tests.mozilla.org",
- "test13@tests.mozilla.org",
- "test12@tests.mozilla.org",
- "test14@tests.mozilla.org",
- "test15@tests.mozilla.org",
- "test17@tests.mozilla.org",
- "test19@tests.mozilla.org",
- "test16@tests.mozilla.org",
- "test20@tests.mozilla.org",
- "test18@tests.mozilla.org",
- ]);
-
- set_order("name", false);
-
- check_order([
- "test1@tests.mozilla.org",
- "test5@tests.mozilla.org",
- "test3@tests.mozilla.org",
- "test4@tests.mozilla.org",
- "test2@tests.mozilla.org",
- "test9@tests.mozilla.org",
- "test10@tests.mozilla.org",
- "test6@tests.mozilla.org",
- "test8@tests.mozilla.org",
- "test7@tests.mozilla.org",
- "test15@tests.mozilla.org",
- "test14@tests.mozilla.org",
- "test12@tests.mozilla.org",
- "test13@tests.mozilla.org",
- "test11@tests.mozilla.org",
- "test18@tests.mozilla.org",
- "test20@tests.mozilla.org",
- "test16@tests.mozilla.org",
- "test19@tests.mozilla.org",
- "test17@tests.mozilla.org",
- ]);
-
- run_next_test();
-});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_sorting_plugins.js b/toolkit/mozapps/extensions/test/browser/browser_sorting_plugins.js
deleted file mode 100644
index d31d378eda..0000000000
--- a/toolkit/mozapps/extensions/test/browser/browser_sorting_plugins.js
+++ /dev/null
@@ -1,109 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-// Tests that sorting of plugins works correctly
-// (this test checks that plugins with "ask to activate" state appear after those with
-// "always activate" and before those with "never activate")
-
-var gManagerWindow;
-var gProvider;
-
-// This test is testing XUL about:addons UI features that are not supported in the
-// HTML about:addons.
-SpecialPowers.pushPrefEnv({
- set: [["extensions.htmlaboutaddons.enabled", false]],
-});
-
-async function test() {
- waitForExplicitFinish();
-
- gProvider = new MockProvider();
- gProvider.createAddons([
- {
- // enabledInstalled group
- // * Always activate
- // * Ask to activate
- // * Never activate
- id: "test1@tests.mozilla.org",
- name: "Java Applet Plug-in Java 7 Update 51",
- description: "foo",
- type: "plugin",
- isActive: true,
- userDisabled: AddonManager.STATE_ASK_TO_ACTIVATE,
- },
- {
- id: "test2@tests.mozilla.org",
- name: "Quick Time Plug-in",
- description: "foo",
- type: "plugin",
- isActive: true,
- userDisabled: false,
- },
- {
- id: "test3@tests.mozilla.org",
- name: "Shockwave Flash",
- description: "foo",
- type: "plugin",
- isActive: false,
- userDisabled: true,
- },
- {
- id: "test4@tests.mozilla.org",
- name: "Adobe Reader Plug-in",
- description: "foo",
- type: "plugin",
- isActive: true,
- userDisabled: AddonManager.STATE_ASK_TO_ACTIVATE,
- },
- {
- id: "test5@tests.mozilla.org",
- name: "3rd Party Plug-in",
- description: "foo",
- type: "plugin",
- isActive: true,
- userDisabled: false,
- },
- ]);
-
- let aWindow = await open_manager("addons://list/plugin");
- gManagerWindow = aWindow;
- run_next_test();
-}
-
-async function end_test() {
- await close_manager(gManagerWindow);
- finish();
-}
-
-function check_order(aExpectedOrder) {
- var order = [];
- var list = gManagerWindow.document.getElementById("addon-list");
- var node = list.firstChild;
- while (node) {
- var id = node.getAttribute("value");
- if (id && id.endsWith("@tests.mozilla.org")) {
- order.push(node.getAttribute("value"));
- }
- node = node.nextSibling;
- }
-
- is(
- order.toSource(),
- aExpectedOrder.toSource(),
- "Should have seen the right order"
- );
-}
-
-// Tests that ascending name ordering was the default
-add_test(function() {
- check_order([
- "test5@tests.mozilla.org",
- "test2@tests.mozilla.org",
- "test4@tests.mozilla.org",
- "test1@tests.mozilla.org",
- "test3@tests.mozilla.org",
- ]);
-
- run_next_test();
-});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_tabsettings.js b/toolkit/mozapps/extensions/test/browser/browser_tabsettings.js
deleted file mode 100644
index 30b0a72a7d..0000000000
--- a/toolkit/mozapps/extensions/test/browser/browser_tabsettings.js
+++ /dev/null
@@ -1,77 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-// Tests various aspects of the details view
-
-var gManagerWindow;
-var gProvider;
-
-// This test is testing XUL about:addons UI (the HTML about:addons has its
-// own test files for these test cases).
-SpecialPowers.pushPrefEnv({
- set: [["extensions.htmlaboutaddons.enabled", false]],
-});
-
-async function test() {
- waitForExplicitFinish();
-
- gProvider = new MockProvider();
-
- gProvider.createAddons([
- {
- id: "tabsettings@tests.mozilla.org",
- name: "Tab Settings",
- version: "1",
- optionsURL: CHROMEROOT + "addon_prefs.xul",
- optionsType: AddonManager.OPTIONS_TYPE_TAB,
- },
- ]);
-
- let aWindow = await open_manager("addons://list/extension");
- gManagerWindow = aWindow;
-
- run_next_test();
-}
-
-async function end_test() {
- await close_manager(gManagerWindow);
- finish();
-}
-
-add_test(function() {
- var addon = get_addon_element(
- gManagerWindow,
- "tabsettings@tests.mozilla.org"
- );
- is(
- addon.mAddon.optionsType,
- AddonManager.OPTIONS_TYPE_TAB,
- "Options should be inline type"
- );
- addon.parentNode.ensureElementIsVisible(addon);
-
- var button = gManagerWindow.document.getAnonymousElementByAttribute(
- addon,
- "anonid",
- "preferences-btn"
- );
- is_element_visible(button, "Preferences button should be visible");
-
- EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, gManagerWindow);
-
- var browser = gBrowser.selectedBrowser;
- browser.addEventListener(
- "DOMContentLoaded",
- function() {
- is(
- browser.currentURI.spec,
- addon.mAddon.optionsURL,
- "New tab should have loaded the options URL"
- );
- browser.contentWindow.close();
- run_next_test();
- },
- { once: true }
- );
-});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_theme_previews.js b/toolkit/mozapps/extensions/test/browser/browser_theme_previews.js
deleted file mode 100644
index 6b13efcb35..0000000000
--- a/toolkit/mozapps/extensions/test/browser/browser_theme_previews.js
+++ /dev/null
@@ -1,184 +0,0 @@
-const { AddonTestUtils } = ChromeUtils.import(
- "resource://testing-common/AddonTestUtils.jsm"
-);
-
-let gManagerWindow;
-let gCategoryUtilities;
-
-// This test is testing the theme list at XUL about:addons. HTML about:addons's
-// theme list is already tested in browser_html_list_view.js.
-// The testThemeOrdering part of this test should be adapted when bug 1557768
-// is fixed.
-SpecialPowers.pushPrefEnv({
- set: [["extensions.htmlaboutaddons.enabled", false]],
-});
-
-registerCleanupFunction(() => {
- // AddonTestUtils with open_manager cause this reference to be maintained and creates a leak.
- gManagerWindow = null;
-});
-
-function imageBufferFromDataURI(encodedImageData) {
- let decodedImageData = atob(encodedImageData);
- return Uint8Array.from(decodedImageData, byte => byte.charCodeAt(0)).buffer;
-}
-const img =
- "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQImWNgYGBgAAAABQABh6FO1AAAAABJRU5ErkJggg==";
-const imageBuffer = imageBufferFromDataURI(img);
-
-const id = "theme@mochi.test";
-
-AddonTestUtils.initMochitest(this);
-
-function getThemeData(_id = id, manifest = {}, files = {}) {
- return {
- "manifest.json": {
- applications: {
- gecko: { id: _id },
- },
- manifest_version: 2,
- name: "atheme",
- description: "wow. such theme.",
- author: "Pixel Pusher",
- version: "1",
- theme: {},
- ...manifest,
- },
- "preview.png": imageBuffer,
- ...files,
- };
-}
-
-async function init(startPage) {
- gManagerWindow = await open_manager(null);
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- return gCategoryUtilities.openType(startPage);
-}
-
-add_task(async function testThemePreviewShown() {
- await init("theme");
-
- await AddonTestUtils.promiseInstallXPI(getThemeData());
- let theme = await AddonManager.getAddonByID(id);
-
- ok(theme.screenshots[0].url, "The add-on has a preview URL");
- let previewURL = theme.screenshots[0].url;
-
- let doc = gManagerWindow.document;
- let item = doc.querySelector(`richlistitem[value="${id}"]`);
-
- await BrowserTestUtils.waitForCondition(
- () =>
- item.getAttribute("status") == "installed" &&
- item.getAttribute("previewURL"),
- "Wait for the item to update to installed"
- );
-
- is(
- item.getAttribute("previewURL"),
- previewURL,
- "The previewURL is set on the item"
- );
- let image = doc.getAnonymousElementByAttribute(
- item,
- "anonid",
- "theme-screenshot"
- );
- is(image.src, previewURL, "The previewURL is set on the image src");
-
- item.click();
- await wait_for_view_load(gManagerWindow);
-
- image = doc.querySelector(".theme-screenshot");
- is(image.src, previewURL, "The previewURL is set on the detail image src");
-
- // Now check that an add-on doesn't have a preview (bug 1519616).
- let extensionId = "extension@mochi.test";
- await AddonTestUtils.promiseInstallXPI({
- "manifest.json": {
- applications: {
- gecko: { id: extensionId },
- },
- manifest_version: 2,
- name: "anextension",
- description: "wow. such extension.",
- author: "Woof",
- version: "1",
- },
- });
-
- await gCategoryUtilities.openType("extension");
-
- // Go to the detail page.
- item = doc.querySelector(`richlistitem[value="${extensionId}"]`);
- item.click();
- await wait_for_view_load(gManagerWindow);
-
- // Check that the image has no src attribute.
- image = doc.querySelector(".theme-screenshot");
- ok(!image.src, "There is no preview for extensions");
-
- await close_manager(gManagerWindow);
- await theme.uninstall();
-
- let extension = await AddonManager.getAddonByID(extensionId);
- await extension.uninstall();
-});
-
-add_task(async function testThemeOrdering() {
- // Install themes before loading the manager, if it's open they'll sort by install date.
- let themeId = id => id + "@mochi.test";
- let themeIds = [themeId(5), themeId(6), themeId(7), themeId(8)];
- await AddonTestUtils.promiseInstallXPI(
- getThemeData(themeId(6), { name: "BBB" })
- );
- await AddonTestUtils.promiseInstallXPI(
- getThemeData(themeId(7), { name: "CCC" })
- );
- await AddonTestUtils.promiseInstallXPI(
- getThemeData(themeId(5), { name: "AAA" }, { previewURL: "" })
- );
- await AddonTestUtils.promiseInstallXPI(
- getThemeData(themeId(8), { name: "DDD" })
- );
-
- // Enable a theme to make sure it's first.
- let addon = await AddonManager.getAddonByID(themeId(8));
- addon.enable();
-
- // Load themes now that the extensions are setup.
- await init("theme");
-
- // Find the order of ids for the ones we installed.
- let list = gManagerWindow.document.getElementById("addon-list");
- let idOrder = list.itemChildren
- .map(row => row.getAttribute("value"))
- .filter(id => themeIds.includes(id));
-
- // Check the order.
- Assert.deepEqual(
- idOrder,
- [
- themeId(8), // The active theme first.
- themeId(6),
- themeId(7), // With previews, ordered by name.
- themeId(5), // The theme without a preview last.
- ],
- "Themes are ordered by enabled, previews, then name"
- );
-
- // Ensure allow in private mode badge is hidden for themes.
- for (let item of list.itemChildren) {
- let badge = gManagerWindow.document.getAnonymousElementByAttribute(
- item,
- "anonid",
- "privateBrowsing"
- );
- is_element_hidden(badge, `private browsing badge is hidden`);
- }
-
- await close_manager(gManagerWindow);
- for (let addon of await promiseAddonsByIDs(themeIds)) {
- await addon.uninstall();
- }
-});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_types.js b/toolkit/mozapps/extensions/test/browser/browser_types.js
deleted file mode 100644
index c9a8d90046..0000000000
--- a/toolkit/mozapps/extensions/test/browser/browser_types.js
+++ /dev/null
@@ -1,492 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-// Tests that registering new types works
-
-var gManagerWindow;
-var gCategoryUtilities;
-
-var gProvider = {};
-
-var gTypes = [
- new AddonManagerPrivate.AddonType(
- "type1",
- null,
- "Type 1",
- AddonManager.VIEW_TYPE_LIST,
- 4500
- ),
- new AddonManagerPrivate.AddonType("missing1", null, "Missing 1"),
- new AddonManagerPrivate.AddonType(
- "type2",
- null,
- "Type 1",
- AddonManager.VIEW_TYPE_LIST,
- 5100,
- AddonManager.TYPE_UI_HIDE_EMPTY
- ),
- {
- id: "type3",
- name: "Type 3",
- uiPriority: 5200,
- viewType: AddonManager.VIEW_TYPE_LIST,
- },
-];
-
-// This test is testing XUL about:addons UI features that are not supported in the
-// HTML about:addons.
-SpecialPowers.pushPrefEnv({
- set: [["extensions.htmlaboutaddons.enabled", false]],
-});
-
-function go_back(aManager) {
- gBrowser.goBack();
-}
-
-function go_forward(aManager) {
- gBrowser.goForward();
-}
-
-function check_state(canGoBack, canGoForward) {
- is(gBrowser.canGoBack, canGoBack, "canGoBack should be correct");
- is(gBrowser.canGoForward, canGoForward, "canGoForward should be correct");
-}
-
-function test() {
- waitForExplicitFinish();
-
- run_next_test();
-}
-
-function end_test() {
- finish();
-}
-
-// Add a new type, open the manager and make sure it is in the right place
-add_test(async function() {
- AddonManagerPrivate.registerProvider(gProvider, gTypes);
-
- let aWindow = await open_manager(null);
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
-
- ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
- ok(gCategoryUtilities.get("type2"), "Type 2 should be present");
- ok(!gCategoryUtilities.get("missing1", true), "Missing 1 should be absent");
-
- is(
- gCategoryUtilities.get("type1").previousSibling.getAttribute("value"),
- "addons://list/extension",
- "Type 1 should be in the right place"
- );
- is(
- gCategoryUtilities.get("type2").previousSibling.getAttribute("value"),
- "addons://list/theme",
- "Type 2 should be in the right place"
- );
-
- ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
- ok(!gCategoryUtilities.isTypeVisible("type2"), "Type 2 should be hidden");
-
- run_next_test();
-});
-
-// Select the type, close the manager and remove it then open the manager and
-// check we're back to the default view
-add_test(async function() {
- await gCategoryUtilities.openType("type1");
- await close_manager(gManagerWindow);
- AddonManagerPrivate.unregisterProvider(gProvider);
-
- let aWindow = await open_manager(null);
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
-
- ok(!gCategoryUtilities.get("type1", true), "Type 1 should be absent");
- ok(!gCategoryUtilities.get("type2", true), "Type 2 should be absent");
- ok(!gCategoryUtilities.get("missing1", true), "Missing 1 should be absent");
-
- close_manager(gManagerWindow, run_next_test);
-});
-
-// Add a type while the manager is still open and check it appears
-add_test(async function() {
- let aWindow = await open_manager("addons://list/extension");
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
-
- ok(!gCategoryUtilities.get("type1", true), "Type 1 should be absent");
- ok(!gCategoryUtilities.get("type2", true), "Type 2 should be absent");
- ok(!gCategoryUtilities.get("missing1", true), "Missing 1 should be absent");
-
- AddonManagerPrivate.registerProvider(gProvider, gTypes);
-
- ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
- ok(gCategoryUtilities.get("type2"), "Type 2 should be present");
- ok(!gCategoryUtilities.get("missing1", true), "Missing 1 should be absent");
-
- is(
- gCategoryUtilities.get("type1").previousSibling.getAttribute("value"),
- "addons://list/extension",
- "Type 1 should be in the right place"
- );
- is(
- gCategoryUtilities.get("type2").previousSibling.getAttribute("value"),
- "addons://list/theme",
- "Type 2 should be in the right place"
- );
-
- ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
- ok(!gCategoryUtilities.isTypeVisible("type2"), "Type 2 should be hidden");
-
- run_next_test();
-});
-
-// Remove the type while it is beng viewed and check it is replaced with the
-// default view
-add_test(async function() {
- await gCategoryUtilities.openType("type1");
- await gCategoryUtilities.openType("plugin");
- go_back(gManagerWindow);
- await wait_for_view_load(gManagerWindow);
- is(
- gCategoryUtilities.selectedCategory,
- "type1",
- "Should be showing the custom view"
- );
- check_state(true, true);
-
- AddonManagerPrivate.unregisterProvider(gProvider);
-
- ok(!gCategoryUtilities.get("type1", true), "Type 1 should be absent");
- ok(!gCategoryUtilities.get("type2", true), "Type 2 should be absent");
- ok(!gCategoryUtilities.get("missing1", true), "Missing 1 should be absent");
-
- check_state(true, true);
-
- go_back(gManagerWindow);
- await wait_for_view_load(gManagerWindow);
- is(
- gCategoryUtilities.selectedCategory,
- "extension",
- "Should be showing the extension view"
- );
- check_state(false, true);
-
- go_forward(gManagerWindow);
- await wait_for_view_load(gManagerWindow);
- check_state(true, true);
-
- go_forward(gManagerWindow);
- await wait_for_view_load(gManagerWindow);
- is(
- gCategoryUtilities.selectedCategory,
- "plugin",
- "Should be back to the plugins view"
- );
- check_state(true, false);
-
- go_back(gManagerWindow);
- await wait_for_view_load(gManagerWindow);
- check_state(true, true);
-
- close_manager(gManagerWindow, run_next_test);
-});
-
-// Test that when going back to a now missing category we skip it
-add_test(async function() {
- let aWindow = await open_manager("addons://list/extension");
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
-
- AddonManagerPrivate.registerProvider(gProvider, gTypes);
-
- ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
- ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
-
- await gCategoryUtilities.openType("type1");
- await gCategoryUtilities.openType("plugin");
- AddonManagerPrivate.unregisterProvider(gProvider);
-
- ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
-
- go_back(gManagerWindow);
-
- await wait_for_view_load(gManagerWindow);
- is(
- gCategoryUtilities.selectedCategory,
- "extension",
- "Should be back to the first view"
- );
- check_state(false, true);
-
- close_manager(gManagerWindow, run_next_test);
-});
-
-// Test that when going forward to a now missing category we skip it
-add_test(async function() {
- let aWindow = await open_manager("addons://list/extension");
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
-
- AddonManagerPrivate.registerProvider(gProvider, gTypes);
-
- ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
- ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
-
- await gCategoryUtilities.openType("type1");
- await gCategoryUtilities.openType("plugin");
- go_back(gManagerWindow);
- await wait_for_view_load(gManagerWindow);
- go_back(gManagerWindow);
- await wait_for_view_load(gManagerWindow);
- is(
- gCategoryUtilities.selectedCategory,
- "extension",
- "Should be back to the extension view"
- );
-
- AddonManagerPrivate.unregisterProvider(gProvider);
-
- ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
-
- go_forward(gManagerWindow);
-
- await wait_for_view_load(gManagerWindow);
- is(
- gCategoryUtilities.selectedCategory,
- "plugin",
- "Should be back to the plugin view"
- );
- check_state(true, false);
-
- close_manager(gManagerWindow, run_next_test);
-});
-
-// Test that when going back to a now missing category and we can't go back any
-// any further then we just display the default view
-add_test(async function() {
- AddonManagerPrivate.registerProvider(gProvider, gTypes);
-
- let aWindow = await open_manager("addons://list/type1");
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- is(
- gCategoryUtilities.selectedCategory,
- "type1",
- "Should be at the custom view"
- );
-
- ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
- ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
-
- await gCategoryUtilities.openType("extension");
- AddonManagerPrivate.unregisterProvider(gProvider);
-
- ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
-
- go_back(gManagerWindow);
-
- await wait_for_view_load(gManagerWindow);
- is(
- gCategoryUtilities.selectedCategory,
- "discover",
- "Should be at the default view"
- );
- check_state(false, true);
-
- close_manager(gManagerWindow, run_next_test);
-});
-
-// Test that when going forward to a now missing category and we can't go
-// forward any further then we just display the default view
-add_test(async function() {
- AddonManagerPrivate.registerProvider(gProvider, gTypes);
-
- let aWindow = await open_manager("addons://list/extension");
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
-
- ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
- ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
-
- await gCategoryUtilities.openType("type1");
- go_back(gManagerWindow);
-
- await wait_for_view_load(gManagerWindow);
- is(
- gCategoryUtilities.selectedCategory,
- "extension",
- "Should be at the extension view"
- );
-
- AddonManagerPrivate.unregisterProvider(gProvider);
-
- ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
-
- go_forward(gManagerWindow);
-
- await wait_for_view_load(gManagerWindow);
- is(
- gCategoryUtilities.selectedCategory,
- "discover",
- "Should be at the default view"
- );
- check_state(true, false);
-
- close_manager(gManagerWindow, run_next_test);
-});
-
-// Test that when going back we skip multiple missing categories
-add_test(async function() {
- let aWindow = await open_manager("addons://list/extension");
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
-
- AddonManagerPrivate.registerProvider(gProvider, gTypes);
-
- ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
- ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
-
- await gCategoryUtilities.openType("type1");
- await gCategoryUtilities.openType("type3");
- await gCategoryUtilities.openType("plugin");
- AddonManagerPrivate.unregisterProvider(gProvider);
-
- ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
-
- go_back(gManagerWindow);
-
- await wait_for_view_load(gManagerWindow);
- is(
- gCategoryUtilities.selectedCategory,
- "extension",
- "Should be back to the first view"
- );
- check_state(false, true);
-
- close_manager(gManagerWindow, run_next_test);
-});
-
-// Test that when going forward we skip multiple missing categories
-add_test(async function() {
- let aWindow = await open_manager("addons://list/extension");
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
-
- AddonManagerPrivate.registerProvider(gProvider, gTypes);
-
- ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
- ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
-
- await gCategoryUtilities.openType("type1");
- await gCategoryUtilities.openType("type3");
- await gCategoryUtilities.openType("plugin");
- go_back(gManagerWindow);
- await wait_for_view_load(gManagerWindow);
- go_back(gManagerWindow);
- await wait_for_view_load(gManagerWindow);
- go_back(gManagerWindow);
- await wait_for_view_load(gManagerWindow);
- is(
- gCategoryUtilities.selectedCategory,
- "extension",
- "Should be back to the extension view"
- );
-
- AddonManagerPrivate.unregisterProvider(gProvider);
-
- ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
-
- go_forward(gManagerWindow);
-
- await wait_for_view_load(gManagerWindow);
- is(
- gCategoryUtilities.selectedCategory,
- "plugin",
- "Should be back to the plugin view"
- );
- check_state(true, false);
-
- close_manager(gManagerWindow, run_next_test);
-});
-
-// Test that when going back we skip all missing categories and when we can't go
-// back any any further then we just display the default view
-add_test(async function() {
- AddonManagerPrivate.registerProvider(gProvider, gTypes);
-
- let aWindow = await open_manager("addons://list/type1");
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- is(
- gCategoryUtilities.selectedCategory,
- "type1",
- "Should be at the custom view"
- );
-
- ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
- ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
-
- await gCategoryUtilities.openType("type3");
- await gCategoryUtilities.openType("extension");
- AddonManagerPrivate.unregisterProvider(gProvider);
-
- ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
-
- go_back(gManagerWindow);
-
- await wait_for_view_load(gManagerWindow);
- is(
- gCategoryUtilities.selectedCategory,
- "discover",
- "Should be at the default view"
- );
- check_state(false, true);
-
- close_manager(gManagerWindow, run_next_test);
-});
-
-// Test that when going forward we skip all missing categories and when we can't
-// go back any any further then we just display the default view
-add_test(async function() {
- AddonManagerPrivate.registerProvider(gProvider, gTypes);
-
- let aWindow = await open_manager("addons://list/extension");
- gManagerWindow = aWindow;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
-
- ok(gCategoryUtilities.get("type1"), "Type 1 should be present");
- ok(gCategoryUtilities.isTypeVisible("type1"), "Type 1 should be visible");
-
- await gCategoryUtilities.openType("type1");
- await gCategoryUtilities.openType("type3");
- go_back(gManagerWindow);
-
- await wait_for_view_load(gManagerWindow);
- go_back(gManagerWindow);
-
- await wait_for_view_load(gManagerWindow);
- is(
- gCategoryUtilities.selectedCategory,
- "extension",
- "Should be at the extension view"
- );
-
- AddonManagerPrivate.unregisterProvider(gProvider);
-
- ok(!gCategoryUtilities.get("type1", true), "Type 1 should not be present");
-
- go_forward(gManagerWindow);
-
- await wait_for_view_load(gManagerWindow);
- is(
- gCategoryUtilities.selectedCategory,
- "discover",
- "Should be at the default view"
- );
- check_state(true, false);
-
- close_manager(gManagerWindow, run_next_test);
-});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_uninstalling.js b/toolkit/mozapps/extensions/test/browser/browser_uninstalling.js
deleted file mode 100644
index 3aaa5b9824..0000000000
--- a/toolkit/mozapps/extensions/test/browser/browser_uninstalling.js
+++ /dev/null
@@ -1,666 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-var gManagerWindow;
-var gDocument;
-var gCategoryUtilities;
-var gProvider;
-
-// This test is testing XUL about:addons UI (the HTML about:addons has its
-// own test files for these test cases).
-SpecialPowers.pushPrefEnv({
- set: [["extensions.htmlaboutaddons.enabled", false]],
-});
-
-async function setup_manager(...args) {
- let aWindow = await open_manager(...args);
- gManagerWindow = aWindow;
- gDocument = gManagerWindow.document;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
-}
-
-async function test() {
- requestLongerTimeout(2);
- waitForExplicitFinish();
-
- gProvider = new MockProvider();
-
- gProvider.createAddons([
- {
- id: "addon2@tests.mozilla.org",
- name: "Uninstall doesn't need restart 1",
- type: "extension",
- operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE,
- },
- {
- id: "addon3@tests.mozilla.org",
- name: "Uninstall doesn't need restart 2",
- type: "extension",
- operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE,
- },
- {
- id: "addon4@tests.mozilla.org",
- name: "Uninstall doesn't need restart 3",
- type: "extension",
- operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE,
- },
- {
- id: "addon5@tests.mozilla.org",
- name: "Uninstall doesn't need restart 4",
- type: "extension",
- operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE,
- },
- {
- id: "addon6@tests.mozilla.org",
- name: "Uninstall doesn't need restart 5",
- type: "extension",
- operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE,
- },
- {
- id: "addon7@tests.mozilla.org",
- name: "Uninstall doesn't need restart 6",
- type: "extension",
- operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE,
- },
- {
- id: "addon8@tests.mozilla.org",
- name: "Uninstall doesn't need restart 7",
- type: "extension",
- operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE,
- },
- {
- id: "addon9@tests.mozilla.org",
- name: "Uninstall doesn't need restart 8",
- type: "extension",
- operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE,
- },
- ]);
-
- await setup_manager(null);
- run_next_test();
-}
-
-async function end_test() {
- await close_manager(gManagerWindow);
- finish();
-}
-
-function get_item_in_list(aId, aList) {
- var item = aList.firstChild;
- while (item) {
- if ("mAddon" in item && item.mAddon.id == aId) {
- aList.ensureElementIsVisible(item);
- return item;
- }
- item = item.nextSibling;
- }
- return null;
-}
-
-// Tests that uninstalling a restartless add-on from the list view can be undone
-add_test(async function() {
- var ID = "addon2@tests.mozilla.org";
- var list = gDocument.getElementById("addon-list");
-
- // Select the extensions category
- await gCategoryUtilities.openType("extension");
- is(
- gCategoryUtilities.selectedCategory,
- "extension",
- "View should have changed to extension"
- );
-
- let aAddon = await AddonManager.getAddonByID(ID);
- ok(aAddon.isActive, "Add-on should be active");
- ok(
- !(
- aAddon.operationsRequiringRestart &
- AddonManager.OP_NEEDS_RESTART_UNINSTALL
- ),
- "Add-on should not require a restart to uninstall"
- );
- ok(
- !(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL),
- "Add-on should not be pending uninstall"
- );
-
- var item = get_item_in_list(ID, list);
- isnot(item, null, "Should have found the add-on in the list");
-
- var button = gDocument.getAnonymousElementByAttribute(
- item,
- "anonid",
- "remove-btn"
- );
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
-
- EventUtils.synthesizeMouseAtCenter(button, {}, gManagerWindow);
-
- // Force XBL to apply
- item.clientTop;
-
- is(
- item.getAttribute("pending"),
- "uninstall",
- "Add-on should be uninstalling"
- );
-
- ok(
- aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL,
- "Add-on should be pending uninstall"
- );
- ok(!aAddon.isActive, "Add-on should be inactive");
-
- button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
- isnot(button, null, "Should have an undo button");
-
- EventUtils.synthesizeMouseAtCenter(button, {}, gManagerWindow);
-
- // Force XBL to apply
- item.clientTop;
-
- ok(aAddon.isActive, "Add-on should be active");
- button = gDocument.getAnonymousElementByAttribute(
- item,
- "anonid",
- "remove-btn"
- );
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
-
- run_next_test();
-});
-
-// Tests that uninstalling a disabled restartless add-on from the list view can
-// be undone and doesn't re-enable
-add_test(async function() {
- var ID = "addon2@tests.mozilla.org";
- var list = gDocument.getElementById("addon-list");
-
- // Select the extensions category
- await gCategoryUtilities.openType("extension");
- is(
- gCategoryUtilities.selectedCategory,
- "extension",
- "View should have changed to extension"
- );
-
- let aAddon = await AddonManager.getAddonByID(ID);
- await aAddon.disable();
-
- ok(!aAddon.isActive, "Add-on should be inactive");
- ok(
- !(
- aAddon.operationsRequiringRestart &
- AddonManager.OP_NEEDS_RESTART_UNINSTALL
- ),
- "Add-on should not require a restart to uninstall"
- );
- ok(
- !(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL),
- "Add-on should not be pending uninstall"
- );
-
- var item = get_item_in_list(ID, list);
- isnot(item, null, "Should have found the add-on in the list");
-
- var button = gDocument.getAnonymousElementByAttribute(
- item,
- "anonid",
- "remove-btn"
- );
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
-
- EventUtils.synthesizeMouseAtCenter(button, {}, gManagerWindow);
-
- // Force XBL to apply
- item.clientTop;
-
- is(
- item.getAttribute("pending"),
- "uninstall",
- "Add-on should be uninstalling"
- );
-
- ok(
- aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL,
- "Add-on should be pending uninstall"
- );
- ok(!aAddon.isActive, "Add-on should be inactive");
-
- button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
- isnot(button, null, "Should have an undo button");
-
- EventUtils.synthesizeMouseAtCenter(button, {}, gManagerWindow);
-
- // Force XBL to apply
- item.clientTop;
-
- ok(!aAddon.isActive, "Add-on should be inactive");
- button = gDocument.getAnonymousElementByAttribute(
- item,
- "anonid",
- "remove-btn"
- );
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
-
- await aAddon.enable();
- ok(aAddon.isActive, "Add-on should be active");
-
- run_next_test();
-});
-
-async function test_uninstall_details(aAddon, ID) {
- is(
- get_current_view(gManagerWindow).id,
- "detail-view",
- "Should be in the detail view"
- );
-
- var button = gDocument.getElementById("detail-uninstall-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
-
- EventUtils.synthesizeMouseAtCenter(button, {}, gManagerWindow);
-
- await wait_for_view_load(gManagerWindow);
- is(
- gCategoryUtilities.selectedCategory,
- "extension",
- "View should have changed to extension"
- );
-
- var list = gDocument.getElementById("addon-list");
- var item = get_item_in_list(ID, list);
- isnot(item, null, "Should have found the add-on in the list");
- is(
- item.getAttribute("pending"),
- "uninstall",
- "Add-on should be uninstalling"
- );
-
- ok(
- !!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL),
- "Add-on should be pending uninstall"
- );
- ok(!aAddon.isActive, "Add-on should be inactive");
-
- // Force XBL to apply
- item.clientTop;
-
- button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
- isnot(button, null, "Should have an undo button");
-
- EventUtils.synthesizeMouseAtCenter(button, {}, gManagerWindow);
-
- // Force XBL to apply
- item.clientTop;
-
- ok(aAddon.isActive, "Add-on should be active");
- button = gDocument.getAnonymousElementByAttribute(
- item,
- "anonid",
- "remove-btn"
- );
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
-
- run_next_test();
-}
-
-// Tests that uninstalling a restartless add-on from the details view switches
-// back to the list view and can be undone
-add_test(async function() {
- var ID = "addon2@tests.mozilla.org";
- var list = gDocument.getElementById("addon-list");
-
- // Select the extensions category
- await gCategoryUtilities.openType("extension");
- is(
- gCategoryUtilities.selectedCategory,
- "extension",
- "View should have changed to extension"
- );
-
- let aAddon = await AddonManager.getAddonByID(ID);
- ok(aAddon.isActive, "Add-on should be active");
- ok(
- !(
- aAddon.operationsRequiringRestart &
- AddonManager.OP_NEEDS_RESTART_UNINSTALL
- ),
- "Add-on should not require a restart to uninstall"
- );
- ok(
- !(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL),
- "Add-on should not be pending uninstall"
- );
-
- var item = get_item_in_list(ID, list);
- isnot(item, null, "Should have found the add-on in the list");
-
- item.click();
- await wait_for_view_load(gManagerWindow);
-
- // Test the uninstall.
- return test_uninstall_details(aAddon, ID);
-});
-
-// Tests that uninstalling a restartless add-on from directly loading the
-// details view switches back to the list view and can be undone
-add_test(async function() {
- // Close this about:addons and open a new one in a new tab.
- await close_manager(gManagerWindow);
-
- // Load the detail view directly.
- var ID = "addon2@tests.mozilla.org";
- await setup_manager(`addons://detail/${ID}`);
-
- let aAddon = await AddonManager.getAddonByID(ID);
- ok(aAddon.isActive, "Add-on should be active");
- ok(
- !(
- aAddon.operationsRequiringRestart &
- AddonManager.OP_NEEDS_RESTART_UNINSTALL
- ),
- "Add-on should not require a restart to uninstall"
- );
- ok(
- !(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL),
- "Add-on should not be pending uninstall"
- );
-
- // Test the uninstall.
- return test_uninstall_details(aAddon, ID);
-});
-
-// Tests that uninstalling a restartless add-on from the details view switches
-// back to the list view and can be undone and doesn't re-enable
-add_test(async function() {
- var ID = "addon2@tests.mozilla.org";
- var list = gDocument.getElementById("addon-list");
-
- // Select the extensions category
- await gCategoryUtilities.openType("extension");
- is(
- gCategoryUtilities.selectedCategory,
- "extension",
- "View should have changed to extension"
- );
-
- let aAddon = await AddonManager.getAddonByID(ID);
- await aAddon.disable();
-
- ok(!aAddon.isActive, "Add-on should be inactive");
- ok(
- !(
- aAddon.operationsRequiringRestart &
- AddonManager.OP_NEEDS_RESTART_UNINSTALL
- ),
- "Add-on should not require a restart to uninstall"
- );
- ok(
- !(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL),
- "Add-on should not be pending uninstall"
- );
-
- var item = get_item_in_list(ID, list);
- isnot(item, null, "Should have found the add-on in the list");
-
- item.click();
- await wait_for_view_load(gManagerWindow);
- is(
- get_current_view(gManagerWindow).id,
- "detail-view",
- "Should be in the detail view"
- );
-
- var button = gDocument.getElementById("detail-uninstall-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
-
- EventUtils.synthesizeMouseAtCenter(button, {}, gManagerWindow);
-
- await wait_for_view_load(gManagerWindow);
- is(
- gCategoryUtilities.selectedCategory,
- "extension",
- "View should have changed to extension"
- );
-
- item = get_item_in_list(ID, list);
- isnot(item, null, "Should have found the add-on in the list");
- is(
- item.getAttribute("pending"),
- "uninstall",
- "Add-on should be uninstalling"
- );
-
- ok(
- !!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL),
- "Add-on should be pending uninstall"
- );
- ok(!aAddon.isActive, "Add-on should be inactive");
-
- // Force XBL to apply
- item.clientTop;
-
- button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
- isnot(button, null, "Should have an undo button");
-
- EventUtils.synthesizeMouseAtCenter(button, {}, gManagerWindow);
-
- // Force XBL to apply
- item.clientTop;
-
- ok(!aAddon.isActive, "Add-on should be inactive");
- button = gDocument.getAnonymousElementByAttribute(
- item,
- "anonid",
- "remove-btn"
- );
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
-
- await aAddon.enable();
- ok(aAddon.isActive, "Add-on should be active");
-
- run_next_test();
-});
-
-// Tests that switching away from the list view finalises the uninstall of
-// multiple restartless add-ons
-add_test(async function() {
- var ID = "addon2@tests.mozilla.org";
- var ID2 = "addon6@tests.mozilla.org";
- var list = gDocument.getElementById("addon-list");
-
- // Select the extensions category
- await gCategoryUtilities.openType("extension");
- is(
- gCategoryUtilities.selectedCategory,
- "extension",
- "View should have changed to extension"
- );
-
- let aAddon = await AddonManager.getAddonByID(ID);
- ok(aAddon.isActive, "Add-on should be active");
- ok(
- !(
- aAddon.operationsRequiringRestart &
- AddonManager.OP_NEEDS_RESTART_UNINSTALL
- ),
- "Add-on should not require a restart to uninstall"
- );
- ok(
- !(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL),
- "Add-on should not be pending uninstall"
- );
-
- var item = get_item_in_list(ID, list);
- isnot(item, null, "Should have found the add-on in the list");
-
- var button = gDocument.getAnonymousElementByAttribute(
- item,
- "anonid",
- "remove-btn"
- );
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
-
- EventUtils.synthesizeMouseAtCenter(button, {}, gManagerWindow);
-
- // Force XBL to apply
- item.clientTop;
-
- is(
- item.getAttribute("pending"),
- "uninstall",
- "Add-on should be uninstalling"
- );
- ok(
- aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL,
- "Add-on should be pending uninstall"
- );
- ok(!aAddon.isActive, "Add-on should be inactive");
-
- button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
- isnot(button, null, "Should have an undo button");
-
- item = get_item_in_list(ID2, list);
- isnot(item, null, "Should have found the add-on in the list");
-
- button = gDocument.getAnonymousElementByAttribute(
- item,
- "anonid",
- "remove-btn"
- );
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
-
- EventUtils.synthesizeMouseAtCenter(button, {}, gManagerWindow);
-
- await gCategoryUtilities.openType("plugin");
- is(
- gCategoryUtilities.selectedCategory,
- "plugin",
- "View should have changed to extension"
- );
-
- let [bAddon, bAddon2] = await AddonManager.getAddonsByIDs([ID, ID2]);
- is(bAddon, null, "Add-on should no longer be installed");
- is(bAddon2, null, "Second add-on should no longer be installed");
-
- await gCategoryUtilities.openType("extension");
- is(
- gCategoryUtilities.selectedCategory,
- "extension",
- "View should have changed to extension"
- );
-
- item = get_item_in_list(ID, list);
- is(item, null, "Should not have found the add-on in the list");
- item = get_item_in_list(ID2, list);
- is(item, null, "Should not have found the second add-on in the list");
-
- run_next_test();
-});
-
-// Tests that closing the manager from the list view finalises the uninstall of
-// multiple restartless add-ons
-add_test(async function() {
- var ID = "addon4@tests.mozilla.org";
- var ID2 = "addon8@tests.mozilla.org";
- var list = gDocument.getElementById("addon-list");
-
- // Select the extensions category
- await gCategoryUtilities.openType("extension");
- is(
- gCategoryUtilities.selectedCategory,
- "extension",
- "View should have changed to extension"
- );
-
- let aAddon = await AddonManager.getAddonByID(ID);
- ok(aAddon.isActive, "Add-on should be active");
- ok(
- !(
- aAddon.operationsRequiringRestart &
- AddonManager.OP_NEEDS_RESTART_UNINSTALL
- ),
- "Add-on should not require a restart to uninstall"
- );
- ok(
- !(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL),
- "Add-on should not be pending uninstall"
- );
-
- var item = get_item_in_list(ID, list);
- isnot(item, null, "Should have found the add-on in the list");
-
- var button = gDocument.getAnonymousElementByAttribute(
- item,
- "anonid",
- "remove-btn"
- );
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
-
- EventUtils.synthesizeMouseAtCenter(button, {}, gManagerWindow);
-
- // Force XBL to apply
- item.clientTop;
-
- is(
- item.getAttribute("pending"),
- "uninstall",
- "Add-on should be uninstalling"
- );
-
- ok(
- aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL,
- "Add-on should be pending uninstall"
- );
- ok(!aAddon.isActive, "Add-on should be inactive");
-
- button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
- isnot(button, null, "Should have an undo button");
-
- item = get_item_in_list(ID2, list);
- isnot(item, null, "Should have found the add-on in the list");
-
- button = gDocument.getAnonymousElementByAttribute(
- item,
- "anonid",
- "remove-btn"
- );
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
-
- EventUtils.synthesizeMouseAtCenter(button, {}, gManagerWindow);
-
- await close_manager(gManagerWindow);
- let [bAddon, bAddon2] = await AddonManager.getAddonsByIDs([ID, ID2]);
- is(bAddon, null, "Add-on should no longer be installed");
- is(bAddon2, null, "Second add-on should no longer be installed");
-
- await setup_manager(null);
- list = gDocument.getElementById("addon-list");
-
- is(
- gCategoryUtilities.selectedCategory,
- "extension",
- "View should have changed to extension"
- );
-
- item = get_item_in_list(ID, list);
- is(item, null, "Should not have found the add-on in the list");
- item = get_item_in_list(ID2, list);
- is(item, null, "Should not have found the second add-on in the list");
-
- run_next_test();
-});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_updateid.js b/toolkit/mozapps/extensions/test/browser/browser_updateid.js
index 5cffb3f263..87e92b92d3 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_updateid.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_updateid.js
@@ -9,33 +9,20 @@ var gManagerWindow;
var gCategoryUtilities;
function getName(item) {
- if (gManagerWindow.useHtmlViews) {
- return item.addonNameEl.textContent;
- }
- return gManagerWindow.document.getAnonymousElementByAttribute(
- item,
- "anonid",
- "name"
- ).textContent;
+ return item.addonNameEl.textContent;
}
async function getUpdateButton(item) {
- if (gManagerWindow.useHtmlViews) {
- let button = item.querySelector('[action="install-update"]');
- let panel = button.closest("panel-list");
- let shown = BrowserTestUtils.waitForEvent(panel, "shown");
- panel.show();
- await shown;
- return button;
- }
- return gManagerWindow.document.getAnonymousElementByAttribute(
- item,
- "anonid",
- "update-btn"
- );
+ 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);
+ await shown;
+ return button;
}
-async function test_updateid() {
+add_task(async function test_updateid() {
// Close the existing about:addons tab and unrestier the existing MockProvider
// instance if a previous failed test has not been able to clear them.
if (gManagerWindow) {
@@ -97,24 +84,4 @@ async function test_updateid() {
gManagerWindow = null;
gProvider.unregister();
gProvider = null;
-}
-
-add_task(async function test_XUL_updateid() {
- await SpecialPowers.pushPrefEnv({
- set: [["extensions.htmlaboutaddons.enabled", false]],
- });
-
- await test_updateid();
-
- // No popPrefEnv because of bug 1557397.
-});
-
-add_task(async function test_HTML_updateid() {
- await SpecialPowers.pushPrefEnv({
- set: [["extensions.htmlaboutaddons.enabled", true]],
- });
-
- await test_updateid();
-
- // No popPrefEnv because of bug 1557397.
});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_updatessl.js b/toolkit/mozapps/extensions/test/browser/browser_updatessl.js
index 6ecaaa5af4..9b7ec2344d 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_updatessl.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_updatessl.js
@@ -88,7 +88,7 @@ function add_update_test(mainURL, redirectURL, expectedStatus) {
function run_update_tests(callback) {
function run_next_update_test() {
- if (gTests.length == 0) {
+ if (!gTests.length) {
callback();
return;
}
diff --git a/toolkit/mozapps/extensions/test/browser/browser_webapi_access.js b/toolkit/mozapps/extensions/test/browser/browser_webapi_access.js
index b6fe3478a6..38d1df18f5 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_webapi_access.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_webapi_access.js
@@ -145,7 +145,7 @@ add_task(async function test_chrome_frame() {
});
await BrowserTestUtils.withNewTab(
- `${CHROMEROOT}webapi_checkchromeframe.xul`,
+ `${CHROMEROOT}webapi_checkchromeframe.xhtml`,
async function test_available(browser) {
let available = await check_frame_availability(browser);
ok(available, "API should be available.");
diff --git a/toolkit/mozapps/extensions/test/browser/browser_webapi_install.js b/toolkit/mozapps/extensions/test/browser/browser_webapi_install.js
index 23b205f41a..f9c42fb735 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_webapi_install.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_webapi_install.js
@@ -152,7 +152,7 @@ async function testInstall(browser, args, steps, description) {
});
}
- while (steps.length > 0) {
+ while (steps.length) {
let nextStep = steps.shift();
if (nextStep.action) {
if (nextStep.action == "install") {
diff --git a/toolkit/mozapps/extensions/test/browser/browser_webext_icon.js b/toolkit/mozapps/extensions/test/browser/browser_webext_icon.js
index 2b477a22ed..b43de20f1d 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_webext_icon.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_webext_icon.js
@@ -64,36 +64,6 @@ add_task(async function test_addon_icon() {
const extension = ExtensionTestUtils.loadExtension(extensionDefinition);
await extension.startup();
- info(`Testing XUL about:addons`);
- await SpecialPowers.pushPrefEnv({
- set: [["extensions.htmlaboutaddons.enabled", false]],
- });
-
- await checkIconInView("addons://list/extension", "list", doc => {
- const addon = get_addon_element(doc.defaultView, id);
- const content = doc.getAnonymousElementByAttribute(
- addon,
- "class",
- "content-container"
- );
- return content.querySelector(".icon");
- });
-
- await checkIconInView(
- "addons://detail/" + encodeURIComponent(id),
- "details",
- doc => {
- return doc.getElementById("detail-icon");
- }
- );
-
- await SpecialPowers.popPrefEnv();
-
- info(`Testing HTML about:addons`);
- await SpecialPowers.pushPrefEnv({
- set: [["extensions.htmlaboutaddons.enabled", true]],
- });
-
await checkIconInView("addons://list/extension", "list", doc => {
return get_addon_element(doc.defaultView, id).querySelector(".addon-icon");
});
@@ -108,7 +78,5 @@ add_task(async function test_addon_icon() {
}
);
- await SpecialPowers.popPrefEnv();
-
await extension.unload();
});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_webext_incognito.js b/toolkit/mozapps/extensions/test/browser/browser_webext_incognito.js
index 1b1491c1b8..42f72fbf36 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_webext_incognito.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_webext_incognito.js
@@ -14,26 +14,15 @@ AddonTestUtils.initMochitest(this);
function get_test_items() {
var items = {};
- if (gManagerWindow.useHtmlViews) {
- for (let item of gManagerWindow
- .getHtmlBrowser()
- .contentDocument.querySelectorAll("addon-card")) {
- items[item.getAttribute("addon-id")] = item;
- }
- } else {
- for (let item of gManagerWindow.document.getElementById("addon-list")
- .childNodes) {
- items[item.mAddon.id] = item;
- }
+ for (let item of gManagerWindow
+ .getHtmlBrowser()
+ .contentDocument.querySelectorAll("addon-card")) {
+ items[item.getAttribute("addon-id")] = item;
}
return items;
}
-function get(aId) {
- return gManagerWindow.document.getElementById(aId);
-}
-
function getHtmlElem(selector) {
return gManagerWindow
.getHtmlBrowser()
@@ -41,184 +30,88 @@ function getHtmlElem(selector) {
}
function getPrivateBrowsingBadge(card) {
- if (gManagerWindow.useHtmlViews) {
- return card.querySelector(".addon-badge-private-browsing-allowed");
- }
- return card.ownerDocument.getAnonymousElementByAttribute(
- card,
- "anonid",
- "privateBrowsing"
- );
+ return card.querySelector(".addon-badge-private-browsing-allowed");
}
function getPreferencesButtonAtListView(card) {
- if (gManagerWindow.useHtmlViews) {
- return card.querySelector("panel-item[action='preferences']");
- }
- return card._preferencesBtn;
+ return card.querySelector("panel-item[action='preferences']");
}
function getPreferencesButtonAtDetailsView() {
- if (gManagerWindow.useHtmlViews) {
- return getHtmlElem("panel-item[action='preferences']");
- }
- return gManagerWindow.document.getElementById("detail-prefs-btn");
+ return getHtmlElem("panel-item[action='preferences']");
}
function isInlineOptionsVisible() {
- if (gManagerWindow.useHtmlViews) {
- // The following button is used to open the inline options browser.
- return !getHtmlElem("named-deck-button[name='preferences']").hidden;
- }
- return !!gManagerWindow.document.getElementById("addon-options");
+ // The following button is used to open the inline options browser.
+ return !getHtmlElem("named-deck-button[name='preferences']").hidden;
}
function getPrivateBrowsingValue() {
- if (gManagerWindow.useHtmlViews) {
- return getHtmlElem("input[type='radio'][name='private-browsing']:checked")
- .value;
- }
- return gManagerWindow.document.getElementById("detail-privateBrowsing").value;
+ return getHtmlElem("input[type='radio'][name='private-browsing']:checked")
+ .value;
}
async function setPrivateBrowsingValue(value) {
- if (gManagerWindow.useHtmlViews) {
- let radio = getHtmlElem(
- `input[type="radio"][name="private-browsing"][value="${value}"]`
- );
- EventUtils.synthesizeMouseAtCenter(
- radio,
- { clickCount: 1 },
- radio.ownerGlobal
- );
- return TestUtils.waitForCondition(
- () => radio.checked,
- `Waiting for privateBrowsing=${value}`
- );
- }
- let privateBrowsing = gManagerWindow.document.getElementById(
- "detail-privateBrowsing"
+ let radio = getHtmlElem(
+ `input[type="radio"][name="private-browsing"][value="${value}"]`
+ );
+ EventUtils.synthesizeMouseAtCenter(
+ radio,
+ { clickCount: 1 },
+ radio.ownerGlobal
);
- let radio = privateBrowsing.querySelector(`radio[value="${value}"]`);
- EventUtils.synthesizeMouseAtCenter(radio, { clickCount: 1 }, gManagerWindow);
return TestUtils.waitForCondition(
- () => privateBrowsing.value == value,
+ () => radio.checked,
`Waiting for privateBrowsing=${value}`
);
}
// Check whether the private browsing inputs are visible in the details view.
function checkIsModifiable(expected) {
- if (gManagerWindow.useHtmlViews) {
- if (expected) {
- is_element_visible(
- getHtmlElem(".addon-detail-row-private-browsing"),
- "Private browsing should be visible"
- );
- } else {
- is_element_hidden(
- getHtmlElem(".addon-detail-row-private-browsing"),
- "Private browsing should be hidden"
- );
- }
- checkHelpRow(".addon-detail-row-private-browsing", expected);
- return;
- }
if (expected) {
is_element_visible(
- get("detail-privateBrowsing-row"),
+ getHtmlElem(".addon-detail-row-private-browsing"),
"Private browsing should be visible"
);
- is_element_visible(
- get("detail-privateBrowsing-row-footer"),
- "Private browsing footer should be visible"
- );
} else {
is_element_hidden(
- get("detail-privateBrowsing-row"),
+ getHtmlElem(".addon-detail-row-private-browsing"),
"Private browsing should be hidden"
);
- is_element_hidden(
- get("detail-privateBrowsing-row-footer"),
- "Private browsing footer should be hidden"
- );
}
+ checkHelpRow(".addon-detail-row-private-browsing", expected);
}
// Check whether the details view shows that private browsing is forcibly disallowed.
function checkIsDisallowed(expected) {
- if (gManagerWindow.useHtmlViews) {
- if (expected) {
- is_element_visible(
- getHtmlElem(".addon-detail-row-private-browsing-disallowed"),
- "Private browsing should be disallowed"
- );
- } else {
- is_element_hidden(
- getHtmlElem(".addon-detail-row-private-browsing-disallowed"),
- "Private browsing should not be disallowed"
- );
- }
- checkHelpRow(".addon-detail-row-private-browsing-disallowed", expected);
- return;
- }
if (expected) {
is_element_visible(
- get("detail-privateBrowsing-disallowed"),
+ getHtmlElem(".addon-detail-row-private-browsing-disallowed"),
"Private browsing should be disallowed"
);
- is_element_visible(
- get("detail-privateBrowsing-disallowed-footer"),
- "Private browsing footer should be disallowed"
- );
} else {
is_element_hidden(
- get("detail-privateBrowsing-disallowed"),
+ getHtmlElem(".addon-detail-row-private-browsing-disallowed"),
"Private browsing should not be disallowed"
);
- is_element_hidden(
- get("detail-privateBrowsing-disallowed-footer"),
- "Private browsing footer should not be disallowed"
- );
}
+ checkHelpRow(".addon-detail-row-private-browsing-disallowed", expected);
}
// Check whether the details view shows that private browsing is forcibly allowed.
function checkIsRequired(expected) {
- if (gManagerWindow.useHtmlViews) {
- if (expected) {
- is_element_visible(
- getHtmlElem(".addon-detail-row-private-browsing-required"),
- "Private browsing should be required"
- );
- } else {
- is_element_hidden(
- getHtmlElem(".addon-detail-row-private-browsing-required"),
- "Private browsing should not be required"
- );
- }
- checkHelpRow(".addon-detail-row-private-browsing-required", expected);
- return;
- }
if (expected) {
is_element_visible(
- get("detail-privateBrowsing-required"),
- "Private required should be visible"
- );
- is_element_visible(
- get("detail-privateBrowsing-required-footer"),
- "Private required footer should be visible"
+ getHtmlElem(".addon-detail-row-private-browsing-required"),
+ "Private browsing should be required"
);
} else {
is_element_hidden(
- get("detail-privateBrowsing-required"),
- "Private required should be hidden"
- );
- is_element_hidden(
- get("detail-privateBrowsing-required-footer"),
- "Private required footer should be hidden"
+ getHtmlElem(".addon-detail-row-private-browsing-required"),
+ "Private browsing should not be required"
);
}
+ checkHelpRow(".addon-detail-row-private-browsing-required", expected);
}
function checkHelpRow(selector, expected) {
@@ -242,7 +135,7 @@ async function hasPrivateAllowed(id) {
);
}
-async function test_badge_and_toggle_incognito() {
+add_task(async function test_badge_and_toggle_incognito() {
await SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
@@ -362,9 +255,9 @@ async function test_badge_and_toggle_incognito() {
};
Services.prefs.clearUserPref("extensions.allowPrivateBrowsingByDefault");
-}
+});
-async function test_addon_preferences_button() {
+add_task(async function test_addon_preferences_button() {
await SpecialPowers.pushPrefEnv({
set: [["extensions.allowPrivateBrowsingByDefault", false]],
});
@@ -437,18 +330,10 @@ async function test_addon_preferences_button() {
};
const setAddonPrivateBrowsingAccess = async (id, allowPrivateBrowsing) => {
- let cardUpdatedPromise;
- if (gManagerWindow.useHtmlViews) {
- cardUpdatedPromise = BrowserTestUtils.waitForEvent(
- getHtmlElem("addon-card"),
- "update"
- );
- } else {
- cardUpdatedPromise = BrowserTestUtils.waitForEvent(
- gManagerWindow,
- "ViewChanged"
- );
- }
+ const cardUpdatedPromise = BrowserTestUtils.waitForEvent(
+ getHtmlElem("addon-card"),
+ "update"
+ );
is(
getPrivateBrowsingValue(),
allowPrivateBrowsing ? "0" : "1",
@@ -479,14 +364,12 @@ async function test_addon_preferences_button() {
allowPrivateBrowsing ? "added" : "removed"
}`
);
- if (gManagerWindow.useHtmlViews) {
- let badge = getPrivateBrowsingBadge(getHtmlElem("addon-card"));
- is(
- !badge.hidden,
- allowPrivateBrowsing,
- `Expected private browsing badge at ${id}`
- );
- }
+ let badge = getPrivateBrowsingBadge(getHtmlElem("addon-card"));
+ is(
+ !badge.hidden,
+ allowPrivateBrowsing,
+ `Expected private browsing badge at ${id}`
+ );
};
const extensions = [];
@@ -543,13 +426,12 @@ async function test_addon_preferences_button() {
// run tests in private and non-private windows.
await runTest(true);
await runTest(false);
-}
+});
-async function test_addon_postinstall_incognito_hidden_checkbox(withHtmlViews) {
+add_task(async function test_addon_postinstall_incognito_hidden_checkbox() {
await SpecialPowers.pushPrefEnv({
set: [
["extensions.allowPrivateBrowsingByDefault", false],
- ["extensions.htmlaboutaddons.enabled", withHtmlViews],
],
});
@@ -577,8 +459,8 @@ async function test_addon_postinstall_incognito_hidden_checkbox(withHtmlViews) {
applications: { gecko: { id: "static-theme@mozilla.com" } },
theme: {
colors: {
- accentcolor: "#FFFFFF",
- textcolor: "#000",
+ frame: "#FFFFFF",
+ tab_background_text: "#000",
},
},
},
@@ -676,9 +558,7 @@ async function test_addon_postinstall_incognito_hidden_checkbox(withHtmlViews) {
// It is not possible to create a privileged add-on and install it, so just
// simulate an installed privileged add-on and check the UI.
await test_incognito_of_privileged_addons();
-
- // No popPrefEnv because of bug 1557397.
-}
+});
// Checks that the private browsing flag of privileged add-ons cannot be modified.
async function test_incognito_of_privileged_addons() {
@@ -721,53 +601,3 @@ async function test_incognito_of_privileged_addons() {
provider.unregister();
}
-
-add_task(async function test_badge_and_toggle_incognito_on_XUL_aboutaddons() {
- await SpecialPowers.pushPrefEnv({
- set: [["extensions.htmlaboutaddons.enabled", false]],
- });
- await test_badge_and_toggle_incognito();
- // No popPrefEnv because of bug 1557397.
-});
-
-add_task(async function test_badge_and_toggle_incognito_on_HTML_aboutaddons() {
- await SpecialPowers.pushPrefEnv({
- set: [["extensions.htmlaboutaddons.enabled", true]],
- });
- await test_badge_and_toggle_incognito();
- // No popPrefEnv because of bug 1557397.
-});
-
-add_task(async function test_addon_preferences_button_on_XUL_aboutaddons() {
- await SpecialPowers.pushPrefEnv({
- set: [
- ["extensions.htmlaboutaddons.enabled", false],
- ["extensions.htmlaboutaddons.inline-options.enabled", false],
- ],
- });
- await test_addon_preferences_button();
- // No popPrefEnv because of bug 1557397.
-});
-
-add_task(async function test_addon_preferences_button_on_HTML_aboutaddons() {
- await SpecialPowers.pushPrefEnv({
- set: [
- ["extensions.htmlaboutaddons.enabled", true],
- ["extensions.htmlaboutaddons.inline-options.enabled", true],
- ],
- });
- await test_addon_preferences_button();
- // No popPrefEnv because of bug 1557397.
-});
-
-add_task(
- async function test_addon_postinstall_incognito_hidden_checkbox_on_XUL_aboutaddons() {
- await test_addon_postinstall_incognito_hidden_checkbox(false);
- }
-);
-
-add_task(
- async function test_addon_postinstall_incognito_hidden_checkbox_on_HTML_aboutaddons() {
- await test_addon_postinstall_incognito_hidden_checkbox(true);
- }
-);
diff --git a/toolkit/mozapps/extensions/test/browser/browser_webext_options.js b/toolkit/mozapps/extensions/test/browser/browser_webext_options.js
deleted file mode 100644
index c460e03331..0000000000
--- a/toolkit/mozapps/extensions/test/browser/browser_webext_options.js
+++ /dev/null
@@ -1,124 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-ChromeUtils.import("resource://testing-common/ContentTask.jsm", {});
-
-// This test is testing XUL about:addons UI (the HTML about:addons preferences
-// panel is already tested in browser_html_options_ui.js).
-SpecialPowers.pushPrefEnv({
- set: [["extensions.htmlaboutaddons.enabled", false]],
-});
-
-// Wrapper to run a test that consists of:
-// 1. opening the add-ons manager viewing the list of extensions
-// 2. installing an extension (using the provider installer callable)
-// 3. opening the preferences panel for the new extension and verifying
-// that it opens cleanly
-async function runTest(installer) {
- let mgrWindow = await open_manager("addons://list/extension");
-
- let { addon, id } = await installer();
- isnot(addon, null, "Extension is installed");
-
- let element = get_addon_element(mgrWindow, id);
- element.parentNode.ensureElementIsVisible(element);
-
- let button = mgrWindow.document.getAnonymousElementByAttribute(
- element,
- "anonid",
- "preferences-btn"
- );
- is_element_visible(button, "Preferences button should be visible");
-
- EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, mgrWindow);
-
- await TestUtils.topicObserved(
- AddonManager.OPTIONS_NOTIFICATION_DISPLAYED,
- (subject, data) => data == id
- );
-
- is(
- mgrWindow.gViewController.currentViewId,
- `addons://detail/${encodeURIComponent(id)}/preferences`,
- "Current view should scroll to preferences"
- );
-
- var browser = mgrWindow.document.querySelector(
- "#detail-grid > rows > stack > .inline-options-browser"
- );
- ok(browser, "Grid should have a browser descendant");
- is(browser.localName, "browser", "Grid should have a browser descendant");
-
- var rows = browser.parentNode;
-
- await ContentTask.spawn(browser, element.mAddon.optionsURL, async url => {
- await ContentTaskUtils.waitForCondition(
- () => content.location.href == url,
- "Browser has the expected options URL loaded"
- );
- });
-
- is(
- browser.clientWidth,
- browser.parentNode.clientWidth,
- "Browser should be the same width as its direct parent"
- );
- is(
- browser.clientWidth,
- rows.clientWidth,
- "Browser should be the same width as its rows ancestor"
- );
-
- button = mgrWindow.document.getElementById("detail-prefs-btn");
- is_element_hidden(button, "Preferences button should not be visible");
-
- await close_manager(mgrWindow);
-
- addon.uninstall();
-}
-
-function promiseWebExtensionStartup() {
- const { Management } = ChromeUtils.import(
- "resource://gre/modules/Extension.jsm",
- null
- );
-
- return new Promise(resolve => {
- let listener = (event, extension) => {
- Management.off("startup", listener);
- resolve(extension);
- };
-
- Management.on("startup", listener);
- });
-}
-
-// Test that deferred handling of optionsURL works for a signed webextension
-add_task(async function test_options_signed() {
- await runTest(async function() {
- // The extension in-tree is signed with this ID:
- const ID = "{9792932b-32b2-4567-998c-e7bf6c4c5e35}";
-
- await Promise.all([
- promiseWebExtensionStartup(),
- install_addon("addons/options_signed.xpi"),
- ]);
- let addon = await promiseAddonByID(ID);
-
- return { addon, id: ID };
- });
-});
-
-add_task(async function test_options_temporary() {
- await runTest(async function() {
- let dir = get_addon_file_url("options_signed").file;
- let [addon] = await Promise.all([
- AddonManager.installTemporaryAddon(dir),
- promiseWebExtensionStartup(),
- ]);
- isnot(addon, null, "Extension is installed (temporarily)");
-
- return { addon, id: addon.id };
- });
-});
diff --git a/toolkit/mozapps/extensions/test/browser/browser_webext_options_addon_reload.js b/toolkit/mozapps/extensions/test/browser/browser_webext_options_addon_reload.js
deleted file mode 100644
index 8179bb9586..0000000000
--- a/toolkit/mozapps/extensions/test/browser/browser_webext_options_addon_reload.js
+++ /dev/null
@@ -1,124 +0,0 @@
-"use strict";
-
-const { AddonTestUtils } = ChromeUtils.import(
- "resource://testing-common/AddonTestUtils.jsm"
-);
-const { ExtensionParent } = ChromeUtils.import(
- "resource://gre/modules/ExtensionParent.jsm"
-);
-
-// This test is testing XUL about:addons UI (the HTML about:addons options page
-// is tested by the testCardRerender test in browser_html_options_ui.js).
-SpecialPowers.pushPrefEnv({
- set: [["extensions.htmlaboutaddons.enabled", false]],
-});
-
-// This test function helps to detect when an addon options browser have been inserted
-// in the about:addons page.
-function waitOptionsBrowserInserted() {
- return new Promise(resolve => {
- async function listener(eventName, browser) {
- // wait for a webextension XUL browser element that is owned by the "about:addons" page.
- if (browser.ownerDocument.location.href == "about:addons") {
- ExtensionParent.apiManager.off("extension-browser-inserted", listener);
-
- resolve(browser);
- }
- }
- ExtensionParent.apiManager.on("extension-browser-inserted", listener);
- });
-}
-
-add_task(async function test_options_on_addon_reload() {
- const ID = "@test-options-on-addon-reload";
-
- function backgroundScript() {
- const { browser } = window;
- browser.runtime.openOptionsPage();
- }
-
- let extensionDefinition = {
- useAddonManager: "temporary",
-
- manifest: {
- options_ui: {
- page: "options.html",
- },
- applications: {
- gecko: {
- id: ID,
- },
- },
- },
- files: {
- "options.html": `
-
-
-
-
-
- Extension Options UI
-
- `,
- },
- background: backgroundScript,
- };
-
- await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:addons");
-
- const extension = ExtensionTestUtils.loadExtension(extensionDefinition);
-
- const onceOptionsBrowserInserted = waitOptionsBrowserInserted();
-
- await extension.startup();
-
- info("Wait for the options_ui page XUL browser to be created");
- await onceOptionsBrowserInserted;
-
- const aboutAddonsDocument = gBrowser.selectedBrowser.contentDocument;
-
- Assert.equal(
- aboutAddonsDocument.location.href,
- "about:addons",
- "The about:addons page is the currently selected tab"
- );
-
- const optionsBrowsers = aboutAddonsDocument.querySelectorAll(
- "#addon-options"
- );
- Assert.equal(
- optionsBrowsers.length,
- 1,
- "Got a single XUL browser for the addon options_ui page"
- );
-
- // Reload the addon five times in a row, and then check that there is still one addon options browser.
-
- let addon = await AddonManager.getAddonByID(ID);
-
- for (let i = 0; i < 5; i++) {
- const onceOptionsReloaded = Promise.all([
- AddonTestUtils.promiseWebExtensionStartup(),
- waitOptionsBrowserInserted(),
- ]);
-
- await addon.reload();
-
- info("Wait for the new options_ui page XUL browser to be created");
- await onceOptionsReloaded;
-
- let optionsBrowsers = aboutAddonsDocument.querySelectorAll(
- "#addon-options"
- );
-
- Assert.equal(
- optionsBrowsers.length,
- 1,
- "Got a single XUL browser for the addon options_ui page"
- );
- }
-
- BrowserTestUtils.removeTab(gBrowser.selectedTab);
-
- await extension.unload();
-});
diff --git a/toolkit/mozapps/extensions/test/browser/head.js b/toolkit/mozapps/extensions/test/browser/head.js
index bc46807bfb..ca107eb57e 100644
--- a/toolkit/mozapps/extensions/test/browser/head.js
+++ b/toolkit/mozapps/extensions/test/browser/head.js
@@ -224,7 +224,7 @@ function run_next_test() {
info("Test " + gTestsRun + " took " + (Date.now() - gTestStart) + "ms");
}
- if (gPendingTests.length == 0) {
+ if (!gPendingTests.length) {
executeSoon(end_test);
return;
}
@@ -242,63 +242,23 @@ function run_next_test() {
}
var get_tooltip_info = async function(addonEl, managerWindow) {
- if (managerWindow && managerWindow.useHtmlViews) {
- // Extract from title attribute.
- const { addon } = addonEl;
- const name = addon.name;
- const nameEl = addonEl.addonNameEl;
+ // Extract from title attribute.
+ const { addon } = addonEl;
+ const name = addon.name;
+ const nameEl = addonEl.addonNameEl;
- let nameWithVersion = nameEl.title;
- if (addonEl.addon.userDisabled) {
- // TODO - Bug 1558077: Currently Fluent is clearing the addon title
- // when the addon is disabled, fixing it requires changes to the
- // HTML about:addons localized strings, and then remove this
- // workaround.
- nameWithVersion = `${name} ${addon.version}`;
- }
-
- return {
- name,
- version: nameWithVersion.substring(name.length + 1),
- };
+ let nameWithVersion = nameEl.title;
+ if (addonEl.addon.userDisabled) {
+ // TODO - Bug 1558077: Currently Fluent is clearing the addon title
+ // when the addon is disabled, fixing it requires changes to the
+ // HTML about:addons localized strings, and then remove this
+ // workaround.
+ nameWithVersion = `${name} ${addon.version}`;
}
- // Retrieve the tooltip from the XUL about:addons view,
- // the popup code uses a triggering event's target to set the
- // document.tooltipNode property.
- let doc = addonEl.ownerDocument;
- let nameNode = doc.getAnonymousElementByAttribute(addonEl, "anonid", "name");
- let event = new doc.ownerGlobal.CustomEvent("TriggerEvent");
- nameNode.dispatchEvent(event);
-
- let tooltip = doc.getElementById("addonitem-tooltip");
-
- let promise = BrowserTestUtils.waitForEvent(tooltip, "popupshown");
- tooltip.openPopup(nameNode, "after_start", 0, 0, false, false, event);
- await promise;
-
- let tiptext = tooltip.label;
-
- promise = BrowserTestUtils.waitForEvent(tooltip, "popuphidden");
- tooltip.hidePopup();
- await promise;
-
- let expectedName = addonEl.getAttribute("name");
- is(
- tiptext.substring(0, expectedName.length),
- expectedName,
- "Tooltip should always start with the expected name"
- );
-
- if (expectedName.length == tiptext.length) {
- return {
- name: tiptext,
- version: undefined,
- };
- }
return {
- name: tiptext.substring(0, expectedName.length),
- version: tiptext.substring(expectedName.length + 1),
+ name,
+ version: nameWithVersion.substring(name.length + 1),
};
};
@@ -365,28 +325,12 @@ function check_all_in_list(aManager, aIds, aIgnoreExtras) {
}
function get_addon_element(aManager, aId) {
- if (aManager.useHtmlViews) {
- const doc = aManager.getHtmlBrowser().contentDocument;
- return doc.querySelector(`addon-card[addon-id="${aId}"]`);
- }
+ const win = aManager.getHtmlBrowser().contentWindow;
+ return getAddonCard(win, aId);
+}
- const doc = aManager.document;
- const view = get_current_view(aManager);
- let listid = "addon-list";
- if (view.id == "updates-view") {
- listid = "updates-list";
- }
- const list = doc.getElementById(listid);
-
- let node = list.firstChild;
- while (node) {
- if (node.value == aId) {
- return node;
- }
- node = node.nextSibling;
- }
-
- return null;
+function getAddonCard(win, id) {
+ return win.document.querySelector(`addon-card[addon-id="${id}"]`);
}
function wait_for_view_load(
@@ -558,7 +502,7 @@ function get_string(aName, ...aArgs) {
var bundle = Services.strings.createBundle(
"chrome://mozapps/locale/extensions/extensions.properties"
);
- if (aArgs.length == 0) {
+ if (!aArgs.length) {
return bundle.GetStringFromName(aName);
}
return bundle.formatStringFromName(aName, aArgs);
@@ -854,7 +798,7 @@ MockProvider.prototype = {
*/
addAddon: function MP_addAddon(aAddon) {
var oldAddons = this.addons.filter(aOldAddon => aOldAddon.id == aAddon.id);
- var oldAddon = oldAddons.length > 0 ? oldAddons[0] : null;
+ var oldAddon = oldAddons.length ? oldAddons[0] : null;
this.addons = this.addons.filter(aOldAddon => aOldAddon.id != aAddon.id);
@@ -1028,7 +972,7 @@ MockProvider.prototype = {
"MockProvider: pending callbacks at shutdown(): calling immediately"
);
}
- while (this.callbackTimers.length > 0) {
+ while (this.callbackTimers.length) {
// When we notify the callback timer, it removes itself from our array
let timer = this.callbackTimers[0];
try {
@@ -1070,7 +1014,7 @@ MockProvider.prototype = {
*/
async getAddonsByTypes(aTypes) {
var addons = this.addons.filter(function(aAddon) {
- if (aTypes && aTypes.length > 0 && !aTypes.includes(aAddon.type)) {
+ if (aTypes && !!aTypes.length && !aTypes.includes(aAddon.type)) {
return false;
}
return true;
@@ -1091,7 +1035,7 @@ MockProvider.prototype = {
return false;
}
- if (aTypes && aTypes.length > 0 && !aTypes.includes(aInstall.type)) {
+ if (aTypes && !!aTypes.length && !aTypes.includes(aInstall.type)) {
return false;
}
@@ -1212,13 +1156,6 @@ function MockAddon(aId, aName, aType, aOperationsRequiringRestart) {
}
MockAddon.prototype = {
- get isCorrectlySigned() {
- if (this.signedState === AddonManager.SIGNEDSTATE_NOT_REQUIRED) {
- return true;
- }
- return this.signedState > AddonManager.SIGNEDSTATE_MISSING;
- },
-
get shouldBeActive() {
return (
!this.appDisabled &&
diff --git a/toolkit/mozapps/extensions/test/browser/more_options.xul b/toolkit/mozapps/extensions/test/browser/more_options.xhtml
similarity index 100%
rename from toolkit/mozapps/extensions/test/browser/more_options.xul
rename to toolkit/mozapps/extensions/test/browser/more_options.xhtml
diff --git a/toolkit/mozapps/extensions/test/browser/options.xul b/toolkit/mozapps/extensions/test/browser/options.xhtml
similarity index 100%
rename from toolkit/mozapps/extensions/test/browser/options.xul
rename to toolkit/mozapps/extensions/test/browser/options.xhtml
diff --git a/toolkit/mozapps/extensions/test/browser/webapi_checkchromeframe.xul b/toolkit/mozapps/extensions/test/browser/webapi_checkchromeframe.xhtml
similarity index 100%
rename from toolkit/mozapps/extensions/test/browser/webapi_checkchromeframe.xul
rename to toolkit/mozapps/extensions/test/browser/webapi_checkchromeframe.xhtml
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/langpack_signed.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/langpack_signed.xpi
deleted file mode 100644
index f60d00348e..0000000000
Binary files a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/langpack_signed.xpi and /dev/null differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/langpack_unsigned.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/langpack_unsigned.xpi
deleted file mode 100644
index 89de7f4409..0000000000
Binary files a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/langpack_unsigned.xpi and /dev/null differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long.xpi
deleted file mode 100644
index f95f3df91e..0000000000
Binary files a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long.xpi and /dev/null differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/privileged.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/privileged.xpi
deleted file mode 100644
index c22acaacd2..0000000000
Binary files a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/privileged.xpi and /dev/null differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed1.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed1.xpi
deleted file mode 100644
index e2ba7d6fd8..0000000000
Binary files a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed1.xpi and /dev/null differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed2.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed2.xpi
deleted file mode 100644
index ccb20796f2..0000000000
Binary files a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed2.xpi and /dev/null differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/unsigned.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/unsigned.xpi
deleted file mode 100644
index 9e10be5db3..0000000000
Binary files a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/unsigned.xpi and /dev/null differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
index 368a634551..9822d5e0ea 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
@@ -131,7 +131,6 @@ const {
ExtensionTestUtils.init(this);
AddonTestUtils.init(this);
-AddonTestUtils.overrideCertDB();
XPCOMUtils.defineLazyGetter(
this,
@@ -863,7 +862,7 @@ class EventChecker {
}
let events = this.expectedEvents[aId];
- Assert.ok(events.length > 0, `Should be expecting events for ${aId}`);
+ Assert.ok(!!events.length, `Should be expecting events for ${aId}`);
return events.shift();
}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/head_system_addons.js b/toolkit/mozapps/extensions/test/xpcshell/head_system_addons.js
index b5f0c4b01c..70bd0db91e 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/head_system_addons.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/head_system_addons.js
@@ -266,10 +266,6 @@ async function checkInstalledSystemAddons(conditions, distroDir) {
Assert.ok(uri instanceof Ci.nsIFileURL);
Assert.equal(uri.file.path, file.path);
-
- if (isUpgrade) {
- Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_SYSTEM);
- }
} else {
info(`Checking state of add-on ${id}, expecting it to be missing`);
diff --git a/toolkit/mozapps/extensions/test/xpcshell/rs-blocklist/test_blocklist_severities.js b/toolkit/mozapps/extensions/test/xpcshell/rs-blocklist/test_blocklist_severities.js
index 21beefb0ce..ade9349fc6 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/rs-blocklist/test_blocklist_severities.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/rs-blocklist/test_blocklist_severities.js
@@ -4,7 +4,7 @@
*/
const URI_EXTENSION_BLOCKLIST_DIALOG =
- "chrome://mozapps/content/extensions/blocklist.xul";
+ "chrome://mozapps/content/extensions/blocklist.xhtml";
// Workaround for Bug 658720 - URL formatter can leak during xpcshell tests
const PREF_BLOCKLIST_ITEM_URL = "extensions.blocklist.itemURL";
diff --git a/toolkit/mozapps/extensions/test/xpcshell/rs-blocklist/test_blocklistchange.js b/toolkit/mozapps/extensions/test/xpcshell/rs-blocklist/test_blocklistchange.js
index 93831403f0..040fabf84d 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/rs-blocklist/test_blocklistchange.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/rs-blocklist/test_blocklistchange.js
@@ -24,7 +24,7 @@
// start with add-ons blocked as it would be identical to softblock3
const URI_EXTENSION_BLOCKLIST_DIALOG =
- "chrome://mozapps/content/extensions/blocklist.xul";
+ "chrome://mozapps/content/extensions/blocklist.xhtml";
// Allow insecure updates
Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_ProductAddonChecker.js b/toolkit/mozapps/extensions/test/xpcshell/test_ProductAddonChecker.js
index 4d25ccf099..1fc7693e5f 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_ProductAddonChecker.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_ProductAddonChecker.js
@@ -186,99 +186,3 @@ add_task(async function test_download_missing() {
Assert.ok(true, "Should have thrown when downloading a missing file.");
}
});
-
-add_task(async function test_download_noverify() {
- let path = await ProductAddonChecker.downloadAddon({
- URL: root + "unsigned.xpi",
- });
-
- let stat = await OS.File.stat(path);
- Assert.ok(!stat.isDir);
- Assert.equal(stat.size, 452);
-
- Assert.ok(
- compareFiles(
- do_get_file("data/productaddons/unsigned.xpi"),
- new LocalFile(path)
- )
- );
-
- await OS.File.remove(path);
-});
-
-add_task(async function test_download_badsize() {
- try {
- let path = await ProductAddonChecker.downloadAddon({
- URL: root + "unsigned.xpi",
- size: 400,
- });
-
- await OS.File.remove(path);
- do_throw("Should not have downloaded a file with a bad size");
- } catch (e) {
- Assert.ok(
- true,
- "Should have thrown when downloading a file with a bad size."
- );
- }
-});
-
-add_task(async function test_download_badhashfn() {
- try {
- let path = await ProductAddonChecker.downloadAddon({
- URL: root + "unsigned.xpi",
- hashFunction: "sha2567",
- hashValue:
- "9b9abf7ddfc1a6d7ffc7e0247481dcc202363e4445ad3494fb22036f1698c7f3",
- });
-
- await OS.File.remove(path);
- do_throw("Should not have downloaded a file with a bad hash function");
- } catch (e) {
- Assert.ok(
- true,
- "Should have thrown when downloading a file with a bad hash function."
- );
- }
-});
-
-add_task(async function test_download_badhash() {
- try {
- let path = await ProductAddonChecker.downloadAddon({
- URL: root + "unsigned.xpi",
- hashFunction: "sha256",
- hashValue:
- "8b9abf7ddfc1a6d7ffc7e0247481dcc202363e4445ad3494fb22036f1698c7f3",
- });
-
- await OS.File.remove(path);
- do_throw("Should not have downloaded a file with a bad hash");
- } catch (e) {
- Assert.ok(
- true,
- "Should have thrown when downloading a file with a bad hash."
- );
- }
-});
-
-add_task(async function test_download_works() {
- let path = await ProductAddonChecker.downloadAddon({
- URL: root + "unsigned.xpi",
- size: 452,
- hashFunction: "sha256",
- hashValue:
- "9b9abf7ddfc1a6d7ffc7e0247481dcc202363e4445ad3494fb22036f1698c7f3",
- });
-
- let stat = await OS.File.stat(path);
- Assert.ok(!stat.isDir);
-
- Assert.ok(
- compareFiles(
- do_get_file("data/productaddons/unsigned.xpi"),
- new LocalFile(path)
- )
- );
-
- await OS.File.remove(path);
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_badschema.js b/toolkit/mozapps/extensions/test/xpcshell/test_badschema.js
index 4f8130cf3e..70720ceace 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_badschema.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_badschema.js
@@ -125,7 +125,7 @@ const ADDONS = {
manifest_version: 2,
name: "Theme 1",
version: "1.0",
- theme: { images: { headerURL: "example.png" } },
+ theme: { images: { theme_frame: "example.png" } },
applications: {
gecko: {
id: "theme1@tests.mozilla.org",
@@ -145,7 +145,7 @@ const ADDONS = {
manifest_version: 2,
name: "Theme 2",
version: "1.0",
- theme: { images: { headerURL: "example.png" } },
+ theme: { images: { theme_frame: "example.png" } },
applications: {
gecko: {
id: "theme2@tests.mozilla.org",
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_corrupt.js b/toolkit/mozapps/extensions/test/xpcshell/test_corrupt.js
index 432db9cf46..f31a64b01b 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_corrupt.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_corrupt.js
@@ -92,7 +92,7 @@ const ADDONS = {
manifest_version: 2,
name: "Theme 1",
version: "1.0",
- theme: { images: { headerURL: "example.png" } },
+ theme: { images: { theme_frame: "example.png" } },
applications: {
gecko: {
id: "theme1@tests.mozilla.org",
@@ -112,7 +112,7 @@ const ADDONS = {
manifest_version: 2,
name: "Theme 2",
version: "1.0",
- theme: { images: { headerURL: "example.png" } },
+ theme: { images: { theme_frame: "example.png" } },
applications: {
gecko: {
id: "theme2@tests.mozilla.org",
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_db_path.js b/toolkit/mozapps/extensions/test/xpcshell/test_db_path.js
index 520c90a4d4..422bb52c44 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_db_path.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_db_path.js
@@ -22,7 +22,6 @@ add_task(async function test_non_ascii_path() {
env.set(PROFILE_VAR, profileDir);
AddonTestUtils.init(global);
- AddonTestUtils.overrideCertDB();
AddonTestUtils.createAppInfo(
"xpcshell@tests.mozilla.org",
"XPCShell",
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_json_updatecheck.js b/toolkit/mozapps/extensions/test/xpcshell/test_json_updatecheck.js
index 4a7bdf252a..303fbbc696 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_json_updatecheck.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_json_updatecheck.js
@@ -285,7 +285,7 @@ add_task(async function test_update_url_security() {
updates: [
{
version: "0.2",
- update_link: "chrome://browser/content/browser.xul",
+ update_link: "chrome://browser/content/browser.xhtml",
update_hash:
"sha256:08ac852190ecd81f40a514ea9299fe9143d9ab5e296b97e73fb2a314de49648a",
},
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_plugins.js b/toolkit/mozapps/extensions/test/xpcshell/test_plugins.js
index 7d566cdcca..9b48b9c66d 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_plugins.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_plugins.js
@@ -82,7 +82,7 @@ async function run_test_1() {
Assert.notEqual(testPlugin, null);
let addons = await AddonManager.getAddonsByTypes(["plugin"]);
- Assert.ok(addons.length > 0);
+ Assert.ok(!!addons.length);
addons.forEach(function(p) {
if (p.description == TEST_PLUGIN_DESCRIPTION) {
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_pref_properties.js b/toolkit/mozapps/extensions/test/xpcshell/test_pref_properties.js
index 99beedde98..6a0597372f 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_pref_properties.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_pref_properties.js
@@ -30,7 +30,7 @@ var gManagerEventsListener = {
},
checkExpected() {
info("Checking expected events...");
- while (this.expectedEvents.length > 0) {
+ while (this.expectedEvents.length) {
let event = this.expectedEvents.pop();
info("Looking for expected event " + event);
let matchingEvents = this.seenEvents.filter(function(aSeenEvent) {
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_sideloads.js b/toolkit/mozapps/extensions/test/xpcshell/test_sideloads.js
index 79e9130f0f..e60364f36f 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_sideloads.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_sideloads.js
@@ -36,7 +36,7 @@ add_task(async function test_sideloading() {
id: ID1,
name: "Test 1",
userDisabled: true,
- permissions: ["history", "https://*/*"],
+ permissions: ["tabs", "https://*/*"],
iconURL: "foo-icon.png",
});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_signed_inject.js b/toolkit/mozapps/extensions/test/xpcshell/test_signed_inject.js
deleted file mode 100644
index 5a5e73acb4..0000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_signed_inject.js
+++ /dev/null
@@ -1,429 +0,0 @@
-// Enable signature checks for these tests
-gUseRealCertChecks = true;
-// Disable update security
-Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
-
-const DATA = "data/signing_checks/";
-const ADDONS = {
- bootstrap: {
- unsigned: "unsigned_bootstrap_2.xpi",
- badid: "signed_bootstrap_badid_2.xpi",
- signed: "signed_bootstrap_2.xpi",
- preliminary: "preliminary_bootstrap_2.xpi",
- },
- nonbootstrap: {
- unsigned: "unsigned_nonbootstrap_2.xpi",
- badid: "signed_nonbootstrap_badid_2.xpi",
- signed: "signed_nonbootstrap_2.xpi",
- },
-};
-const ID = "test@tests.mozilla.org";
-
-const profileDir = gProfD.clone();
-profileDir.append("extensions");
-
-// Deletes a file from the test add-on in the profile
-function breakAddon(file) {
- if (TEST_UNPACKED) {
- let f = file.clone();
- f.append("test.txt");
- f.remove(true);
-
- f = file.clone();
- f.append("install.rdf");
- f.lastModifiedTime = Date.now();
- } else {
- var zipW = Cc["@mozilla.org/zipwriter;1"].createInstance(Ci.nsIZipWriter);
- zipW.open(file, FileUtils.MODE_RDWR | FileUtils.MODE_APPEND);
- zipW.removeEntry("test.txt", false);
- zipW.close();
- }
-}
-
-function resetPrefs() {
- Services.prefs.setIntPref("bootstraptest.active_version", -1);
- Services.prefs.setIntPref("bootstraptest.installed_version", -1);
- Services.prefs.setIntPref("bootstraptest.startup_reason", -1);
- Services.prefs.setIntPref("bootstraptest.shutdown_reason", -1);
- Services.prefs.setIntPref("bootstraptest.install_reason", -1);
- Services.prefs.setIntPref("bootstraptest.uninstall_reason", -1);
- Services.prefs.setIntPref("bootstraptest.startup_oldversion", -1);
- Services.prefs.setIntPref("bootstraptest.shutdown_newversion", -1);
- Services.prefs.setIntPref("bootstraptest.install_oldversion", -1);
- Services.prefs.setIntPref("bootstraptest.uninstall_newversion", -1);
-}
-
-function clearCache(file) {
- if (TEST_UNPACKED) {
- return;
- }
-
- Services.obs.notifyObservers(file, "flush-cache-entry");
-}
-
-function getActiveVersion() {
- return Services.prefs.getIntPref("bootstraptest.active_version");
-}
-
-add_task(async function setup() {
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "4", "4");
-
- // Start and stop the manager to initialise everything in the profile before
- // actual testing
- await promiseStartupManager();
- await promiseShutdownManager();
- resetPrefs();
-});
-
-// Injecting into profile (bootstrap)
-add_task(async function() {
- let file = await manuallyInstall(
- do_get_file(DATA + ADDONS.bootstrap.unsigned),
- profileDir,
- ID
- );
-
- await promiseStartupManager();
-
- // Currently we leave the sideloaded add-on there but just don't run it
- let addon = await promiseAddonByID(ID);
- Assert.notEqual(addon, null);
- Assert.ok(addon.appDisabled);
- Assert.ok(!addon.isActive);
- Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_MISSING);
- Assert.equal(getActiveVersion(), -1);
-
- await addon.uninstall();
- await promiseShutdownManager();
- resetPrefs();
-
- Assert.ok(!file.exists());
- clearCache(file);
-});
-
-add_task(async function() {
- let file = await manuallyInstall(
- do_get_file(DATA + ADDONS.bootstrap.signed),
- profileDir,
- ID
- );
- breakAddon(file);
-
- await promiseStartupManager();
-
- // Currently we leave the sideloaded add-on there but just don't run it
- let addon = await promiseAddonByID(ID);
- Assert.notEqual(addon, null);
- Assert.ok(addon.appDisabled);
- Assert.ok(!addon.isActive);
- Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_BROKEN);
- Assert.equal(getActiveVersion(), -1);
-
- await addon.uninstall();
- await promiseShutdownManager();
- resetPrefs();
-
- Assert.ok(!file.exists());
- clearCache(file);
-});
-
-add_task(async function() {
- let file = await manuallyInstall(
- do_get_file(DATA + ADDONS.bootstrap.badid),
- profileDir,
- ID
- );
-
- await promiseStartupManager();
-
- // Currently we leave the sideloaded add-on there but just don't run it
- let addon = await promiseAddonByID(ID);
- Assert.notEqual(addon, null);
- Assert.ok(addon.appDisabled);
- Assert.ok(!addon.isActive);
- Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_BROKEN);
- Assert.equal(getActiveVersion(), -1);
-
- await addon.uninstall();
- await promiseShutdownManager();
- resetPrefs();
-
- Assert.ok(!file.exists());
- clearCache(file);
-});
-
-// Installs a signed add-on then modifies it in place breaking its signing
-add_task(async function() {
- let file = await manuallyInstall(
- do_get_file(DATA + ADDONS.bootstrap.signed),
- profileDir,
- ID
- );
-
- // Make it appear to come from the past so when we modify it later it is
- // detected during startup. Obviously malware can bypass this method of
- // detection but the periodic scan will catch that
- await promiseSetExtensionModifiedTime(file.path, Date.now() - 600000);
-
- await promiseStartupManager();
- let addon = await promiseAddonByID(ID);
- Assert.notEqual(addon, null);
- Assert.ok(!addon.appDisabled);
- Assert.ok(addon.isActive);
- Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_SIGNED);
- Assert.equal(getActiveVersion(), 2);
-
- await promiseShutdownManager();
- Assert.equal(getActiveVersion(), 0);
-
- clearCache(file);
- breakAddon(file);
- resetPrefs();
-
- await promiseStartupManager();
-
- addon = await promiseAddonByID(ID);
- Assert.notEqual(addon, null);
- Assert.ok(addon.appDisabled);
- Assert.ok(!addon.isActive);
- Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_BROKEN);
- Assert.equal(getActiveVersion(), -1);
-
- let ids = AddonManager.getStartupChanges(
- AddonManager.STARTUP_CHANGE_DISABLED
- );
- Assert.equal(ids.length, 1);
- Assert.equal(ids[0], ID);
-
- await addon.uninstall();
- await promiseShutdownManager();
- resetPrefs();
-
- Assert.ok(!file.exists());
- clearCache(file);
-});
-
-// Injecting into profile (non-bootstrap)
-add_task(async function() {
- let file = await manuallyInstall(
- do_get_file(DATA + ADDONS.nonbootstrap.unsigned),
- profileDir,
- ID
- );
-
- await promiseStartupManager();
-
- // Currently we leave the sideloaded add-on there but just don't run it
- let addon = await promiseAddonByID(ID);
- Assert.notEqual(addon, null);
- Assert.ok(addon.appDisabled);
- Assert.ok(!addon.isActive);
- Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_MISSING);
-
- await addon.uninstall();
- await promiseRestartManager();
- await promiseShutdownManager();
-
- Assert.ok(!file.exists());
- clearCache(file);
-});
-
-add_task(async function() {
- let file = await manuallyInstall(
- do_get_file(DATA + ADDONS.nonbootstrap.signed),
- profileDir,
- ID
- );
- breakAddon(file);
-
- await promiseStartupManager();
-
- // Currently we leave the sideloaded add-on there but just don't run it
- let addon = await promiseAddonByID(ID);
- Assert.notEqual(addon, null);
- Assert.ok(addon.appDisabled);
- Assert.ok(!addon.isActive);
- Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_BROKEN);
-
- await addon.uninstall();
- await promiseRestartManager();
- await promiseShutdownManager();
-
- Assert.ok(!file.exists());
- clearCache(file);
-});
-
-add_task(async function() {
- let file = await manuallyInstall(
- do_get_file(DATA + ADDONS.nonbootstrap.badid),
- profileDir,
- ID
- );
-
- await promiseStartupManager();
-
- // Currently we leave the sideloaded add-on there but just don't run it
- let addon = await promiseAddonByID(ID);
- Assert.notEqual(addon, null);
- Assert.ok(addon.appDisabled);
- Assert.ok(!addon.isActive);
- Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_BROKEN);
-
- await addon.uninstall();
- await promiseRestartManager();
- await promiseShutdownManager();
-
- Assert.ok(!file.exists());
- clearCache(file);
-});
-
-// Installs a signed add-on then modifies it in place breaking its signing
-add_task(async function() {
- let file = await manuallyInstall(
- do_get_file(DATA + ADDONS.nonbootstrap.signed),
- profileDir,
- ID
- );
-
- // Make it appear to come from the past so when we modify it later it is
- // detected during startup. Obviously malware can bypass this method of
- // detection but the periodic scan will catch that
- await promiseSetExtensionModifiedTime(file.path, Date.now() - 60000);
-
- await promiseStartupManager();
- let addon = await promiseAddonByID(ID);
- Assert.notEqual(addon, null);
- Assert.ok(!addon.appDisabled);
- Assert.ok(addon.isActive);
- Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_SIGNED);
-
- await promiseShutdownManager();
-
- clearCache(file);
- breakAddon(file);
-
- await promiseStartupManager();
-
- addon = await promiseAddonByID(ID);
- Assert.notEqual(addon, null);
- Assert.ok(addon.appDisabled);
- Assert.ok(!addon.isActive);
- Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_BROKEN);
-
- let ids = AddonManager.getStartupChanges(
- AddonManager.STARTUP_CHANGE_DISABLED
- );
- Assert.equal(ids.length, 1);
- Assert.equal(ids[0], ID);
-
- await addon.uninstall();
- await promiseRestartManager();
- await promiseShutdownManager();
-
- Assert.ok(!file.exists());
- clearCache(file);
-});
-
-// Stage install then modify before startup (non-bootstrap)
-add_task(async function() {
- await promiseStartupManager();
- await promiseInstallAllFiles([
- do_get_file(DATA + ADDONS.nonbootstrap.signed),
- ]);
- await promiseShutdownManager();
-
- let staged = profileDir.clone();
- staged.append("staged");
- staged.append(do_get_expected_addon_name(ID));
- Assert.ok(staged.exists());
-
- breakAddon(staged);
- await promiseStartupManager();
-
- // Should have refused to install the broken staged version
- let addon = await promiseAddonByID(ID);
- Assert.equal(addon, null);
-
- clearCache(staged);
-
- await promiseShutdownManager();
-});
-
-// Manufacture staged install (bootstrap)
-add_task(async function() {
- let stage = profileDir.clone();
- stage.append("staged");
-
- let file = await manuallyInstall(
- do_get_file(DATA + ADDONS.bootstrap.signed),
- stage,
- ID
- );
- breakAddon(file);
-
- await promiseStartupManager();
-
- // Should have refused to install the broken staged version
- let addon = await promiseAddonByID(ID);
- Assert.equal(addon, null);
- Assert.equal(getActiveVersion(), -1);
-
- Assert.ok(!file.exists());
- clearCache(file);
-
- await promiseShutdownManager();
- resetPrefs();
-});
-
-// Preliminarily-signed sideloaded add-ons should work
-add_task(async function() {
- let file = await manuallyInstall(
- do_get_file(DATA + ADDONS.bootstrap.preliminary),
- profileDir,
- ID
- );
-
- await promiseStartupManager();
-
- let addon = await promiseAddonByID(ID);
- Assert.notEqual(addon, null);
- Assert.ok(!addon.appDisabled);
- Assert.ok(addon.isActive);
- Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_PRELIMINARY);
- Assert.equal(getActiveVersion(), 2);
-
- await addon.uninstall();
- await promiseShutdownManager();
- resetPrefs();
-
- Assert.ok(!file.exists());
- clearCache(file);
-});
-
-// Preliminarily-signed sideloaded add-ons should work via staged install
-add_task(async function() {
- let stage = profileDir.clone();
- stage.append("staged");
-
- let file = await manuallyInstall(
- do_get_file(DATA + ADDONS.bootstrap.preliminary),
- stage,
- ID
- );
-
- await promiseStartupManager();
-
- let addon = await promiseAddonByID(ID);
- Assert.notEqual(addon, null);
- Assert.ok(!addon.appDisabled);
- Assert.ok(addon.isActive);
- Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_PRELIMINARY);
- Assert.equal(getActiveVersion(), 2);
-
- await addon.uninstall();
- await promiseShutdownManager();
- resetPrefs();
-
- Assert.ok(!file.exists());
- clearCache(file);
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_signed_install.js b/toolkit/mozapps/extensions/test/xpcshell/test_signed_install.js
deleted file mode 100644
index 842176773c..0000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_signed_install.js
+++ /dev/null
@@ -1,279 +0,0 @@
-// Enable signature checks for these tests
-gUseRealCertChecks = true;
-
-const DATA = "data/signing_checks/";
-const ADDONS = {
- unsigned: "unsigned.xpi",
- signed1: "signed1.xpi",
- signed2: "signed2.xpi",
- privileged: "privileged.xpi",
-
- // Bug 1509093
- // sha256Signed: "signed_bootstrap_sha256_1.xpi",
-};
-
-// The ID in signed1.xpi and signed2.xpi
-const ID = "test@somewhere.com";
-
-let testserver = createHttpServer({ hosts: ["example.com"] });
-
-Services.prefs.setCharPref(
- "extensions.update.background.url",
- "http://example.com/update.json"
-);
-Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
-
-// Creates an add-on with a broken signature by changing an existing file
-function createBrokenAddonModify(file) {
- let brokenFile = gTmpD.clone();
- brokenFile.append("broken.xpi");
- file.copyTo(brokenFile.parent, brokenFile.leafName);
-
- var stream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(
- Ci.nsIStringInputStream
- );
- stream.setData("FOOBAR", -1);
- var zipW = Cc["@mozilla.org/zipwriter;1"].createInstance(Ci.nsIZipWriter);
- zipW.open(brokenFile, FileUtils.MODE_RDWR | FileUtils.MODE_APPEND);
- zipW.removeEntry("test.txt", false);
- zipW.addEntryStream(
- "test.txt",
- 0,
- Ci.nsIZipWriter.COMPRESSION_NONE,
- stream,
- false
- );
- zipW.close();
-
- return brokenFile;
-}
-
-// Creates an add-on with a broken signature by adding a new file
-function createBrokenAddonAdd(file) {
- let brokenFile = gTmpD.clone();
- brokenFile.append("broken.xpi");
- file.copyTo(brokenFile.parent, brokenFile.leafName);
-
- var stream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(
- Ci.nsIStringInputStream
- );
- stream.setData("FOOBAR", -1);
- var zipW = Cc["@mozilla.org/zipwriter;1"].createInstance(Ci.nsIZipWriter);
- zipW.open(brokenFile, FileUtils.MODE_RDWR | FileUtils.MODE_APPEND);
- zipW.addEntryStream(
- "test2.txt",
- 0,
- Ci.nsIZipWriter.COMPRESSION_NONE,
- stream,
- false
- );
- zipW.close();
-
- return brokenFile;
-}
-
-// Creates an add-on with a broken signature by removing an existing file
-function createBrokenAddonRemove(file) {
- let brokenFile = gTmpD.clone();
- brokenFile.append("broken.xpi");
- file.copyTo(brokenFile.parent, brokenFile.leafName);
-
- var stream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(
- Ci.nsIStringInputStream
- );
- stream.setData("FOOBAR", -1);
- var zipW = Cc["@mozilla.org/zipwriter;1"].createInstance(Ci.nsIZipWriter);
- zipW.open(brokenFile, FileUtils.MODE_RDWR | FileUtils.MODE_APPEND);
- zipW.removeEntry("test.txt", false);
- zipW.close();
-
- return brokenFile;
-}
-
-function serveUpdate(filename) {
- const RESPONSE = {
- addons: {
- [ID]: {
- updates: [
- {
- version: "2.0",
- update_link: `http://example.com/${filename}`,
- applications: {
- gecko: {
- strict_min_version: "4",
- advisory_max_version: "6",
- },
- },
- },
- ],
- },
- },
- };
- AddonTestUtils.registerJSON(testserver, "/update.json", RESPONSE);
-}
-
-async function test_install_broken(file, expectedError) {
- let install = await AddonManager.getInstallForFile(file);
- await Assert.rejects(
- install.install(),
- /Install failed/,
- "Install of an improperly signed extension should throw"
- );
-
- Assert.equal(install.state, AddonManager.STATE_DOWNLOAD_FAILED);
- Assert.equal(install.error, expectedError);
- Assert.equal(install.addon, null);
-}
-
-async function test_install_working(file, expectedSignedState) {
- let install = await AddonManager.getInstallForFile(file);
- await install.install();
-
- Assert.equal(install.state, AddonManager.STATE_INSTALLED);
- Assert.notEqual(install.addon, null);
- Assert.equal(install.addon.signedState, expectedSignedState);
-
- await install.addon.uninstall();
-}
-
-async function test_update_broken(file1, file2, expectedError) {
- // First install the older version
- await Promise.all([
- promiseInstallFile(file1),
- promiseWebExtensionStartup(ID),
- ]);
-
- testserver.registerFile("/" + file2.leafName, file2);
- serveUpdate(file2.leafName);
-
- let addon = await promiseAddonByID(ID);
- let update = await promiseFindAddonUpdates(addon);
- let install = update.updateAvailable;
- await Assert.rejects(
- install.install(),
- /Install failed/,
- "Update to an improperly signed extension should throw"
- );
-
- Assert.equal(install.state, AddonManager.STATE_DOWNLOAD_FAILED);
- Assert.equal(install.error, expectedError);
- Assert.equal(install.addon, null);
-
- testserver.registerFile("/" + file2.leafName, null);
- testserver.registerPathHandler("/update.json", null);
-
- await addon.uninstall();
-}
-
-async function test_update_working(file1, file2, expectedSignedState) {
- // First install the older version
- await promiseInstallFile(file1);
-
- testserver.registerFile("/" + file2.leafName, file2);
- serveUpdate(file2.leafName);
-
- let addon = await promiseAddonByID(ID);
- let update = await promiseFindAddonUpdates(addon);
- let install = update.updateAvailable;
- await Promise.all([install.install(), promiseWebExtensionStartup(ID)]);
-
- Assert.equal(install.state, AddonManager.STATE_INSTALLED);
- Assert.notEqual(install.addon, null);
- Assert.equal(install.addon.signedState, expectedSignedState);
-
- testserver.registerFile("/" + file2.leafName, null);
- testserver.registerPathHandler("/update.json", null);
-
- await install.addon.uninstall();
-}
-
-add_task(async function setup() {
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "4", "4");
- await promiseStartupManager();
-});
-
-// Try to install a broken add-on
-add_task(async function test_install_invalid_modified() {
- let file = createBrokenAddonModify(do_get_file(DATA + ADDONS.signed1));
- await test_install_broken(file, AddonManager.ERROR_CORRUPT_FILE);
- file.remove(true);
-});
-
-add_task(async function test_install_invalid_added() {
- let file = createBrokenAddonAdd(do_get_file(DATA + ADDONS.signed1));
- await test_install_broken(file, AddonManager.ERROR_CORRUPT_FILE);
- file.remove(true);
-});
-
-add_task(async function test_install_invalid_removed() {
- let file = createBrokenAddonRemove(do_get_file(DATA + ADDONS.signed1));
- await test_install_broken(file, AddonManager.ERROR_CORRUPT_FILE);
- file.remove(true);
-});
-
-// Try to install an unsigned add-on
-add_task(async function test_install_invalid_unsigned() {
- let file = do_get_file(DATA + ADDONS.unsigned);
- await test_install_broken(file, AddonManager.ERROR_SIGNEDSTATE_REQUIRED);
-});
-
-// Try to install a signed add-on
-add_task(async function test_install_valid() {
- let file = do_get_file(DATA + ADDONS.signed1);
- await test_install_working(file, AddonManager.SIGNEDSTATE_SIGNED);
-});
-
-// Try to install an add-on signed with SHA-256
-add_task(async function test_install_valid_sha256() {
- // Bug 1509093
- // let file = do_get_file(DATA + ADDONS.sha256Signed);
- // await test_install_working(file, AddonManager.SIGNEDSTATE_SIGNED);
-});
-
-// Try to install an add-on with the "Mozilla Extensions" OU
-add_task(async function test_install_valid_privileged() {
- let file = do_get_file(DATA + ADDONS.privileged);
- await test_install_working(file, AddonManager.SIGNEDSTATE_PRIVILEGED);
-});
-
-// Try to update to a broken add-on
-add_task(async function test_update_invalid_modified() {
- let file1 = do_get_file(DATA + ADDONS.signed1);
- let file2 = createBrokenAddonModify(do_get_file(DATA + ADDONS.signed2));
- await test_update_broken(file1, file2, AddonManager.ERROR_CORRUPT_FILE);
- file2.remove(true);
-});
-
-add_task(async function test_update_invalid_added() {
- let file1 = do_get_file(DATA + ADDONS.signed1);
- let file2 = createBrokenAddonAdd(do_get_file(DATA + ADDONS.signed2));
- await test_update_broken(file1, file2, AddonManager.ERROR_CORRUPT_FILE);
- file2.remove(true);
-});
-
-add_task(async function test_update_invalid_removed() {
- let file1 = do_get_file(DATA + ADDONS.signed1);
- let file2 = createBrokenAddonRemove(do_get_file(DATA + ADDONS.signed2));
- await test_update_broken(file1, file2, AddonManager.ERROR_CORRUPT_FILE);
- file2.remove(true);
-});
-
-// Try to update to an unsigned add-on
-add_task(async function test_update_invalid_unsigned() {
- let file1 = do_get_file(DATA + ADDONS.signed1);
- let file2 = do_get_file(DATA + ADDONS.unsigned);
- await test_update_broken(
- file1,
- file2,
- AddonManager.ERROR_SIGNEDSTATE_REQUIRED
- );
-});
-
-// Try to update to a signed add-on
-add_task(async function test_update_valid() {
- let file1 = do_get_file(DATA + ADDONS.signed1);
- let file2 = do_get_file(DATA + ADDONS.signed2);
- await test_update_working(file1, file2, AddonManager.SIGNEDSTATE_SIGNED);
-});
-
-add_task(() => promiseShutdownManager());
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_signed_long.js b/toolkit/mozapps/extensions/test/xpcshell/test_signed_long.js
deleted file mode 100644
index 2aa76e8ff8..0000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_signed_long.js
+++ /dev/null
@@ -1,23 +0,0 @@
-gUseRealCertChecks = true;
-
-const ID = "123456789012345678901234567890123456789012345678901@somewhere.com";
-
-// Tests that signature verification works correctly on an extension with
-// an ID that does not fit into a certificate CN field.
-add_task(async function test_long_id() {
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
- await promiseStartupManager();
-
- Assert.greater(ID.length, 64, "ID is > 64 characters");
-
- await promiseInstallFile(do_get_file("data/signing_checks/long.xpi"));
- let addon = await promiseAddonByID(ID);
-
- Assert.notEqual(addon, null, "Addon install properly");
- Assert.ok(
- addon.signedState > AddonManager.SIGNEDSTATE_MISSING,
- "Signature verification worked properly"
- );
-
- await addon.uninstall();
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_signed_updatepref.js b/toolkit/mozapps/extensions/test/xpcshell/test_signed_updatepref.js
deleted file mode 100644
index 656f4fdd26..0000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_signed_updatepref.js
+++ /dev/null
@@ -1,131 +0,0 @@
-// Disable update security
-Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
-gUseRealCertChecks = true;
-
-const DATA = "data/signing_checks/";
-const ID = "test@somewhere.com";
-
-let testserver = createHttpServer({ hosts: ["example.com"] });
-
-AddonTestUtils.registerJSON(testserver, "/update.json", {
- addons: {
- [ID]: {
- version: "2.0",
- applications: {
- gecko: {
- strict_min_version: "4",
- strict_max_version: "6",
- },
- },
- },
- },
-});
-
-Services.prefs.setCharPref(
- "extensions.update.background.url",
- "http://example.com/update.json"
-);
-
-function verifySignatures() {
- return new Promise(resolve => {
- let observer = (subject, topic, data) => {
- Services.obs.removeObserver(observer, "xpi-signature-changed");
- resolve(JSON.parse(data));
- };
- Services.obs.addObserver(observer, "xpi-signature-changed");
-
- info("Verifying signatures");
- let XPIscope = ChromeUtils.import(
- "resource://gre/modules/addons/XPIProvider.jsm",
- null
- );
- XPIscope.XPIDatabase.verifySignatures();
- });
-}
-
-add_task(async function setup() {
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "4", "4");
-});
-
-// Updating the pref without changing the app version won't disable add-ons
-// immediately but will after a signing check
-add_task(async function() {
- Services.prefs.setBoolPref(PREF_XPI_SIGNATURES_REQUIRED, false);
- await promiseStartupManager();
-
- // Install an unsigned add-on
- await promiseInstallFile(do_get_file(DATA + "unsigned.xpi"));
-
- let addon = await promiseAddonByID(ID);
- Assert.notEqual(addon, null);
- Assert.ok(!addon.appDisabled);
- Assert.ok(addon.isActive);
- Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_MISSING);
-
- await promiseShutdownManager();
-
- Services.prefs.setBoolPref(PREF_XPI_SIGNATURES_REQUIRED, true);
-
- await promiseStartupManager();
-
- addon = await promiseAddonByID(ID);
- Assert.notEqual(addon, null);
- Assert.ok(!addon.appDisabled);
- Assert.ok(addon.isActive);
- Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_MISSING);
-
- // Update checks shouldn't affect the add-on
- await AddonManagerInternal.backgroundUpdateCheck();
- addon = await promiseAddonByID(ID);
- Assert.notEqual(addon, null);
- Assert.ok(!addon.appDisabled);
- Assert.ok(addon.isActive);
- Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_MISSING);
-
- let changes = await verifySignatures();
-
- Assert.equal(changes.disabled.length, 1);
- Assert.equal(changes.disabled[0], ID);
-
- addon = await promiseAddonByID(ID);
- Assert.notEqual(addon, null);
- Assert.ok(addon.appDisabled);
- Assert.ok(!addon.isActive);
- Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_MISSING);
-
- await addon.uninstall();
-
- await promiseShutdownManager();
-});
-
-// Updating the pref with changing the app version will disable add-ons
-// immediately
-add_task(async function() {
- Services.prefs.setBoolPref(PREF_XPI_SIGNATURES_REQUIRED, false);
- await promiseStartupManager();
-
- // Install an unsigned add-on
- await promiseInstallFile(do_get_file(DATA + "unsigned.xpi"));
-
- let addon = await promiseAddonByID(ID);
- Assert.notEqual(addon, null);
- Assert.ok(!addon.appDisabled);
- Assert.ok(addon.isActive);
- Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_MISSING);
-
- await promiseShutdownManager();
-
- Services.prefs.setBoolPref(PREF_XPI_SIGNATURES_REQUIRED, true);
- gAppInfo.version = 5.0;
- await promiseStartupManager();
-
- addon = await promiseAddonByID(ID);
- Assert.notEqual(addon, null);
- Assert.ok(addon.appDisabled);
- Assert.ok(!addon.isActive);
- Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_MISSING);
-
- await addon.uninstall();
-
- await promiseShutdownManager();
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_signed_verify.js b/toolkit/mozapps/extensions/test/xpcshell/test_signed_verify.js
deleted file mode 100644
index 4bbaeaba7c..0000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_signed_verify.js
+++ /dev/null
@@ -1,110 +0,0 @@
-// Enable signature checks for these tests
-gUseRealCertChecks = true;
-
-const DATA = "data/signing_checks";
-const ID = "test@somewhere.com";
-
-const profileDir = gProfD.clone();
-profileDir.append("extensions");
-
-function verifySignatures() {
- return new Promise(resolve => {
- let observer = (subject, topic, data) => {
- Services.obs.removeObserver(observer, "xpi-signature-changed");
- resolve(JSON.parse(data));
- };
- Services.obs.addObserver(observer, "xpi-signature-changed");
-
- info("Verifying signatures");
- let XPIscope = ChromeUtils.import(
- "resource://gre/modules/addons/XPIProvider.jsm",
- null
- );
- XPIscope.XPIDatabase.verifySignatures();
- });
-}
-
-createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "4", "4");
-
-add_task(async function test_no_change() {
- await promiseStartupManager();
-
- // Install the first add-on
- await promiseInstallFile(do_get_file(`${DATA}/signed1.xpi`));
-
- let addon = await promiseAddonByID(ID);
- Assert.notEqual(addon, null);
- Assert.equal(addon.appDisabled, false);
- Assert.equal(addon.isActive, true);
- Assert.equal(addon.pendingOperations, AddonManager.PENDING_NONE);
- Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_SIGNED);
-
- // Swap in the files from the next add-on
- manuallyUninstall(profileDir, ID);
- await manuallyInstall(do_get_file(`${DATA}/signed2.xpi`), profileDir, ID);
-
- let listener = {
- onPropetyChanged(_addon, properties) {
- Assert.ok(false, `Got unexpected onPropertyChanged for ${_addon.id}`);
- },
- };
-
- AddonManager.addAddonListener(listener);
-
- // Trigger the check
- let changes = await verifySignatures();
- Assert.equal(changes.enabled.length, 0);
- Assert.equal(changes.disabled.length, 0);
-
- Assert.equal(addon.appDisabled, false);
- Assert.equal(addon.isActive, true);
- Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_SIGNED);
-
- await addon.uninstall();
- AddonManager.removeAddonListener(listener);
-});
-
-add_task(async function test_diable() {
- // Install the first add-on
- await promiseInstallFile(do_get_file(`${DATA}/signed1.xpi`));
-
- let addon = await promiseAddonByID(ID);
- Assert.notEqual(addon, null);
- Assert.ok(addon.isActive);
- Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_SIGNED);
-
- // Swap in the files from the next add-on
- manuallyUninstall(profileDir, ID);
- await manuallyInstall(do_get_file(`${DATA}/unsigned.xpi`), profileDir, ID);
-
- let changedProperties = [];
- let listener = {
- onPropertyChanged(_, properties) {
- changedProperties.push(...properties);
- },
- };
- AddonManager.addAddonListener(listener);
-
- // Trigger the check
- let [changes] = await Promise.all([
- verifySignatures(),
- promiseAddonEvent("onDisabling"),
- ]);
-
- Assert.equal(changes.enabled.length, 0);
- Assert.equal(changes.disabled.length, 1);
- Assert.equal(changes.disabled[0], ID);
-
- Assert.deepEqual(
- changedProperties,
- ["signedState", "appDisabled"],
- "Got onPropertyChanged events for signedState and appDisabled"
- );
-
- Assert.ok(addon.appDisabled);
- Assert.ok(!addon.isActive);
- Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_MISSING);
-
- await addon.uninstall();
- AddonManager.removeAddonListener(listener);
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js b/toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js
index fd711094a6..d1ea8f7fd1 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js
@@ -81,10 +81,6 @@ async function check_installed(conditions) {
Assert.ok(file.isFile());
Assert.equal(getAddonFile(addon).path, file.path);
-
- if (isUpgrade) {
- Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_SYSTEM);
- }
} else if (isUpgrade) {
// Add-on should not be installed
Assert.equal(addon, null);
@@ -474,7 +470,6 @@ add_task(async function test_bad_app_cert() {
// Add-on will still be present
let addon = await promiseAddonByID("system1@tests.mozilla.org");
Assert.notEqual(addon, null);
- Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_NOT_REQUIRED);
let conditions = [
{ isUpgrade: false, version: "1.0" },
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_temporary.js b/toolkit/mozapps/extensions/test/xpcshell/test_temporary.js
index d73785c3b3..b0a7c1c986 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_temporary.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_temporary.js
@@ -108,7 +108,6 @@ add_task(async function test_new_temporary() {
appDisabled: false,
isActive: true,
type: "extension",
- signedState: AddonManager.SIGNEDSTATE_PRIVILEGED,
temporarilyInstalled: true,
});
@@ -148,7 +147,6 @@ add_task(async function test_replace_temporary() {
appDisabled: false,
isActive: true,
type: "extension",
- signedState: AddonManager.SIGNEDSTATE_PRIVILEGED,
temporarilyInstalled: false,
});
@@ -212,10 +210,6 @@ add_task(async function test_replace_temporary() {
addon = await promiseAddonByID(ID);
- let signedState = packed
- ? AddonManager.SIGNEDSTATE_PRIVILEGED
- : AddonManager.SIGNEDSTATE_UNKNOWN;
-
// temporary add-on is installed and started
checkAddon(ID, addon, {
version: newversion,
@@ -224,7 +218,6 @@ add_task(async function test_replace_temporary() {
appDisabled: false,
isActive: true,
type: "extension",
- signedState,
temporarilyInstalled: true,
});
@@ -280,7 +273,6 @@ add_task(async function test_replace_temporary() {
appDisabled: false,
isActive: true,
type: "extension",
- signedState: AddonManager.SIGNEDSTATE_PRIVILEGED,
temporarilyInstalled: false,
});
@@ -328,7 +320,6 @@ add_task(async function test_samefile() {
appDisabled: false,
isActive: true,
type: "extension",
- signedState: AddonManager.SIGNEDSTATE_PRIVILEGED,
temporarilyInstalled: true,
});
@@ -357,7 +348,6 @@ add_task(async function test_samefile() {
isActive: true,
type: "extension",
isWebExtension: true,
- signedState: AddonManager.SIGNEDSTATE_PRIVILEGED,
temporarilyInstalled: true,
});
@@ -438,7 +428,6 @@ add_task(async function test_replace_permanent() {
appDisabled: false,
isActive: true,
type: "extension",
- signedState: AddonManager.SIGNEDSTATE_UNKNOWN,
temporarilyInstalled: true,
});
@@ -457,7 +446,6 @@ add_task(async function test_replace_permanent() {
appDisabled: false,
isActive: true,
type: "extension",
- signedState: AddonManager.SIGNEDSTATE_PRIVILEGED,
temporarilyInstalled: false,
});
@@ -711,7 +699,6 @@ add_task(async function test_replace_permanent_disabled() {
appDisabled: false,
isActive: true,
type: "extension",
- signedState: AddonManager.SIGNEDSTATE_UNKNOWN,
temporarilyInstalled: true,
});
@@ -733,7 +720,6 @@ add_task(async function test_replace_permanent_disabled() {
appDisabled: false,
isActive: true,
type: "extension",
- signedState: AddonManager.SIGNEDSTATE_PRIVILEGED,
temporarilyInstalled: false,
});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_webextension.js b/toolkit/mozapps/extensions/test/xpcshell/test_webextension.js
index 582df83654..0a16d535c8 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_webextension.js
@@ -102,7 +102,6 @@ add_task(async function test_1() {
isSystem: false,
type: "extension",
isWebExtension: true,
- signedState: AddonManager.SIGNEDSTATE_PRIVILEGED,
iconURL: `${uri}icon48.png`,
});
@@ -128,7 +127,6 @@ add_task(async function test_1() {
isActive: true,
isSystem: false,
type: "extension",
- signedState: AddonManager.SIGNEDSTATE_PRIVILEGED,
iconURL: `${uri}icon48.png`,
});
@@ -176,7 +174,6 @@ add_task(async function test_2() {
isActive: true,
isSystem: false,
type: "extension",
- signedState: AddonManager.SIGNEDSTATE_PRIVILEGED,
});
await addon.uninstall();
@@ -388,6 +385,7 @@ add_task(async function developerEmpty() {
});
add_task(async function authorNotString() {
+ ExtensionTestUtils.failOnSchemaWarnings(false);
for (let author of [{}, [], 42]) {
let addon = await promiseInstallWebExtension({
manifest: {
@@ -404,6 +402,7 @@ add_task(async function authorNotString() {
await addon.uninstall();
}
+ ExtensionTestUtils.failOnSchemaWarnings(true);
});
add_task(async function testThemeExtension() {
@@ -413,7 +412,7 @@ add_task(async function testThemeExtension() {
manifest_version: 2,
name: "Web Extension Name",
version: "1.0",
- theme: { images: { headerURL: "example.png" } },
+ theme: { images: { theme_frame: "example.png" } },
},
});
@@ -428,12 +427,12 @@ add_task(async function testThemeExtension() {
isSystem: false,
type: "theme",
isWebExtension: true,
- signedState: AddonManager.SIGNEDSTATE_PRIVILEGED,
});
await addon.uninstall();
// Also test one without a proper 'theme' section.
+ ExtensionTestUtils.failOnSchemaWarnings(false);
addon = await promiseInstallWebExtension({
manifest: {
author: "Some author",
@@ -443,6 +442,7 @@ add_task(async function testThemeExtension() {
theme: null,
},
});
+ ExtensionTestUtils.failOnSchemaWarnings(true);
checkAddon(ID, addon, {
type: "extension",
@@ -474,7 +474,6 @@ add_task(async function test_theme_upgrade() {
appDisabled: false,
isActive: true,
type: "extension",
- signedState: AddonManager.SIGNEDSTATE_PRIVILEGED,
});
// Create a webextension theme with the same ID
@@ -487,7 +486,7 @@ add_task(async function test_theme_upgrade() {
id: ID,
},
},
- theme: { images: { headerURL: "example.png" } },
+ theme: { images: { theme_frame: "example.png" } },
},
});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_icons.js b/toolkit/mozapps/extensions/test/xpcshell/test_webextension_icons.js
index 9af0b52f23..c466bbf72e 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_icons.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_webextension_icons.js
@@ -141,7 +141,7 @@ add_task(async function() {
48: "icon48.png",
64: "icon64.png",
},
- theme: { images: { headerURL: "example.png" } },
+ theme: { images: { theme_frame: "example.png" } },
});
});
@@ -181,7 +181,7 @@ add_task(async function() {
128: "icon128.png",
256: "icon256.png",
},
- theme: { images: { headerURL: "example.png" } },
+ theme: { images: { theme_frame: "example.png" } },
});
});
@@ -207,6 +207,6 @@ add_task(async function() {
id: ID,
},
},
- theme: { images: { headerURL: "example.png" } },
+ theme: { images: { theme_frame: "example.png" } },
});
});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js b/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js
index a4c96afd2a..a6082b3168 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js
@@ -654,7 +654,9 @@ add_task(async function test_non_gecko_bss_install() {
manifest,
useAddonManager: "temporary",
});
+ ExtensionTestUtils.failOnSchemaWarnings(false);
await extension.startup();
+ ExtensionTestUtils.failOnSchemaWarnings(true);
const addon = await promiseAddonByID(ID);
notEqual(addon, null, "Add-on is installed");
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_theme.js b/toolkit/mozapps/extensions/test/xpcshell/test_webextension_theme.js
index 599b2cb4cd..0b5a854399 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_theme.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_webextension_theme.js
@@ -36,7 +36,7 @@ add_task(async function setup_to_default_browserish_state() {
manifest_version: 2,
name: "Web Extension Name",
version: "1.0",
- theme: { images: { headerURL: "example.png" } },
+ theme: { images: { theme_frame: "example.png" } },
applications: {
gecko: {
id: THEME_IDS[0],
@@ -232,8 +232,8 @@ add_task(async function default_locale_themes() {
description: "__MSG_description__",
theme: {
colors: {
- accentcolor: "black",
- textcolor: "white",
+ frame: "black",
+ tab_background_text: "white",
},
},
},
diff --git a/toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_blocklist_metadata_filters.js b/toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_blocklist_metadata_filters.js
index ce7e998dda..9ec47d01f0 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_blocklist_metadata_filters.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_blocklist_metadata_filters.js
@@ -6,7 +6,7 @@
// and RegExps for each. See bug 897735.
const URI_EXTENSION_BLOCKLIST_DIALOG =
- "chrome://mozapps/content/extensions/blocklist.xul";
+ "chrome://mozapps/content/extensions/blocklist.xhtml";
var testserver = AddonTestUtils.createHttpServer({ hosts: ["example.com"] });
gPort = testserver.identity.primaryPort;
diff --git a/toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_blocklist_prefs.js b/toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_blocklist_prefs.js
index 9ca5cc2a0b..b9e91afed9 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_blocklist_prefs.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_blocklist_prefs.js
@@ -6,7 +6,7 @@
// See bug 802434.
const URI_EXTENSION_BLOCKLIST_DIALOG =
- "chrome://mozapps/content/extensions/blocklist.xul";
+ "chrome://mozapps/content/extensions/blocklist.xhtml";
var testserver = createHttpServer({ hosts: ["example.com"] });
gPort = testserver.identity.primaryPort;
diff --git a/toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_blocklist_severities.js b/toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_blocklist_severities.js
index 0996774d48..95755d0243 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_blocklist_severities.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_blocklist_severities.js
@@ -4,7 +4,7 @@
*/
const URI_EXTENSION_BLOCKLIST_DIALOG =
- "chrome://mozapps/content/extensions/blocklist.xul";
+ "chrome://mozapps/content/extensions/blocklist.xhtml";
var gTestserver = AddonTestUtils.createHttpServer({ hosts: ["example.com"] });
gTestserver.registerDirectory("/data/", do_get_file("../data"));
diff --git a/toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_blocklistchange.js b/toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_blocklistchange.js
index d0a70046f9..ac8ef1a844 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_blocklistchange.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_blocklistchange.js
@@ -24,7 +24,7 @@
// start with add-ons blocked as it would be identical to softblock3
const URI_EXTENSION_BLOCKLIST_DIALOG =
- "chrome://mozapps/content/extensions/blocklist.xul";
+ "chrome://mozapps/content/extensions/blocklist.xhtml";
// Allow insecure updates
Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser.ini b/toolkit/mozapps/extensions/test/xpinstall/browser.ini
index 5345d4f6b6..3123d9f890 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser.ini
+++ b/toolkit/mozapps/extensions/test/xpinstall/browser.ini
@@ -22,13 +22,6 @@ support-files =
triggerredirect.html
unsigned.xpi
-[browser_amosigned_trigger.js]
-[browser_amosigned_trigger_iframe.js]
-[browser_amosigned_url.js]
-[browser_auth.js]
-[browser_auth2.js]
-[browser_auth3.js]
-[browser_auth4.js]
[browser_badargs.js]
[browser_badargs2.js]
[browser_badhash.js]
@@ -54,14 +47,6 @@ skip-if = true # Bug 1084646
[browser_enabled.js]
[browser_enabled2.js]
[browser_enabled3.js]
-[browser_hash.js]
-[browser_hash2.js]
-[browser_httphash.js]
-[browser_httphash2.js]
-[browser_httphash3.js]
-[browser_httphash4.js]
-[browser_httphash5.js]
-[browser_httphash6.js]
skip-if = true # Bug 1449788
[browser_installchrome.js]
[browser_localfile.js]
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger.js b/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger.js
deleted file mode 100644
index 8c10e61450..0000000000
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger.js
+++ /dev/null
@@ -1,77 +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);
-
-// ----------------------------------------------------------------------------
-// Tests installing an unsigned add-on through an InstallTrigger call in web
-// content.
-function test() {
- Harness.installConfirmCallback = confirm_install;
- Harness.installEndedCallback = install_ended;
- Harness.installsCompletedCallback = finish_test;
- Harness.finalContentEvent = "InstallComplete";
- Harness.setup();
-
- PermissionTestUtils.add(
- "http://example.com/",
- "install",
- Services.perms.ALLOW_ACTION
- );
-
- var triggers = encodeURIComponent(
- JSON.stringify({
- "Unsigned XPI": {
- URL: TESTROOT + "amosigned.xpi",
- IconURL: TESTROOT + "icon.png",
- toString() {
- return this.URL;
- },
- },
- })
- );
- gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
- BrowserTestUtils.loadURI(
- gBrowser,
- TESTROOT + "installtrigger.html?" + triggers
- );
-}
-
-function confirm_install(panel) {
- is(panel.getAttribute("name"), "XPI Test", "Should have seen the name");
- return true;
-}
-
-function install_ended(install, addon) {
- install.cancel();
-}
-
-const finish_test = async function(count) {
- is(count, 1, "1 Add-on should have been successfully installed");
-
- PermissionTestUtils.remove("http://example.com", "install");
-
- const results = await ContentTask.spawn(
- gBrowser.selectedBrowser,
- null,
- () => {
- return {
- return: content.document.getElementById("return").textContent,
- status: content.document.getElementById("status").textContent,
- };
- }
- );
-
- is(results.return, "true", "installTrigger should have claimed success");
- is(results.status, "0", "Callback should have seen a success");
-
- gBrowser.removeCurrentTab();
- Harness.finish();
-};
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger_iframe.js b/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger_iframe.js
deleted file mode 100644
index 2fa2a97070..0000000000
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger_iframe.js
+++ /dev/null
@@ -1,74 +0,0 @@
-// ----------------------------------------------------------------------------
-// Test for bug 589598 - Ensure that installing through InstallTrigger
-// works in an iframe in web content.
-
-function test() {
- Harness.installConfirmCallback = confirm_install;
- Harness.installEndedCallback = install_ended;
- Harness.installsCompletedCallback = finish_test;
- Harness.finalContentEvent = "InstallComplete";
- Harness.setup();
-
- PermissionTestUtils.add(
- "http://example.com/",
- "install",
- Services.perms.ALLOW_ACTION
- );
-
- var inner_url = encodeURIComponent(
- TESTROOT +
- "installtrigger.html?" +
- encodeURIComponent(
- JSON.stringify({
- "Unsigned XPI": {
- URL: TESTROOT + "amosigned.xpi",
- IconURL: TESTROOT + "icon.png",
- toString() {
- return this.URL;
- },
- },
- })
- )
- );
- gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
- BrowserTestUtils.loadURI(
- gBrowser,
- TESTROOT + "installtrigger_frame.html?" + inner_url
- );
-}
-
-function confirm_install(panel) {
- is(panel.getAttribute("name"), "XPI Test", "Should have seen the name");
- return true;
-}
-
-function install_ended(install, addon) {
- install.cancel();
-}
-
-const finish_test = async function(count) {
- is(count, 1, "1 Add-on should have been successfully installed");
-
- PermissionTestUtils.remove("http://example.com", "install");
-
- const results = await ContentTask.spawn(
- gBrowser.selectedBrowser,
- null,
- () => {
- return {
- return: content.frames[0].document.getElementById("return").textContent,
- status: content.frames[0].document.getElementById("status").textContent,
- };
- }
- );
-
- is(
- results.return,
- "true",
- "installTrigger in iframe should have claimed success"
- );
- is(results.status, "0", "Callback in iframe should have seen a success");
-
- gBrowser.removeCurrentTab();
- Harness.finish();
-};
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_url.js b/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_url.js
deleted file mode 100644
index 58111cb9bd..0000000000
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_url.js
+++ /dev/null
@@ -1,42 +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);
-
-// ----------------------------------------------------------------------------
-// Tests installing an unsigned add-on by navigating directly to the url
-function test() {
- Harness.installConfirmCallback = confirm_install;
- Harness.installEndedCallback = install_ended;
- Harness.installsCompletedCallback = finish_test;
- Harness.setup();
-
- gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
- BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => {
- BrowserTestUtils.loadURI(gBrowser, TESTROOT + "amosigned.xpi");
- });
-}
-
-function confirm_install(panel) {
- is(panel.getAttribute("name"), "XPI Test", "Should have seen the name");
- return true;
-}
-
-function install_ended(install, addon) {
- install.cancel();
-}
-
-function finish_test(count) {
- is(count, 1, "1 Add-on should have been successfully installed");
-
- gBrowser.removeCurrentTab();
- Harness.finish();
-}
-// ----------------------------------------------------------------------------
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_auth.js b/toolkit/mozapps/extensions/test/xpinstall/browser_auth.js
deleted file mode 100644
index 263576ddf9..0000000000
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_auth.js
+++ /dev/null
@@ -1,65 +0,0 @@
-// ----------------------------------------------------------------------------
-// Test whether an install succeeds when authentication is required
-// This verifies bug 312473
-function test() {
- // Turn off the authentication dialog blocking for this test.
- Services.prefs.setBoolPref(
- "network.auth.non-web-content-triggered-resources-http-auth-allow",
- true
- );
-
- Harness.authenticationCallback = get_auth_info;
- Harness.downloadFailedCallback = download_failed;
- Harness.installEndedCallback = install_ended;
- Harness.installsCompletedCallback = finish_test;
- Harness.setup();
-
- Services.prefs.setIntPref("network.auth.subresource-http-auth-allow", 2);
-
- PermissionTestUtils.add(
- "http://example.com/",
- "install",
- Services.perms.ALLOW_ACTION
- );
-
- var triggers = encodeURIComponent(
- JSON.stringify({
- "Unsigned XPI":
- TESTROOT + "authRedirect.sjs?" + TESTROOT + "amosigned.xpi",
- })
- );
- gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
- BrowserTestUtils.loadURI(
- gBrowser,
- TESTROOT + "installtrigger.html?" + triggers
- );
-}
-
-function get_auth_info() {
- return ["testuser", "testpass"];
-}
-
-function download_failed(install) {
- ok(false, "Install should not have failed");
-}
-
-function install_ended(install, addon) {
- install.cancel();
-}
-
-function finish_test(count) {
- is(count, 1, "1 Add-on should have been successfully installed");
- var authMgr = Cc["@mozilla.org/network/http-auth-manager;1"].getService(
- Ci.nsIHttpAuthManager
- );
- authMgr.clearAll();
-
- PermissionTestUtils.remove("http://example.com", "install");
-
- Services.prefs.clearUserPref(
- "network.auth.non-web-content-triggered-resources-http-auth-allow"
- );
-
- gBrowser.removeCurrentTab();
- Harness.finish();
-}
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_auth2.js b/toolkit/mozapps/extensions/test/xpinstall/browser_auth2.js
deleted file mode 100644
index aa16bf1172..0000000000
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_auth2.js
+++ /dev/null
@@ -1,70 +0,0 @@
-// ----------------------------------------------------------------------------
-// Test whether an install fails when authentication is required and bad
-// credentials are given
-// This verifies bug 312473
-function test() {
- // Turn off the authentication dialog blocking for this test.
- Services.prefs.setBoolPref(
- "network.auth.non-web-content-triggered-resources-http-auth-allow",
- true
- );
-
- requestLongerTimeout(2);
- Harness.authenticationCallback = get_auth_info;
- Harness.downloadFailedCallback = download_failed;
- Harness.installEndedCallback = install_ended;
- Harness.installsCompletedCallback = finish_test;
- Harness.setup();
-
- PermissionTestUtils.add(
- "http://example.com/",
- "install",
- Services.perms.ALLOW_ACTION
- );
-
- var triggers = encodeURIComponent(
- JSON.stringify({
- "Unsigned XPI":
- TESTROOT + "authRedirect.sjs?" + TESTROOT + "amosigned.xpi",
- })
- );
- gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
- BrowserTestUtils.loadURI(
- gBrowser,
- TESTROOT + "installtrigger.html?" + triggers
- );
-}
-
-function get_auth_info() {
- return ["baduser", "badpass"];
-}
-
-function download_failed(install) {
- is(
- install.error,
- AddonManager.ERROR_NETWORK_FAILURE,
- "Install should have failed"
- );
-}
-
-function install_ended(install, addon) {
- ok(false, "Add-on should not have installed");
- install.cancel();
-}
-
-function finish_test(count) {
- is(count, 0, "No add-ons should have been installed");
- var authMgr = Cc["@mozilla.org/network/http-auth-manager;1"].getService(
- Ci.nsIHttpAuthManager
- );
- authMgr.clearAll();
-
- PermissionTestUtils.remove("http://example.com", "install");
-
- Services.prefs.clearUserPref(
- "network.auth.non-web-content-triggered-resources-http-auth-allow"
- );
-
- gBrowser.removeCurrentTab();
- Harness.finish();
-}
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_auth3.js b/toolkit/mozapps/extensions/test/xpinstall/browser_auth3.js
deleted file mode 100644
index 1b812c0b1c..0000000000
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_auth3.js
+++ /dev/null
@@ -1,69 +0,0 @@
-// ----------------------------------------------------------------------------
-// Test whether an install fails when authentication is required and it is
-// canceled
-// This verifies bug 312473
-function test() {
- // Turn off the authentication dialog blocking for this test.
- Services.prefs.setBoolPref(
- "network.auth.non-web-content-triggered-resources-http-auth-allow",
- true
- );
-
- Harness.authenticationCallback = get_auth_info;
- Harness.downloadFailedCallback = download_failed;
- Harness.installEndedCallback = install_ended;
- Harness.installsCompletedCallback = finish_test;
- Harness.setup();
-
- PermissionTestUtils.add(
- "http://example.com/",
- "install",
- Services.perms.ALLOW_ACTION
- );
-
- var triggers = encodeURIComponent(
- JSON.stringify({
- "Unsigned XPI":
- TESTROOT + "authRedirect.sjs?" + TESTROOT + "amosigned.xpi",
- })
- );
- gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
- BrowserTestUtils.loadURI(
- gBrowser,
- TESTROOT + "installtrigger.html?" + triggers
- );
-}
-
-function get_auth_info() {
- return null;
-}
-
-function download_failed(install) {
- is(
- install.error,
- AddonManager.ERROR_NETWORK_FAILURE,
- "Install should have failed"
- );
-}
-
-function install_ended(install, addon) {
- ok(false, "Add-on should not have installed");
- install.cancel();
-}
-
-function finish_test(count) {
- is(count, 0, "No add-ons should have been installed");
- var authMgr = Cc["@mozilla.org/network/http-auth-manager;1"].getService(
- Ci.nsIHttpAuthManager
- );
- authMgr.clearAll();
-
- PermissionTestUtils.remove("http://example.com", "install");
-
- Services.prefs.clearUserPref(
- "network.auth.non-web-content-triggered-resources-http-auth-allow"
- );
-
- gBrowser.removeCurrentTab();
- Harness.finish();
-}
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_auth4.js b/toolkit/mozapps/extensions/test/xpinstall/browser_auth4.js
deleted file mode 100644
index c86c6999f1..0000000000
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_auth4.js
+++ /dev/null
@@ -1,68 +0,0 @@
-// Test whether a request for auth for an XPI switches to the appropriate tab
-var gNewTab;
-
-function test() {
- // Turn off the authentication dialog blocking for this test.
- Services.prefs.setBoolPref(
- "network.auth.non-web-content-triggered-resources-http-auth-allow",
- true
- );
-
- Harness.authenticationCallback = get_auth_info;
- Harness.downloadFailedCallback = download_failed;
- Harness.installEndedCallback = install_ended;
- Harness.installsCompletedCallback = finish_test;
- Harness.setup();
-
- PermissionTestUtils.add(
- "http://example.com/",
- "install",
- Services.perms.ALLOW_ACTION
- );
-
- var triggers = encodeURIComponent(
- JSON.stringify({
- "Unsigned XPI":
- TESTROOT + "authRedirect.sjs?" + TESTROOT + "amosigned.xpi",
- })
- );
- gNewTab = BrowserTestUtils.addTab(gBrowser);
- BrowserTestUtils.loadURI(
- gBrowser.getBrowserForTab(gNewTab),
- TESTROOT + "installtrigger.html?" + triggers
- );
-}
-
-function get_auth_info() {
- is(
- gBrowser.selectedTab,
- gNewTab,
- "Should have focused the tab loading the XPI"
- );
- return ["testuser", "testpass"];
-}
-
-function download_failed(install) {
- ok(false, "Install should not have failed");
-}
-
-function install_ended(install, addon) {
- install.cancel();
-}
-
-function finish_test(count) {
- is(count, 1, "1 Add-on should have been successfully installed");
- var authMgr = Cc["@mozilla.org/network/http-auth-manager;1"].getService(
- Ci.nsIHttpAuthManager
- );
- authMgr.clearAll();
-
- PermissionTestUtils.remove("http://example.com", "install");
-
- Services.prefs.clearUserPref(
- "network.auth.non-web-content-triggered-resources-http-auth-allow"
- );
-
- gBrowser.removeTab(gNewTab);
- Harness.finish();
-}
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_hash.js b/toolkit/mozapps/extensions/test/xpinstall/browser_hash.js
deleted file mode 100644
index 55ad2bb4bb..0000000000
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_hash.js
+++ /dev/null
@@ -1,44 +0,0 @@
-// ----------------------------------------------------------------------------
-// Test whether an install succeeds when a valid hash is included
-// This verifies bug 302284
-function test() {
- Harness.installEndedCallback = install_ended;
- Harness.installsCompletedCallback = finish_test;
- Harness.setup();
-
- PermissionTestUtils.add(
- "http://example.com/",
- "install",
- Services.perms.ALLOW_ACTION
- );
-
- var triggers = encodeURIComponent(
- JSON.stringify({
- "Unsigned XPI": {
- URL: TESTROOT + "amosigned.xpi",
- Hash: "sha1:ee95834ad862245a9ef99ccecc2a857cadc16404",
- toString() {
- return this.URL;
- },
- },
- })
- );
- gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
- BrowserTestUtils.loadURI(
- gBrowser,
- TESTROOT + "installtrigger.html?" + triggers
- );
-}
-
-function install_ended(install, addon) {
- install.cancel();
-}
-
-function finish_test(count) {
- is(count, 1, "1 Add-on should have been successfully installed");
-
- PermissionTestUtils.remove("http://example.com", "install");
-
- gBrowser.removeCurrentTab();
- Harness.finish();
-}
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_hash2.js b/toolkit/mozapps/extensions/test/xpinstall/browser_hash2.js
deleted file mode 100644
index 0f06cd9715..0000000000
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_hash2.js
+++ /dev/null
@@ -1,44 +0,0 @@
-// ----------------------------------------------------------------------------
-// Test whether an install succeeds using case-insensitive hashes
-// This verifies bug 603021
-function test() {
- Harness.installEndedCallback = install_ended;
- Harness.installsCompletedCallback = finish_test;
- Harness.setup();
-
- PermissionTestUtils.add(
- "http://example.com/",
- "install",
- Services.perms.ALLOW_ACTION
- );
-
- var triggers = encodeURIComponent(
- JSON.stringify({
- "Unsigned XPI": {
- URL: TESTROOT + "amosigned.xpi",
- Hash: "sha1:EE95834AD862245A9EF99CCECC2A857CADC16404",
- toString() {
- return this.URL;
- },
- },
- })
- );
- gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
- BrowserTestUtils.loadURI(
- gBrowser,
- TESTROOT + "installtrigger.html?" + triggers
- );
-}
-
-function install_ended(install, addon) {
- install.cancel();
-}
-
-function finish_test(count) {
- is(count, 1, "1 Add-on should have been successfully installed");
-
- PermissionTestUtils.remove("http://example.com", "install");
-
- gBrowser.removeCurrentTab();
- Harness.finish();
-}
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash.js b/toolkit/mozapps/extensions/test/xpinstall/browser_httphash.js
deleted file mode 100644
index 9248f5962b..0000000000
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash.js
+++ /dev/null
@@ -1,52 +0,0 @@
-// ----------------------------------------------------------------------------
-// Test whether an install succeeds when a valid hash is included in the HTTPS
-// request
-// This verifies bug 591070
-function test() {
- Harness.installEndedCallback = install_ended;
- Harness.installsCompletedCallback = finish_test;
- Harness.setup();
-
- PermissionTestUtils.add(
- "http://example.com/",
- "install",
- Services.perms.ALLOW_ACTION
- );
- Services.prefs.setBoolPref(PREF_INSTALL_REQUIREBUILTINCERTS, false);
-
- var url = "https://example.com/browser/" + RELATIVE_DIR + "hashRedirect.sjs";
- url +=
- "?sha1:ee95834ad862245a9ef99ccecc2a857cadc16404|" +
- TESTROOT +
- "amosigned.xpi";
-
- var triggers = encodeURIComponent(
- JSON.stringify({
- "Unsigned XPI": {
- URL: url,
- toString() {
- return this.URL;
- },
- },
- })
- );
- gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
- BrowserTestUtils.loadURI(
- gBrowser,
- TESTROOT + "installtrigger.html?" + triggers
- );
-}
-
-function install_ended(install, addon) {
- install.cancel();
-}
-
-function finish_test(count) {
- is(count, 1, "1 Add-on should have been successfully installed");
-
- PermissionTestUtils.remove("http://example.com", "install");
- Services.prefs.clearUserPref(PREF_INSTALL_REQUIREBUILTINCERTS);
-
- gBrowser.removeCurrentTab();
- Harness.finish();
-}
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash2.js b/toolkit/mozapps/extensions/test/xpinstall/browser_httphash2.js
deleted file mode 100644
index a411aa0ecb..0000000000
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash2.js
+++ /dev/null
@@ -1,49 +0,0 @@
-// ----------------------------------------------------------------------------
-// Test whether an install fails when a invalid hash is included in the HTTPS
-// request
-// This verifies bug 591070
-function test() {
- Harness.downloadFailedCallback = download_failed;
- Harness.installsCompletedCallback = finish_test;
- Harness.setup();
-
- PermissionTestUtils.add(
- "http://example.com/",
- "install",
- Services.perms.ALLOW_ACTION
- );
- Services.prefs.setBoolPref(PREF_INSTALL_REQUIREBUILTINCERTS, false);
-
- var url = "https://example.com/browser/" + RELATIVE_DIR + "hashRedirect.sjs";
- url += "?sha1:foobar|" + TESTROOT + "amosigned.xpi";
-
- var triggers = encodeURIComponent(
- JSON.stringify({
- "Unsigned XPI": {
- URL: url,
- toString() {
- return this.URL;
- },
- },
- })
- );
- gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
- BrowserTestUtils.loadURI(
- gBrowser,
- TESTROOT + "installtrigger.html?" + triggers
- );
-}
-
-function download_failed(install) {
- is(install.error, AddonManager.ERROR_INCORRECT_HASH, "Download should fail");
-}
-
-function finish_test(count) {
- is(count, 0, "0 Add-ons should have been successfully installed");
-
- PermissionTestUtils.remove("http://example.com", "install");
- Services.prefs.clearUserPref(PREF_INSTALL_REQUIREBUILTINCERTS);
-
- gBrowser.removeCurrentTab();
- Harness.finish();
-}
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash3.js b/toolkit/mozapps/extensions/test/xpinstall/browser_httphash3.js
deleted file mode 100644
index 7892e84781..0000000000
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash3.js
+++ /dev/null
@@ -1,49 +0,0 @@
-// ----------------------------------------------------------------------------
-// Tests that the HTTPS hash is ignored when InstallTrigger is passed a hash.
-// This verifies bug 591070
-function test() {
- Harness.installEndedCallback = install_ended;
- Harness.installsCompletedCallback = finish_test;
- Harness.setup();
-
- PermissionTestUtils.add(
- "http://example.com/",
- "install",
- Services.perms.ALLOW_ACTION
- );
- Services.prefs.setBoolPref(PREF_INSTALL_REQUIREBUILTINCERTS, false);
-
- var url = "https://example.com/browser/" + RELATIVE_DIR + "hashRedirect.sjs";
- url += "?sha1:foobar|" + TESTROOT + "amosigned.xpi";
-
- var triggers = encodeURIComponent(
- JSON.stringify({
- "Unsigned XPI": {
- URL: url,
- Hash: "sha1:ee95834ad862245a9ef99ccecc2a857cadc16404",
- toString() {
- return this.URL;
- },
- },
- })
- );
- gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
- BrowserTestUtils.loadURI(
- gBrowser,
- TESTROOT + "installtrigger.html?" + triggers
- );
-}
-
-function install_ended(install, addon) {
- install.cancel();
-}
-
-function finish_test(count) {
- is(count, 1, "1 Add-on should have been successfully installed");
-
- PermissionTestUtils.remove("http://example.com", "install");
- Services.prefs.clearUserPref(PREF_INSTALL_REQUIREBUILTINCERTS);
-
- gBrowser.removeCurrentTab();
- Harness.finish();
-}
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash4.js b/toolkit/mozapps/extensions/test/xpinstall/browser_httphash4.js
deleted file mode 100644
index 1ca0735b90..0000000000
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash4.js
+++ /dev/null
@@ -1,46 +0,0 @@
-// ----------------------------------------------------------------------------
-// Test that hashes are ignored in the headers of HTTP requests
-// This verifies bug 591070
-function test() {
- Harness.installEndedCallback = install_ended;
- Harness.installsCompletedCallback = finish_test;
- Harness.setup();
-
- PermissionTestUtils.add(
- "http://example.com/",
- "install",
- Services.perms.ALLOW_ACTION
- );
-
- var url = "http://example.com/browser/" + RELATIVE_DIR + "hashRedirect.sjs";
- url += "?sha1:foobar|" + TESTROOT + "amosigned.xpi";
-
- var triggers = encodeURIComponent(
- JSON.stringify({
- "Unsigned XPI": {
- URL: url,
- toString() {
- return this.URL;
- },
- },
- })
- );
- gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
- BrowserTestUtils.loadURI(
- gBrowser,
- TESTROOT + "installtrigger.html?" + triggers
- );
-}
-
-function install_ended(install, addon) {
- install.cancel();
-}
-
-function finish_test(count) {
- is(count, 1, "1 Add-on should have been successfully installed");
-
- PermissionTestUtils.remove("http://example.com", "install");
-
- gBrowser.removeCurrentTab();
- Harness.finish();
-}
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash5.js b/toolkit/mozapps/extensions/test/xpinstall/browser_httphash5.js
deleted file mode 100644
index 2f7b5d7b74..0000000000
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash5.js
+++ /dev/null
@@ -1,50 +0,0 @@
-// ----------------------------------------------------------------------------
-// Test that only the first HTTPS hash is used
-// This verifies bug 591070
-function test() {
- Harness.installEndedCallback = install_ended;
- Harness.installsCompletedCallback = finish_test;
- Harness.setup();
-
- PermissionTestUtils.add(
- "http://example.com/",
- "install",
- Services.perms.ALLOW_ACTION
- );
- Services.prefs.setBoolPref(PREF_INSTALL_REQUIREBUILTINCERTS, false);
-
- var url = "https://example.com/browser/" + RELATIVE_DIR + "hashRedirect.sjs";
- url += "?sha1:ee95834ad862245a9ef99ccecc2a857cadc16404|";
- url += "https://example.com/browser/" + RELATIVE_DIR + "hashRedirect.sjs";
- url += "?sha1:foobar|" + TESTROOT + "amosigned.xpi";
-
- var triggers = encodeURIComponent(
- JSON.stringify({
- "Unsigned XPI": {
- URL: url,
- toString() {
- return this.URL;
- },
- },
- })
- );
- gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
- BrowserTestUtils.loadURI(
- gBrowser,
- TESTROOT + "installtrigger.html?" + triggers
- );
-}
-
-function install_ended(install, addon) {
- install.cancel();
-}
-
-function finish_test(count) {
- is(count, 1, "1 Add-on should have been successfully installed");
-
- PermissionTestUtils.remove("http://example.com", "install");
- Services.prefs.clearUserPref(PREF_INSTALL_REQUIREBUILTINCERTS);
-
- gBrowser.removeCurrentTab();
- Harness.finish();
-}
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash6.js b/toolkit/mozapps/extensions/test/xpinstall/browser_httphash6.js
deleted file mode 100644
index 7437dfaa7d..0000000000
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash6.js
+++ /dev/null
@@ -1,104 +0,0 @@
-// ----------------------------------------------------------------------------
-// Tests that a new hash is accepted when restarting a failed download
-// This verifies bug 593535
-function setup_redirect(aSettings) {
- var url =
- "https://example.com/browser/" + RELATIVE_DIR + "redirect.sjs?mode=setup";
- for (var name in aSettings) {
- url += "&" + name + "=" + aSettings[name];
- }
-
- var req = new XMLHttpRequest();
- req.open("GET", url, false);
- req.send(null);
-}
-
-var gInstall = null;
-
-function test() {
- Harness.downloadFailedCallback = download_failed;
- Harness.installsCompletedCallback = finish_failed_download;
- Harness.setup();
-
- PermissionTestUtils.add(
- "http://example.com/",
- "install",
- Services.perms.ALLOW_ACTION
- );
- Services.prefs.setBoolPref(PREF_INSTALL_REQUIREBUILTINCERTS, false);
-
- // Set up the redirect to give a bad hash
- setup_redirect({
- "X-Target-Digest": "sha1:foo",
- Location: "http://example.com/browser/" + RELATIVE_DIR + "amosigned.xpi",
- });
-
- var url =
- "https://example.com/browser/" +
- RELATIVE_DIR +
- "redirect.sjs?mode=redirect";
-
- var triggers = encodeURIComponent(
- JSON.stringify({
- "Unsigned XPI": {
- URL: url,
- toString() {
- return this.URL;
- },
- },
- })
- );
- gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
- BrowserTestUtils.loadURI(
- gBrowser,
- TESTROOT + "installtrigger.html?" + triggers
- );
-}
-
-function download_failed(install) {
- is(
- install.error,
- AddonManager.ERROR_INCORRECT_HASH,
- "Should have seen a hash failure"
- );
- // Stash the failed download while the harness cleans itself up
- gInstall = install;
-}
-
-function finish_failed_download() {
- // Setup to track the successful re-download
- Harness.installEndedCallback = install_ended;
- Harness.installsCompletedCallback = finish_test;
- Harness.setup();
-
- // Give it the right hash this time
- setup_redirect({
- "X-Target-Digest": "sha1:ee95834ad862245a9ef99ccecc2a857cadc16404",
- Location: "http://example.com/browser/" + RELATIVE_DIR + "amosigned.xpi",
- });
-
- // The harness expects onNewInstall events for all installs that are about to start
- Harness.onNewInstall(gInstall);
-
- // Restart the install as a regular webpage install so the harness tracks it
- AddonManager.installAddonFromWebpage(
- "application/x-xpinstall",
- gBrowser.selectedBrowser,
- gBrowser.contentPrincipal,
- gInstall
- );
-}
-
-function install_ended(install, addon) {
- install.cancel();
-}
-
-function finish_test(count) {
- is(count, 1, "1 Add-on should have been successfully installed");
-
- PermissionTestUtils.remove("http://example.com", "install");
- Services.prefs.clearUserPref(PREF_INSTALL_REQUIREBUILTINCERTS);
-
- gBrowser.removeCurrentTab();
- Harness.finish();
-}
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_whitelist.js b/toolkit/mozapps/extensions/test/xpinstall/browser_whitelist.js
deleted file mode 100644
index f52aa2816d..0000000000
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_whitelist.js
+++ /dev/null
@@ -1,66 +0,0 @@
-// ----------------------------------------------------------------------------
-// Tests installing an unsigned add-on through an InstallTrigger call in web
-// content. This should be blocked by the whitelist check.
-// This verifies bug 252830
-function test() {
- Harness.installConfirmCallback = confirm_install;
- Harness.installBlockedCallback = allow_blocked;
- Harness.installEndedCallback = install_ended;
- Harness.installsCompletedCallback = finish_test;
- Harness.setup();
-
- var triggers = encodeURIComponent(
- JSON.stringify({
- "Unsigned XPI": TESTROOT + "amosigned.xpi",
- })
- );
- gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
- BrowserTestUtils.loadURI(
- gBrowser,
- TESTROOT + "installtrigger.html?" + triggers
- );
-}
-
-function allow_blocked(installInfo) {
- is(
- installInfo.browser,
- gBrowser.selectedBrowser,
- "Install should have been triggered by the right browser"
- );
- is(
- installInfo.originatingURI.spec,
- gBrowser.currentURI.spec,
- "Install should have been triggered by the right uri"
- );
- return true;
-}
-
-function confirm_install(panel) {
- is(panel.getAttribute("name"), "XPI Test", "Should have seen the name");
- return true;
-}
-
-function install_ended(install, addon) {
- install.cancel();
-}
-
-const finish_test = async function(count) {
- is(count, 1, "1 Add-on should have been successfully installed");
-
- const results = await ContentTask.spawn(
- gBrowser.selectedBrowser,
- null,
- () => {
- return {
- return: content.document.getElementById("return").textContent,
- status: content.document.getElementById("status").textContent,
- };
- }
- );
-
- is(results.return, "false", "installTrigger should seen a failure");
-
- gBrowser.removeCurrentTab();
- Harness.finish();
-};
-// ----------------------------------------------------------------------------
diff --git a/toolkit/mozapps/extensions/test/xpinstall/head.js b/toolkit/mozapps/extensions/test/xpinstall/head.js
index 56d88c75e0..46d017c380 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/head.js
+++ b/toolkit/mozapps/extensions/test/xpinstall/head.js
@@ -8,8 +8,8 @@ const RELATIVE_DIR = "toolkit/mozapps/extensions/test/xpinstall/";
const TESTROOT = "http://example.com/browser/" + RELATIVE_DIR;
const TESTROOT2 = "http://example.org/browser/" + RELATIVE_DIR;
-const PROMPT_URL = "chrome://global/content/commonDialog.xul";
-const ADDONS_URL = "chrome://mozapps/content/extensions/extensions.xul";
+const PROMPT_URL = "chrome://global/content/commonDialog.xhtml";
+const ADDONS_URL = "chrome://mozapps/content/extensions/extensions.xhtml";
const PREF_LOGGING_ENABLED = "extensions.logging.enabled";
const PREF_INSTALL_REQUIREBUILTINCERTS =
"extensions.install.requireBuiltInCerts";
@@ -218,13 +218,14 @@ var Harness = {
windowReady(window) {
if (window.document.location.href == PROMPT_URL) {
var promptType = window.args.promptType;
+ let dialog = window.document.getElementById("commonDialog");
switch (promptType) {
case "alert":
case "alertCheck":
case "confirmCheck":
case "confirm":
case "confirmEx":
- window.document.documentElement.acceptDialog();
+ dialog.acceptDialog();
break;
case "promptUserAndPass":
// This is a login dialog, hopefully an authentication prompt
@@ -235,12 +236,12 @@ var Harness = {
window.document.getElementById("loginTextbox").value = auth[0];
window.document.getElementById("password1Textbox").value =
auth[1];
- window.document.documentElement.acceptDialog();
+ dialog.acceptDialog();
} else {
- window.document.documentElement.cancelDialog();
+ dialog.cancelDialog();
}
} else {
- window.document.documentElement.cancelDialog();
+ dialog.cancelDialog();
}
break;
default:
diff --git a/toolkit/mozapps/handling/ContentDispatchChooser.jsm b/toolkit/mozapps/handling/ContentDispatchChooser.jsm
index 6ab81da0ca..3f8668b42f 100644
--- a/toolkit/mozapps/handling/ContentDispatchChooser.jsm
+++ b/toolkit/mozapps/handling/ContentDispatchChooser.jsm
@@ -6,7 +6,7 @@
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-const CONTENT_HANDLING_URL = "chrome://mozapps/content/handling/dialog.xul";
+const CONTENT_HANDLING_URL = "chrome://mozapps/content/handling/dialog.xhtml";
const STRINGBUNDLE_URL = "chrome://mozapps/locale/handling/handling.properties";
// nsContentDispatchChooser class
diff --git a/toolkit/mozapps/handling/content/dialog.js b/toolkit/mozapps/handling/content/dialog.js
index ae17be5e6f..d2f5586dc7 100644
--- a/toolkit/mozapps/handling/content/dialog.js
+++ b/toolkit/mozapps/handling/content/dialog.js
@@ -114,7 +114,7 @@ var dialog = {
(window.opener && PrivateBrowsingUtils.isWindowPrivate(window.opener));
this._itemChoose = document.getElementById("item-choose");
- this._okButton = document.documentElement.getButton("extra1");
+ this._okButton = document.getElementById("handling").getButton("extra1");
var description = {
image: document.getElementById("description-image"),
@@ -172,7 +172,7 @@ var dialog = {
var preferredHandler = this._handlerInfo.preferredApplicationHandler;
for (let i = possibleHandlers.length - 1; i >= 0; --i) {
let app = possibleHandlers.queryElementAt(i, Ci.nsIHandlerApp);
- let elm = document.createElement("richlistitem", {
+ let elm = document.createXULElement("richlistitem", {
is: "mozapps-handler",
});
elm.setAttribute("name", app.name);
@@ -225,7 +225,7 @@ var dialog = {
}
if (this._handlerInfo.hasDefaultHandler) {
- let elm = document.createElement("richlistitem", {
+ let elm = document.createXULElement("richlistitem", {
is: "mozapps-handler",
});
elm.id = "os-default-handler";
@@ -261,7 +261,7 @@ var dialog = {
}
}
if (!appAlreadyInHandlers) {
- let elm = document.createElement("richlistitem", {
+ let elm = document.createXULElement("richlistitem", {
is: "mozapps-handler",
});
elm.setAttribute("name", handler.name);
@@ -308,7 +308,7 @@ var dialog = {
}
}
- let elm = document.createElement("richlistitem", {
+ let elm = document.createXULElement("richlistitem", {
is: "mozapps-handler",
});
elm.setAttribute("name", fp.file.leafName);
diff --git a/toolkit/mozapps/handling/content/dialog.xul b/toolkit/mozapps/handling/content/dialog.xhtml
similarity index 86%
rename from toolkit/mozapps/handling/content/dialog.xul
rename to toolkit/mozapps/handling/content/dialog.xhtml
index c153cfbf2d..163811eeb0 100644
--- a/toolkit/mozapps/handling/content/dialog.xul
+++ b/toolkit/mozapps/handling/content/dialog.xhtml
@@ -6,15 +6,15 @@
- 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/. -->
-
+
-