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

Side by Side 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.
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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 try 492 try
493 { 493 {
494 // nsILoadInfo.contentPolicyType was introduced in Gecko 35, then 494 // nsILoadInfo.contentPolicyType was introduced in Gecko 35, then
495 // renamed to nsILoadInfo.externalContentPolicyType in Gecko 44. 495 // renamed to nsILoadInfo.externalContentPolicyType in Gecko 44.
496 let loadInfo = oldChannel.loadInfo; 496 let loadInfo = oldChannel.loadInfo;
497 let contentType = ("externalContentPolicyType" in loadInfo ? 497 let contentType = ("externalContentPolicyType" in loadInfo ?
498 loadInfo.externalContentPolicyType : loadInfo.contentPolicyType); 498 loadInfo.externalContentPolicyType : loadInfo.contentPolicyType);
499 if (!contentType) 499 if (!contentType)
500 return; 500 return;
501 501
502 let newLocation = null;
503 try
504 {
505 newLocation = newChannel.URI;
506 } catch(e2) {}
507 if (!newLocation)
508 return;
509
510 let wnd = Utils.getRequestWindow(newChannel); 502 let wnd = Utils.getRequestWindow(newChannel);
511 if (!wnd) 503 if (!wnd)
512 return; 504 return;
513 505
514 if (contentType == Policy.type.POPUP && wnd.opener) 506 if (contentType == Ci.nsIContentPolicy.TYPE_DOCUMENT)
515 { 507 {
516 // Popups are initiated by their opener, not their own window. 508 if (wnd.history.length <= 1 && wnd.opener)
517 wnd = wnd.opener; 509 {
510 // Special treatment for pop-up windows - this will close the window
511 // rather than preventing the redirect. Note that we might not have
512 // seen the original channel yet because the redirect happened before
513 // the async code in observe() had a chance to run.
514 this.observe(wnd, "content-document-global-created", null, oldChannel. URI);
515 this.observe(wnd, "content-document-global-created", null, newChannel. URI);
516 }
517 return;
518 } 518 }
519 519
520 if (!Policy.processNode(wnd, wnd.document, contentType, newLocation, false )) 520 if (!Policy.processNode(wnd, wnd.document, contentType, newChannel.URI, fa lse))
521 result = Cr.NS_BINDING_ABORTED; 521 result = Cr.NS_BINDING_ABORTED;
522 } 522 }
523 catch (e) 523 catch (e)
524 { 524 {
525 // We shouldn't throw exceptions here - this will prevent the redirect. 525 // We shouldn't throw exceptions here - this will prevent the redirect.
526 Cu.reportError(e); 526 Cu.reportError(e);
527 } 527 }
528 finally 528 finally
529 { 529 {
530 callback.onRedirectVerifyCallback(result); 530 callback.onRedirectVerifyCallback(result);
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 if (!wnd || wnd.closed) 729 if (!wnd || wnd.closed)
730 return; 730 return;
731 731
732 if (entry.type == Policy.type.OBJECT) 732 if (entry.type == Policy.type.OBJECT)
733 { 733 {
734 node.removeEventListener("mouseover", objectMouseEventHander, true); 734 node.removeEventListener("mouseover", objectMouseEventHander, true);
735 node.removeEventListener("mouseout", objectMouseEventHander, true); 735 node.removeEventListener("mouseout", objectMouseEventHander, true);
736 } 736 }
737 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true) ; 737 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true) ;
738 } 738 }
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