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: Created Aug. 28, 2013, 1:04 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 <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 // Workaround: Under some circumstances Chrome 29+ gives top frame the
61 // type "object" instead of "main_frame". We work around that by assuming
62 // that the first request belongs to the top frame.
63 if (!(details.tabId in frames))
64 type = "main_frame";
Wladimir Palant 2013/08/29 05:57:40 There are two assumption here which both seem to b
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