Bug 1354507 - Add cookie-related filter options for network requests. r?Honza
MozReview-Commit-ID: 48zc0qcasvK
--- a/devtools/client/netmonitor/src/utils/filter-text-utils.js
+++ b/devtools/client/netmonitor/src/utils/filter-text-utils.js
@@ -34,16 +34,19 @@ const { HEADERS } = require("../constant
const { getFormattedIPAndPort } = require("./format-utils");
const HEADER_FILTERS = HEADERS
.filter(h => h.canFilter)
.map(h => h.filterKey || h.name);
const FILTER_FLAGS = [
...HEADER_FILTERS,
"scheme",
+ "set-cookie-domain",
+ "set-cookie-name",
+ "set-cookie-value",
"mime-type",
"larger-than",
"is",
"has-response-header",
];
/*
The function `parseFilters` is from:
@@ -112,16 +115,18 @@ function processFlagFilter(type, value)
}
function getSizeOrder(size) {
return Math.round(Math.log10(size));
}
function isFlagFilterMatch(item, { type, value, negative }) {
let match = true;
+ let { responseCookies = { cookies: [] } } = item;
+ responseCookies = responseCookies.cookies || responseCookies;
switch (type) {
case "status-code":
match = item.status === value;
break;
case "method":
match = item.method.toLowerCase() === value;
break;
case "protocol":
@@ -172,16 +177,34 @@ function isFlagFilterMatch(item, { type,
} else if (value === "running") {
match = !item.status;
}
break;
case "scheme":
let scheme = new URL(item.url).protocol.replace(":", "").toLowerCase();
match = scheme === value;
break;
+ case "set-cookie-domain":
+ if (responseCookies.length > 0) {
+ let host = item.urlDetails.host;
+ let i = responseCookies.findIndex(c => {
+ let domain = c.hasOwnProperty("domain") ? c.domain : host;
+ return domain === value;
+ });
+ match = i > -1;
+ } else {
+ match = false;
+ }
+ break;
+ case "set-cookie-name":
+ match = responseCookies.findIndex(c => c.name.toLowerCase() === value) > -1;
+ break;
+ case "set-cookie-value":
+ match = responseCookies.findIndex(c => c.value.toLowerCase() === value) > -1;
+ break;
}
if (negative) {
return !match;
}
return match;
}
function isTextFilterMatch({ url }, text) {