| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 }()); | 74 }()); |
| 75 | 75 |
| 76 function getRelatedTabIds(details) | 76 function getRelatedTabIds(details) |
| 77 { | 77 { |
| 78 // This is the common case, the request is associated with a single tab. | 78 // This is the common case, the request is associated with a single tab. |
| 79 // If tabId is -1, its not (e.g. the request was sent by | 79 // If tabId is -1, its not (e.g. the request was sent by |
| 80 // a Service/Shared Worker) and we have to identify the related tabs. | 80 // a Service/Shared Worker) and we have to identify the related tabs. |
| 81 if (details.tabId != -1) | 81 if (details.tabId != -1) |
| 82 return Promise.resolve([details.tabId]); | 82 return Promise.resolve([details.tabId]); |
| 83 | 83 |
| 84 // Firefox >=48 provides "originUrl" indicating the URL of the tab | 84 let url; // Firefox provides "originUrl" indicating the |
| 85 // that caused this request. In case of Service/Shared Worker, | 85 if (details.originUrl) // URL of the tab that caused this request. |
| 86 // this is URL of the tab that caused the worker to be spawned. | 86 url = details.originUrl; // In case of Service/Shared Worker, this is the |
| 87 if (details.originUrl) | 87 // URL of the tab that caused the worker to spawn. |
|
kzar
2018/04/03 12:49:30
Nit: Please use braces since the body spans multip
Sebastian Noack
2018/04/04 01:04:45
No longer relevant (the block has only one line no
| |
| 88 return browser.tabs.query({url: details.originUrl}).then( | 88 |
| 89 tabs => tabs.map(tab => tab.id) | 89 else if (details.initiator) // Chromium >=63 provides "intiator" which |
| 90 ); | 90 url = details.initiator + "/*"; // is equivalent to "originUrl" on Firefox |
| 91 | 91 // except that its not a full URL but just |
| 92 // Chromium >=63 provides "intiator" which is equivalent to "originUrl" on | 92 // an origin (proto + host). |
| 93 // Firefox except that its not a full URL but just an origin (proto + host). | 93 else |
| 94 // So we have to find each tab with an URL of the same origin. | 94 return Promise.resolve([]); |
|
kzar
2018/04/05 10:31:51
I wonder if there is a situation where details.ini
Sebastian Noack
2018/04/05 16:56:33
There are two scenarios (I have seen in my testing
kzar
2018/04/09 14:39:18
Sounds reasonable to me, maybe add a note to the i
Sebastian Noack
2018/04/09 21:08:20
There you go: https://issues.adblockplus.org/ticke
| |
| 95 if (details.initiator) | 95 |
| 96 return browser.tabs.query({}).then(tabs => | 96 return browser.tabs.query({url}).then(tabs => tabs.map(tab => tab.id)); |
|
kzar
2018/04/03 12:49:30
Couldn't we pass something like `details.initiator
Sebastian Noack
2018/04/04 01:04:45
In fact we can. I wasn't aware that tab.query() ac
kzar
2018/04/05 10:31:51
Cool, I assumed I was wrong somehow :p. This looks
| |
| 97 { | |
| 98 let tabIds = []; | |
| 99 for (let tab of tabs) | |
| 100 { | |
| 101 if (new URL(tab.url).origin == details.initiator) | |
| 102 tabIds.push(tab.id); | |
|
kzar
2018/04/03 12:49:30
Wouldn't this mean we sometimes log a request for
Sebastian Noack
2018/04/04 01:04:45
This usually means that the request was sent by a
kzar
2018/04/05 10:31:51
Acknowledged.
| |
| 103 } | |
| 104 return tabIds; | |
| 105 }); | |
| 106 | |
| 107 return Promise.resolve([]); | |
| 108 } | 97 } |
| 109 | 98 |
| 110 function logRequest(details, url, type, docDomain, thirdParty, | 99 function logRequest(details, url, type, docDomain, thirdParty, |
| 111 sitekey, specificOnly, filter) | 100 sitekey, specificOnly, filter) |
| 112 { | 101 { |
| 113 getRelatedTabIds(details).then(tabIds => | 102 getRelatedTabIds(details).then(tabIds => |
| 114 { | 103 { |
| 115 if (filter) | 104 if (filter) |
| 116 FilterNotifier.emit("filter.hitCount", filter, 0, 0, tabIds); | 105 FilterNotifier.emit("filter.hitCount", filter, 0, 0, tabIds); |
| 117 | 106 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 | 264 |
| 276 port.on("request.blockedByRTCWrapper", (msg, sender) => | 265 port.on("request.blockedByRTCWrapper", (msg, sender) => |
| 277 { | 266 { |
| 278 return ext.webRequest.onBeforeRequest._dispatch( | 267 return ext.webRequest.onBeforeRequest._dispatch( |
| 279 new URL(msg.url), | 268 new URL(msg.url), |
| 280 "webrtc", | 269 "webrtc", |
| 281 sender.page, | 270 sender.page, |
| 282 sender.frame | 271 sender.frame |
| 283 ).includes(false); | 272 ).includes(false); |
| 284 }); | 273 }); |
| LEFT | RIGHT |