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

Unified Diff: lib/devtools.js

Issue 29737602: Issue 4580 - Make filter/request logging use plain tabIds, prepare for multi-tab requests (Closed)
Patch Set: Removed outdated comment Created April 4, 2018, 1:48 a.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 | « lib/cssInjection.js ('k') | lib/popupBlocker.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/devtools.js
===================================================================
--- a/lib/devtools.js
+++ b/lib/devtools.js
@@ -30,9 +30,6 @@
const nonRequestTypes = ["DOCUMENT", "ELEMHIDE",
"GENERICBLOCK", "GENERICHIDE", "CSP"];
-// Mapping of inspected tabs to their devpanel page
-// and recorded items. We can't use a PageMap here,
-// because data must persist after navigation/reload.
let panels = new Map();
function isActivePanel(panel)
@@ -40,9 +37,9 @@
return panel && !panel.reload && !panel.reloading;
}
-function getActivePanel(page)
+function getActivePanel(tabId)
{
- let panel = panels.get(page.id);
+ let panel = panels.get(tabId);
if (isActivePanel(panel))
return panel;
return null;
@@ -122,8 +119,7 @@
/**
* Logs a request to the devtools panel.
*
- * @param {?Page} page The page the request occured on or null if
- * the request isn't associated with a page
+ * @param {number[]} tabIds The tabIds associated with the request
* @param {string} url The URL of the request
* @param {string} type The request type
* @param {string} docDomain The IDN-decoded hostname of the document
@@ -134,7 +130,7 @@
* @param {?BlockingFilter} filter The matched filter or null if there is no
* match
*/
-exports.logRequest = function(page, url, type, docDomain,
+exports.logRequest = function(tabIds, url, type, docDomain,
thirdParty, sitekey,
specificOnly, filter)
{
@@ -143,21 +139,21 @@
let request = {url, type, docDomain, thirdParty, sitekey, specificOnly};
for (let [tabId, panel] of panels)
- if ((!page || page.id == tabId) && isActivePanel(panel))
+ if ((tabIds.length == 0 || tabIds.includes(tabId)) && isActivePanel(panel))
addRecord(panel, request, filter);
};
/**
* Logs active element hiding filters to the devtools panel.
*
- * @param {Page} page The page the elements were hidden on
+ * @param {number} tabId The ID of the tab, the elements were hidden in
* @param {string[]} selectors The selectors of applied ElemHideFilters
* @param {string[]} filters The text of applied ElemHideEmulationFilters
* @param {string} docDomain The IDN-decoded hostname of the document
*/
-function logHiddenElements(page, selectors, filters, docDomain)
+function logHiddenElements(tabId, selectors, filters, docDomain)
{
- let panel = getActivePanel(page);
+ let panel = getActivePanel(tabId);
if (panel)
{
for (let subscription of FilterStorage.subscriptions)
@@ -186,7 +182,7 @@
* Logs a whitelisting filter, that disables (some kind of)
* blocking for a particular document, to the devtools panel.
*
- * @param {Page} page The page the whitelisting is active on
+ * @param {number} tabId The tabId the whitelisting is active for
* @param {string} url The url of the whitelisted document
* @param {number} typeMask The bit mask of whitelisting types checked
* for
@@ -194,10 +190,10 @@
* document
* @param {WhitelistFilter} filter The matched whitelisting filter
*/
-exports.logWhitelistedDocument = function(page, url, typeMask, docDomain,
+exports.logWhitelistedDocument = function(tabId, url, typeMask, docDomain,
filter)
{
- let panel = getActivePanel(page);
+ let panel = getActivePanel(tabId);
if (panel)
{
for (let type of nonRequestTypes)
@@ -209,14 +205,14 @@
};
/**
- * Checks whether a page is inspected by the devtools panel.
+ * Checks whether a tab is inspected by the devtools panel.
*
- * @param {Page} page
+ * @param {number} tabId
* @return {boolean}
*/
-exports.hasPanel = function(page)
+exports.hasPanel = function(tabId)
{
- return panels.has(page.id);
+ return panels.has(tabId);
};
function onBeforeRequest(details)
@@ -381,7 +377,7 @@
port.on("devtools.traceElemHide", (message, sender) =>
{
logHiddenElements(
- sender.page, message.selectors, message.filters,
+ sender.page.id, message.selectors, message.filters,
extractHostFromFrame(sender.frame)
);
});
« no previous file with comments | « lib/cssInjection.js ('k') | lib/popupBlocker.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld