| Index: chrome/ext/background.js |
| diff --git a/chrome/ext/background.js b/chrome/ext/background.js |
| index 0c8bdfc289fc8276fa7a8c6b5f171ad41e729328..53058d0b5c01578024698ac645a6bae5e48abc7e 100644 |
| --- a/chrome/ext/background.js |
| +++ b/chrome/ext/background.js |
| @@ -123,13 +123,6 @@ |
| return frame; |
| } |
| - chrome.webNavigation.onBeforeNavigate.addListener(function(details) |
| - { |
| - // Capture parent frame here because onCommitted doesn't get this info. |
| - var frame = createFrame(details.tabId, details.frameId); |
| - frame.parent = framesOfTabs[details.tabId][details.parentFrameId] || null; |
| - }); |
| - |
| var eagerlyUpdatedPages = new ext.PageMap(); |
| ext._updatePageFrameStructure = function(frameId, tabId, url, eager) |
| @@ -168,6 +161,21 @@ |
| frame.url = new URL(url); |
| }; |
| + chrome.webNavigation.onBeforeNavigate.addListener(function(details) |
| + { |
| + // Capture parent frame here because onCommitted doesn't get this info. |
| + var frame = createFrame(details.tabId, details.frameId); |
| + frame.parent = framesOfTabs[details.tabId][details.parentFrameId] || null; |
| + |
| + // Chrome will sometimes perform requests for a pre-rendered page before |
| + // navigation was confirmed and the onComitted event was fired. Those |
| + // requests will often wrongly be considered as third party, since their |
| + // page structure was not recorded. As a work around we update the page |
| + // structure eagerly for new tabs (which includes pre-rendered pages). |
| + if (!(details.tabId in framesOfTabs)) |
| + ext._updatePageFrameStructure(details.frameId, details.tabId, details.url); |
| + }); |
| + |
| chrome.webNavigation.onCommitted.addListener(function(details) |
| { |
| ext._updatePageFrameStructure(details.frameId, details.tabId, details.url); |