mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 16:55:40 +00:00
Bug 1354682 Add legacy badges in about:addons r=mossop
MozReview-Commit-ID: 3ch4lfApSIc --HG-- extra : rebase_source : 107378e2340176531e51e47c7c52cb4220a1b3d0 extra : source : 9f83f42258cfe7c796fb85d8c75571279646fc41
This commit is contained in:
parent
46e486f880
commit
1173530c2f
@ -188,6 +188,10 @@
|
||||
<!ENTITY addon.details.label "More">
|
||||
<!ENTITY addon.details.tooltip "Show more details about this add-on">
|
||||
<!ENTITY addon.unknownDate "Unknown">
|
||||
<!-- LOCALIZATION NOTE (addon.legacy.label): This appears in a badge next
|
||||
to the add-on name for extensions that are not webextensions, which
|
||||
will stop working in Firefox 57. -->
|
||||
<!ENTITY addon.legacy.label "LEGACY">
|
||||
<!-- LOCALIZATION NOTE (addon.disabled.postfix): This is used in a normal list
|
||||
to signify that an add-on is disabled, in the form
|
||||
"<Addon name> <1.0> (disabled)" -->
|
||||
|
@ -157,12 +157,14 @@ setting[type="menulist"] {
|
||||
.addon[active="true"] .disabled-postfix,
|
||||
.addon[pending="install"] .update-postfix,
|
||||
.addon[pending="install"] .disabled-postfix,
|
||||
.addon[legacy="false"] .legacy-warning,
|
||||
#detail-view:not([notification="warning"]) .warning,
|
||||
#detail-view:not([notification="error"]) .error,
|
||||
#detail-view:not([notification="info"]) .info,
|
||||
#detail-view:not([pending]) .pending,
|
||||
#detail-view:not([upgrade="true"]) .update-postfix,
|
||||
#detail-view[active="true"] .disabled-postfix,
|
||||
#detail-view[legacy="false"] .legacy-warning,
|
||||
#detail-view[loading] .detail-view-container,
|
||||
#detail-view:not([loading]) .alert-container,
|
||||
.detail-row:not([value]),
|
||||
|
@ -56,6 +56,7 @@ const PREF_GETADDONS_CACHE_ENABLED = "extensions.getAddons.cache.enabled";
|
||||
const PREF_GETADDONS_CACHE_ID_ENABLED = "extensions.%ID%.getAddons.cache.enabled";
|
||||
const PREF_UI_TYPE_HIDDEN = "extensions.ui.%TYPE%.hidden";
|
||||
const PREF_UI_LASTCATEGORY = "extensions.ui.lastCategory";
|
||||
const PREF_LEGACY_EXCEPTIONS = "extensions.legacy.exceptions";
|
||||
|
||||
const LOADING_MSG_DELAY = 100;
|
||||
|
||||
@ -104,6 +105,10 @@ XPCOMUtils.defineLazyGetter(this, "gInlineOptionsStylesheets", () => {
|
||||
return stylesheets;
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(this, "legacyWarningExceptions",
|
||||
PREF_LEGACY_EXCEPTIONS, "",
|
||||
raw => raw.split(","));
|
||||
|
||||
document.addEventListener("load", initialize, true);
|
||||
window.addEventListener("unload", shutdown);
|
||||
|
||||
@ -3059,6 +3064,32 @@ var gDetailView = {
|
||||
|
||||
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.signedStatus == 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;
|
||||
}
|
||||
}
|
||||
this.node.setAttribute("legacy", legacy);
|
||||
|
||||
// If the search category isn't selected then make sure to select the
|
||||
// correct category
|
||||
if (gCategories.selected != "addons://search/")
|
||||
|
@ -748,6 +748,38 @@
|
||||
<binding id="addon-base"
|
||||
extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">
|
||||
<implementation>
|
||||
<property name="isLegacy" readonly="true">
|
||||
<getter><![CDATA[
|
||||
if (this.mAddon.install) {
|
||||
return false;
|
||||
}
|
||||
let legacy = false;
|
||||
if (this.mAddon.type == "extension" && !this.mAddon.isWebExtension) {
|
||||
legacy = true;
|
||||
}
|
||||
if (this.mAddon.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 = !(this.mAddon.isWebExtension ||
|
||||
this.mAddon.id.endsWith("@personas.mozilla.org"));
|
||||
}
|
||||
|
||||
if (legacy && this.mAddon.signedStatus == 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(this.mAddon.id)) {
|
||||
legacy = false;
|
||||
}
|
||||
return legacy;
|
||||
]]></getter>
|
||||
</property>
|
||||
|
||||
<method name="hasPermission">
|
||||
<parameter name="aPerm"/>
|
||||
<body><![CDATA[
|
||||
@ -833,6 +865,7 @@
|
||||
<xul:hbox class="name-container">
|
||||
<xul:label anonid="name" class="name" crop="end" flex="1"
|
||||
tooltip="addonitem-tooltip" xbl:inherits="value=name"/>
|
||||
<xul:label anonid="legacy" class="legacy-warning" value="&addon.legacy.label;"/>
|
||||
<xul:label class="disabled-postfix" value="&addon.disabled.postfix;"/>
|
||||
<xul:label class="update-postfix" value="&addon.update.postfix;"/>
|
||||
<xul:spacer flex="5000"/> <!-- Necessary to make the name crop -->
|
||||
@ -1154,6 +1187,8 @@
|
||||
else
|
||||
this._description.hidden = true;
|
||||
|
||||
this.setAttribute("legacy", this.isLegacy);
|
||||
|
||||
if (!("applyBackgroundUpdates" in this.mAddon) ||
|
||||
(this.mAddon.applyBackgroundUpdates == AddonManager.AUTOUPDATE_DISABLE ||
|
||||
(this.mAddon.applyBackgroundUpdates == AddonManager.AUTOUPDATE_DEFAULT &&
|
||||
|
@ -567,6 +567,7 @@
|
||||
align="start">
|
||||
<label id="detail-name" flex="1"/>
|
||||
<label id="detail-version"/>
|
||||
<label class="legacy-warning" value="&addon.legacy.label;"/>
|
||||
<label class="disabled-postfix" value="&addon.disabled.postfix;"/>
|
||||
<label class="update-postfix" value="&addon.update.postfix;"/>
|
||||
<spacer flex="5000"/> <!-- Necessary to allow the name to wrap -->
|
||||
|
@ -64,6 +64,7 @@ skip-if = buildapp == 'mulet'
|
||||
skip-if = require_signing
|
||||
[browser_install.js]
|
||||
[browser_installssl.js]
|
||||
[browser_legacy.js]
|
||||
[browser_newaddon.js]
|
||||
[browser_non_mpc.js]
|
||||
[browser_searching.js]
|
||||
|
93
toolkit/mozapps/extensions/test/browser/browser_legacy.js
Normal file
93
toolkit/mozapps/extensions/test/browser/browser_legacy.js
Normal file
@ -0,0 +1,93 @@
|
||||
|
||||
add_task(async function() {
|
||||
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,
|
||||
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, "class", "legacy-warning");
|
||||
|
||||
if (isLegacy) {
|
||||
is_element_visible(badge, `Legacy badge is visible for ${name}`);
|
||||
} else {
|
||||
is_element_hidden(badge, `Legacy badge is hidden for ${name}`);
|
||||
}
|
||||
|
||||
// Click down to the details page.
|
||||
let detailsButton = document.getAnonymousElementByAttribute(item, "anonid", "details-btn");
|
||||
EventUtils.synthesizeMouseAtCenter(detailsButton, {}, 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}`);
|
||||
} 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);
|
||||
});
|
@ -457,6 +457,18 @@ button.warning {
|
||||
-moz-box-flex: 1;
|
||||
}
|
||||
|
||||
.legacy-warning {
|
||||
background-color: #FFE900;
|
||||
color: #3E2800;
|
||||
padding: 4px 5px 3px;
|
||||
font-size: 0.9rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
#detail-view .legacy-warning {
|
||||
margin-top: 0.78rem;
|
||||
}
|
||||
|
||||
.creator {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user