зеркало из https://github.com/mozilla/gecko-dev.git
Merge mozilla-central to mozilla-inbound
This commit is contained in:
Коммит
8e72d78ed1
|
@ -46,7 +46,6 @@ const PREF_SELECTED_LOCALE = "general.useragent.locale";
|
||||||
const UNKNOWN_XPCOM_ABI = "unknownABI";
|
const UNKNOWN_XPCOM_ABI = "unknownABI";
|
||||||
|
|
||||||
const PREF_MIN_WEBEXT_PLATFORM_VERSION = "extensions.webExtensionsMinPlatformVersion";
|
const PREF_MIN_WEBEXT_PLATFORM_VERSION = "extensions.webExtensionsMinPlatformVersion";
|
||||||
const PREF_WEBAPI_TESTING = "extensions.webapi.testing";
|
|
||||||
|
|
||||||
const UPDATE_REQUEST_VERSION = 2;
|
const UPDATE_REQUEST_VERSION = 2;
|
||||||
const CATEGORY_UPDATE_PARAMS = "extension-update-params";
|
const CATEGORY_UPDATE_PARAMS = "extension-update-params";
|
||||||
|
@ -67,13 +66,6 @@ const TOOLKIT_ID = "toolkit@mozilla.org";
|
||||||
|
|
||||||
const VALID_TYPES_REGEXP = /^[\w\-]+$/;
|
const VALID_TYPES_REGEXP = /^[\w\-]+$/;
|
||||||
|
|
||||||
const WEBAPI_INSTALL_HOSTS = ["addons.mozilla.org", "addons.cdn.mozilla.net"];
|
|
||||||
const WEBAPI_TEST_INSTALL_HOSTS = [
|
|
||||||
"addons.allizom.org", "addons-stage-cdn.allizom.org",
|
|
||||||
"addons-dev.allizom.org", "addons-dev-cdn-allizom.org",
|
|
||||||
"example.com"
|
|
||||||
];
|
|
||||||
|
|
||||||
Cu.import("resource://gre/modules/Services.jsm");
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
Cu.import("resource://gre/modules/AsyncShutdown.jsm");
|
Cu.import("resource://gre/modules/AsyncShutdown.jsm");
|
||||||
|
@ -2904,22 +2896,7 @@ var AddonManagerInternal = {
|
||||||
},
|
},
|
||||||
|
|
||||||
createInstall(target, options) {
|
createInstall(target, options) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve) => {
|
||||||
try {
|
|
||||||
let host = Services.io.newURI(options.url, null, null).host;
|
|
||||||
if (WEBAPI_INSTALL_HOSTS.includes(host)) {
|
|
||||||
// good
|
|
||||||
} else if (Services.prefs.getBoolPref(PREF_WEBAPI_TESTING)
|
|
||||||
&& WEBAPI_TEST_INSTALL_HOSTS.includes(host)) {
|
|
||||||
// good
|
|
||||||
} else {
|
|
||||||
throw new Error(`Install from ${host} not permitted`);
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
reject({message: err.message});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let newInstall = install => {
|
let newInstall = install => {
|
||||||
let id = this.nextInstall++;
|
let id = this.nextInstall++;
|
||||||
let listener = this.makeListener(id, target);
|
let listener = this.makeListener(id, target);
|
||||||
|
|
|
@ -248,9 +248,7 @@ amManager.prototype = {
|
||||||
}
|
}
|
||||||
AddonManager.addAddonListener(this.addonListener);
|
AddonManager.addAddonListener(this.addonListener);
|
||||||
} else {
|
} else {
|
||||||
if (this.addonListener) {
|
AddonManager.removeAddonListener(this.addonListener);
|
||||||
AddonManager.removeAddonListener(this.addonListener);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,22 +240,3 @@ add_task(makeInstallTest(function* (browser) {
|
||||||
ok(AddonManager.webAPI.installs.size > 0, "webAPI is tracking the AddonInstall");
|
ok(AddonManager.webAPI.installs.size > 0, "webAPI is tracking the AddonInstall");
|
||||||
}));
|
}));
|
||||||
|
|
||||||
add_task(function test_badhost() {
|
|
||||||
return BrowserTestUtils.withNewTab(TESTPAGE, function*(browser) {
|
|
||||||
let result = yield ContentTask.spawn(browser, null, function () {
|
|
||||||
return new Promise(resolve => {
|
|
||||||
const url = "https://addons.not-really-mozilla.org/impostor.xpi";
|
|
||||||
content.navigator.mozAddonManager.createInstall({url})
|
|
||||||
.then(() => {
|
|
||||||
resolve({success: false, message: "createInstall should not have succeeded"});
|
|
||||||
}, err => {
|
|
||||||
if (!err.message.match(/not permitted/)) {
|
|
||||||
resolve({success: false, message: "Wrong error message for invalid download url"});
|
|
||||||
}
|
|
||||||
resolve({success: true});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
is(result.success, true, result.message || "Trying to download an invalid URL resulted in an error");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче