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

Unified Diff: lib/child/contentPolicy.js

Issue 29333141: Issue 3458 - When blocking pop-ups, consider the case where window.opener becomes null due to redir… (Closed)
Patch Set: Created Jan. 4, 2016, 4:42 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/child/contentPolicy.js
===================================================================
--- a/lib/child/contentPolicy.js
+++ b/lib/child/contentPolicy.js
@@ -306,43 +306,46 @@ var PolicyImplementation =
shouldProcess: function(contentType, contentLocation, requestOrigin, insecNode, mimeType, extra)
{
return Ci.nsIContentPolicy.ACCEPT;
},
//
// nsIObserver interface implementation
//
- observe: function(subject, topic, data, additional)
+ observe: function(subject, topic, data, uri, opener)
{
switch (topic)
{
case "content-document-global-created":
{
- if (!(subject instanceof Ci.nsIDOMWindow) || !subject.opener)
+ if (!opener && subject instanceof Ci.nsIDOMWindow)
+ opener = subject.opener;
+ if (!opener)
return;
- let uri = additional || subject.location.href;
- if (!shouldAllow(subject.opener, subject.opener.document, "POPUP", uri))
+ if (!uri && subject instanceof Ci.nsIDOMWindow)
+ uri = subject.location.href;
+ if (!shouldAllow(opener, opener.document, "POPUP", uri))
{
subject.stop();
Utils.runAsync(() => subject.close());
}
else if (uri == "about:blank")
{
// An about:blank pop-up most likely means that a load will be
// initiated asynchronously. Wait for that.
Utils.runAsync(() =>
{
let channel = subject.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDocShell)
.QueryInterface(Ci.nsIDocumentLoader)
.documentChannel;
if (channel)
- this.observe(subject, topic, data, channel.URI.spec);
+ this.observe(subject, topic, data, channel.URI.spec, opener);
});
}
break;
}
}
},
//
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld