| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 | 118 |
| 119 var frame = frames[frameId]; | 119 var frame = frames[frameId]; |
| 120 if (!frame) | 120 if (!frame) |
| 121 frame = frames[frameId] = {}; | 121 frame = frames[frameId] = {}; |
| 122 | 122 |
| 123 return frame; | 123 return frame; |
| 124 } | 124 } |
| 125 | 125 |
| 126 var eagerlyUpdatedPages = new ext.PageMap(); | 126 var eagerlyUpdatedPages = new ext.PageMap(); |
| 127 | 127 |
| 128 ext._updatePageFrameStructure = function(frameId, tabId, url, eager, | 128 ext._updatePageFrameStructure = function(frameId, tabId, url, eager) |
| 129 parentFrameId) | |
| 130 { | 129 { |
| 131 if (frameId == 0) | 130 if (frameId == 0) |
| 132 { | 131 { |
| 133 let page = new Page({id: tabId, url: url}); | 132 let page = new Page({id: tabId, url: url}); |
| 134 | 133 |
| 135 if (eagerlyUpdatedPages.get(page) != url) | 134 if (eagerlyUpdatedPages.get(page) != url) |
| 136 { | 135 { |
| 137 ext._removeFromAllPageMaps(tabId); | 136 ext._removeFromAllPageMaps(tabId); |
| 138 | 137 |
| 139 // When a sitekey header is received we must immediately update the page | 138 // When a sitekey header is received we must immediately update the page |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 153 // when Chrome automatically resets them on navigation. | 152 // when Chrome automatically resets them on navigation. |
| 154 if (chrome.runtime.lastError) | 153 if (chrome.runtime.lastError) |
| 155 ext.pages.onLoading._dispatch(page); | 154 ext.pages.onLoading._dispatch(page); |
| 156 }); | 155 }); |
| 157 } | 156 } |
| 158 } | 157 } |
| 159 | 158 |
| 160 // Update frame URL in frame structure | 159 // Update frame URL in frame structure |
| 161 var frame = createFrame(tabId, frameId); | 160 var frame = createFrame(tabId, frameId); |
| 162 frame.url = new URL(url); | 161 frame.url = new URL(url); |
| 163 | |
| 164 // We only get the parentFrameId for onBeforeNavigate, not for onCommitted | |
| 165 if (typeof parentFrameId != "undefined") | |
| 166 frame.parent = framesOfTabs[tabId][parentFrameId] || null; | |
| 167 }; | 162 }; |
| 168 | 163 |
| 169 chrome.webNavigation.onBeforeNavigate.addListener(function(details) | 164 chrome.webNavigation.onBeforeNavigate.addListener(function(details) |
| 170 { | 165 { |
| 171 // Since requests are sometimes made by a page before its onCommitted event | 166 // Capture parent frame here because onCommitted doesn't get this info. |
| 172 // fires we also need to update the page structure here. Otherwise those | 167 var frame = createFrame(details.tabId, details.frameId); |
| 173 // requests will be considered third party since a URL for the page wasn't | 168 frame.parent = framesOfTabs[details.tabId][details.parentFrameId] || null; |
| 174 // yet determined. | 169 |
| 175 ext._updatePageFrameStructure(details.frameId, details.tabId, | 170 // Chrome will sometimes perform requests for pre-rendered pages before |
| 176 details.url, false, details.parentFrameId); | 171 // navigation was confirmed and the onComitted event was fired. Those |
|
Wladimir Palant
2016/11/14 08:18:44
You are essentially reverting changes from issue 4
| |
| 172 // requests will often wrongly be considered to be third party, since we | |
| 173 // don't know the correct document domain for requests until after we've | |
| 174 // updated the page structure. As a work around we update the page | |
| 175 // structure eagerly for new tabs (which includes pre-rendered pages). | |
| 176 if (!(details.tabId in framesOfTabs)) | |
|
Wladimir Palant
2016/11/14 15:56:29
While this is probably not wrong, I think that you
kzar
2016/11/15 12:19:28
Well so far the issue only described a problem wit
| |
| 177 ext._updatePageFrameStructure(details.frameId, details.tabId, details.url) ; | |
| 177 }); | 178 }); |
| 178 | 179 |
| 179 chrome.webNavigation.onCommitted.addListener(function(details) | 180 chrome.webNavigation.onCommitted.addListener(function(details) |
| 180 { | 181 { |
| 181 ext._updatePageFrameStructure(details.frameId, details.tabId, | 182 ext._updatePageFrameStructure(details.frameId, details.tabId, details.url); |
| 182 details.url, false); | |
| 183 }); | 183 }); |
| 184 | 184 |
| 185 function forgetTab(tabId) | 185 function forgetTab(tabId) |
| 186 { | 186 { |
| 187 ext.pages.onRemoved._dispatch(tabId); | 187 ext.pages.onRemoved._dispatch(tabId); |
| 188 | 188 |
| 189 ext._removeFromAllPageMaps(tabId); | 189 ext._removeFromAllPageMaps(tabId); |
| 190 delete framesOfTabs[tabId]; | 190 delete framesOfTabs[tabId]; |
| 191 } | 191 } |
| 192 | 192 |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 648 ext.windows = { | 648 ext.windows = { |
| 649 create: function(createData, callback) | 649 create: function(createData, callback) |
| 650 { | 650 { |
| 651 chrome.windows.create(createData, function(createdWindow) | 651 chrome.windows.create(createData, function(createdWindow) |
| 652 { | 652 { |
| 653 afterTabLoaded(callback)(createdWindow.tabs[0]); | 653 afterTabLoaded(callback)(createdWindow.tabs[0]); |
| 654 }); | 654 }); |
| 655 } | 655 } |
| 656 }; | 656 }; |
| 657 })(); | 657 })(); |
| LEFT | RIGHT |