Index: lib/contentPolicy.js |
=================================================================== |
--- a/lib/contentPolicy.js |
+++ b/lib/contentPolicy.js |
@@ -366,26 +366,32 @@ let PolicyImplementation = |
{ |
let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); |
registrar.registerFactory(this.classID, this.classDescription, this.contractID, this); |
let catMan = Utils.categoryManager; |
for each (let category in this.xpcom_categories) |
catMan.addCategoryEntry(category, this.contractID, this.contractID, false, true); |
- Services.obs.addObserver(this, "http-on-modify-request", true); |
+ // http-on-opening-request is new in Gecko 18, http-on-modify-request can |
+ // be used in earlier releases. |
+ let httpTopic = "http-on-opening-request"; |
+ if (Services.vc.compare(Utils.platformVersion, "18.0") < 0) |
+ httpTopic = "http-on-modify-request"; |
+ |
+ Services.obs.addObserver(this, httpTopic, true); |
Services.obs.addObserver(this, "content-document-global-created", true); |
Services.obs.addObserver(this, "xpcom-category-entry-removed", true); |
Services.obs.addObserver(this, "xpcom-category-cleared", true); |
onShutdown.add(function() |
{ |
// Our category observers should be removed before changing category |
// memberships, just in case. |
- Services.obs.removeObserver(this, "http-on-modify-request"); |
+ Services.obs.removeObserver(this, httpTopic); |
Services.obs.removeObserver(this, "content-document-global-created"); |
Services.obs.removeObserver(this, "xpcom-category-entry-removed"); |
Services.obs.removeObserver(this, "xpcom-category-cleared"); |
for each (let category in this.xpcom_categories) |
catMan.deleteCategoryEntry(category, this.contractID, false); |
// This needs to run asynchronously, see bug 753687 |
@@ -431,17 +437,17 @@ let PolicyImplementation = |
// Interpret unknown types as "other" |
if (!(contentType in Policy.typeDescr)) |
contentType = Policy.type.OTHER; |
let result = Policy.processNode(wnd, node, contentType, location, false); |
if (result) |
{ |
// We didn't block this request so we will probably see it again in |
- // http-on-modify-request. Keep it so that we can associate it with the |
+ // http-on-opening-request. Keep it so that we can associate it with the |
// channel there - will be needed in case of redirect. |
this.previousRequest = [location, contentType]; |
} |
return (result ? Ci.nsIContentPolicy.ACCEPT : Ci.nsIContentPolicy.REJECT_REQUEST); |
}, |
shouldProcess: function(contentType, contentLocation, requestOrigin, insecNode, mimeType, extra) |
{ |
@@ -464,26 +470,27 @@ let PolicyImplementation = |
if (!Policy.processNode(subject.opener, subject.opener.document, Policy.type.POPUP, uri, false)) |
{ |
subject.stop(); |
Utils.runAsync(subject.close, subject); |
} |
else if (uri.spec == "about:blank") |
{ |
// An about:blank pop-up most likely means that a load will be |
- // initiated synchronously. Set a flag for our "http-on-modify-request" |
+ // initiated synchronously. Set a flag for our "http-on-opening-request" |
// handler. |
this.expectingPopupLoad = true; |
Utils.runAsync(function() |
{ |
this.expectingPopupLoad = false; |
}); |
} |
break; |
} |
+ case "http-on-opening-request": |
case "http-on-modify-request": |
{ |
if (!(subject instanceof Ci.nsIHttpChannel)) |
return; |
if (this.previousRequest && subject.URI == this.previousRequest[0] && |
subject instanceof Ci.nsIWritablePropertyBag) |
{ |