1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/webconsole/test/browser_repeated_messages_accuracy.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,118 @@ 1.4 +/* vim:set ts=2 sw=2 sts=2 et: */ 1.5 +/* 1.6 + * Any copyright is dedicated to the Public Domain. 1.7 + * http://creativecommons.org/publicdomain/zero/1.0/ 1.8 + */ 1.9 + 1.10 +// Test that makes sure messages are not considered repeated when coming from 1.11 +// different lines of code, or from different severities, etc. 1.12 +// See bugs 720180 and 800510. 1.13 + 1.14 +const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-repeated-messages.html"; 1.15 + 1.16 +function test() { 1.17 + const PREF = "devtools.webconsole.persistlog"; 1.18 + Services.prefs.setBoolPref(PREF, true); 1.19 + registerCleanupFunction(() => Services.prefs.clearUserPref(PREF)); 1.20 + 1.21 + addTab(TEST_URI); 1.22 + browser.addEventListener("load", function onLoad() { 1.23 + browser.removeEventListener("load", onLoad, true); 1.24 + openConsole(null, consoleOpened); 1.25 + }, true); 1.26 +} 1.27 + 1.28 +function consoleOpened(hud) { 1.29 + // Check that css warnings are not coalesced if they come from different lines. 1.30 + info("waiting for 2 css warnings"); 1.31 + 1.32 + waitForMessages({ 1.33 + webconsole: hud, 1.34 + messages: [{ 1.35 + name: "two css warnings", 1.36 + category: CATEGORY_CSS, 1.37 + count: 2, 1.38 + repeats: 1, 1.39 + }], 1.40 + }).then(testCSSRepeats.bind(null, hud)); 1.41 +} 1.42 + 1.43 +function testCSSRepeats(hud) { 1.44 + browser.addEventListener("load", function onLoad() { 1.45 + browser.removeEventListener("load", onLoad, true); 1.46 + 1.47 + info("wait for repeats after page reload"); 1.48 + 1.49 + waitForMessages({ 1.50 + webconsole: hud, 1.51 + messages: [{ 1.52 + name: "two css warnings, repeated twice", 1.53 + category: CATEGORY_CSS, 1.54 + repeats: 2, 1.55 + count: 2, 1.56 + }], 1.57 + }).then(testCSSRepeatsAfterReload.bind(null, hud)); 1.58 + }, true); 1.59 + content.location.reload(); 1.60 +} 1.61 + 1.62 +function testCSSRepeatsAfterReload(hud) { 1.63 + hud.jsterm.clearOutput(true); 1.64 + content.wrappedJSObject.testConsole(); 1.65 + 1.66 + info("wait for repeats with the console API"); 1.67 + 1.68 + waitForMessages({ 1.69 + webconsole: hud, 1.70 + messages: [ 1.71 + { 1.72 + name: "console.log 'foo repeat' repeated twice", 1.73 + category: CATEGORY_WEBDEV, 1.74 + severity: SEVERITY_LOG, 1.75 + repeats: 2, 1.76 + }, 1.77 + { 1.78 + name: "console.log 'foo repeat' repeated once", 1.79 + category: CATEGORY_WEBDEV, 1.80 + severity: SEVERITY_LOG, 1.81 + repeats: 1, 1.82 + }, 1.83 + { 1.84 + name: "console.error 'foo repeat' repeated once", 1.85 + category: CATEGORY_WEBDEV, 1.86 + severity: SEVERITY_ERROR, 1.87 + repeats: 1, 1.88 + }, 1.89 + ], 1.90 + }).then(testConsoleRepeats.bind(null, hud)); 1.91 +} 1.92 + 1.93 +function testConsoleRepeats(hud) { 1.94 + hud.jsterm.clearOutput(true); 1.95 + hud.jsterm.execute("undefined"); 1.96 + content.console.log("undefined"); 1.97 + 1.98 + info("make sure console API messages are not coalesced with jsterm output"); 1.99 + 1.100 + waitForMessages({ 1.101 + webconsole: hud, 1.102 + messages: [ 1.103 + { 1.104 + name: "'undefined' jsterm input message", 1.105 + text: "undefined", 1.106 + category: CATEGORY_INPUT, 1.107 + }, 1.108 + { 1.109 + name: "'undefined' jsterm output message", 1.110 + text: "undefined", 1.111 + category: CATEGORY_OUTPUT, 1.112 + }, 1.113 + { 1.114 + name: "'undefined' console.log message", 1.115 + text: "undefined", 1.116 + category: CATEGORY_WEBDEV, 1.117 + repeats: 1, 1.118 + }, 1.119 + ], 1.120 + }).then(finishTest); 1.121 +}