Bug 1423687 - show warning in about:debugging when loading a temporary legacy extension;r=aswan,pbro

MozReview-Commit-ID: I9U5zzwZCSj

--HG--
extra : rebase_source : 72a8141a50d4420910a6e1051a56b38579ec14e8
This commit is contained in:
Julian Descottes 2017-12-08 14:44:46 +01:00
Родитель 2c43d71711
Коммит 38f14b6373
5 изменённых файлов: 63 добавлений и 7 удалений

Просмотреть файл

@ -9,8 +9,14 @@
const { Component } = require("devtools/client/shared/vendor/react"); const { Component } = require("devtools/client/shared/vendor/react");
const PropTypes = require("devtools/client/shared/vendor/react-prop-types"); const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
const dom = require("devtools/client/shared/vendor/react-dom-factories"); const dom = require("devtools/client/shared/vendor/react-dom-factories");
const { debugLocalAddon, debugRemoteAddon, isTemporaryID, parseFileUri, uninstallAddon } = const {
require("../../modules/addon"); debugLocalAddon,
debugRemoteAddon,
isLegacyTemporaryExtension,
isTemporaryID,
parseFileUri,
uninstallAddon
} = require("../../modules/addon");
const Services = require("Services"); const Services = require("Services");
loader.lazyImporter(this, "BrowserToolboxProcess", loader.lazyImporter(this, "BrowserToolboxProcess",
@ -24,6 +30,7 @@ const Strings = Services.strings.createBundle(
const TEMP_ID_URL = "https://developer.mozilla.org/Add-ons" + const TEMP_ID_URL = "https://developer.mozilla.org/Add-ons" +
"/WebExtensions/WebExtensions_and_the_Add-on_ID"; "/WebExtensions/WebExtensions_and_the_Add-on_ID";
const LEGACY_WARNING_URL = "https://wiki.mozilla.org/Add-ons/Future_of_Bootstrap";
function filePathForTarget(target) { function filePathForTarget(target) {
// Only show file system paths, and only for temporarily installed add-ons. // Only show file system paths, and only for temporarily installed add-ons.
@ -90,7 +97,7 @@ function internalIDForTarget(target) {
function showMessages(target) { function showMessages(target) {
const messages = [ const messages = [
...warningMessages(target.warnings), ...warningMessages(target),
...infoMessages(target), ...infoMessages(target),
]; ];
if (messages.length > 0) { if (messages.length > 0) {
@ -112,15 +119,37 @@ function infoMessages(target) {
Strings.GetStringFromName("temporaryID.learnMore") Strings.GetStringFromName("temporaryID.learnMore")
))); )));
} }
return messages; return messages;
} }
function warningMessages(warnings = []) { function warningMessages(target) {
return warnings.map((warning) => { let messages = [];
if (isLegacyTemporaryExtension(target.form)) {
messages.push(dom.li(
{
className: "addon-target-warning-message addon-target-message"
},
Strings.GetStringFromName("legacyExtensionWarning"),
" ",
dom.a(
{
href: LEGACY_WARNING_URL,
target: "_blank"
},
Strings.GetStringFromName("legacyExtensionWarning.learnMore"))
));
}
let warnings = target.warnings || [];
messages = messages.concat(warnings.map((warning) => {
return dom.li( return dom.li(
{ className: "addon-target-warning-message addon-target-message" }, { className: "addon-target-warning-message addon-target-message" },
warning); warning);
}); }));
return messages;
} }
class AddonTarget extends Component { class AddonTarget extends Component {

Просмотреть файл

@ -81,6 +81,19 @@ exports.isTemporaryID = function (addonID) {
return AddonManagerPrivate.isTemporaryInstallID(addonID); return AddonManagerPrivate.isTemporaryInstallID(addonID);
}; };
exports.isLegacyTemporaryExtension = function (addonForm) {
if (!addonForm.type) {
// If about:debugging is connected to an older then 59 remote Firefox, and type is
// not available on the addon/webextension actors, return false to avoid showing
// irrelevant warning messages.
return false;
}
return addonForm.type == "extension" &&
addonForm.temporarilyInstalled &&
!addonForm.isWebExtension &&
!addonForm.isAPIExtension;
};
exports.parseFileUri = function (url) { exports.parseFileUri = function (url) {
// Strip a leading slash from Windows drive letter URIs. // Strip a leading slash from Windows drive letter URIs.
// file:///home/foo ~> /home/foo // file:///home/foo ~> /home/foo

Просмотреть файл

@ -106,6 +106,15 @@ temporaryID = This WebExtension has a temporary ID.
# the user to MDN. # the user to MDN.
temporaryID.learnMore = Learn more temporaryID.learnMore = Learn more
# LOCALIZATION NOTE (legacyExtensionWarning):
# This string is displayed as a warning message when loading a temporary legacy extension.
legacyExtensionWarning = This is a legacy extension, be aware that these are no longer fully supported. Please read the linked documentation and then proceed with caution.
# LOCALIZATION NOTE (temporaryID.learnMore):
# This string is displayed as a link next to the legacyExtensionWarning message and leads
# the user to https://wiki.mozilla.org/Add-ons/Future_of_Bootstrap.
legacyExtensionWarning.learnMore = Learn more
# LOCALIZATION NOTE (selectAddonFromFile2): # LOCALIZATION NOTE (selectAddonFromFile2):
# This string is displayed as the title of the file picker that appears when # This string is displayed as the title of the file picker that appears when
# the user clicks the 'Load Temporary Add-on' button # the user clicks the 'Load Temporary Add-on' button

Просмотреть файл

@ -85,6 +85,9 @@ BrowserAddonActor.prototype = {
iconURL: this._addon.iconURL, iconURL: this._addon.iconURL,
debuggable: this._addon.isDebuggable, debuggable: this._addon.isDebuggable,
temporarilyInstalled: this._addon.temporarilyInstalled, temporarilyInstalled: this._addon.temporarilyInstalled,
type: this._addon.type,
isWebExtension: this._addon.isWebExtension,
isAPIExtension: this._addon.isAPIExtension,
consoleActor: this._consoleActor.actorID, consoleActor: this._consoleActor.actorID,
traits: { traits: {

Просмотреть файл

@ -73,7 +73,9 @@ const WebExtensionParentActor = protocol.ActorClassWithSpec(webExtensionSpec, {
iconURL: this.addon.iconURL, iconURL: this.addon.iconURL,
debuggable: this.addon.isDebuggable, debuggable: this.addon.isDebuggable,
temporarilyInstalled: this.addon.temporarilyInstalled, temporarilyInstalled: this.addon.temporarilyInstalled,
isWebExtension: true, type: this.addon.type,
isWebExtension: this.addon.isWebExtension,
isAPIExtension: this.addon.isAPIExtension,
manifestURL: policy && policy.getURL("manifest.json"), manifestURL: policy && policy.getURL("manifest.json"),
warnings: ExtensionParent.DebugUtils.getExtensionManifestWarnings(this.id), warnings: ExtensionParent.DebugUtils.getExtensionManifestWarnings(this.id),
}; };