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

Side by Side 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.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 }, 304 },
305 305
306 shouldProcess: function(contentType, contentLocation, requestOrigin, insecNode , mimeType, extra) 306 shouldProcess: function(contentType, contentLocation, requestOrigin, insecNode , mimeType, extra)
307 { 307 {
308 return Ci.nsIContentPolicy.ACCEPT; 308 return Ci.nsIContentPolicy.ACCEPT;
309 }, 309 },
310 310
311 // 311 //
312 // nsIObserver interface implementation 312 // nsIObserver interface implementation
313 // 313 //
314 observe: function(subject, topic, data, additional) 314 observe: function(subject, topic, data, uri, opener)
315 { 315 {
316 switch (topic) 316 switch (topic)
317 { 317 {
318 case "content-document-global-created": 318 case "content-document-global-created":
319 { 319 {
320 if (!(subject instanceof Ci.nsIDOMWindow) || !subject.opener) 320 if (!opener && subject instanceof Ci.nsIDOMWindow)
321 opener = subject.opener;
322 if (!opener)
321 return; 323 return;
322 324
323 let uri = additional || subject.location.href; 325 if (!uri && subject instanceof Ci.nsIDOMWindow)
324 if (!shouldAllow(subject.opener, subject.opener.document, "POPUP", uri)) 326 uri = subject.location.href;
327 if (!shouldAllow(opener, opener.document, "POPUP", uri))
325 { 328 {
326 subject.stop(); 329 subject.stop();
327 Utils.runAsync(() => subject.close()); 330 Utils.runAsync(() => subject.close());
328 } 331 }
329 else if (uri == "about:blank") 332 else if (uri == "about:blank")
330 { 333 {
331 // An about:blank pop-up most likely means that a load will be 334 // An about:blank pop-up most likely means that a load will be
332 // initiated asynchronously. Wait for that. 335 // initiated asynchronously. Wait for that.
333 Utils.runAsync(() => 336 Utils.runAsync(() =>
334 { 337 {
335 let channel = subject.QueryInterface(Ci.nsIInterfaceRequestor) 338 let channel = subject.QueryInterface(Ci.nsIInterfaceRequestor)
336 .getInterface(Ci.nsIDocShell) 339 .getInterface(Ci.nsIDocShell)
337 .QueryInterface(Ci.nsIDocumentLoader) 340 .QueryInterface(Ci.nsIDocumentLoader)
338 .documentChannel; 341 .documentChannel;
339 if (channel) 342 if (channel)
340 this.observe(subject, topic, data, channel.URI.spec); 343 this.observe(subject, topic, data, channel.URI.spec, opener);
341 }); 344 });
342 } 345 }
343 break; 346 break;
344 } 347 }
345 } 348 }
346 }, 349 },
347 350
348 // 351 //
349 // nsIChannelEventSink interface implementation 352 // nsIChannelEventSink interface implementation
350 // 353 //
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 let property = (hasCols ? "cols" : "rows"); 466 let property = (hasCols ? "cols" : "rows");
464 let weights = parentNode[property].split(","); 467 let weights = parentNode[property].split(",");
465 weights[index] = "0"; 468 weights[index] = "0";
466 parentNode[property] = weights.join(","); 469 parentNode[property] = weights.join(",");
467 } 470 }
468 } 471 }
469 else 472 else
470 node.classList.add(collapsedClass); 473 node.classList.add(collapsedClass);
471 } 474 }
472 } 475 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld