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

Unified Diff: webrequest.js

Issue 8699074: Fixed: Requests by javascript: or data: frames aren`t being blocked (Closed)
Patch Set: Created Oct. 29, 2012, 12:44 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: webrequest.js
===================================================================
--- a/webrequest.js
+++ b/webrequest.js
@@ -122,28 +122,32 @@ function onHeadersReceived(details)
function recordFrame(tabId, frameId, parentFrameId, frameUrl)
{
if (!(tabId in frames))
frames[tabId] = {};
frames[tabId][frameId] = {url: frameUrl, parent: parentFrameId};
}
-function getFrameUrl(tabId, frameId)
+function getFrameData(tabId, frameId)
{
if (tabId in frames && frameId in frames[tabId])
- return frames[tabId][frameId].url;
+ return frames[tabId][frameId];
+ else if (frameId > 0 && tabId in frames && 0 in frames[tabId])
+ {
+ // We don't know anything about javascript: or data: frames, use top frame
+ return frames[tabId][0];
+ }
return null;
}
-function getFrameParent(tabId, frameId)
+function getFrameUrl(tabId, frameId)
{
- if (tabId in frames && frameId in frames[tabId])
- return frames[tabId][frameId].parent;
- return -1;
+ var frameData = getFrameData(tabId, frameId);
+ return (frameData ? frameData.url : null);
}
function forgetTab(tabId)
{
delete frames[tabId];
}
function checkRequest(type, tabId, url, frameId)
@@ -179,17 +183,18 @@ function checkRequest(type, tabId, url,
return filter;
}
function isFrameWhitelisted(tabId, frameId, type)
{
var parent = frameId;
while (parent != -1)
{
- var parentUrl = getFrameUrl(tabId, parent);
- if (parentUrl && isWhitelisted(parentUrl, type))
+ var parentData = getFrameData(tabId, parent);
+ if (!parentData)
+ break;
+
+ if (isWhitelisted(parentData.url, type) || "keyException" in parentData)
return true;
- if (parentUrl && "keyException" in frames[tabId][frameId])
- return true;
- parent = getFrameParent(tabId, parent);
+ parent = parentData.parent;
}
return false;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld