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

Side by Side Diff: webrequest.js

Issue 11579001: Workaround for Chrome not specifying which request is main_frame under some circumstances (Closed)
Patch Set: Added more checks Created Aug. 30, 2013, 8:24 a.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 <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 }); 49 });
50 50
51 var frames = {}; 51 var frames = {};
52 52
53 function onBeforeRequest(details) 53 function onBeforeRequest(details)
54 { 54 {
55 if (details.tabId == -1) 55 if (details.tabId == -1)
56 return {}; 56 return {};
57 57
58 var type = details.type; 58 var type = details.type;
59
60 // Assume that the first request belongs to the top frame. Chrome may give the
61 // top frame the type "object" instead of "main_frame".
62 // https://code.google.com/p/chromium/issues/detail?id=281711
63 if (details.frameId == 0 && !(details.tabId in frames) && type == "object")
Wladimir Palant 2013/08/30 12:16:25 Please ensure details.tabId >= 0, tabId -1 means a
64 type = "main_frame";
65
59 if (type == "main_frame" || type == "sub_frame") 66 if (type == "main_frame" || type == "sub_frame")
60 recordFrame(details.tabId, details.frameId, details.parentFrameId, details.u rl); 67 recordFrame(details.tabId, details.frameId, details.parentFrameId, details.u rl);
61 68
62 if (type == "main_frame") 69 if (type == "main_frame")
63 return {}; 70 return {};
64 71
65 // Type names match Mozilla's with main_frame and sub_frame being the only exc eptions. 72 // Type names match Mozilla's with main_frame and sub_frame being the only exc eptions.
66 if (type == "sub_frame") 73 if (type == "sub_frame")
67 type = "SUBDOCUMENT"; 74 type = "SUBDOCUMENT";
68 else 75 else
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 parent = frameData.parent; 197 parent = frameData.parent;
191 parentData = getFrameData(tabId, parent); 198 parentData = getFrameData(tabId, parent);
192 199
193 var frameUrl = frameData.url; 200 var frameUrl = frameData.url;
194 var parentUrl = (parentData ? parentData.url : frameUrl); 201 var parentUrl = (parentData ? parentData.url : frameUrl);
195 if ("keyException" in frameData || isWhitelisted(frameUrl, parentUrl, type)) 202 if ("keyException" in frameData || isWhitelisted(frameUrl, parentUrl, type))
196 return true; 203 return true;
197 } 204 }
198 return false; 205 return false;
199 } 206 }
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