Bug 1374457: Key cached manifest and locale data by add-on version. r?rhelmer
MozReview-Commit-ID: 7NdS0Etmhot
--- a/toolkit/components/extensions/Extension.jsm
+++ b/toolkit/components/extensions/Extension.jsm
@@ -743,16 +743,17 @@ this.Extension = class extends Extension
Cu.reportError(new Error("Remote extensions should not be enabled without also setting " +
"the layers.popups.compositing.enabled preference to true"));
}
// This is filled in the first time an extension child is created.
this.parentMessageManager = null;
this.id = addonData.id;
+ this.version = addonData.version;
this.baseURI = NetUtil.newURI(this.getURL("")).QueryInterface(Ci.nsIURL);
this.principal = this.createPrincipal();
this.onStartup = null;
this.hasShutdown = false;
this.onShutdown = new Set();
@@ -850,25 +851,25 @@ this.Extension = class extends Extension
isExtensionURL(url) {
let uri = Services.io.newURI(url);
let common = this.baseURI.getCommonBaseSpec(uri);
return common == this.baseURI.spec;
}
readLocaleFile(locale) {
- return StartupCache.locales.get([this.id, locale],
+ return StartupCache.locales.get([this.id, this.version, locale],
() => super.readLocaleFile(locale))
.then(result => {
this.localeData.messages.set(locale, result);
});
}
parseManifest() {
- return StartupCache.manifests.get([this.id, Locale.getLocale()],
+ return StartupCache.manifests.get([this.id, this.version, Locale.getLocale()],
() => super.parseManifest());
}
loadManifest() {
return super.loadManifest().then(manifest => {
if (this.errors.length) {
return Promise.reject({errors: this.errors});
}
--- a/toolkit/components/extensions/LegacyExtensionsUtils.jsm
+++ b/toolkit/components/extensions/LegacyExtensionsUtils.jsm
@@ -104,22 +104,25 @@ class EmbeddedExtension {
* Create a new EmbeddedExtension given the add-on id and the base resource URI of the
* container add-on (the webextension resources will be loaded from the "webextension/"
* subdir of the base resource URI for the legacy extension add-on).
*
* @param {Object} containerAddonParams
* An object with the following properties:
* @param {string} containerAddonParams.id
* The Add-on id of the Legacy Extension which will contain the embedded webextension.
+ * @param {string} containerAddonParams.version
+ * The add-on version.
* @param {nsIURI} containerAddonParams.resourceURI
* The nsIURI of the Legacy Extension container add-on.
*/
- constructor({id, resourceURI}) {
+ constructor({id, resourceURI, version}) {
this.addonId = id;
this.resourceURI = resourceURI;
+ this.version = version;
// Setup status flag.
this.started = false;
}
/**
* Start the embedded webextension.
*
@@ -134,16 +137,17 @@ class EmbeddedExtension {
// Setup the startup promise.
this.startupPromise = new Promise((resolve, reject) => {
let embeddedExtensionURI = Services.io.newURI("webextension/", null, this.resourceURI);
// This is the instance of the WebExtension embedded in the hybrid add-on.
this.extension = new Extension({
id: this.addonId,
resourceURI: embeddedExtensionURI,
+ version: this.version,
});
// This callback is register to the "startup" event, emitted by the Extension instance
// after the extension manifest.json has been loaded without any errors, but before
// starting any of the defined contexts (which give the legacy part a chance to subscribe
// runtime.onMessage/onConnect listener before the background page has been loaded).
const onBeforeStarted = () => {
this.extension.off("startup", onBeforeStarted);
@@ -222,21 +226,21 @@ EmbeddedExtensionManager = {
untrackEmbeddedExtension(embeddedExtensionInstance) {
// Remove this instance from the tracked embedded extensions
let id = embeddedExtensionInstance.addonId;
if (this.embeddedExtensionsByAddonId.get(id) == embeddedExtensionInstance) {
this.embeddedExtensionsByAddonId.delete(id);
}
},
- getEmbeddedExtensionFor({id, resourceURI}) {
+ getEmbeddedExtensionFor({id, resourceURI, version}) {
let embeddedExtension = this.embeddedExtensionsByAddonId.get(id);
if (!embeddedExtension) {
- embeddedExtension = new EmbeddedExtension({id, resourceURI});
+ embeddedExtension = new EmbeddedExtension({id, resourceURI, version});
// Keep track of the embedded extension instance.
this.embeddedExtensionsByAddonId.set(id, embeddedExtension);
}
return embeddedExtension;
},
};