From 131be93acde051f4809adff63d23c65dc0526ecb Mon Sep 17 00:00:00 2001 From: abhinav Date: Fri, 25 May 2018 02:43:14 +0530 Subject: [PATCH] Bug 1462886 - Fix for filter flag breaking the netmonitor when using invalid values.r=Honza MozReview-Commit-ID: 5cvUX2sb7k0 --HG-- extra : rebase_source : 57caba2b7b6927e2564a0894afc35f709402f386 --- .../client/netmonitor/src/utils/filter-text-utils.js | 4 ++++ .../netmonitor/test/browser_net_filter-flags.js | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/devtools/client/netmonitor/src/utils/filter-text-utils.js b/devtools/client/netmonitor/src/utils/filter-text-utils.js index 6f41ff351310..a119845850ec 100644 --- a/devtools/client/netmonitor/src/utils/filter-text-utils.js +++ b/devtools/client/netmonitor/src/utils/filter-text-utils.js @@ -104,6 +104,10 @@ function processFlagFilter(type, value) { } function isFlagFilterMatch(item, { type, value, negative }) { + if (value == null) { + return false; + } + // Ensures when filter token is exactly a flag ie. "remote-ip:", all values are shown if (value.length < 1) { return true; diff --git a/devtools/client/netmonitor/test/browser_net_filter-flags.js b/devtools/client/netmonitor/test/browser_net_filter-flags.js index cc75973408fd..d23114f33709 100644 --- a/devtools/client/netmonitor/test/browser_net_filter-flags.js +++ b/devtools/client/netmonitor/test/browser_net_filter-flags.js @@ -257,6 +257,9 @@ add_task(async function() { setFreetextFilter("size:34"); await testContents([0, 0, 1, 1, 0, 0, 0, 0, 0, 0]); + setFreetextFilter("size:0kb"); + await testContents([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); + // Testing the lower bound setFreetextFilter("size:9.659k"); await testContents([0, 0, 0, 0, 0, 0, 0, 0, 1, 0]); @@ -279,6 +282,9 @@ add_task(async function() { setFreetextFilter("transferred:248"); await testContents([0, 0, 1, 1, 0, 0, 0, 0, 0, 1]); + setFreetextFilter("transferred:0kb"); + await testContents([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); + // Test larger-than setFreetextFilter("larger-than:-1"); await testContents([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]); @@ -298,6 +304,9 @@ add_task(async function() { setFreetextFilter("larger-than:10.732k"); await testContents([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); + setFreetextFilter("larger-than:0kb"); + await testContents([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); + // Test transferred-larger-than setFreetextFilter("transferred-larger-than:-1"); await testContents([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]); @@ -314,6 +323,9 @@ add_task(async function() { setFreetextFilter("transferred-larger-than:10.73k"); await testContents([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); + setFreetextFilter("transferred-larger-than:0kb"); + await testContents([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); + // Test cause setFreetextFilter("cause:xhr"); await testContents([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]);