mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-23 02:05:42 +00:00
Bug 865288 - Do not count console.log messages with different objects as repeats; r=past
This commit is contained in:
parent
7e8f2f6c0a
commit
0427e04da4
@ -124,6 +124,7 @@ MOCHITEST_BROWSER_FILES = \
|
||||
browser_console_consolejsm_output.js \
|
||||
browser_webconsole_bug_837351_securityerrors.js \
|
||||
browser_bug_865871_variables_view_close_on_esc_key.js \
|
||||
browser_bug_865288_repeat_different_objects.js \
|
||||
head.js \
|
||||
$(NULL)
|
||||
|
||||
|
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Tests that makes sure messages are not considered repeated when console.log()
|
||||
// is invoked with different objects, see bug 865288.
|
||||
|
||||
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-repeated-messages.html";
|
||||
|
||||
let hud = null;
|
||||
|
||||
function test() {
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
openConsole(null, consoleOpened);
|
||||
}, true);
|
||||
}
|
||||
|
||||
function consoleOpened(aHud) {
|
||||
hud = aHud;
|
||||
|
||||
// Check that css warnings are not coalesced if they come from different lines.
|
||||
info("waiting for 3 console.log objects");
|
||||
|
||||
hud.jsterm.clearOutput(true);
|
||||
content.wrappedJSObject.testConsoleObjects();
|
||||
|
||||
waitForMessages({
|
||||
webconsole: hud,
|
||||
messages: [{
|
||||
name: "3 console.log messages",
|
||||
text: "abba",
|
||||
category: CATEGORY_WEBDEV,
|
||||
severity: SEVERITY_LOG,
|
||||
count: 3,
|
||||
repeats: 1,
|
||||
objects: true,
|
||||
}],
|
||||
}).then(checkMessages);
|
||||
}
|
||||
|
||||
function checkMessages(aResults)
|
||||
{
|
||||
let result = aResults[0];
|
||||
let msgs = [...result.matched];
|
||||
is(msgs.length, 3, "3 message elements");
|
||||
let m = -1;
|
||||
|
||||
function nextMessage()
|
||||
{
|
||||
let msg = msgs[++m];
|
||||
if (msg) {
|
||||
ok(msg, "message element #" + m);
|
||||
|
||||
let clickable = msg.querySelector(".hud-clickable");
|
||||
ok(clickable, "clickable object #" + m);
|
||||
|
||||
scrollOutputToNode(msg);
|
||||
clickObject(clickable);
|
||||
}
|
||||
else {
|
||||
finishTest();
|
||||
}
|
||||
}
|
||||
|
||||
nextMessage();
|
||||
|
||||
function clickObject(aObject)
|
||||
{
|
||||
hud.jsterm.once("variablesview-fetched", onObjectFetch);
|
||||
EventUtils.synthesizeMouse(aObject, 2, 2, {}, hud.iframeWindow);
|
||||
}
|
||||
|
||||
function onObjectFetch(aEvent, aVar)
|
||||
{
|
||||
findVariableViewProperties(aVar, [
|
||||
{ name: "id", value: "abba" + m },
|
||||
], { webconsole: hud }).then(nextMessage);
|
||||
}
|
||||
}
|
@ -869,6 +869,8 @@ function getMessageElementText(aElement)
|
||||
* Properties:
|
||||
* - text: string or RegExp to match the textContent of each new
|
||||
* message.
|
||||
* - noText: string or RegExp that must not match in the message
|
||||
* textContent.
|
||||
* - repeats: the number of message repeats, as displayed by the Web
|
||||
* Console.
|
||||
* - category: match message category. See CATEGORY_* constants at
|
||||
@ -877,8 +879,31 @@ function getMessageElementText(aElement)
|
||||
* the top of this file.
|
||||
* - count: how many unique web console messages should be matched by
|
||||
* this rule.
|
||||
* - consoleTrace: boolean, set to |true| to match a console.trace()
|
||||
* message. Optionally this can be an object of the form
|
||||
* { file, fn, line } that can match the specified file, function
|
||||
* and/or line number in the trace message.
|
||||
* - consoleTime: string that matches a console.time() timer name.
|
||||
* Provide this if you want to match a console.time() message.
|
||||
* - consoleTimeEnd: same as above, but for console.timeEnd().
|
||||
* - consoleDir: boolean, set to |true| to match a console.dir()
|
||||
* message.
|
||||
* - longString: boolean, set to |true} to match long strings in the
|
||||
* message.
|
||||
* - objects: boolean, set to |true| if you expect inspectable
|
||||
* objects in the message.
|
||||
* @return object
|
||||
* A Promise object is returned once the messages you want are found.
|
||||
* The promise is resolved with the array of rule objects you give in
|
||||
* the |messages| property. Each objects is the same as provided, with
|
||||
* additional properties:
|
||||
* - matched: a Set of web console messages that matched the rule.
|
||||
* - clickableElements: a list of inspectable objects. This is available
|
||||
* if any of the following properties are present in the rule:
|
||||
* |consoleTrace| or |objects|.
|
||||
* - longStrings: a list of long string ellipsis elements you can click
|
||||
* in the message element, to expand a long string. This is available
|
||||
* only if |longString| is present in the matching rule.
|
||||
*/
|
||||
function waitForMessages(aOptions)
|
||||
{
|
||||
|
@ -2,12 +2,18 @@
|
||||
<html dir="ltr" xml:lang="en-US" lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf8">
|
||||
<title>Test for bugs 720180 and 800510</title>
|
||||
<title>Test for bugs 720180, 800510 and 865288</title>
|
||||
<script>
|
||||
function testConsole() {
|
||||
console.log("foo repeat"); 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" + i };
|
||||
console.log("abba", o);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
body {
|
||||
|
@ -1098,6 +1098,9 @@ WebConsoleFrame.prototype = {
|
||||
|
||||
if (objectActors.size > 0) {
|
||||
node._objectActors = objectActors;
|
||||
|
||||
let repeatNode = node.querySelector(".webconsole-msg-repeat");
|
||||
repeatNode._uid += [...objectActors].join("-");
|
||||
}
|
||||
|
||||
// Make the node bring up the variables view, to allow the user to inspect
|
||||
|
Loading…
Reference in New Issue
Block a user