Bug 1406069 - Enable browser_webconsole_cached_messages.js in new console frontend; r=jdescottes.
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Mon, 06 Nov 2017 09:43:16 +0100
changeset 443815 deaf42e9dbecacba453afa921cad45f3dfeebc6c
parent 443814 5e887aadb923fc933cc09d500c01c540791a76da
child 443816 888caf45e5efb1d4cb7c816e7d61e5895a02c13e
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes
bugs1406069
milestone58.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 1406069 - Enable browser_webconsole_cached_messages.js in new console frontend; r=jdescottes. MozReview-Commit-ID: EypyZoZUWeo
devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_cached_messages.js
devtools/client/webconsole/new-console-output/test/mochitest/head.js
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
@@ -225,17 +225,16 @@ tags = mcb
 skip-if = true #	Bug 1403452
 # old console skip-if = (os == 'win' && bits == 64) # Bug 1390001
 [browser_webconsole_batching.js]
 [browser_webconsole_block_mixedcontent_securityerrors.js]
 tags = mcb
 skip-if = true #	Bug 1403899
 # old console skip-if = (os == 'win' && bits == 64) # Bug 1390001
 [browser_webconsole_cached_messages.js]
-skip-if = true #	Bug 1406069
 [browser_webconsole_cd_iframe.js]
 skip-if = true #	Bug 1406030
 [browser_webconsole_certificate_messages.js]
 skip-if = true # Bug 1408925
 # old console skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
 [browser_webconsole_charset.js]
 skip-if = true #	Bug 1404400
 [browser_webconsole_chrome.js]
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_cached_messages.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_cached_messages.js
@@ -4,56 +4,46 @@
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Test to see if the cached messages are displayed when the console UI is
 // opened.
 
 "use strict";
 
 const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
-                 "test/test-webconsole-error-observer.html";
+                 "new-console-output/test/mochitest/test-webconsole-error-observer.html";
 
-// On e10s, the exception is triggered in child process
-// and is ignored by test harness
-if (!Services.appinfo.browserTabsRemoteAutostart) {
-  expectUncaughtException();
-}
+add_task(async function() {
+  // On e10s, the exception is triggered in child process
+  // and is ignored by test harness
+  if (!Services.appinfo.browserTabsRemoteAutostart) {
+    expectUncaughtException();
+  }
+  // Enable CSS filter for the test.
+  await pushPref("devtools.webconsole.filter.css", true);
 
-function test() {
-  waitForExplicitFinish();
+  await addTab(TEST_URI);
 
-  loadTab(TEST_URI).then(testOpenUI);
-}
+  info("Open the console");
+  let hud = await openConsole();
+  testMessagesVisibility(hud);
 
-function testOpenUI(aTestReopen) {
-  openConsole().then((hud) => {
-    waitForMessages({
-      webconsole: hud,
-      messages: [
-        {
-          text: "log Bazzle",
-          category: CATEGORY_WEBDEV,
-          severity: SEVERITY_LOG,
-        },
-        {
-          text: "error Bazzle",
-          category: CATEGORY_WEBDEV,
-          severity: SEVERITY_ERROR,
-        },
-        {
-          text: "bazBug611032",
-          category: CATEGORY_JS,
-          severity: SEVERITY_ERROR,
-        },
-        {
-          text: "cssColorBug611032",
-          category: CATEGORY_CSS,
-          severity: SEVERITY_WARNING,
-        },
-      ],
-    }).then(() => {
-      closeConsole(gBrowser.selectedTab).then(() => {
-        aTestReopen && info("will reopen the Web Console");
-        executeSoon(aTestReopen ? testOpenUI : finishTest);
-      });
-    });
-  });
+  info("Close the toolbox");
+  await closeToolbox();
+
+  info("Open the console again");
+  hud = await openConsole();
+  testMessagesVisibility(hud);
+});
+
+function testMessagesVisibility(hud) {
+  let message = findMessage(hud, "log Bazzle", ".message.log");
+  ok(message, "console.log message is visible");
+
+  message = findMessage(hud, "error Bazzle", ".message.error");
+  ok(message, "console.error message is visible");
+
+  message = findMessage(hud, "bazBug611032", ".message.error");
+  ok(message, "exception message is visible");
+
+  message = findMessage(hud, "cssColorBug611032", ".message.warn.css");
+  ok(message, "css warning message is visible");
 }
--- a/devtools/client/webconsole/new-console-output/test/mochitest/head.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/head.js
@@ -1,17 +1,17 @@
 /* -*- 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/ */
 /* import-globals-from ../../../../framework/test/shared-head.js */
 /* exported WCUL10n, openNewTabAndConsole, waitForMessages, waitForMessage, waitFor,
    findMessage, openContextMenu, hideContextMenu, loadDocument, hasFocus,
    waitForNodeMutation, testOpenInDebugger, checkClickOnNode, jstermSetValueAndComplete,
-   openDebugger */
+   openDebugger, openConsole */
 
 "use strict";
 
 // shared-head.js handles imports, constants, and utility functions
 // Load the shared-head file first.
 Services.scriptloader.loadSubScript(
   "chrome://mochitests/content/browser/devtools/client/framework/test/shared-head.js",
   this);
@@ -344,8 +344,23 @@ async function openDebugger(options = {}
   let panel = toolbox.getCurrentPanel();
 
   // Do not clear VariableView lazily so it doesn't disturb test ending.
   panel._view.Variables.lazyEmpty = false;
 
   await panel.panelWin.DebuggerController.waitForSourcesLoaded();
   return {target, toolbox, panel};
 }
+
+/**
+ * Open the Web Console for the given tab, or the current one if none given.
+ *
+ * @param nsIDOMElement tab
+ *        Optional tab element for which you want open the Web Console.
+ *        Defaults to current selected tab.
+ * @return Promise
+ *         A promise that is resolved with the console hud once the web console is open.
+ */
+async function openConsole(tab) {
+  let target = TargetFactory.forTab(tab || gBrowser.selectedTab);
+  const toolbox = await gDevTools.showToolbox(target, "webconsole");
+  return toolbox.getCurrentPanel().hud;
+};