Bug 1404384 - enable browser_webconsole_message_categories;r=bgrins

MozReview-Commit-ID: 5TCviNEy4tg

--HG--
rename : devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-canvas-css.html => devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-canvas-css.html
rename : devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-canvas-css.js => devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-canvas-css.js
rename : devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-css-loader.css => devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-css-loader.css
rename : devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-css-loader.css^headers^ => devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-css-loader.css^headers^
rename : devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-css-loader.html => devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-css-loader.html
rename : devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-css-parser.css => devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-css-parser.css
rename : devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-css-parser.html => devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-css-parser.html
rename : devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-empty-getelementbyid.html => devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-empty-getelementbyid.html
rename : devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-empty-getelementbyid.js => devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-empty-getelementbyid.js
rename : devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-html.html => devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-html.html
rename : devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-image.html => devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-image.html
rename : devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-image.jpg => devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-image.jpg
rename : devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-imagemap.html => devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-imagemap.html
rename : devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-malformedxml-external.html => devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-malformedxml-external.html
rename : devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-malformedxml-external.xml => devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-malformedxml-external.xml
rename : devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-malformedxml.xhtml => devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-malformedxml.xhtml
rename : devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-svg.xhtml => devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-svg.xhtml
rename : devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-workers.html => devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-workers.html
rename : devtools/client/webconsole/new-console-output/test/mochitest/test-bug-595934-workers.js => devtools/client/webconsole/new-console-output/test/mochitest/test-message-categories-workers.js
extra : rebase_source : 9da465d9411599e1056ac724a88b2808aa0e2595
This commit is contained in:
Julian Descottes 2018-01-19 12:59:41 +01:00
Родитель 9d81b07e04
Коммит 11f7cdb11c
21 изменённых файлов: 94 добавлений и 165 удалений

Просмотреть файл

@ -25,25 +25,6 @@ support-files =
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
@ -137,6 +118,25 @@ support-files =
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
@ -314,8 +314,6 @@ 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

Просмотреть файл

@ -5,208 +5,139 @@
"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]),
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);
}
}
};
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;
pos++;
info("testNext: #" + pos);
if (pos < TESTS.length) {
test = TESTS[pos];
waitForMessages({
webconsole: hud,
messages: [{
name: "message for test #" + pos + ": '" + test.matchString + "'",
text: test.matchString,
}],
}).then(() => {
foundText = true;
startNextTest();
});
let testLocation = TESTS_PATH + test.file;
gBrowser.selectedBrowser.addEventListener("load", function onLoad(evt) {
if (content.location.href != testLocation) {
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;
}
startNextTest();
}, true);
BrowserTestUtils.loadURI(gBrowser.selectedBrowser, testLocation);
} else {
testEnded = true;
finishTest();
}
}
function testEnd() {
if (!testEnded) {
info("foundCategory " + foundCategory + " foundText " + foundText +
" pageLoaded " + pageLoaded + " pageError " + pageError);
}
Services.console.unregisterListener(TestObserver);
hud = TestObserver = output = jsterm = null;
}
function startNextTest() {
if (!testEnded && foundCategory && foundText && pageLoaded && pageError) {
testNext();
}
}
function test() {
add_task(async function () {
requestLongerTimeout(2);
loadTab(TEST_URI).then(() => {
openConsole().then(consoleOpened);
await pushPref("devtools.webconsole.filter.css", true);
await pushPref("devtools.webconsole.filter.net", true);
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);
}
});
async function runTest(test, hud) {
let {file, category, matchString, onload, skipInE10s} = test;
if (skipInE10s && Services.appinfo.browserTabsRemoteAutostart) {
return;
}
let onMessageLogged = waitForMessage(hud, matchString);
let onMessageObserved = new Promise(resolve => {
Services.console.registerListener(function listener(subject) {
if (!(subject instanceof Ci.nsIScriptError)) {
return;
}
if (subject.category != category) {
return;
}
ok(true, "Expected category [" + category + "] received in observer");
Services.console.unregisterListener(listener);
resolve();
});
});
info("Load test file " + file);
await loadDocument(TESTS_PATH + file);
// Call test specific callback if defined
if (onload) {
onload();
}
info("Wait for log message to be observed with the correct category");
await onMessageObserved;
info("Wait for log message to be displayed in the hud");
await onMessageLogged;
}

Просмотреть файл

@ -7,7 +7,7 @@
<!-- 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

Просмотреть файл

@ -5,7 +5,7 @@
<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>

Просмотреть файл

@ -6,7 +6,7 @@
<!-- 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>

Просмотреть файл

@ -7,7 +7,7 @@
<!-- 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"

Просмотреть файл

@ -8,7 +8,7 @@
</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>

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 2.5 KiB

После

Ширина:  |  Высота:  |  Размер: 2.5 KiB

Просмотреть файл

@ -8,7 +8,7 @@
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>

Просмотреть файл

@ -10,7 +10,7 @@
<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>