Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/contentPolicy.js

Issue 29329404: Issue 443 - Fix blocking pop-ups after redirect (Closed)
Patch Set: Improved comment Created Nov. 5, 2015, 3:51 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld