Bug 1481732 - Fixed netmonitor request parameter parsing so equals signs are not removed from value field. r=Honza
authortossj <tossj@outlook.com>
Thu, 23 Aug 2018 13:34:39 -0400
changeset 483815 06ce1febd1fc254e480e7b87288c2ee4fd7046b9
parent 483814 d74c0e9d7add52918af57e05b0aa2092196d30ec
child 483816 684e70bc7dec3de92f3e4016acf90c5dcf210615
push id241
push userfmarier@mozilla.com
push dateMon, 24 Sep 2018 21:48:02 +0000
reviewersHonza
bugs1481732
milestone64.0a1
Bug 1481732 - Fixed netmonitor request parameter parsing so equals signs are not removed from value field. r=Honza
devtools/client/netmonitor/src/utils/request-utils.js
devtools/client/netmonitor/test/browser_net_complex-params.js
devtools/client/netmonitor/test/html_params-test-page.html
--- a/devtools/client/netmonitor/src/utils/request-utils.js
+++ b/devtools/client/netmonitor/src/utils/request-utils.js
@@ -302,17 +302,17 @@ function parseQueryString(query) {
   if (!query) {
     return null;
   }
 
   return query.replace(/^[?&]/, "").split("&").map(e => {
     const param = e.split("=");
     return {
       name: param[0] ? getUnicodeUrlPath(param[0]) : "",
-      value: param[1] ? getUnicodeUrlPath(param[1]) : "",
+      value: param[1] ? getUnicodeUrlPath(param.slice(1).join("=")) : "",
     };
   });
 }
 
 /**
  * Parse a string of formdata sections into its components
  *
  * @param {string} sections - sections of formdata joined by &
--- a/devtools/client/netmonitor/test/browser_net_complex-params.js
+++ b/devtools/client/netmonitor/test/browser_net_complex-params.js
@@ -14,17 +14,17 @@ add_task(async function() {
 
   const { document, store, windowRequire } = monitor.panelWin;
   const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
   const { L10N } = windowRequire("devtools/client/netmonitor/src/utils/l10n");
 
   store.dispatch(Actions.batchEnable(false));
 
   // Execute requests.
-  await performRequests(monitor, tab, 7);
+  await performRequests(monitor, tab, 10);
 
   wait = waitForDOM(document, "#params-panel .tree-section", 2);
   EventUtils.sendMouseEvent({ type: "mousedown" },
     document.querySelectorAll(".request-list-item")[0]);
   EventUtils.sendMouseEvent({ type: "click" },
     document.querySelector("#params-tab"));
   await wait;
   testParamsTab1("a", "", '{ "foo": "bar" }', "");
@@ -60,16 +60,36 @@ add_task(async function() {
     document.querySelectorAll(".request-list-item")[5]);
   await Promise.all([waitSections, waitSourceEditor]);
   testParamsTab2("a", "b", "?foo=bar", "text");
 
   EventUtils.sendMouseEvent({ type: "mousedown" },
     document.querySelectorAll(".request-list-item")[6]);
   testParamsTab3();
 
+  wait = waitForDOM(document, "#params-panel .tree-section", 2);
+  EventUtils.sendMouseEvent({ type: "mousedown" },
+    document.querySelectorAll(".request-list-item")[7]);
+  await wait;
+  testParamsTab1("a", "b", '{ "foo": "bar" }', "");
+
+  wait = waitForDOM(document, "#params-panel .tree-section", 2);
+  EventUtils.sendMouseEvent({ type: "mousedown" },
+    document.querySelectorAll(".request-list-item")[8]);
+  await wait;
+  testParamsTab1("a", "b", '{ "foo": "bar" }', "");
+
+  wait = waitForDOM(document, "#params-panel .tree-section", 1);
+  EventUtils.sendMouseEvent({ type: "mousedown" },
+    document.querySelectorAll(".request-list-item")[9]);
+  await wait;
+  testParamsTabGetWithArgs(new Map([
+    ["species", "in=(52,60)"],
+  ]));
+
   await teardown(monitor);
 
   function testParamsTab1(queryStringParamName, queryStringParamValue,
                           formDataParamName, formDataParamValue) {
     const tabpanel = document.querySelector("#params-panel");
 
     is(tabpanel.querySelectorAll(".tree-section").length, 2,
       "The number of param tree sections displayed in this tabpanel is incorrect.");
@@ -171,9 +191,48 @@ add_task(async function() {
     is(tabpanel.querySelectorAll(".empty-notice").length, 1,
       "The empty notice should be displayed in this tabpanel.");
 
     ok(!tabpanel.querySelector(".treeTable"),
       "The request params box should be hidden.");
     ok(!tabpanel.querySelector(".CodeMirror-code"),
       "The request post data editor should be hidden.");
   }
+
+  /**
+   * @param {Map} expectedParams A map of expected parameter keys and values
+   * as Strings.
+   */
+  function testParamsTabGetWithArgs(expectedParams) {
+    const tabpanel = document.querySelector("#params-panel");
+
+    is(tabpanel.querySelectorAll(".tree-section").length, 1,
+      "Check the number of param tree sections displayed in this tabpanel.");
+    is(tabpanel.querySelectorAll("tr:not(.tree-section).treeRow").length, 1,
+      "Check the number of param rows displayed in this tabpanel.");
+    ok(!tabpanel.querySelector(".empty-notice"),
+      "The empty notice should not be displayed in this tabpanel.");
+
+    ok(tabpanel.querySelector(".treeTable"),
+      "The request params box should be shown.");
+    ok(!tabpanel.querySelector(".CodeMirror-code"),
+      "The request post data editor should be hidden.");
+
+    const treeSections = tabpanel.querySelectorAll(".tree-section");
+    const labels = tabpanel
+      .querySelectorAll("tr:not(.tree-section) .treeLabelCell .treeLabel");
+    const values = tabpanel
+      .querySelectorAll("tr:not(.tree-section) .treeValueCell .objectBox");
+
+    is(treeSections[0].querySelector(".treeLabel").textContent,
+      L10N.getStr("paramsQueryString"),
+      "Check the displayed params section title.");
+
+    const labelsIter = labels.values();
+    const valuesIter = values.values();
+    for (const [expKey, expValue] of expectedParams) {
+      const label = labelsIter.next().value;
+      const value = valuesIter.next().value;
+      is(label.textContent, expKey, "Check that parameter name matches.");
+      is(value.textContent, expValue, "Check that parameter value matches.");
+    }
+  }
 });
--- a/devtools/client/netmonitor/test/html_params-test-page.html
+++ b/devtools/client/netmonitor/test/html_params-test-page.html
@@ -63,13 +63,14 @@
         await post("baz", "?a=b", urlencoded, '{ "foo": "bar" }');
         await post("baz", "?a=b", urlencoded, "?foo=bar");
         await post("baz", "?a", undefined, '{ "foo": "bar" }');
         await post("baz", "?a=b", undefined, '{ "foo": "bar" }');
         await post("baz", "?a=b", undefined, "?foo=bar");
         await get("baz", "");
         await patch("baz", "?a=b", urlencoded, '{ "foo": "bar" }');
         await put("baz", "?a=b", urlencoded, '{ "foo": "bar" }');
+        await get("baz", "?species=in=(52,60)");
       }
     </script>
   </body>
 
 </html>