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, 12:50 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 if (type == "main_frame" || type == "sub_frame") 59 // Workaround: Under some circumstances Chrome 29+ gives top frame the
60 // type "object" instead of "main_frame". We work around that by assuming
61 // that the first request belongs to the top frame.
62 if (type == "main_frame" || type == "sub_frame" || !(details.tabId in frames))
60 recordFrame(details.tabId, details.frameId, details.parentFrameId, details.u rl); 63 recordFrame(details.tabId, details.frameId, details.parentFrameId, details.u rl);
61 64
62 if (type == "main_frame") 65 if (type == "main_frame")
63 return {}; 66 return {};
64 67
65 // Type names match Mozilla's with main_frame and sub_frame being the only exc eptions. 68 // Type names match Mozilla's with main_frame and sub_frame being the only exc eptions.
66 if (type == "sub_frame") 69 if (type == "sub_frame")
67 type = "SUBDOCUMENT"; 70 type = "SUBDOCUMENT";
68 else 71 else
69 type = type.toUpperCase(); 72 type = type.toUpperCase();
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 parent = frameData.parent; 193 parent = frameData.parent;
191 parentData = getFrameData(tabId, parent); 194 parentData = getFrameData(tabId, parent);
192 195
193 var frameUrl = frameData.url; 196 var frameUrl = frameData.url;
194 var parentUrl = (parentData ? parentData.url : frameUrl); 197 var parentUrl = (parentData ? parentData.url : frameUrl);
195 if ("keyException" in frameData || isWhitelisted(frameUrl, parentUrl, type)) 198 if ("keyException" in frameData || isWhitelisted(frameUrl, parentUrl, type))
196 return true; 199 return true;
197 } 200 }
198 return false; 201 return false;
199 } 202 }
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