Bug 1404877 - Migrate browser_webconsole_bug_658368_time_methods.js to the new frontend. r=nchevobbe
authorsole <spenades@mozilla.com>
Fri, 16 Feb 2018 14:25:09 +0000
changeset 404258 06c8e6e3303cb4787fb15038d074301e84342726
parent 404257 81617ea852ba672742f87dd247c0182f151aa882
child 404259 ed39a38f8647e094616752efd2a1f8f408b35ab8
push id99968
push userrgurzau@mozilla.com
push dateFri, 16 Feb 2018 22:14:56 +0000
treeherdermozilla-inbound@2e16779c96cc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnchevobbe
bugs1404877
milestone60.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 1404877 - Migrate browser_webconsole_bug_658368_time_methods.js to the new frontend. r=nchevobbe MozReview-Commit-ID: 3Z6097zECDn
devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_time_methods.js
devtools/client/webconsole/new-console-output/test/mochitest/test-bug-658368-time-methods.html
devtools/client/webconsole/new-console-output/test/mochitest/test-time-methods.html
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
@@ -25,17 +25,16 @@ support-files =
   test-console-trace-duplicates.html
   test-bug-585956-console-trace.html
   test-bug-599725-response-headers.sjs
   test-bug-601177-log-levels.html
   test-bug-601177-log-levels.js
   test-bug-630733-response-redirect-headers.sjs
   test-bug-632275-getters.html
   test-bug-646025-console-file-location.html
-  test-bug-658368-time-methods.html
   test-bug-766001-console-log.js
   test-bug-766001-js-console-links.html
   test-bug-766001-js-errors.js
   test-bug-782653-css-errors-1.css
   test-bug-782653-css-errors-2.css
   test-bug-782653-css-errors.html
   test-bug-837351-security-errors.html
   test-bug-859170-longstring-hang.html
@@ -148,16 +147,17 @@ support-files =
   test-sourcemap-error-01.html
   test-sourcemap-error-01.js
   test-sourcemap-error-02.html
   test-sourcemap-error-02.js
   test-stacktrace-location-debugger-link.html
   test-subresource-security-error.html
   test-subresource-security-error.js
   test-subresource-security-error.js^headers^
+  test-time-methods.html
   test-trackingprotection-securityerrors.html
   test-webconsole-error-observer.html
   test-websocket.html
   test-websocket.js
   testscript.js
   !/devtools/client/netmonitor/test/sjs_cors-test-server.sjs
   !/image/test/mochitest/blue.png
   !/devtools/client/framework/test/shared-head.js
@@ -346,16 +346,15 @@ subsuite = clipboard
 [browser_webconsole_split_escape_key.js]
 [browser_webconsole_split_focus.js]
 [browser_webconsole_split_persist.js]
 [browser_webconsole_stacktrace_location_debugger_link.js]
 [browser_webconsole_stacktrace_location_scratchpad_link.js]
 [browser_webconsole_strict_mode_errors.js]
 [browser_webconsole_string.js]
 [browser_webconsole_time_methods.js]
-skip-if = true #	Bug 1404877
 [browser_webconsole_timestamps.js]
 [browser_webconsole_trackingprotection_errors.js]
 tags = trackingprotection
 [browser_webconsole_view_source.js]
 [browser_webconsole_visibility_messages.js]
 [browser_webconsole_warn_about_replaced_api.js]
 [browser_webconsole_websocket.js]
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_time_methods.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_time_methods.js
@@ -1,67 +1,68 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
-// Tests that the Console API implements the time() and timeEnd() methods. See Bug 658368.
+// Tests that the Console API implements the time() and timeEnd() methods.
 
 "use strict";
 
 const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
-                 "test/test-bug-658368-time-methods.html";
+                 "new-console-output/test/mochitest/test-time-methods.html";
 
 const TEST_URI2 = "data:text/html;charset=utf-8,<script>" +
                   "console.timeEnd('bTimer');</script>";
 
 const TEST_URI3 = "data:text/html;charset=utf-8,<script>" +
-                  "console.time('bTimer');</script>";
+                  "console.time('bTimer');console.log('smoke signal');</script>";
 
 const TEST_URI4 = "data:text/html;charset=utf-8," +
                   "<script>console.timeEnd('bTimer');</script>";
 
-add_task(function* () {
-  yield loadTab(TEST_URI);
-
-  let hud1 = yield openConsole();
+add_task(async function () {
+  // Calling console.time('aTimer') followed by console.timeEnd('aTimer')
+  // should result in the aTimer being ended, and a message like aTimer: 123ms
+  // printed to the console
+  let hud1 = await openNewTabAndConsole(TEST_URI);
 
-  yield waitForMessages({
-    webconsole: hud1,
-    messages: [{
-      name: "aTimer started",
-      consoleTime: "aTimer",
-    }, {
-      name: "aTimer end",
-      consoleTimeEnd: "aTimer",
-    }],
-  });
+  let aTimerCompleted = await waitFor(() => findMessage(hud1, "aTimer: "));
+  ok(aTimerCompleted, "Calling console.time('a') and console.timeEnd('a')"
+    + "ends the 'a' timer");
+
+  // Calling console.time('bTimer') in the current tab, opening a new tab
+  // and calling console.timeEnd('bTimer') in the new tab should not result in
+  // the bTimer in the initial tab being ended, but rather a warning message
+  // output to the console: Timer "bTimer" doesn't exist
+  let hud2 = await openNewTabAndConsole(TEST_URI2);
 
-  // The next test makes sure that timers with the same name but in separate
-  // tabs, do not contain the same value.
-  let { browser } = yield loadTab(TEST_URI2);
-  let hud2 = yield openConsole();
+  let error1 = await waitFor(() => findMessage(hud2, "bTimer", ".message.timeEnd.warn"));
+  ok(error1, "Timers with the same name but in separate tabs do not contain "
+    + "the same value");
 
-  testLogEntry(hud2.outputNode, "bTimer: timer started",
-               "bTimer was not started", false, true);
+  // The next tests make sure that timers with the same name but in separate
+  // pages do not contain the same value.
+  await BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_URI3);
 
-  // The next test makes sure that timers with the same name but in separate
-  // pages, do not contain the same value.
-  BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_URI3);
+  // The new console front-end does not display a message when timers are started,
+  // so there should not be a 'bTimer started' message on the output
 
-  yield waitForMessages({
-    webconsole: hud2,
-    messages: [{
-      name: "bTimer started",
-      consoleTime: "bTimer",
-    }],
-  });
+  // We use this await to 'sync' until the message appears, as the console API
+  // guarantees us that the smoke signal will be printed after the message for
+  // console.time("bTimer") (if there were any)
+  await waitFor(() => findMessage(hud2, "smoke signal"));
+
+  is(findMessage(hud2, "bTimer started"), null, "No message is printed to "
+    + "the console when the timer starts");
 
   hud2.jsterm.clearOutput();
 
-  // Now the following console.timeEnd() call shouldn't display anything,
-  // if the timers in different pages are not related.
-  BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_URI4);
-  yield loadBrowser(browser);
+  // Calling console.time('bTimer') on a page, then navigating to another page
+  // and calling console.timeEnd('bTimer') on the new console front-end should
+  // result on a warning message: 'Timer "bTimer" does not exist',
+  // as the timers in different pages are not related
+  await BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_URI4);
 
-  testLogEntry(hud2.outputNode, "bTimer: timer started",
-               "bTimer was not started", false, true);
+  let error2 = await waitFor(() => findMessage(hud2, "bTimer", ".message.timeEnd.warn"));
+  ok(error2, "Timers with the same name but in separate pages do not contain "
+    + "the same value");
 });
rename from devtools/client/webconsole/new-console-output/test/mochitest/test-bug-658368-time-methods.html
rename to devtools/client/webconsole/new-console-output/test/mochitest/test-time-methods.html