Index: chrome/ext/background.js |
diff --git a/chrome/ext/background.js b/chrome/ext/background.js |
index 0c8bdfc289fc8276fa7a8c6b5f171ad41e729328..5355d5b86db91211ec61d6c4056407a5bd1b2bd4 100644 |
--- a/chrome/ext/background.js |
+++ b/chrome/ext/background.js |
@@ -123,16 +123,10 @@ |
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) |
+ ext._updatePageFrameStructure = function(frameId, tabId, url, eager, |
+ parentFrameId) |
{ |
if (frameId == 0) |
{ |
@@ -166,11 +160,27 @@ |
// Update frame URL in frame structure |
var frame = createFrame(tabId, frameId); |
frame.url = new URL(url); |
+ |
+ // We only get the parentFrameId for onBeforeNavigate, not for onCommitted |
+ if (typeof parentFrameId != "undefined") |
+ frame.parent = framesOfTabs[tabId][parentFrameId] || null; |
}; |
+ chrome.webNavigation.onBeforeNavigate.addListener(function(details) |
+ { |
+ // Since requests can be fired from a page before its navigation has been |
+ // confirmed we have to also update the page structure here. Otherwise those |
+ // requests will be using the old structure, meaning first party requests |
+ // might be considered third party. (We also need to listen for this event |
+ // in order to get the parentFrameId which onCommitted doesn't provide.) |
+ ext._updatePageFrameStructure(details.frameId, details.tabId, |
+ details.url, false, details.parentFrameId); |
+ }); |
+ |
chrome.webNavigation.onCommitted.addListener(function(details) |
{ |
- ext._updatePageFrameStructure(details.frameId, details.tabId, details.url); |
+ ext._updatePageFrameStructure(details.frameId, details.tabId, |
+ details.url, false); |
}); |
function forgetTab(tabId) |