Index: lib/contentPolicy.js |
=================================================================== |
--- a/lib/contentPolicy.js |
+++ b/lib/contentPolicy.js |
@@ -494,35 +494,35 @@ var PolicyImplementation = |
// nsILoadInfo.contentPolicyType was introduced in Gecko 35, then |
// renamed to nsILoadInfo.externalContentPolicyType in Gecko 44. |
let loadInfo = oldChannel.loadInfo; |
let contentType = ("externalContentPolicyType" in loadInfo ? |
loadInfo.externalContentPolicyType : loadInfo.contentPolicyType); |
if (!contentType) |
return; |
- let newLocation = null; |
- try |
- { |
- newLocation = newChannel.URI; |
- } catch(e2) {} |
- if (!newLocation) |
- return; |
- |
let wnd = Utils.getRequestWindow(newChannel); |
if (!wnd) |
return; |
- if (contentType == Policy.type.POPUP && wnd.opener) |
+ if (contentType == Ci.nsIContentPolicy.TYPE_DOCUMENT) |
{ |
- // Popups are initiated by their opener, not their own window. |
- wnd = wnd.opener; |
+ if (wnd.history.length <= 1 && wnd.opener) |
+ { |
+ // Special treatment for pop-up windows - this will close the window |
+ // rather than preventing the redirect. Note that we might not have |
+ // seen the original channel yet because the redirect happened before |
+ // the async code in observe() had a chance to run. |
+ this.observe(wnd, "content-document-global-created", null, oldChannel.URI); |
+ this.observe(wnd, "content-document-global-created", null, newChannel.URI); |
+ } |
+ return; |
} |
- if (!Policy.processNode(wnd, wnd.document, contentType, newLocation, false)) |
+ if (!Policy.processNode(wnd, wnd.document, contentType, newChannel.URI, false)) |
result = Cr.NS_BINDING_ABORTED; |
} |
catch (e) |
{ |
// We shouldn't throw exceptions here - this will prevent the redirect. |
Cu.reportError(e); |
} |
finally |