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

Unified Diff: include.preload.js

Issue 9756009: Make sure to collapse <frame> tags as well (Closed)
Patch Set: Created March 11, 2013, 1:59 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
@@ -57,35 +57,43 @@ function setElemhideCSSRules(selectors)
setRules();
}
var typeMap = {
"img": "IMAGE",
"input": "IMAGE",
"audio": "MEDIA",
"video": "MEDIA",
+ "frame": "SUBDOCUMENT",
"iframe": "SUBDOCUMENT"
};
function checkCollapse(event)
{
var target = event.target;
var tag = target.localName;
- if (tag in typeMap && event.type == (tag == "iframe" ? "load" : "error"))
+ var expectedEvent = (tag == "iframe" || tag == "frame" ? "load" : "error");
+ if (tag in typeMap && event.type == expectedEvent)
{
// This element failed loading, did we block it?
var url = target.src;
if (!url)
return;
var type = typeMap[tag];
chrome.extension.sendRequest({reqtype: "should-collapse", url: url, documentUrl: document.URL, type: type}, function(response)
{
if (response && target.parentNode)
- target.parentNode.removeChild(target);
+ {
+ // <frame> cannot be removed, doing that will mess up the frameset
+ if (tag == "frame")
+ target.style.setProperty("visibility", "hidden", "!important");
+ else
+ target.parentNode.removeChild(target);
+ }
});
}
}
function init()
{
// Make sure this is really an HTML page, as Chrome runs these scripts on just about everything
if (!(document.documentElement instanceof HTMLElement))
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld