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

Unified 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.
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: include.preload.js
===================================================================
--- a/include.preload.js
+++ b/include.preload.js
@@ -76,25 +76,22 @@
ext.backgroundPage.sendMessage({type: "add-sitekey", token: attr});
}
-function hasInlineURL(element, attribute)
-{
- var value = element.getAttribute(attribute);
- return value == null || /^\s*(javascript:|about:|$)/i.test(value);
-}
-
function isInlineFrame(element)
{
- switch (element.localName)
+ var contentDocument;
+ try
{
- case "iframe":
- return hasInlineURL(element, "src") || element.hasAttribute("srcdoc");
- case "frame":
- return hasInlineURL(element, "src");
- case "object":
- return hasInlineURL(element, "data") && element.contentDocument;
- default:
- return false;
+ contentDocument = element.contentDocument;
}
+ catch (e)
+ {
+ return false; // third-party
+ }
+
+ if (!contentDocument)
+ return false; // not a frame
+
+ 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
}
function resolveURL(url)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld