Bug 1406069 - Enable browser_webconsole_cached_messages.js in new console frontend; r=jdescottes.
MozReview-Commit-ID: EypyZoZUWeo
--- 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;
+};