 Issue 29739603:
  Issue 6544 - Prevent requests sent by Chrome or Adblock Plus from being blocked  (Closed)
    
  
    Issue 29739603:
  Issue 6544 - Prevent requests sent by Chrome or Adblock Plus from being blocked  (Closed) 
  | 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 | 
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. | 
| 13 * | 13 * | 
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License | 
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 
| 16 */ | 16 */ | 
| 17 | 17 | 
| 18 "use strict"; | 18 "use strict"; | 
| 19 | 19 | 
| 20 const {RegExpFilter, | 20 const {RegExpFilter, | 
| 21 WhitelistFilter, | 21 WhitelistFilter, | 
| 22 ElemHideFilter} = require("filterClasses"); | 22 ElemHideFilter} = require("../adblockpluscore/lib/filterClasses"); | 
| 23 const {SpecialSubscription} = require("subscriptionClasses"); | 23 const {SpecialSubscription} = | 
| 24 const {FilterStorage} = require("filterStorage"); | 24 require("../adblockpluscore/lib/subscriptionClasses"); | 
| 25 const {defaultMatcher} = require("matcher"); | 25 const {FilterStorage} = require("../adblockpluscore/lib/filterStorage"); | 
| 26 const {FilterNotifier} = require("filterNotifier"); | 26 const {defaultMatcher} = require("../adblockpluscore/lib/matcher"); | 
| 27 const {extractHostFromFrame} = require("url"); | 27 const {FilterNotifier} = require("../adblockpluscore/lib/filterNotifier"); | 
| 28 const {port} = require("messaging"); | 28 const {extractHostFromFrame} = require("./url"); | 
| 29 const {port} = require("./messaging"); | |
| 29 | 30 | 
| 30 const nonRequestTypes = ["DOCUMENT", "ELEMHIDE", | 31 const nonRequestTypes = ["DOCUMENT", "ELEMHIDE", | 
| 31 "GENERICBLOCK", "GENERICHIDE", "CSP"]; | 32 "GENERICBLOCK", "GENERICHIDE", "CSP"]; | 
| 32 | 33 | 
| 33 let panels = new Map(); | 34 let panels = new Map(); | 
| 34 | 35 | 
| 35 function isActivePanel(panel) | 36 function isActivePanel(panel) | 
| 36 { | 37 { | 
| 37 return panel && !panel.reload && !panel.reloading; | 38 return panel && !panel.reload && !panel.reloading; | 
| 38 } | 39 } | 
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 */ | 133 */ | 
| 133 exports.logRequest = function(tabIds, url, type, docDomain, | 134 exports.logRequest = function(tabIds, url, type, docDomain, | 
| 134 thirdParty, sitekey, | 135 thirdParty, sitekey, | 
| 135 specificOnly, filter) | 136 specificOnly, filter) | 
| 136 { | 137 { | 
| 137 for (let tabId of tabIds) | 138 for (let tabId of tabIds) | 
| 138 { | 139 { | 
| 139 let panel = getActivePanel(tabId); | 140 let panel = getActivePanel(tabId); | 
| 140 if (panel) | 141 if (panel) | 
| 141 { | 142 { | 
| 142 let request = {url, type, docDomain, thirdParty, sitekey, specificOnly}; | 143 let request = {url, type, docDomain, thirdParty, sitekey, specificOnly}; | 
| 
kzar
2018/04/05 10:56:37
How come we're now assigning request inside the lo
 
Sebastian Noack
2018/04/05 17:38:59
Most of the time we have only one tabId which most
 
kzar
2018/04/06 14:48:10
Sure, that's why we had the extra check above whic
 
Sebastian Noack
2018/04/06 17:55:46
The object was still created redundantly if there
 
kzar
2018/04/09 11:08:43
Well I guess we disagree on this but whatever, I w
 | |
| 143 addRecord(panel, request, filter); | 144 addRecord(panel, request, filter); | 
| 144 } | 145 } | 
| 145 } | 146 } | 
| 
Sebastian Noack
2018/04/05 05:42:45
I figured now where we don't log requests out of c
 
Sebastian Noack
2018/04/05 06:03:58
For reference, the case of `tabIds.length == 0` ri
 | |
| 146 }; | 147 }; | 
| 147 | 148 | 
| 148 /** | 149 /** | 
| 149 * Logs active element hiding filters to the devtools panel. | 150 * Logs active element hiding filters to the devtools panel. | 
| 150 * | 151 * | 
| 151 * @param {number} tabId The ID of the tab, the elements were hidden in | 152 * @param {number} tabId The ID of the tab, the elements were hidden in | 
| 152 * @param {string[]} selectors The selectors of applied ElemHideFilters | 153 * @param {string[]} selectors The selectors of applied ElemHideFilters | 
| 153 * @param {string[]} filters The text of applied ElemHideEmulationFilters | 154 * @param {string[]} filters The text of applied ElemHideEmulationFilters | 
| 154 * @param {string} docDomain The IDN-decoded hostname of the document | 155 * @param {string} docDomain The IDN-decoded hostname of the document | 
| 155 */ | 156 */ | 
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 376 panels.set(inspectedTabId, {port: newPort, records: []}); | 377 panels.set(inspectedTabId, {port: newPort, records: []}); | 
| 377 }); | 378 }); | 
| 378 | 379 | 
| 379 port.on("devtools.traceElemHide", (message, sender) => | 380 port.on("devtools.traceElemHide", (message, sender) => | 
| 380 { | 381 { | 
| 381 logHiddenElements( | 382 logHiddenElements( | 
| 382 sender.page.id, message.selectors, message.filters, | 383 sender.page.id, message.selectors, message.filters, | 
| 383 extractHostFromFrame(sender.frame) | 384 extractHostFromFrame(sender.frame) | 
| 384 ); | 385 ); | 
| 385 }); | 386 }); | 
| LEFT | RIGHT |