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

Side by Side Diff: include.preload.js

Issue 4553357519749120: Issue 1977 - Consider content location instead element attributes when detecting anonymous frames (Closed)
Patch Set: Created Feb. 9, 2015, 2:56 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 69 }
70 } 70 }
71 71
72 function checkSitekey() 72 function checkSitekey()
73 { 73 {
74 var attr = document.documentElement.getAttribute("data-adblockkey"); 74 var attr = document.documentElement.getAttribute("data-adblockkey");
75 if (attr) 75 if (attr)
76 ext.backgroundPage.sendMessage({type: "add-sitekey", token: attr}); 76 ext.backgroundPage.sendMessage({type: "add-sitekey", token: attr});
77 } 77 }
78 78
79 function hasInlineURL(element, attribute)
80 {
81 var value = element.getAttribute(attribute);
82 return value == null || /^\s*(javascript:|about:|$)/i.test(value);
83 }
84
85 function isInlineFrame(element) 79 function isInlineFrame(element)
86 { 80 {
87 switch (element.localName) 81 var contentDocument;
82 try
88 { 83 {
89 case "iframe": 84 contentDocument = element.contentDocument;
90 return hasInlineURL(element, "src") || element.hasAttribute("srcdoc");
91 case "frame":
92 return hasInlineURL(element, "src");
93 case "object":
94 return hasInlineURL(element, "data") && element.contentDocument;
95 default:
96 return false;
97 } 85 }
86 catch (e)
87 {
88 return false; // third-party
89 }
90
91 if (!contentDocument)
92 return false; // not a frame
93
94 return contentDocument.location.protocol == "about:";
kzar 2015/02/09 16:52:11 Previously we would return true if the URL started
Sebastian Noack 2015/02/09 17:10:00 Previously, we checked against the raw attribute v
98 } 95 }
99 96
100 function resolveURL(url) 97 function resolveURL(url)
101 { 98 {
102 var a = document.createElement("a"); 99 var a = document.createElement("a");
103 a.href = url; 100 a.href = url;
104 return a.href; 101 return a.href;
105 } 102 }
106 103
107 function reinjectRulesWhenRemoved(document, style) 104 function reinjectRulesWhenRemoved(document, style)
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 }, true); 270 }, true);
274 271
275 ext.backgroundPage.sendMessage({type: "get-selectors"}, setElemhideCSSRules); 272 ext.backgroundPage.sendMessage({type: "get-selectors"}, setElemhideCSSRules);
276 } 273 }
277 274
278 if (document instanceof HTMLDocument) 275 if (document instanceof HTMLDocument)
279 { 276 {
280 checkSitekey(); 277 checkSitekey();
281 init(document); 278 init(document);
282 } 279 }
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