Bug 1462886 - Fix for filter flag breaking the netmonitor when using invalid values. r=Honza, a=RyanVM
authorabhinav <abhinav.koppula@gmail.com>
Fri, 25 May 2018 02:43:14 +0530
changeset 806026 d7e42c12b4a70535e0a81df0f54ec13cf6263d52
parent 806025 bd1438686c3f1c174e49c7eb5ec864b252e119e8
child 806027 d34e9c8ef02396c13e216328fb088c476ed4a3d4
push id112832
push userbballo@mozilla.com
push dateFri, 08 Jun 2018 21:11:22 +0000
reviewersHonza, RyanVM
bugs1462886
milestone60.0.3
Bug 1462886 - Fix for filter flag breaking the netmonitor when using invalid values. r=Honza, a=RyanVM MozReview-Commit-ID: 5cvUX2sb7k0
devtools/client/netmonitor/src/utils/filter-text-utils.js
devtools/client/netmonitor/test/browser_net_filter-flags.js
--- a/devtools/client/netmonitor/src/utils/filter-text-utils.js
+++ b/devtools/client/netmonitor/src/utils/filter-text-utils.js
@@ -98,16 +98,20 @@ function processFlagFilter(type, value) 
       }
       return quantity * multiplier;
     default:
       return value.toLowerCase();
   }
 }
 
 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;
   }
 
   let match = true;
   let { responseCookies = { cookies: [] } } = item;
   responseCookies = responseCookies.cookies || responseCookies;
--- a/devtools/client/netmonitor/test/browser_net_filter-flags.js
+++ b/devtools/client/netmonitor/test/browser_net_filter-flags.js
@@ -252,16 +252,19 @@ add_task(async function () {
   await testContents([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
 
   setFreetextFilter("size:0");
   await testContents([0, 0, 0, 0, 1, 1, 1, 1, 0, 1]);
 
   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]);
 
   // Testing the actual value
   setFreetextFilter("size:10989");
   await testContents([0, 0, 0, 0, 0, 0, 0, 0, 1, 0]);
 
@@ -274,16 +277,19 @@ add_task(async function () {
   await testContents([0, 0, 0, 0, 1, 1, 1, 1, 0, 0]);
 
   setFreetextFilter("transferred:234");
   await testContents([1, 0, 1, 0, 0, 0, 0, 0, 0, 1]);
 
   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]);
 
   setFreetextFilter("larger-than:0");
   await testContents([1, 1, 1, 1, 0, 0, 0, 0, 1, 0]);
 
   setFreetextFilter("larger-than:33");
@@ -293,32 +299,38 @@ add_task(async function () {
   await testContents([0, 0, 0, 0, 0, 0, 0, 0, 1, 0]);
 
   setFreetextFilter("larger-than:10.73k");
   await testContents([0, 0, 0, 0, 0, 0, 0, 0, 1, 0]);
 
   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]);
 
   setFreetextFilter("transferred-larger-than:214");
   await testContents([1, 1, 1, 1, 0, 0, 0, 0, 1, 1]);
 
   setFreetextFilter("transferred-larger-than:247");
   await testContents([0, 1, 1, 1, 0, 0, 0, 0, 1, 0]);
 
   setFreetextFilter("transferred-larger-than:248");
   await testContents([0, 1, 0, 1, 0, 0, 0, 0, 1, 0]);
 
   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]);
 
   setFreetextFilter("cause:script");
   await testContents([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
 
   // Test has-response-header