Backed out changesets 82e0d9a22463 and 9b936f748c46 (bug 1308688) for test_ext_webrequest.html failures.
authorRyan VanderMeulen <ryanvm@gmail.com>
Wed, 30 Nov 2016 21:18:31 -0500
changeset 356831 b28660caae81517d310fb6c4073faec681704313
parent 356830 1930eb067498647c3a291fceaa63a3518102f92d
child 356832 88ae43bdada9e2076136cb02f4d4083ba0f50773
push id6646
push userryanvm@gmail.com
push dateThu, 01 Dec 2016 02:21:05 +0000
treeherdermozilla-beta@63121d897767 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1308688
milestone51.0
backs out82e0d9a22463a20649f21791e419634f9a0d7f7a
9b936f748c46eadf73ea923faebacafe14934de2
Backed out changesets 82e0d9a22463 and 9b936f748c46 (bug 1308688) for test_ext_webrequest.html failures.
dom/bindings/Bindings.conf
dom/webidl/AddonManager.webidl
toolkit/modules/addons/.eslintrc
toolkit/modules/addons/WebRequest.jsm
toolkit/mozapps/extensions/AddonManagerWebAPI.cpp
toolkit/mozapps/extensions/AddonManagerWebAPI.h
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -48,21 +48,16 @@
 # descriptor to use when generating that interface's binding.
 
 DOMInterfaces = {
 
 'AbstractWorker': {
     'concrete': False
 },
 
-'AddonManagerPermissions': {
-    'wrapperCache': False,
-    'concrete': False
-},
-
 'AnimationEffectReadOnly': {
     'concrete': False
 },
 
 'AnimationTimeline': {
     'concrete': False
 },
 
--- a/dom/webidl/AddonManager.webidl
+++ b/dom/webidl/AddonManager.webidl
@@ -78,14 +78,8 @@ interface AddonManager : EventTarget {
   Promise<AddonInstall> createInstall(optional addonInstallOptions options);
 
   /* Hooks for managing event listeners */
   [ChromeOnly]
   void eventListenerWasAdded(DOMString type);
   [ChromeOnly]
   void eventListenerWasRemoved(DOMString type);
 };
-
-[ChromeOnly,Exposed=System,HeaderFile="mozilla/AddonManagerWebAPI.h"]
-interface AddonManagerPermissions {
-  static boolean isHostPermitted(DOMString host);
-};
-
--- a/toolkit/modules/addons/.eslintrc
+++ b/toolkit/modules/addons/.eslintrc
@@ -1,13 +1,12 @@
 {
   "extends": "../../components/extensions/.eslintrc",
 
   "globals": {
     "addEventListener": false,
     "addMessageListener": false,
     "removeEventListener": false,
     "sendAsyncMessage": false,
-    "AddonManagerPermissions": false,
 
     "initialProcessData": true,
   },
 }
--- a/toolkit/modules/addons/WebRequest.jsm
+++ b/toolkit/modules/addons/WebRequest.jsm
@@ -597,23 +597,19 @@ HttpObserverManager = {
 
       let result = null;
       try {
         result = callback(data);
       } catch (e) {
         Cu.reportError(e);
       }
 
-      if (!result || !opts.blocking
-          || AddonManagerPermissions.isHostPermitted(uri.host)
-          || !loadInfo || !loadInfo.loadingPrincipal.URI
-          || AddonManagerPermissions.isHostPermitted(loadInfo.loadingPrincipal.URI.host)) {
+      if (!result || !opts.blocking) {
         continue;
       }
-
       if (result.cancel) {
         channel.cancel(Cr.NS_ERROR_ABORT);
         this.errorCheck(channel, loadContext);
         return false;
       }
       if (result.redirectUrl) {
         channel.redirectTo(BrowserUtils.makeURI(result.redirectUrl));
         return false;
--- a/toolkit/mozapps/extensions/AddonManagerWebAPI.cpp
+++ b/toolkit/mozapps/extensions/AddonManagerWebAPI.cpp
@@ -13,62 +13,57 @@
 #include "nsGlobalWindow.h"
 
 #include "nsIDocShell.h"
 #include "nsIScriptObjectPrincipal.h"
 
 namespace mozilla {
 using namespace mozilla::dom;
 
-static bool
-IsValidHost(const nsACString& host) {
-  if (host.Equals("addons.mozilla.org") ||
-      host.Equals("discovery.addons.mozilla.org") ||
-      host.Equals("testpilot.firefox.com")) {
-    return true;
-  }
-
-  // When testing allow access to the developer sites.
-  if (Preferences::GetBool("extensions.webapi.testing", false)) {
-    if (host.LowerCaseEqualsLiteral("addons.allizom.org") ||
-        host.LowerCaseEqualsLiteral("discovery.addons.allizom.org") ||
-        host.LowerCaseEqualsLiteral("addons-dev.allizom.org") ||
-        host.LowerCaseEqualsLiteral("discovery.addons-dev.allizom.org") ||
-        host.LowerCaseEqualsLiteral("testpilot.stage.mozaws.net") ||
-        host.LowerCaseEqualsLiteral("testpilot.dev.mozaws.net") ||
-        host.LowerCaseEqualsLiteral("example.com")) {
-      return true;
-    }
-  }
-
-  return false;
-}
-
 // Checks if the given uri is secure and matches one of the hosts allowed to
 // access the API.
 bool
 AddonManagerWebAPI::IsValidSite(nsIURI* uri)
 {
   if (!uri) {
     return false;
   }
 
   bool isSecure;
   nsresult rv = uri->SchemeIs("https", &isSecure);
   if (NS_FAILED(rv) || !isSecure) {
     return false;
   }
 
-  nsAutoCString host;
+  nsCString host;
   rv = uri->GetHost(host);
   if (NS_FAILED(rv)) {
     return false;
   }
 
-  return IsValidHost(host);
+  if (host.Equals("addons.mozilla.org") ||
+      host.Equals("discovery.addons.mozilla.org") ||
+      host.Equals("testpilot.firefox.com")) {
+    return true;
+  }
+
+  // When testing allow access to the developer sites.
+  if (Preferences::GetBool("extensions.webapi.testing", false)) {
+    if (host.Equals("addons.allizom.org") ||
+        host.Equals("discovery.addons.allizom.org") ||
+        host.Equals("addons-dev.allizom.org") ||
+        host.Equals("discovery.addons-dev.allizom.org") ||
+        host.Equals("testpilot.stage.mozaws.net") ||
+        host.Equals("testpilot.dev.mozaws.net") ||
+        host.Equals("example.com")) {
+      return true;
+    }
+  }
+
+  return false;
 }
 
 bool
 AddonManagerWebAPI::IsAPIEnabled(JSContext* cx, JSObject* obj)
 {
   nsGlobalWindow* global = xpc::WindowGlobalOrNull(obj);
   if (!global) {
     return false;
@@ -136,20 +131,9 @@ AddonManagerWebAPI::IsAPIEnabled(JSConte
 
     win = doc->GetInnerWindow();
   }
 
   // Found a document with no inner window, don't grant access to the API.
   return false;
 }
 
-namespace dom {
-
-bool
-AddonManagerPermissions::IsHostPermitted(const GlobalObject& /*unused*/, const nsAString& host)
-{
-  return IsValidHost(NS_ConvertUTF16toUTF8(host));
-}
-
-} // namespace mozilla::dom
-
-
 } // namespace mozilla
--- a/toolkit/mozapps/extensions/AddonManagerWebAPI.h
+++ b/toolkit/mozapps/extensions/AddonManagerWebAPI.h
@@ -14,20 +14,11 @@ namespace mozilla {
 class AddonManagerWebAPI {
 public:
   static bool IsAPIEnabled(JSContext* cx, JSObject* obj);
 
 private:
   static bool IsValidSite(nsIURI* uri);
 };
 
-namespace dom {
-
-class AddonManagerPermissions {
-public:
-  static bool IsHostPermitted(const GlobalObject&, const nsAString& host);
-};
-
-} // namespace mozilla::dom
-
 } // namespace mozilla
 
 #endif // addonmanagerwebapi_h_