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

Side by Side Diff: ext/background.js

Issue 29755575: Issue 6595 - Make sure frame structure gets always updated (Closed)
Patch Set: Created April 18, 2018, 11:16 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 return; 252 return;
253 } 253 }
254 } 254 }
255 255
256 updatePageFrameStructure(details.frameId, details.tabId, details.url, 256 updatePageFrameStructure(details.frameId, details.tabId, details.url,
257 details.parentFrameId); 257 details.parentFrameId);
258 }, 258 },
259 {types: ["main_frame", "sub_frame"], urls: ["http://*/*", "https://*/*"]}, 259 {types: ["main_frame", "sub_frame"], urls: ["http://*/*", "https://*/*"]},
260 ["responseHeaders"]); 260 ["responseHeaders"]);
261 261
262 browser.webNavigation.onBeforeNavigate.addListener(details => 262 browser.webNavigation.onCommitted.addListener(details =>
263 { 263 {
264 // Since we can only listen for HTTP(S) responses using 264 // We have to update the frame structure for documents that weren't
265 // webRequest.onHeadersReceived we must update the page structure here for 265 // loaded over HTTP (including documents cached by Service Workers),
266 // other navigations. 266 // when the navigation occurs. However, we must be careful to not
267 let {url} = details; 267 // update the state of the same document twice, otherewise the number
268 if (!(url.startsWith("http:") || 268 // of any ads blocked already and any recorded sitekey could get lost.
269 url.startsWith("https:") && 269 let frame = ext.getFrame(details.tabId, details.frameId);
Sebastian Noack 2018/04/18 11:25:36 The assumption that every document with an HTTP(S)
kzar 2018/05/02 12:06:52 Initially I worried you removed the whole onHeader
Sebastian Noack 2018/05/02 14:32:15 During onBeforeNavigate we don't know yet whether
kzar 2018/05/02 15:26:52 OK, yea that makes sense. I can't think of a bette
Sebastian Noack 2018/05/02 15:34:49 Well, if blob: URLs are opaque to the webRequest A
kzar 2018/05/02 15:46:35 Well if you paste this snippet from my Chromium is
Sebastian Noack 2018/05/02 16:27:55 I tested it, and the onCommitted listener is emitt
270 // Chrome doesn't dispatch webRequest.onHeadersReceived 270 if (!frame || frame.url.href != details.url)
271 // for Web Store URLs.
272 // https://crrev.com/76882bf/extensions/common/extension_urls.cc#33
273 !url.startsWith("https://chrome.google.com/webstore/")))
Sebastian Noack 2018/04/18 11:25:36 This special case is redundant now, since onCommit
kzar 2018/05/02 12:06:52 Acknowledged.
274 { 271 {
275 updatePageFrameStructure(details.frameId, details.tabId, url, 272 updatePageFrameStructure(details.frameId, details.tabId, details.url,
276 details.parentFrameId); 273 details.parentFrameId);
277 } 274 }
278 }); 275 });
279 276
280 function forgetTab(tabId) 277 function forgetTab(tabId)
281 { 278 {
282 ext.pages.onRemoved._dispatch(tabId); 279 ext.pages.onRemoved._dispatch(tabId);
283 280
284 removeFromAllPageMaps(tabId); 281 removeFromAllPageMaps(tabId);
285 framesOfTabs.delete(tabId); 282 framesOfTabs.delete(tabId);
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 ext.windows = { 602 ext.windows = {
606 create(createData, callback) 603 create(createData, callback)
607 { 604 {
608 browser.windows.create(createData, createdWindow => 605 browser.windows.create(createData, createdWindow =>
609 { 606 {
610 afterTabLoaded(callback)(createdWindow.tabs[0]); 607 afterTabLoaded(callback)(createdWindow.tabs[0]);
611 }); 608 });
612 } 609 }
613 }; 610 };
614 } 611 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld