зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1403450 - Add test cases from browser_webconsole_repeated_messages_accuracy.js to mocha; r=jdescottes.
This test had some cases that weren't covered in our mocha tests, so we add them. In order to do that, we added a stub. We remove the mochitest and its support file. Since the support file was used by another test, we modify it to add the part that was used. MozReview-Commit-ID: AL4qWcWHQiA --HG-- extra : rebase_source : 632e10a25c724044979d2ef4a02648e95ff88bbb
This commit is contained in:
Родитель
344ccb9379
Коммит
2b3f80a3b5
|
@ -178,7 +178,8 @@ const evaluationResultCommands = [
|
|||
"asdf()",
|
||||
"1 + @",
|
||||
"inspect({a: 1})",
|
||||
"cd(document)"
|
||||
"cd(document)",
|
||||
"undefined"
|
||||
];
|
||||
|
||||
let evaluationResult = new Map(evaluationResultCommands.map(cmd => [cmd, cmd]));
|
||||
|
|
|
@ -166,6 +166,28 @@ stubPreparedMessages.set(`cd(document)`, new ConsoleMessage({
|
|||
"indent": 0
|
||||
}));
|
||||
|
||||
stubPreparedMessages.set(`undefined`, new ConsoleMessage({
|
||||
"id": "1",
|
||||
"allowRepeating": true,
|
||||
"source": "javascript",
|
||||
"timeStamp": 1518606917356,
|
||||
"type": "result",
|
||||
"helperType": null,
|
||||
"level": "log",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "undefined"
|
||||
}
|
||||
],
|
||||
"repeatId": "{\"frame\":null,\"groupId\":null,\"indent\":0,\"level\":\"log\",\"parameters\":[{\"type\":\"undefined\"}],\"source\":\"javascript\",\"type\":\"result\",\"userProvidedStyles\":null}",
|
||||
"stacktrace": null,
|
||||
"frame": null,
|
||||
"groupId": null,
|
||||
"userProvidedStyles": null,
|
||||
"notes": null,
|
||||
"indent": 0
|
||||
}));
|
||||
|
||||
stubPreparedMessages.set(`longString message Error`, new ConsoleMessage({
|
||||
"id": "1",
|
||||
"allowRepeating": true,
|
||||
|
@ -390,6 +412,19 @@ stubPackets.set(`cd(document)`, {
|
|||
"notes": null
|
||||
});
|
||||
|
||||
stubPackets.set(`undefined`, {
|
||||
"from": "server1.conn0.child1/consoleActor2",
|
||||
"input": "undefined",
|
||||
"result": {
|
||||
"type": "undefined"
|
||||
},
|
||||
"timestamp": 1518606917356,
|
||||
"exception": null,
|
||||
"frame": null,
|
||||
"helperResult": null,
|
||||
"notes": null
|
||||
});
|
||||
|
||||
stubPackets.set(`longString message Error`, {
|
||||
"from": "server1.conn0.child1/consoleActor2",
|
||||
"input": "throw new Error(\"Long error \".repeat(10000))",
|
||||
|
|
|
@ -144,7 +144,6 @@ support-files =
|
|||
test-own-console.html
|
||||
test-property-provider.html
|
||||
test-reopen-closed-tab.html
|
||||
test-repeated-messages.html
|
||||
test-result-format-as-string.html
|
||||
test-sourcemap-error-01.html
|
||||
test-sourcemap-error-01.js
|
||||
|
@ -332,8 +331,6 @@ subsuite = clipboard
|
|||
[browser_webconsole_persist.js]
|
||||
[browser_webconsole_reopen_closed_tab.js]
|
||||
[browser_webconsole_repeat_different_objects.js]
|
||||
[browser_webconsole_repeated_messages_accuracy.js]
|
||||
skip-if = true # Bug 1403450
|
||||
[browser_webconsole_sandbox_update_after_navigation.js]
|
||||
[browser_webconsole_script_errordoc_urls.js]
|
||||
[browser_webconsole_scroll.js]
|
||||
|
|
|
@ -8,14 +8,12 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
|
||||
"new-console-output/test/mochitest/test-repeated-messages.html";
|
||||
const TEST_URI = "data:text/html,Test repeated objects";
|
||||
|
||||
add_task(async function () {
|
||||
let hud = await openNewTabAndConsole(TEST_URI);
|
||||
hud.jsterm.clearOutput();
|
||||
const hud = await openNewTabAndConsole(TEST_URI);
|
||||
|
||||
let onMessages = waitForMessages({
|
||||
const onMessages = waitForMessages({
|
||||
hud,
|
||||
messages: [
|
||||
{ text: "abba" },
|
||||
|
@ -24,10 +22,14 @@ add_task(async function () {
|
|||
],
|
||||
});
|
||||
|
||||
hud.jsterm.execute("window.testConsoleObjects()");
|
||||
ContentTask.spawn(gBrowser.selectedBrowser, null, () => {
|
||||
for (var i = 0; i < 3; i++) {
|
||||
const o = { id: "abba" };
|
||||
content.console.log("abba", o);
|
||||
}
|
||||
});
|
||||
|
||||
info("waiting for 3 console.log objects, with the exact same text content");
|
||||
let messages = await onMessages;
|
||||
|
||||
is(messages.length, 3, "3 message elements");
|
||||
is(messages.length, 3, "There are 3 messages, as expected.");
|
||||
});
|
||||
|
|
|
@ -1,178 +0,0 @@
|
|||
/* -*- 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/ */
|
||||
|
||||
// Test that makes sure messages are not considered repeated when coming from
|
||||
// different lines of code, or from different severities, etc.
|
||||
// See bugs 720180 and 800510.
|
||||
|
||||
"use strict";
|
||||
|
||||
const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
|
||||
"test/test-repeated-messages.html";
|
||||
const PREF = "devtools.webconsole.persistlog";
|
||||
|
||||
add_task(function* () {
|
||||
Services.prefs.setBoolPref(PREF, true);
|
||||
|
||||
let { browser } = yield loadTab(TEST_URI);
|
||||
|
||||
let hud = yield openConsole();
|
||||
|
||||
yield consoleOpened(hud);
|
||||
|
||||
let loaded = loadBrowser(browser);
|
||||
BrowserReload();
|
||||
yield loaded;
|
||||
|
||||
yield testCSSRepeats(hud);
|
||||
yield testCSSRepeatsAfterReload(hud);
|
||||
yield testConsoleRepeats(hud);
|
||||
yield testConsoleFalsyValues(hud);
|
||||
|
||||
Services.prefs.clearUserPref(PREF);
|
||||
});
|
||||
|
||||
function consoleOpened(hud) {
|
||||
// Check that css warnings are not coalesced if they come from different
|
||||
// lines.
|
||||
info("waiting for 2 css warnings");
|
||||
|
||||
return waitForMessages({
|
||||
webconsole: hud,
|
||||
messages: [{
|
||||
name: "two css warnings",
|
||||
category: CATEGORY_CSS,
|
||||
count: 2,
|
||||
repeats: 1,
|
||||
}],
|
||||
});
|
||||
}
|
||||
|
||||
function testCSSRepeats(hud) {
|
||||
info("wait for repeats after page reload");
|
||||
|
||||
return waitForMessages({
|
||||
webconsole: hud,
|
||||
messages: [{
|
||||
name: "two css warnings, repeated twice",
|
||||
category: CATEGORY_CSS,
|
||||
repeats: 2,
|
||||
count: 2,
|
||||
}],
|
||||
});
|
||||
}
|
||||
|
||||
function testCSSRepeatsAfterReload(hud) {
|
||||
hud.jsterm.clearOutput(true);
|
||||
hud.jsterm.execute("testConsole()");
|
||||
|
||||
info("wait for repeats with the console API");
|
||||
|
||||
return waitForMessages({
|
||||
webconsole: hud,
|
||||
messages: [
|
||||
{
|
||||
name: "console.log 'foo repeat' repeated twice",
|
||||
category: CATEGORY_WEBDEV,
|
||||
severity: SEVERITY_LOG,
|
||||
repeats: 2,
|
||||
},
|
||||
{
|
||||
name: "console.log 'foo repeat' repeated once",
|
||||
category: CATEGORY_WEBDEV,
|
||||
severity: SEVERITY_LOG,
|
||||
repeats: 1,
|
||||
},
|
||||
{
|
||||
name: "console.error 'foo repeat' repeated once",
|
||||
category: CATEGORY_WEBDEV,
|
||||
severity: SEVERITY_ERROR,
|
||||
repeats: 1,
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
function testConsoleRepeats(hud) {
|
||||
hud.jsterm.clearOutput(true);
|
||||
hud.jsterm.execute("undefined");
|
||||
|
||||
ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
|
||||
content.console.log("undefined");
|
||||
});
|
||||
|
||||
info("make sure console API messages are not coalesced with jsterm output");
|
||||
|
||||
return waitForMessages({
|
||||
webconsole: hud,
|
||||
messages: [
|
||||
{
|
||||
name: "'undefined' jsterm input message",
|
||||
text: "undefined",
|
||||
category: CATEGORY_INPUT,
|
||||
},
|
||||
{
|
||||
name: "'undefined' jsterm output message",
|
||||
text: "undefined",
|
||||
category: CATEGORY_OUTPUT,
|
||||
},
|
||||
{
|
||||
name: "'undefined' console.log message",
|
||||
text: "undefined",
|
||||
category: CATEGORY_WEBDEV,
|
||||
repeats: 1,
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
function testConsoleFalsyValues(hud) {
|
||||
hud.jsterm.clearOutput(true);
|
||||
hud.jsterm.execute("testConsoleFalsyValues()");
|
||||
|
||||
info("wait for repeats of falsy values with the console API");
|
||||
|
||||
return waitForMessages({
|
||||
webconsole: hud,
|
||||
messages: [
|
||||
{
|
||||
name: "console.log 'NaN' repeated once",
|
||||
category: CATEGORY_WEBDEV,
|
||||
severity: SEVERITY_LOG,
|
||||
repeats: 1,
|
||||
},
|
||||
{
|
||||
name: "console.log 'undefined' repeated once",
|
||||
category: CATEGORY_WEBDEV,
|
||||
severity: SEVERITY_LOG,
|
||||
repeats: 1,
|
||||
},
|
||||
{
|
||||
name: "console.log 'null' repeated once",
|
||||
category: CATEGORY_WEBDEV,
|
||||
severity: SEVERITY_LOG,
|
||||
repeats: 1,
|
||||
},
|
||||
{
|
||||
name: "console.log 'NaN' repeated twice",
|
||||
category: CATEGORY_WEBDEV,
|
||||
severity: SEVERITY_LOG,
|
||||
repeats: 2,
|
||||
},
|
||||
{
|
||||
name: "console.log 'undefined' repeated twice",
|
||||
category: CATEGORY_WEBDEV,
|
||||
severity: SEVERITY_LOG,
|
||||
repeats: 2,
|
||||
},
|
||||
{
|
||||
name: "console.log 'null' repeated twice",
|
||||
category: CATEGORY_WEBDEV,
|
||||
severity: SEVERITY_LOG,
|
||||
repeats: 2,
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html dir="ltr" xml:lang="en-US" lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf8">
|
||||
<title>Test for bugs 720180, 800510, 865288 and 1218089</title>
|
||||
<script>
|
||||
function testConsole() {
|
||||
// same line and column number
|
||||
for(var i = 0; i < 2; i++) {
|
||||
console.log("foo repeat");
|
||||
}
|
||||
console.log("foo repeat");
|
||||
console.error("foo repeat");
|
||||
}
|
||||
function testConsoleObjects() {
|
||||
for (var i = 0; i < 3; i++) {
|
||||
var o = { id: "abba" };
|
||||
console.log("abba", o);
|
||||
}
|
||||
}
|
||||
function testConsoleFalsyValues(){
|
||||
[NaN, undefined, null].forEach(function(item, index){
|
||||
console.log(item);
|
||||
});
|
||||
[NaN, NaN].forEach(function(item, index){
|
||||
console.log(item);
|
||||
});
|
||||
[undefined, undefined].forEach(function(item, index){
|
||||
console.log(item);
|
||||
});
|
||||
[null, null].forEach(function(item, index){
|
||||
console.log(item);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
body {
|
||||
background-image: foobarz;
|
||||
}
|
||||
p {
|
||||
background-image: foobarz;
|
||||
}
|
||||
</style>
|
||||
<!--
|
||||
- Any copyright is dedicated to the Public Domain.
|
||||
- http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
</head>
|
||||
<body>
|
||||
<p>Hello world!</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -64,6 +64,31 @@ describe("Message reducer:", () => {
|
|||
expect(repeat[getFirstMessage(getState()).id]).toBe(4);
|
||||
});
|
||||
|
||||
it("doesn't increment repeat on same log message with different locations", () => {
|
||||
const key1 = "console.log('foobar', 'test')";
|
||||
const { dispatch, getState } = setupStore();
|
||||
|
||||
const packet = clonePacket(stubPackets.get(key1));
|
||||
|
||||
// Dispatch original packet.
|
||||
dispatch(actions.messagesAdd([packet]));
|
||||
|
||||
// Dispatch same packet with modified column number.
|
||||
packet.message.columnNumber = packet.message.columnNumber + 1;
|
||||
dispatch(actions.messagesAdd([packet]));
|
||||
|
||||
// Dispatch same packet with modified line number.
|
||||
packet.message.lineNumber = packet.message.lineNumber + 1;
|
||||
dispatch(actions.messagesAdd([packet]));
|
||||
|
||||
const messages = getAllMessagesById(getState());
|
||||
|
||||
expect(messages.size).toBe(3);
|
||||
|
||||
const repeat = getAllRepeatById(getState());
|
||||
expect(Object.keys(repeat).length).toBe(0);
|
||||
});
|
||||
|
||||
it("increments repeat on a repeating css message", () => {
|
||||
const key1 = "Unknown property ‘such-unknown-property’. Declaration dropped.";
|
||||
const { dispatch, getState } = setupStore([key1, key1]);
|
||||
|
@ -84,6 +109,31 @@ describe("Message reducer:", () => {
|
|||
expect(repeat[getFirstMessage(getState()).id]).toBe(4);
|
||||
});
|
||||
|
||||
it("doesn't increment repeat on same css message with different locations", () => {
|
||||
const key1 = "Unknown property ‘such-unknown-property’. Declaration dropped.";
|
||||
const { dispatch, getState } = setupStore();
|
||||
|
||||
const packet = clonePacket(stubPackets.get(key1));
|
||||
|
||||
// Dispatch original packet.
|
||||
dispatch(actions.messagesAdd([packet]));
|
||||
|
||||
// Dispatch same packet with modified column number.
|
||||
packet.pageError.columnNumber = packet.pageError.columnNumber + 1;
|
||||
dispatch(actions.messagesAdd([packet]));
|
||||
|
||||
// Dispatch same packet with modified line number.
|
||||
packet.pageError.lineNumber = packet.pageError.lineNumber + 1;
|
||||
dispatch(actions.messagesAdd([packet]));
|
||||
|
||||
const messages = getAllMessagesById(getState());
|
||||
|
||||
expect(messages.size).toBe(3);
|
||||
|
||||
const repeat = getAllRepeatById(getState());
|
||||
expect(Object.keys(repeat).length).toBe(0);
|
||||
});
|
||||
|
||||
it("increments repeat on a repeating error message", () => {
|
||||
const key1 = "ReferenceError: asdf is not defined";
|
||||
const { dispatch, getState } = setupStore([key1, key1]);
|
||||
|
@ -126,6 +176,57 @@ describe("Message reducer:", () => {
|
|||
expect(repeat[getLastMessage(getState()).id]).toBe(undefined);
|
||||
});
|
||||
|
||||
it("doesn't increment undefined messages coming from different places", () => {
|
||||
const { getState } = setupStore([
|
||||
"console.log(undefined)",
|
||||
"undefined",
|
||||
]);
|
||||
|
||||
const messages = getAllMessagesById(getState());
|
||||
expect(messages.size).toBe(2);
|
||||
|
||||
const repeat = getAllRepeatById(getState());
|
||||
expect(Object.keys(repeat).length).toBe(0);
|
||||
});
|
||||
|
||||
it("doesn't increment successive falsy but different messages", () => {
|
||||
const { getState } = setupStore([
|
||||
"console.log(NaN)",
|
||||
"console.log(undefined)",
|
||||
"console.log(null)",
|
||||
], {actions});
|
||||
|
||||
let messages = getAllMessagesById(getState());
|
||||
expect(messages.size).toBe(3);
|
||||
let repeat = getAllRepeatById(getState());
|
||||
expect(Object.keys(repeat).length).toBe(0);
|
||||
});
|
||||
|
||||
it("increment falsy messages when expected", () => {
|
||||
const { dispatch, getState } = setupStore();
|
||||
|
||||
const nanPacket = stubPackets.get("console.log(NaN)");
|
||||
dispatch(actions.messagesAdd([nanPacket, nanPacket]));
|
||||
let messages = getAllMessagesById(getState());
|
||||
expect(messages.size).toBe(1);
|
||||
let repeat = getAllRepeatById(getState());
|
||||
expect(repeat[getLastMessage(getState()).id]).toBe(2);
|
||||
|
||||
const undefinedPacket = stubPackets.get("console.log(undefined)");
|
||||
dispatch(actions.messagesAdd([undefinedPacket, undefinedPacket]));
|
||||
messages = getAllMessagesById(getState());
|
||||
expect(messages.size).toBe(2);
|
||||
repeat = getAllRepeatById(getState());
|
||||
expect(repeat[getLastMessage(getState()).id]).toBe(2);
|
||||
|
||||
const nullPacket = stubPackets.get("console.log(null)");
|
||||
dispatch(actions.messagesAdd([nullPacket, nullPacket]));
|
||||
messages = getAllMessagesById(getState());
|
||||
expect(messages.size).toBe(3);
|
||||
repeat = getAllRepeatById(getState());
|
||||
expect(repeat[getLastMessage(getState()).id]).toBe(2);
|
||||
});
|
||||
|
||||
it("does not clobber a unique message", () => {
|
||||
const key1 = "console.log('foobar', 'test')";
|
||||
const { dispatch, getState } = setupStore([key1, key1]);
|
||||
|
|
Загрузка…
Ссылка в новой задаче