Merge mozilla-central to fx-team
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Mon, 18 Jul 2016 09:11:27 +0200
changeset 330371 79862ac0b7dfe992dde4bf0179b66a1cc792a460
parent 330370 e7a27a7538b2bee268abdb08f4f3a6e41c5c58c8 (current diff)
parent 330298 0fbdcd21fad76a00328e67875c6f40dc219235f4 (diff)
child 330372 76bb0b29a7509fe35db3beb571fec162cc781a80
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone50.0a1
Merge mozilla-central to fx-team
--- a/toolkit/mozapps/extensions/AddonManager.jsm
+++ b/toolkit/mozapps/extensions/AddonManager.jsm
@@ -41,17 +41,16 @@ const PREF_EM_HOTFIX_LASTVERSION      = 
 const PREF_EM_HOTFIX_URL              = "extensions.hotfix.url";
 const PREF_EM_CERT_CHECKATTRIBUTES    = "extensions.hotfix.cert.checkAttributes";
 const PREF_EM_HOTFIX_CERTS            = "extensions.hotfix.certs.";
 const PREF_MATCH_OS_LOCALE            = "intl.locale.matchOS";
 const PREF_SELECTED_LOCALE            = "general.useragent.locale";
 const UNKNOWN_XPCOM_ABI               = "unknownABI";
 
 const PREF_MIN_WEBEXT_PLATFORM_VERSION = "extensions.webExtensionsMinPlatformVersion";
-const PREF_WEBAPI_TESTING             = "extensions.webapi.testing";
 
 const UPDATE_REQUEST_VERSION          = 2;
 const CATEGORY_UPDATE_PARAMS          = "extension-update-params";
 
 const XMLURI_BLOCKLIST                = "http://www.mozilla.org/2006/addons-blocklist";
 
 const KEY_PROFILEDIR                  = "ProfD";
 const KEY_APPDIR                      = "XCurProcD";
@@ -62,23 +61,16 @@ const PREF_EM_CHECK_COMPATIBILITY_BASE =
 var PREF_EM_CHECK_COMPATIBILITY = MOZ_COMPATIBILITY_NIGHTLY ?
                                   PREF_EM_CHECK_COMPATIBILITY_BASE + ".nightly" :
                                   undefined;
 
 const TOOLKIT_ID                      = "toolkit@mozilla.org";
 
 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/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/AsyncShutdown.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "Task",
                                   "resource://gre/modules/Task.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "Promise",
                                   "resource://gre/modules/Promise.jsm");
@@ -2899,32 +2891,17 @@ var AddonManagerInternal = {
       if (!info) {
         throw new Error(`forgetInstall cannot find ${id}`);
       }
       info.install.removeListener(info.listener);
       this.installs.delete(id);
     },
 
     createInstall(target, options) {
-      return new Promise((resolve, reject) => {
-        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;
-        }
-
+      return new Promise((resolve) => {
         let newInstall = install => {
           let id = this.nextInstall++;
           let listener = this.makeListener(id, target);
           install.addListener(listener);
 
           this.installs.set(id, {install, target, listener});
 
           let result = {id};
--- a/toolkit/mozapps/extensions/addonManager.js
+++ b/toolkit/mozapps/extensions/addonManager.js
@@ -243,19 +243,17 @@ amManager.prototype = {
               onInstalled: (addon) => handler("onInstalled", addon.id, false),
               onUninstalling: (addon, needsRestart) => handler("onUninstalling", addon.id, needsRestart),
               onUninstalled: (addon) => handler("onUninstalled", addon.id, false),
               onOperationCancelled: (addon) => handler("onOperationCancelled", addon.id, false),
             };
           }
           AddonManager.addAddonListener(this.addonListener);
         } else {
-          if (this.addonListener) {
-            AddonManager.removeAddonListener(this.addonListener);
-          }
+          AddonManager.removeAddonListener(this.addonListener);
         }
       }
     }
     return undefined;
   },
 
   sendEvent(target, data) {
     target.sendAsyncMessage(MSG_INSTALL_EVENT, data);
--- a/toolkit/mozapps/extensions/test/browser/browser_webapi_install.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_webapi_install.js
@@ -235,27 +235,8 @@ add_task(makeInstallTest(function* (brow
   yield testInstall(browser, XPI_URL + "bogus", steps, "install of a bad url fails");
 
   let addons = yield promiseAddonsByIDs([ID]);
   is(addons[0], null, "The addon was not installed");
 
   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");
-  });
-});