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

Delta Between Two Patch Sets: lib/devtools.js

Issue 29737602: Issue 4580 - Make filter/request logging use plain tabIds, prepare for multi-tab requests (Closed)
Left Patch Set: Created April 2, 2018, 12:27 a.m.
Right Patch Set: Removed outdated comment Created April 4, 2018, 1:48 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « lib/cssInjection.js ('k') | lib/popupBlocker.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 12 matching lines...) Expand all
23 const {SpecialSubscription} = require("subscriptionClasses"); 23 const {SpecialSubscription} = require("subscriptionClasses");
24 const {FilterStorage} = require("filterStorage"); 24 const {FilterStorage} = require("filterStorage");
25 const {defaultMatcher} = require("matcher"); 25 const {defaultMatcher} = require("matcher");
26 const {FilterNotifier} = require("filterNotifier"); 26 const {FilterNotifier} = require("filterNotifier");
27 const {extractHostFromFrame} = require("url"); 27 const {extractHostFromFrame} = require("url");
28 const {port} = require("messaging"); 28 const {port} = require("messaging");
29 29
30 const nonRequestTypes = ["DOCUMENT", "ELEMHIDE", 30 const nonRequestTypes = ["DOCUMENT", "ELEMHIDE",
31 "GENERICBLOCK", "GENERICHIDE", "CSP"]; 31 "GENERICBLOCK", "GENERICHIDE", "CSP"];
32 32
33 // Mapping of inspected tabs to their devpanel page
34 // and recorded items. We can't use a PageMap here,
kzar 2018/04/03 17:14:03 Maybe remove/change this comment since it wouldn't
Sebastian Noack 2018/04/04 01:50:33 Well spotted. Done.
35 // because data must persist after navigation/reload.
36 let panels = new Map(); 33 let panels = new Map();
37 34
38 function isActivePanel(panel) 35 function isActivePanel(panel)
39 { 36 {
40 return panel && !panel.reload && !panel.reloading; 37 return panel && !panel.reload && !panel.reloading;
41 } 38 }
42 39
43 function getActivePanel(tabId) 40 function getActivePanel(tabId)
44 { 41 {
45 let panel = panels.get(tabId); 42 let panel = panels.get(tabId);
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 localOnBeforeRequest, 344 localOnBeforeRequest,
348 { 345 {
349 urls: ["http://*/*", "https://*/*"], 346 urls: ["http://*/*", "https://*/*"],
350 types: ["main_frame"], 347 types: ["main_frame"],
351 tabId: inspectedTabId 348 tabId: inspectedTabId
352 } 349 }
353 ); 350 );
354 351
355 if (panels.size == 0) 352 if (panels.size == 0)
356 { 353 {
357 ext.pages.onLoading.addListener(onLoading); 354 ext.pages.onLoading.addListener(onLoading);
kzar 2018/04/03 17:14:03 What about these? Well I don't mind if we remove t
Sebastian Noack 2018/04/04 01:50:33 There is quite some magic around the ext.pages.onL
358 FilterNotifier.on("filter.added", onFilterAdded); 355 FilterNotifier.on("filter.added", onFilterAdded);
359 FilterNotifier.on("filter.removed", onFilterRemoved); 356 FilterNotifier.on("filter.removed", onFilterRemoved);
360 FilterNotifier.on("subscription.added", onSubscriptionAdded); 357 FilterNotifier.on("subscription.added", onSubscriptionAdded);
361 } 358 }
362 359
363 newPort.onDisconnect.addListener(() => 360 newPort.onDisconnect.addListener(() =>
364 { 361 {
365 panels.delete(inspectedTabId); 362 panels.delete(inspectedTabId);
366 browser.webRequest.onBeforeRequest.removeListener(localOnBeforeRequest); 363 browser.webRequest.onBeforeRequest.removeListener(localOnBeforeRequest);
367 364
368 if (panels.size == 0) 365 if (panels.size == 0)
369 { 366 {
370 ext.pages.onLoading.removeListener(onLoading); 367 ext.pages.onLoading.removeListener(onLoading);
371 FilterNotifier.off("filter.added", onFilterAdded); 368 FilterNotifier.off("filter.added", onFilterAdded);
372 FilterNotifier.off("filter.removed", onFilterRemoved); 369 FilterNotifier.off("filter.removed", onFilterRemoved);
373 FilterNotifier.off("subscription.added", onSubscriptionAdded); 370 FilterNotifier.off("subscription.added", onSubscriptionAdded);
374 } 371 }
375 }); 372 });
376 373
377 panels.set(inspectedTabId, {port: newPort, records: []}); 374 panels.set(inspectedTabId, {port: newPort, records: []});
378 }); 375 });
379 376
380 port.on("devtools.traceElemHide", (message, sender) => 377 port.on("devtools.traceElemHide", (message, sender) =>
381 { 378 {
382 logHiddenElements( 379 logHiddenElements(
383 sender.page.id, message.selectors, message.filters, 380 sender.page.id, message.selectors, message.filters,
384 extractHostFromFrame(sender.frame) 381 extractHostFromFrame(sender.frame)
385 ); 382 );
386 }); 383 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld