Bug 1338860 - Fixing missing onErrorOcurred in WebRequest WebExtensions draft
authorJonathan Kingston <jkt@mozilla.com>
Sun, 12 Feb 2017 03:29:29 +0000
changeset 482275 3f014eda5ece009ec274efc91f22692260fbc1d3
parent 482232 0eef1d5a39366059677c6d7944cfe8a97265a011
child 545407 c875418443f7b1b4f1922cb4e5e8ba1e81001c46
push id45052
push userjkingston@mozilla.com
push dateSun, 12 Feb 2017 03:31:35 +0000
bugs1338860
milestone54.0a1
Bug 1338860 - Fixing missing onErrorOcurred in WebRequest WebExtensions MozReview-Commit-ID: 5g40c2ZA7r5
toolkit/modules/addons/WebRequest.jsm
--- a/toolkit/modules/addons/WebRequest.jsm
+++ b/toolkit/modules/addons/WebRequest.jsm
@@ -667,16 +667,22 @@ HttpObserverManager = {
       let loadContext = this.getLoadContext(channel);
       if (!this.errorCheck(channel, loadContext, channelData)) {
         this.runChannelListener(channel, loadContext, "onError",
           {error: this.activityErrorsMap.get(lastActivity) ||
                   `NS_ERROR_NET_UNKNOWN_${lastActivity}`});
       }
     } else if (lastActivity !== this.GOOD_LAST_ACTIVITY &&
                lastActivity !== nsIHttpActivityObserver.ACTIVITY_SUBTYPE_TRANSACTION_CLOSE) {
+      let loadContext = this.getLoadContext(channel);
+      if (!this.errorCheck(channel, loadContext, channelData)) {
+        this.runChannelListener(channel, loadContext, "onError",
+          {error: this.activityErrorsMap.get(lastActivity) ||
+                  `NS_ERROR_NET_UNKNOWN_${lastActivity}`});
+      }
       channelData.lastActivity = activitySubtype;
     }
   },
 
   shouldRunListener(policyType, uri, filter) {
     return WebRequestCommon.typeMatches(policyType, filter.types) &&
            WebRequestCommon.urlMatches(uri, filter.urls);
   },
@@ -790,17 +796,17 @@ HttpObserverManager = {
     }
 
     return Object.assign(data, extraData);
   },
 
   canModify(channel) {
     let {isHostPermitted} = AddonManagerPermissions;
 
-    if (isHostPermitted(channel.URI.host)) {
+    if (!channel.URI || isHostPermitted(channel.URI.host)) {
       return false;
     }
 
     let {loadInfo} = channel;
     if (loadInfo && loadInfo.loadingPrincipal) {
       let {loadingPrincipal} = loadInfo;
 
       return loadingPrincipal.URI && !isHostPermitted(loadingPrincipal.URI.host);