Bug 1293721 follow up: handle pre-existing absolute optionsURL r?kmag
MozReview-Commit-ID: GafnS4ckUiY
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -81,16 +81,18 @@ XPCOMUtils.defineLazyServiceGetter(this,
"amIAddonPathService");
XPCOMUtils.defineLazyGetter(this, "CertUtils", function() {
let certUtils = {};
Components.utils.import("resource://gre/modules/CertUtils.jsm", certUtils);
return certUtils;
});
+Cu.importGlobalProperties(["URL"]);
+
const nsIFile = Components.Constructor("@mozilla.org/file/local;1", "nsIFile",
"initWithPath");
const PREF_DB_SCHEMA = "extensions.databaseSchema";
const PREF_INSTALL_CACHE = "extensions.installCache";
const PREF_XPI_STATE = "extensions.xpiState";
const PREF_BOOTSTRAP_ADDONS = "extensions.bootstrappedAddons";
const PREF_PENDING_OPERATIONS = "extensions.pendingOperations";
@@ -7242,17 +7244,25 @@ AddonWrapper.prototype = {
get optionsURL() {
if (!this.isActive) {
return null;
}
let addon = addonFor(this);
if (addon.optionsURL) {
if (this.isWebExtension) {
- return ExtensionManagement.getURLForExtension(addon.id, addon.optionsURL);
+ // The internal object's optionsURL property comes from the addons
+ // DB and should be a relative URL. However, extensions with
+ // options pages installed before bug 1293721 was fixed got absolute
+ // URLs in the addons db. This code handles both cases.
+ let base = ExtensionManagement.getURLForExtension(addon.id);
+ if (!base) {
+ return null;
+ }
+ return new URL(addon.optionsURL, base).href;
}
return addon.optionsURL;
}
if (this.hasResource("options.xul"))
return this.getResourceURI("options.xul").spec;
return null;