Bug 1474207 - Network Monitor response payload testing method variances. r=Honza
authorHemakshi Sachdev <sachdev.hemakshi@gmail.com>
Thu, 07 Mar 2019 15:38:21 +0000
changeset 520833 f32615dcb3302a20cf2027b4f280fde809c31329
parent 520773 ca64604d4b781aa8191144e97b660ae3b09fae6e
child 520834 dc0a6a6383984ea1b60fe9dde982620e3869be1a
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza
bugs1474207
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1474207 - Network Monitor response payload testing method variances. r=Honza Changed the way we to access contents of `.CodeMirror`, by using `CodeMirror.getValue()` instead of `.textContent` Differential Revision: https://phabricator.services.mozilla.com/D22079
devtools/client/netmonitor/test/browser_net_brotli.js
devtools/client/netmonitor/test/browser_net_complex-params.js
devtools/client/netmonitor/test/browser_net_content-type.js
devtools/client/netmonitor/test/browser_net_cyrillic-01.js
devtools/client/netmonitor/test/browser_net_json-malformed.js
devtools/client/netmonitor/test/browser_net_large-response.js
devtools/client/netmonitor/test/browser_net_post-data-01.js
devtools/client/netmonitor/test/browser_net_post-data-04.js
devtools/client/netmonitor/test/browser_net_streaming-response.js
devtools/client/netmonitor/test/head.js
--- a/devtools/client/netmonitor/test/browser_net_brotli.js
+++ b/devtools/client/netmonitor/test/browser_net_brotli.js
@@ -55,15 +55,15 @@ add_task(async function() {
   await wait;
   await onResponseContent;
   await testResponse("br");
   await teardown(monitor);
 
   function testResponse(type) {
     switch (type) {
       case "br": {
-        is(document.querySelector(".CodeMirror-line").textContent, "X".repeat(64),
+        is(getCodeMirrorValue(monitor), "X".repeat(64),
           "The text shown in the source editor is incorrect for the brotli request.");
         break;
       }
     }
   }
 });
--- a/devtools/client/netmonitor/test/browser_net_complex-params.js
+++ b/devtools/client/netmonitor/test/browser_net_complex-params.js
@@ -178,17 +178,17 @@ add_task(async function() {
     const values = tabpanel
       .querySelectorAll("tr:not(.treeS-section) .treeValueCell .objectBox");
 
     is(labels[0].textContent, queryStringParamName,
       "The first query string param name was incorrect.");
     is(values[0].textContent, queryStringParamValue,
       "The first query string param value was incorrect.");
 
-    ok(tabpanel.querySelector(".CodeMirror-code").textContent.includes(requestPayload),
+    ok(getCodeMirrorValue(monitor).includes(requestPayload),
       "The text shown in the source editor is incorrect.");
 
     if (isJSON) {
       is(treeSections[2].querySelector(".treeLabel").textContent,
         L10N.getStr("paramsPostPayload"),
         "The post section doesn't have the correct title.");
 
       const requestPayloadObject = JSON.parse(requestPayload);
--- a/devtools/client/netmonitor/test/browser_net_content-type.js
+++ b/devtools/client/netmonitor/test/browser_net_content-type.js
@@ -180,35 +180,35 @@ add_task(async function() {
         box != "image",
         "The response image view doesn't display");
     }
 
     switch (type) {
       case "xml": {
         checkVisibility("textarea");
 
-        const text = document.querySelector(".CodeMirror-line").textContent;
+        const text = getCodeMirrorValue(monitor);
 
         is(text, "<label value='greeting'>Hello XML!</label>",
           "The text shown in the source editor is incorrect for the xml request.");
         break;
       }
       case "css": {
         checkVisibility("textarea");
 
-        const text = document.querySelector(".CodeMirror-line").textContent;
+        const text = getCodeMirrorValue(monitor);
 
         is(text, "body:pre { content: 'Hello CSS!' }",
           "The text shown in the source editor is incorrect for the css request.");
         break;
       }
       case "js": {
         checkVisibility("textarea");
 
-        const text = document.querySelector(".CodeMirror-line").textContent;
+        const text = getCodeMirrorValue(monitor);
 
         is(text, "function() { return 'Hello JS!'; }",
           "The text shown in the source editor is incorrect for the js request.");
         break;
       }
       case "json": {
         checkVisibility("json");
 
@@ -230,17 +230,17 @@ add_task(async function() {
           "The first json property name was incorrect.");
         is(values[0].textContent,
           "Hello JSON!", "The first json property value was incorrect.");
         break;
       }
       case "html": {
         checkVisibility("textarea");
 
-        const text = document.querySelector(".CodeMirror-line").textContent;
+        const text = getCodeMirrorValue(monitor);
 
         is(text, "<blink>Not Found</blink>",
           "The text shown in the source editor is incorrect for the html request.");
         break;
       }
       case "png": {
         checkVisibility("image");
 
@@ -253,17 +253,17 @@ add_task(async function() {
           "The image mime info isn't correct.");
         is(dimensions.textContent, "16" + " \u00D7 " + "16",
           "The image dimensions info isn't correct.");
         break;
       }
       case "gzip": {
         checkVisibility("textarea");
 
-        const text = document.querySelector(".CodeMirror-line").textContent;
+        const text = getCodeMirrorValue(monitor);
 
         is(text, new Array(1000).join("Hello gzip!"),
           "The text shown in the source editor is incorrect for the gzip request.");
         break;
       }
     }
   }
 
--- a/devtools/client/netmonitor/test/browser_net_cyrillic-01.js
+++ b/devtools/client/netmonitor/test/browser_net_cyrillic-01.js
@@ -44,15 +44,14 @@ add_task(async function() {
   wait = waitForDOM(document, "#headers-panel");
   EventUtils.sendMouseEvent({ type: "mousedown" },
     document.querySelectorAll(".request-list-item")[0]);
   await wait;
   wait = waitForDOM(document, "#response-panel .CodeMirror-code");
   EventUtils.sendMouseEvent({ type: "click" },
     document.querySelector("#response-tab"));
   await wait;
-  const text = document.querySelector(".CodeMirror-line").textContent;
 
-  ok(text.includes("\u0411\u0440\u0430\u0442\u0430\u043d"),
+  ok(getCodeMirrorValue(monitor).includes("\u0411\u0440\u0430\u0442\u0430\u043d"),
     "The text shown in the source editor is correct.");
 
   return teardown(monitor);
 });
--- a/devtools/client/netmonitor/test/browser_net_json-malformed.js
+++ b/devtools/client/netmonitor/test/browser_net_json-malformed.js
@@ -62,14 +62,13 @@ add_task(async function() {
   const jsonView = tabpanel.querySelector(".tree-section .treeLabel") || {};
   is(jsonView.textContent === L10N.getStr("jsonScopeName"), false,
     "The response json view doesn't have the intended visibility.");
   is(tabpanel.querySelector(".CodeMirror-code") === null, false,
     "The response editor has the intended visibility.");
   is(tabpanel.querySelector(".response-image-box") === null, true,
     "The response image box doesn't have the intended visibility.");
 
-  is(document.querySelector(".CodeMirror-line").textContent,
-    "{ \"greeting\": \"Hello malformed JSON!\" },",
+  is(getCodeMirrorValue(monitor), "{ \"greeting\": \"Hello malformed JSON!\" },",
     "The text shown in the source editor is incorrect.");
 
   await teardown(monitor);
 });
--- a/devtools/client/netmonitor/test/browser_net_large-response.js
+++ b/devtools/client/netmonitor/test/browser_net_large-response.js
@@ -50,18 +50,17 @@ add_task(async function() {
     });
 
   wait = waitForDOM(document, "#response-panel .CodeMirror-code");
   store.dispatch(Actions.toggleNetworkDetails());
   EventUtils.sendMouseEvent({ type: "click" },
     document.querySelector("#response-tab"));
   await wait;
 
-  const text = document.querySelector(".CodeMirror-line").textContent;
-
-  ok(text.match(/^<p>/), "The text shown in the source editor is incorrect.");
+  ok(getCodeMirrorValue(monitor).match(/^<p>/),
+    "The text shown in the source editor is incorrect.");
 
   await teardown(monitor);
 
   // This test uses a lot of memory, so force a GC to help fragmentation.
   info("Forcing GC after netmonitor test.");
   Cu.forceGC();
 });
--- a/devtools/client/netmonitor/test/browser_net_post-data-01.js
+++ b/devtools/client/netmonitor/test/browser_net_post-data-01.js
@@ -131,23 +131,17 @@ add_task(async function() {
       is(values[3].textContent, "bar", "The first post param value was incorrect.");
       is(labels[4].textContent, "baz", "The second post param name was incorrect.");
       is(values[4].textContent, "123", "The second post param value was incorrect.");
     } else {
       checkVisibility("params editor");
 
       is(labels.length, 3, "There should be 3 param values displayed in this tabpanel.");
 
-      // Collect code lines and combine into one text for checking
-      let text = "";
-      const lines = [...document.querySelectorAll(".CodeMirror-line")];
-
-      lines.forEach((line) => {
-        text += line.textContent + "\n";
-      });
+      const text = getCodeMirrorValue(monitor);
 
       ok(text.includes("Content-Disposition: form-data; name=\"text\""),
         "The text shown in the source editor is incorrect (1.1).");
       ok(text.includes("Content-Disposition: form-data; name=\"email\""),
         "The text shown in the source editor is incorrect (2.1).");
       ok(text.includes("Content-Disposition: form-data; name=\"range\""),
         "The text shown in the source editor is incorrect (3.1).");
       ok(text.includes("Content-Disposition: form-data; name=\"Custom field\""),
--- a/devtools/client/netmonitor/test/browser_net_post-data-04.js
+++ b/devtools/client/netmonitor/test/browser_net_post-data-04.js
@@ -52,13 +52,13 @@ add_task(async function() {
   const labels = tabpanel
     .querySelectorAll("tr:not(.tree-section) .treeLabelCell .treeLabel");
   const values = tabpanel
     .querySelectorAll("tr:not(.tree-section) .treeValueCell .objectBox");
 
   is(labels[0].textContent, "a", "The JSON var name was incorrect.");
   is(values[0].textContent, "1", "The JSON var value was incorrect.");
 
-  ok(tabpanel.querySelector(".CodeMirror-code").textContent.includes('{"a":1}'),
+  ok(getCodeMirrorValue(monitor).includes('{"a":1}'),
     "The text shown in the source editor is incorrect.");
 
   return teardown(monitor);
 });
--- a/devtools/client/netmonitor/test/browser_net_streaming-response.js
+++ b/devtools/client/netmonitor/test/browser_net_streaming-response.js
@@ -70,12 +70,12 @@ add_task(async function() {
 
   await selectIndexAndWaitForSourceEditor(monitor, 1);
   // the mpeg-dash part
   testEditorContent(REQUESTS[1]);
 
   return teardown(monitor);
 
   function testEditorContent([ fmt, textRe ]) {
-    ok(document.querySelector(".CodeMirror-line").textContent.match(textRe),
+    ok(getCodeMirrorValue(monitor).match(textRe),
       "The text shown in the source editor for " + fmt + " is correct.");
   }
 });
--- a/devtools/client/netmonitor/test/head.js
+++ b/devtools/client/netmonitor/test/head.js
@@ -763,16 +763,24 @@ async function performRequests(monitor, 
   const wait = waitForNetworkEvents(monitor, count);
   await ContentTask.spawn(tab.linkedBrowser, count, requestCount => {
     content.wrappedJSObject.performRequests(requestCount);
   });
   await wait;
 }
 
 /**
+ * Helper function for retrieving `.CodeMirror` content
+ */
+function getCodeMirrorValue(monitor) {
+  const document = monitor.panelWin.document;
+  return document.querySelector(".CodeMirror").CodeMirror.getValue();
+}
+
+/**
  * Wait for lazy fields to be loaded in a request.
  *
  * @param Object Store redux store containing request list.
  * @param array fields array of strings which contain field names to be checked
  * on the request.
  */
 function waitForRequestData(store, fields, id) {
   return waitUntil(() => {