Bug 1338860 - Fixing missing onErrorOcurred in WebRequest WebExtensions
MozReview-Commit-ID: 5g40c2ZA7r5
--- 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);