Index: ext/background.js |
diff --git a/ext/background.js b/ext/background.js |
index 7bf5e393f74b5785b4c83580edc63bee67410d85..a04393d66aa9250058287436393f7b63c023dd37 100644 |
--- a/ext/background.js |
+++ b/ext/background.js |
@@ -259,13 +259,32 @@ |
{types: ["main_frame", "sub_frame"], urls: ["http://*/*", "https://*/*"]}, |
["responseHeaders"]); |
+ browser.webNavigation.onBeforeNavigate.addListener(details => |
+ { |
+ // Since we can only listen for HTTP(S) responses using |
+ // webRequest.onHeadersReceived we must update the page structure here for |
+ // other navigations. |
+ let {url} = details; |
+ if (!(url.startsWith("http:") || |
Sebastian Noack
2018/05/29 16:48:48
Wouldn't checking for "about:blank" be sufficient
kzar
2018/05/29 17:28:12
Yep, seems to work. Done.
|
+ url.startsWith("https:") && |
+ // Chrome doesn't dispatch webRequest.onHeadersReceived |
+ // for Web Store URLs. |
+ // https://crrev.com/76882bf/extensions/common/extension_urls.cc#33 |
+ !url.startsWith("https://chrome.google.com/webstore/"))) |
+ { |
+ updatePageFrameStructure(details.frameId, details.tabId, url, |
+ details.parentFrameId); |
+ } |
+ }); |
+ |
browser.webNavigation.onCommitted.addListener(details => |
{ |
- // We have to update the frame structure for documents that weren't |
- // loaded over HTTP (including documents cached by Service Workers), |
- // when the navigation occurs. However, we must be careful to not |
- // update the state of the same document twice, otherewise the number |
- // of any ads blocked already and any recorded sitekey could get lost. |
+ // For navigations which the previous two listeners missed - |
+ // including documents cached by Service Workers - we must now |
+ // update the frame structure. However, since this event fires |
+ // last we must be careful to not update the state of the same |
+ // document twice, otherwise the number of any ads blocked already |
+ // and any recorded sitekey could get lost. |
let frame = ext.getFrame(details.tabId, details.frameId); |
if (!frame || frame.url.href != details.url) |
{ |