Bug 1218089 - Don't set different falsy values as repeated messages in console.log();r=bgrins

This commit is contained in:
Nicolas Chevobbe 2016-01-31 17:02:37 +01:00
parent b3b931b8b9
commit e235757591
3 changed files with 68 additions and 3 deletions

View File

@ -1089,7 +1089,7 @@ Messages.Extended = function(messagePieces, options = {})
}
this._repeatID.quoteStrings = this._quoteStrings;
this._repeatID.messagePieces = messagePieces + "";
this._repeatID.messagePieces = JSON.stringify(messagePieces);
this._repeatID.actors = new Set(); // using a set to avoid duplicates
};

View File

@ -29,6 +29,7 @@ add_task(function* () {
yield testCSSRepeats(hud);
yield testCSSRepeatsAfterReload(hud);
yield testConsoleRepeats(hud);
yield testConsoleFalsyValues(hud);
Services.prefs.clearUserPref(PREF);
});
@ -124,3 +125,52 @@ function testConsoleRepeats(hud) {
],
});
}
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,
},
],
});
}

View File

@ -2,14 +2,15 @@
<html dir="ltr" xml:lang="en-US" lang="en-US">
<head>
<meta charset="utf8">
<title>Test for bugs 720180, 800510 and 865288</title>
<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");
console.log("foo repeat");
console.error("foo repeat");
}
function testConsoleObjects() {
for (var i = 0; i < 3; i++) {
@ -17,6 +18,20 @@
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 {