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

Side by Side Diff: lib/contentPolicy.js

Issue 29329396: Issue 3208 - Improve the approach used to detect pop-up URL (Closed)
Patch Set: Fixed unbound this Created Oct. 29, 2015, 6:13 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 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 474
475 let uri = additional || Utils.makeURI(subject.location.href); 475 let uri = additional || Utils.makeURI(subject.location.href);
476 if (!Policy.processNode(subject.opener, subject.opener.document, Policy. type.POPUP, uri, false)) 476 if (!Policy.processNode(subject.opener, subject.opener.document, Policy. type.POPUP, uri, false))
477 { 477 {
478 subject.stop(); 478 subject.stop();
479 Utils.runAsync(() => subject.close()); 479 Utils.runAsync(() => subject.close());
480 } 480 }
481 else if (uri.spec == "about:blank") 481 else if (uri.spec == "about:blank")
482 { 482 {
483 // An about:blank pop-up most likely means that a load will be 483 // An about:blank pop-up most likely means that a load will be
484 // initiated synchronously. Set a flag for our "http-on-opening-reques t" 484 // initiated asynchronously. Wait for that.
485 // handler. 485 Utils.runAsync(() =>
486 this.expectingPopupLoad = true;
487 Utils.runAsync(function()
488 { 486 {
489 this.expectingPopupLoad = false; 487 let channel = subject.QueryInterface(Ci.nsIInterfaceRequestor)
488 .getInterface(Ci.nsIDocShell)
489 .QueryInterface(Ci.nsIDocumentLoader)
490 .documentChannel;
491 if (channel)
492 this.observe(subject, topic, data, channel.URI);
490 }); 493 });
491 } 494 }
492 break; 495 break;
493 } 496 }
494 case "http-on-opening-request": 497 case "http-on-opening-request":
495 case "http-on-modify-request": 498 case "http-on-modify-request":
496 { 499 {
497 if (!(subject instanceof Ci.nsIHttpChannel)) 500 if (!(subject instanceof Ci.nsIHttpChannel))
498 return; 501 return;
499 502
500 if (this.previousRequest && subject.URI == this.previousRequest[0] && 503 if (this.previousRequest && subject.URI == this.previousRequest[0] &&
501 subject instanceof Ci.nsIWritablePropertyBag) 504 subject instanceof Ci.nsIWritablePropertyBag)
502 { 505 {
503 // We just handled a content policy call for this request - associate 506 // We just handled a content policy call for this request - associate
504 // the data with the channel so that we can find it in case of a redir ect. 507 // the data with the channel so that we can find it in case of a redir ect.
505 subject.setProperty("abpRequestType", this.previousRequest[1]); 508 subject.setProperty("abpRequestType", this.previousRequest[1]);
506 this.previousRequest = null; 509 this.previousRequest = null;
507 } 510 }
508
509 if (this.expectingPopupLoad)
510 {
511 let wnd = Utils.getRequestWindow(subject);
512 if (wnd && wnd.opener && wnd.location.href == "about:blank")
513 {
514 this.observe(wnd, "content-document-global-created", null, subject.U RI);
515 if (subject instanceof Ci.nsIWritablePropertyBag)
516 subject.setProperty("abpRequestType", Policy.type.POPUP);
517 }
518 }
519
520 break; 511 break;
521 } 512 }
522 } 513 }
523 }, 514 },
524 515
525 // 516 //
526 // nsIChannelEventSink interface implementation 517 // nsIChannelEventSink interface implementation
527 // 518 //
528 519
529 asyncOnChannelRedirect: function(oldChannel, newChannel, flags, callback) 520 asyncOnChannelRedirect: function(oldChannel, newChannel, flags, callback)
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 if (!wnd || wnd.closed) 774 if (!wnd || wnd.closed)
784 return; 775 return;
785 776
786 if (entry.type == Policy.type.OBJECT) 777 if (entry.type == Policy.type.OBJECT)
787 { 778 {
788 node.removeEventListener("mouseover", objectMouseEventHander, true); 779 node.removeEventListener("mouseover", objectMouseEventHander, true);
789 node.removeEventListener("mouseout", objectMouseEventHander, true); 780 node.removeEventListener("mouseout", objectMouseEventHander, true);
790 } 781 }
791 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true) ; 782 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true) ;
792 } 783 }
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