Bug 1389251 - Fix browser_webconsole_context_menu_copy_entire_message.js so findMessage doesn't match on the wrong thing r=jdescottes draft
authorValentin Gosu <valentin.gosu@gmail.com>
Tue, 12 Jun 2018 03:05:14 +0200
changeset 806831 ab6dc43f3a9f823187a579856690bdcdb75f2b06
parent 806830 8c0d5caa56b9649abc7a324e19e02c239938e20e
push id112966
push uservalentin.gosu@gmail.com
push dateTue, 12 Jun 2018 01:05:49 +0000
reviewersjdescottes
bugs1389251
milestone62.0a1
Bug 1389251 - Fix browser_webconsole_context_menu_copy_entire_message.js so findMessage doesn't match on the wrong thing r=jdescottes See Bug 1389251 comment 29 for full explanation of why we do this. Also replaces ok(lines.length, value) with is(lines.length, value) MozReview-Commit-ID: BQMty9vR9q
devtools/client/webconsole/test/mochitest/browser_webconsole_context_menu_copy_entire_message.js
--- a/devtools/client/webconsole/test/mochitest/browser_webconsole_context_menu_copy_entire_message.js
+++ b/devtools/client/webconsole/test/mochitest/browser_webconsole_context_menu_copy_entire_message.js
@@ -12,17 +12,17 @@ const LOG_FORMAT_WITH_TIMESTAMP = /^[\d:
 const LOG_FORMAT_WITHOUT_TIMESTAMP = /^.+ (\d+ )?.+:\d+$/;
 // RegExp that validates copied text for stacktrace lines.
 const TRACE_FORMAT = /^\t.+ .+:\d+:\d+$/;
 
 const PREF_MESSAGE_TIMESTAMP = "devtools.webconsole.timestampMessages";
 
 const TEST_URI = `data:text/html;charset=utf-8,<script>
   window.logStuff = function () {
-    console.log("simple text message");
+    console.log("simple " +  "text message");
     function wrapper() {
       console.trace();
     }
     wrapper();
   };
 </script>`;
 
 // Test the Copy menu item of the webconsole copies the expected clipboard text for
@@ -44,29 +44,29 @@ add_task(async function() {
 
   info("Test copy menu item for the simple log");
   let message = await waitFor(() => findMessage(hud, "simple text message"));
   let clipboardText = await copyMessageContent(hud, message);
   ok(true, "Clipboard text was found and saved");
 
   info("Check copied text for simple log message");
   let lines = clipboardText.split("\n");
-  ok(lines.length, 2, "There are 2 lines in the copied text");
+  is(lines.length, 2, "There are 2 lines in the copied text");
   is(lines[1], "", "The last line is an empty new line");
   ok(LOG_FORMAT_WITH_TIMESTAMP.test(lines[0]),
     "Log line has the right format:\n" + lines[0]);
 
   info("Test copy menu item for the stack trace message");
   message = await waitFor(() => findMessage(hud, "console.trace"));
   clipboardText = await copyMessageContent(hud, message);
   ok(true, "Clipboard text was found and saved");
 
   info("Check copied text for stack trace message");
   lines = clipboardText.split("\n");
-  ok(lines.length, 4, "There are 4 lines in the copied text");
+  is(lines.length, 4, "There are 4 lines in the copied text");
   is(lines[3], "", "The last line is an empty new line");
   ok(LOG_FORMAT_WITH_TIMESTAMP.test(lines[0]),
     "Log line has the right format:\n" + lines[0]);
   ok(TRACE_FORMAT.test(lines[1]), "Stacktrace line has the right format:\n" + lines[1]);
   ok(TRACE_FORMAT.test(lines[2]), "Stacktrace line has the right format:\n" + lines[2]);
 
   info("Test copy menu item without timestamp");
 
@@ -76,29 +76,29 @@ add_task(async function() {
 
   info("Test copy menu item for the simple log");
   message = await waitFor(() => findMessage(hud, "simple text message"));
   clipboardText = await copyMessageContent(hud, message);
   ok(true, "Clipboard text was found and saved");
 
   info("Check copied text for simple log message");
   lines = clipboardText.split("\n");
-  ok(lines.length, 2, "There are 2 lines in the copied text");
+  is(lines.length, 2, "There are 2 lines in the copied text");
   is(lines[1], "", "The last line is an empty new line");
   ok(LOG_FORMAT_WITHOUT_TIMESTAMP.test(lines[0]),
     "Log line has the right format:\n" + lines[0]);
 
   info("Test copy menu item for the stack trace message");
   message = await waitFor(() => findMessage(hud, "console.trace"));
   clipboardText = await copyMessageContent(hud, message);
   ok(true, "Clipboard text was found and saved");
 
   info("Check copied text for stack trace message");
   lines = clipboardText.split("\n");
-  ok(lines.length, 4, "There are 4 lines in the copied text");
+  is(lines.length, 4, "There are 4 lines in the copied text");
   is(lines[3], "", "The last line is an empty new line");
   ok(LOG_FORMAT_WITHOUT_TIMESTAMP.test(lines[0]),
     "Log line has the right format:\n" + lines[0]);
   ok(TRACE_FORMAT.test(lines[1]), "Stacktrace line has the right format:\n" + lines[1]);
   ok(TRACE_FORMAT.test(lines[2]), "Stacktrace line has the right format:\n" + lines[2]);
 
   observer.destroy();
   Services.prefs.clearUserPref(PREF_MESSAGE_TIMESTAMP);