Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: ext/background.js

Issue 29793570: Issue 6692 - Update frame structure for about:blank frames earlier (Closed)
Patch Set: Created May 29, 2018, 4:45 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
{
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld