Bug 1404384 - enable browser_webconsole_message_categories;r=bgrins
MozReview-Commit-ID: 5TCviNEy4tg
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
@@ -20,35 +20,16 @@ support-files =
test_hsts-invalid-headers.sjs
test-autocomplete-in-stackframe.html
test-batching.html
test-bug_923281_console_log_filter.html
test-bug_923281_test1.js
test-bug_923281_test2.js
test-bug_939783_console_trace_duplicates.html
test-bug-585956-console-trace.html
- test-bug-595934-canvas-css.html
- test-bug-595934-canvas-css.js
- test-bug-595934-css-loader.css
- test-bug-595934-css-loader.css^headers^
- test-bug-595934-css-loader.html
- test-bug-595934-css-parser.css
- test-bug-595934-css-parser.html
- test-bug-595934-empty-getelementbyid.html
- test-bug-595934-empty-getelementbyid.js
- test-bug-595934-html.html
- test-bug-595934-image.html
- test-bug-595934-image.jpg
- test-bug-595934-imagemap.html
- test-bug-595934-malformedxml-external.html
- test-bug-595934-malformedxml-external.xml
- test-bug-595934-malformedxml.xhtml
- test-bug-595934-svg.xhtml
- test-bug-595934-workers.html
- test-bug-595934-workers.js
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-644419-log-limits.html
test-bug-646025-console-file-location.html
test-bug-658368-time-methods.html
@@ -132,16 +113,35 @@ support-files =
test-inspect-cross-domain-objects-top.html
test-jsterm-dollar.html
test-location-debugger-link-console-log.js
test-location-debugger-link-errors.js
test-location-debugger-link.html
test-location-styleeditor-link-1.css
test-location-styleeditor-link-2.css
test-location-styleeditor-link.html
+ test-message-categories-canvas-css.html
+ test-message-categories-canvas-css.js
+ test-message-categories-css-loader.css
+ test-message-categories-css-loader.css^headers^
+ test-message-categories-css-loader.html
+ test-message-categories-css-parser.css
+ test-message-categories-css-parser.html
+ test-message-categories-empty-getelementbyid.html
+ test-message-categories-empty-getelementbyid.js
+ test-message-categories-html.html
+ test-message-categories-image.html
+ test-message-categories-image.jpg
+ test-message-categories-imagemap.html
+ test-message-categories-malformedxml-external.html
+ test-message-categories-malformedxml-external.xml
+ test-message-categories-malformedxml.xhtml
+ test-message-categories-svg.xhtml
+ test-message-categories-workers.html
+ test-message-categories-workers.js
test-mixedcontent-securityerrors.html
test-mutation.html
test-network-exceptions.html
test-network-request.html
test-network.html
test-observe-http-ajax.html
test-own-console.html
test-property-provider.html
@@ -309,18 +309,16 @@ skip-if = true # Bug 1404831
[browser_webconsole_location_scratchpad_link.js]
[browser_webconsole_location_styleeditor_link.js]
[browser_webconsole_logErrorInPage.js]
[browser_webconsole_longstring_expand.js]
skip-if = true # Bug 1403448
[browser_webconsole_longstring_hang.js]
skip-if = true # Bug 1403448
[browser_webconsole_message_categories.js]
-skip-if = true # Bug 1404384
-# old console skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
[browser_webconsole_mixedcontent.js]
tags = mcb
skip-if = true # Bug 1404886
[browser_webconsole_multiple_windows_and_tabs.js]
[browser_webconsole_network_attach.js]
[browser_webconsole_network_exceptions.js]
[browser_webconsole_network_messages_expand.js]
[browser_webconsole_network_messages_openinnet.js]
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_message_categories.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_message_categories.js
@@ -1,212 +1,143 @@
/* -*- 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/ */
"use strict";
-// See Bug 595934.
+// Check that messages are logged and observed with the correct category. See Bug 595934.
const TEST_URI = "data:text/html;charset=utf-8,Web Console test for " +
"bug 595934 - message categories coverage.";
const TESTS_PATH = "http://example.com/browser/devtools/client/webconsole/" +
- "test/";
+ "new-console-output/test/mochitest/";
const TESTS = [
{
// #0
- file: "test-bug-595934-css-loader.html",
+ file: "test-message-categories-css-loader.html",
category: "CSS Loader",
matchString: "text/css",
},
{
// #1
- file: "test-bug-595934-imagemap.html",
+ file: "test-message-categories-imagemap.html",
category: "Layout: ImageMap",
matchString: "shape=\"rect\"",
},
{
// #2
- file: "test-bug-595934-html.html",
+ file: "test-message-categories-html.html",
category: "HTML",
matchString: "multipart/form-data",
onload: function () {
- let form = content.document.querySelector("form");
- form.submit();
+ ContentTask.spawn(gBrowser.selectedBrowser, null, function* () {
+ let form = content.document.querySelector("form");
+ form.submit();
+ });
},
},
{
// #3
- file: "test-bug-595934-workers.html",
+ file: "test-message-categories-workers.html",
category: "Web Worker",
matchString: "fooBarWorker",
},
{
// #4
- file: "test-bug-595934-malformedxml.xhtml",
+ file: "test-message-categories-malformedxml.xhtml",
category: "malformed-xml",
matchString: "no root element found",
},
{
// #5
- file: "test-bug-595934-svg.xhtml",
+ file: "test-message-categories-svg.xhtml",
category: "SVG",
matchString: "fooBarSVG",
},
{
// #6
- file: "test-bug-595934-css-parser.html",
+ file: "test-message-categories-css-parser.html",
category: "CSS Parser",
matchString: "foobarCssParser",
},
{
// #7
- file: "test-bug-595934-malformedxml-external.html",
+ file: "test-message-categories-malformedxml-external.html",
category: "malformed-xml",
matchString: "</html>",
},
{
// #8
- file: "test-bug-595934-empty-getelementbyid.html",
+ file: "test-message-categories-empty-getelementbyid.html",
category: "DOM",
matchString: "getElementById",
},
{
// #9
- file: "test-bug-595934-canvas-css.html",
+ file: "test-message-categories-canvas-css.html",
category: "CSS Parser",
matchString: "foobarCanvasCssParser",
},
{
// #10
- file: "test-bug-595934-image.html",
+ file: "test-message-categories-image.html",
category: "Image",
matchString: "corrupt",
+ // This message is not displayed in the main console in e10s. Bug 1431731
+ skipInE10s: true,
},
];
-var pos = -1;
-
-var foundCategory = false;
-var foundText = false;
-var pageLoaded = false;
-var pageError = false;
-var output = null;
-var jsterm = null;
-var hud = null;
-var testEnded = false;
-
-var TestObserver = {
- QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
+add_task(async function () {
+ requestLongerTimeout(2);
- observe: function testObserve(subject) {
- if (testEnded || !(subject instanceof Ci.nsIScriptError)) {
- return;
- }
-
- let expectedCategory = TESTS[pos].category;
-
- info("test #" + pos + " console observer got " + subject.category +
- ", is expecting " + expectedCategory);
-
- if (subject.category == expectedCategory) {
- foundCategory = true;
- startNextTest();
- } else {
- info("unexpected message was: " + subject.sourceName + ":" +
- subject.lineNumber + "; " + subject.errorMessage);
- }
- }
-};
+ await pushPref("devtools.webconsole.filter.css", true);
+ await pushPref("devtools.webconsole.filter.net", true);
-function consoleOpened(hudConsole) {
- hud = hudConsole;
- output = hud.outputNode;
- jsterm = hud.jsterm;
-
- Services.console.registerListener(TestObserver);
-
- registerCleanupFunction(testEnd);
-
- testNext();
-}
-
-function testNext() {
- jsterm.clearOutput();
- foundCategory = false;
- foundText = false;
- pageLoaded = false;
- pageError = false;
+ let hud = await openNewTabAndConsole(TEST_URI);
+ for (let i = 0; i < TESTS.length; i++) {
+ let test = TESTS[i];
+ info("Running test #" + i);
+ await runTest(test, hud);
+ }
+});
- pos++;
- info("testNext: #" + pos);
- if (pos < TESTS.length) {
- test = TESTS[pos];
+async function runTest(test, hud) {
+ let {file, category, matchString, onload, skipInE10s} = test;
- waitForMessages({
- webconsole: hud,
- messages: [{
- name: "message for test #" + pos + ": '" + test.matchString + "'",
- text: test.matchString,
- }],
- }).then(() => {
- foundText = true;
- startNextTest();
- });
+ if (skipInE10s && Services.appinfo.browserTabsRemoteAutostart) {
+ return;
+ }
- let testLocation = TESTS_PATH + test.file;
- gBrowser.selectedBrowser.addEventListener("load", function onLoad(evt) {
- if (content.location.href != testLocation) {
+ let onMessageLogged = waitForMessage(hud, matchString);
+
+ let onMessageObserved = new Promise(resolve => {
+ Services.console.registerListener(function listener(subject) {
+ if (!(subject instanceof Ci.nsIScriptError)) {
return;
}
- gBrowser.selectedBrowser.removeEventListener(evt.type, onLoad, true);
- pageLoaded = true;
- test.onload && test.onload(evt);
-
- if (test.expectError) {
- content.addEventListener("error", function () {
- pageError = true;
- startNextTest();
- }, {once: true});
- // On e10s, the exception is triggered in child process
- // and is ignored by test harness
- if (!Services.appinfo.browserTabsRemoteAutostart) {
- expectUncaughtException();
- }
- } else {
- pageError = true;
+ if (subject.category != category) {
+ return;
}
- startNextTest();
- }, true);
+ ok(true, "Expected category [" + category + "] received in observer");
+ Services.console.unregisterListener(listener);
+ resolve();
+ });
+ });
- BrowserTestUtils.loadURI(gBrowser.selectedBrowser, testLocation);
- } else {
- testEnded = true;
- finishTest();
- }
-}
+ info("Load test file " + file);
+ await loadDocument(TESTS_PATH + file);
-function testEnd() {
- if (!testEnded) {
- info("foundCategory " + foundCategory + " foundText " + foundText +
- " pageLoaded " + pageLoaded + " pageError " + pageError);
+ // Call test specific callback if defined
+ if (onload) {
+ onload();
}
- Services.console.unregisterListener(TestObserver);
- hud = TestObserver = output = jsterm = null;
-}
+ info("Wait for log message to be observed with the correct category");
+ await onMessageObserved;
-function startNextTest() {
- if (!testEnded && foundCategory && foundText && pageLoaded && pageError) {
- testNext();
- }
+ info("Wait for log message to be displayed in the hud");
+ await onMessageLogged;
}
-
-function test() {
- requestLongerTimeout(2);
-
- loadTab(TEST_URI).then(() => {
- openConsole().then(consoleOpened);
- });
-}
rename from devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-canvas-css.html
rename to devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-canvas-css.html
--- a/devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-canvas-css.html
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-canvas-css.html
@@ -2,16 +2,16 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>Web Console test for bug 595934 - category: CSS Parser (with
Canvas)</title>
<!-- Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ -->
<script type="text/javascript"
- src="test-bug-595934-canvas-css.js"></script>
+ src="test-message-categories-canvas-css.js"></script>
</head>
<body>
<p>Web Console test for bug 595934 - category "CSS Parser" (with
Canvas).</p>
<p><canvas width="200" height="200">Canvas support is required!</canvas></p>
</body>
</html>
rename from devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-canvas-css.js
rename to devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-canvas-css.js
rename from devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-css-loader.css
rename to devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-css-loader.css
rename from devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-css-loader.css^headers^
rename to devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-css-loader.css^headers^
rename from devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-css-loader.html
rename to devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-css-loader.html
--- a/devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-css-loader.html
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-css-loader.html
@@ -1,13 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Web Console test for bug 595934 - category: CSS Loader</title>
<!-- Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ -->
- <link rel="stylesheet" href="test-bug-595934-css-loader.css">
+ <link rel="stylesheet" href="test-message-categories-css-loader.css">
</head>
<body>
<p>Web Console test for bug 595934 - category "CSS Loader".</p>
</body>
</html>
rename from devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-css-parser.css
rename to devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-css-parser.css
rename from devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-css-parser.html
rename to devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-css-parser.html
--- a/devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-css-parser.html
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-css-parser.html
@@ -1,14 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Web Console test for bug 595934 - category: CSS Parser</title>
<!-- Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ -->
<link rel="stylesheet" type="text/css"
- href="test-bug-595934-css-parser.css">
+ href="test-message-categories-css-parser.css">
</head>
<body>
<p>Web Console test for bug 595934 - category "CSS Parser".</p>
</body>
</html>
rename from devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-empty-getelementbyid.html
rename to devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-empty-getelementbyid.html
--- a/devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-empty-getelementbyid.html
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-empty-getelementbyid.html
@@ -2,15 +2,15 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>Web Console test for bug 595934 - category: DOM.
(empty getElementById())</title>
<!-- Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ -->
<script type="text/javascript"
- src="test-bug-595934-empty-getelementbyid.js"></script>
+ src="test-message-categories-empty-getelementbyid.js"></script>
</head>
<body>
<p>Web Console test for bug 595934 - category "DOM"
(empty getElementById()).</p>
</body>
</html>
rename from devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-empty-getelementbyid.js
rename to devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-empty-getelementbyid.js
rename from devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-html.html
rename to devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-html.html
rename from devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-image.html
rename to devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-image.html
--- a/devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-image.html
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-image.html
@@ -3,13 +3,13 @@
<head>
<meta charset="utf-8">
<title>Web Console test for bug 595934 - category: Image</title>
<!-- Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ -->
</head>
<body>
<p>Web Console test for bug 595934 - category Image.</p>
- <p><img src="test-bug-595934-image.jpg" alt="corrupted image"></p>
+ <p><img src="test-message-categories-image.jpg" alt="corrupted image"></p>
</body>
</html>
rename from devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-image.jpg
rename to devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-image.jpg
rename from devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-imagemap.html
rename to devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-imagemap.html
rename from devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-malformedxml-external.html
rename to devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-malformedxml-external.html
--- a/devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-malformedxml-external.html
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-malformedxml-external.html
@@ -3,17 +3,17 @@
<head>
<meta charset="utf-8">
<title>Web Console test for bug 595934 - category: malformed-xml.
(external file)</title>
<!-- Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ -->
<script type="text/javascript"><!--
var req = new XMLHttpRequest();
- req.open("GET", "test-bug-595934-malformedxml-external.xml", true);
+ req.open("GET", "test-message-categories-malformedxml-external.xml", true);
req.send(null);
// --></script>
</head>
<body>
<p>Web Console test for bug 595934 - category "malformed-xml"
(external file).</p>
</body>
</html>
rename from devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-malformedxml-external.xml
rename to devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-malformedxml-external.xml
rename from devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-malformedxml.xhtml
rename to devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-malformedxml.xhtml
rename from devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-svg.xhtml
rename to devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-svg.xhtml
rename from devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-workers.html
rename to devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-workers.html
--- a/devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-workers.html
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-workers.html
@@ -5,14 +5,14 @@
javascript</title>
<!-- Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ -->
</head>
<body>
<p id="foobar">Web Console test for bug 595934 - category "DOM Worker
javascript".</p>
<script type="text/javascript">
- var myWorker = new Worker("test-bug-595934-workers.js");
+ var myWorker = new Worker("test-message-categories-workers.js");
myWorker.postMessage("hello world");
</script>
</body>
</html>
rename from devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-workers.js
rename to devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-workers.js