Bug 1472286 - Fix checks for legacy themes. r=kmag
MozReview-Commit-ID: 9bkTG2njxJJ
--- a/toolkit/mozapps/extensions/content/extensions.js
+++ b/toolkit/mozapps/extensions/content/extensions.js
@@ -235,23 +235,17 @@ function isDisabledUnsigned(addon) {
}
function isLegacyExtension(addon) {
let legacy = false;
if (addon.type == "extension" && !addon.isWebExtension) {
legacy = true;
}
if (addon.type == "theme") {
- // The logic here is kind of clunky but we want to mark complete
- // themes as legacy. There's no explicit flag for complete
- // themes so explicitly check for new style themes (for which
- // isWebExtension is true) or lightweight themes (which have
- // ids that end with @personas.mozilla.org)
- legacy = !(addon.isWebExtension || addon.id.endsWith("@personas.mozilla.org") ||
- addon.id == "default-theme@mozilla.org");
+ legacy = false;
}
if (legacy && (addon.hidden || addon.signedState == AddonManager.SIGNEDSTATE_PRIVILEGED)) {
legacy = false;
}
// Exceptions that can slip through above: the default theme plus
// test pilot addons until we get SIGNEDSTATE_PRIVILEGED deployed.
if (legacy && legacyWarningExceptions.includes(addon.id)) {
@@ -2578,37 +2572,17 @@ var gDetailView = {
this._addon = aAddon;
gEventManager.registerAddonListener(this, aAddon.id);
gEventManager.registerInstallListener(this);
this.node.setAttribute("type", aAddon.type);
let legacy = false;
if (!aAddon.install) {
- if (aAddon.type == "extension" && !aAddon.isWebExtension) {
- legacy = true;
- }
- if (aAddon.type == "theme") {
- // The logic here is kind of clunky but we want to mark complete
- // themes as legacy. There's no explicit flag for complete
- // themes so explicitly check for new style themes (for which
- // isWebExtension is true) or lightweight themes (which have
- // ids that end with @personas.mozilla.org)
- legacy = !(aAddon.isWebExtension || aAddon.id.endsWith("@personas.mozilla.org"));
- }
-
- if (legacy && aAddon.signedState == AddonManager.SIGNEDSTATE_PRIVILEGED) {
- legacy = false;
- }
-
- // Exceptions that can slip through above: the default theme plus
- // test pilot addons until we get SIGNEDSTATE_PRIVILEGED deployed.
- if (legacy && legacyWarningExceptions.includes(aAddon.id)) {
- legacy = false;
- }
+ legacy = isLegacyExtension(aAddon);
}
this.node.setAttribute("legacy", legacy);
document.getElementById("detail-legacy-warning").href = SUPPORT_URL + "webextensions";
// Make sure to select the correct category
let category = (isDisabledLegacy(aAddon) || isDisabledUnsigned(aAddon)) ?
"addons://legacy" : `addons://list/${aAddon.type}`;
gCategories.select(category);
--- a/toolkit/mozapps/extensions/test/browser/browser.ini
+++ b/toolkit/mozapps/extensions/test/browser/browser.ini
@@ -65,17 +65,16 @@ skip-if = true # Bug 1449071 - Frequent
skip-if = os == 'linux' && !debug # Bug 1398766
[browser_inlinesettings_browser.js]
skip-if = (verify && debug && (os == 'mac'))
[browser_installssl.js]
skip-if = verify
[browser_langpack_signing.js]
[browser_legacy.js]
[browser_legacy_pre57.js]
-[browser_legacy_themes.js]
[browser_list.js]
[browser_manualupdates.js]
[browser_pluginprefs.js]
[browser_pluginprefs_is_not_disabled.js]
[browser_plugin_enabled_state_locked.js]
[browser_recentupdates.js]
[browser_sorting.js]
[browser_sorting_plugins.js]
--- a/toolkit/mozapps/extensions/test/browser/browser_legacy_pre57.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_legacy_pre57.js
@@ -1,28 +1,21 @@
add_task(async function() {
const INFO_URL = Services.urlFormatter.formatURLPref("app.support.baseURL") + "webextensions";
const NAMES = {
- fullTheme: "Full Theme",
newTheme: "New LWT",
legacy: "Legacy Extension",
webextension: "WebExtension",
dictionary: "Dictionary",
langpack: "Language Pack",
};
let addons = [
{
- id: "full-theme@tests.mozilla.org",
- name: NAMES.fullTheme,
- type: "theme",
- isWebExtension: false,
- },
- {
id: "new-theme@tests.mozilla.org",
name: NAMES.newTheme,
type: "theme",
isWebExtension: true,
},
{
id: "legacy@tests.mozilla.org",
name: NAMES.legacy,
@@ -82,16 +75,15 @@ add_task(async function() {
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.fullTheme, true);
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);
});
deleted file mode 100644
--- a/toolkit/mozapps/extensions/test/browser/browser_legacy_themes.js
+++ /dev/null
@@ -1,77 +0,0 @@
-
-add_task(async function() {
- // 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",
- ];
-
- let exceptions = Services.prefs.getCharPref("extensions.legacy.exceptions");
- exceptions = [ exceptions, ...IGNORE ].join(",");
-
- await SpecialPowers.pushPrefEnv({
- set: [
- ["extensions.legacy.enabled", false],
- ["extensions.legacy.exceptions", exceptions],
- ],
- });
-
- const ID = "theme@tests.mozilla.org";
-
- let provider = new MockProvider();
- provider.createAddons([{
- id: ID,
- name: "Complete Theme",
- type: "theme",
- appDisabled: true,
- }]);
-
- // Open about:addons and go to the themes list
- let mgrWin = await open_manager(null);
- let catUtils = new CategoryUtilities(mgrWin);
- await catUtils.openType("theme");
-
- // Our complete theme should not be displayed
- let list = mgrWin.document.getElementById("addon-list");
- let item = list.children.find(item => item.mAddon.id == ID);
- is(item, undefined, `Theme ${ID} should not be in the list of active themes`);
-
- // The warning banner and the legacy category should both be visible
- let banner = mgrWin.document.getElementById("legacy-extensions-notice");
- is_element_visible(banner, "Warning about legacy themes should be visible");
- is(mgrWin.gLegacyView._categoryItem.disabled, false, "Legacy category should be visible ");
-
- // Follow the link to the legacy extensions page
- let legacyLink = mgrWin.document.getElementById("legacy-extensions-learnmore-link");
- is_element_visible(legacyLink, "Link to legacy extensions 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");
-
- list = mgrWin.document.getElementById("legacy-list");
- is(list.children.length, 1, "Should have 1 item in the legacy list");
- item = list.children[0];
- is(item.mAddon.id, ID, "Complete theme should be in the list");
-
- // Click the find a replacement button
- let button = document.getAnonymousElementByAttribute(item, "anonid", "replacement-btn");
- is_element_visible(button, "Find a replacement butotn is visible");
-
- // In automation, app.support.baseURL points to a page on localhost.
- // The actual page is 404 in the test but that doesn't matter here,
- // just the fact that we load the right URL.
- let url = Services.prefs.getStringPref("app.support.baseURL") + "complete-themes";
- let tabPromise = BrowserTestUtils.waitForNewTab(gBrowser, url);
- button.click();
- let tab = await tabPromise;
- ok(true, "Find a replacement button opened SUMO page");
- BrowserTestUtils.removeTab(tab);
-
- await close_manager(mgrWin);
-});