michael@0: /* vim:set ts=2 sw=2 sts=2 et: */ michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: */ michael@0: michael@0: // Test that makes sure messages are not considered repeated when coming from michael@0: // different lines of code, or from different severities, etc. michael@0: // See bugs 720180 and 800510. michael@0: michael@0: const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-repeated-messages.html"; michael@0: michael@0: function test() { michael@0: const PREF = "devtools.webconsole.persistlog"; michael@0: Services.prefs.setBoolPref(PREF, true); michael@0: registerCleanupFunction(() => Services.prefs.clearUserPref(PREF)); michael@0: michael@0: addTab(TEST_URI); michael@0: browser.addEventListener("load", function onLoad() { michael@0: browser.removeEventListener("load", onLoad, true); michael@0: openConsole(null, consoleOpened); michael@0: }, true); michael@0: } michael@0: michael@0: function consoleOpened(hud) { michael@0: // Check that css warnings are not coalesced if they come from different lines. michael@0: info("waiting for 2 css warnings"); michael@0: michael@0: waitForMessages({ michael@0: webconsole: hud, michael@0: messages: [{ michael@0: name: "two css warnings", michael@0: category: CATEGORY_CSS, michael@0: count: 2, michael@0: repeats: 1, michael@0: }], michael@0: }).then(testCSSRepeats.bind(null, hud)); michael@0: } michael@0: michael@0: function testCSSRepeats(hud) { michael@0: browser.addEventListener("load", function onLoad() { michael@0: browser.removeEventListener("load", onLoad, true); michael@0: michael@0: info("wait for repeats after page reload"); michael@0: michael@0: waitForMessages({ michael@0: webconsole: hud, michael@0: messages: [{ michael@0: name: "two css warnings, repeated twice", michael@0: category: CATEGORY_CSS, michael@0: repeats: 2, michael@0: count: 2, michael@0: }], michael@0: }).then(testCSSRepeatsAfterReload.bind(null, hud)); michael@0: }, true); michael@0: content.location.reload(); michael@0: } michael@0: michael@0: function testCSSRepeatsAfterReload(hud) { michael@0: hud.jsterm.clearOutput(true); michael@0: content.wrappedJSObject.testConsole(); michael@0: michael@0: info("wait for repeats with the console API"); michael@0: michael@0: waitForMessages({ michael@0: webconsole: hud, michael@0: messages: [ michael@0: { michael@0: name: "console.log 'foo repeat' repeated twice", michael@0: category: CATEGORY_WEBDEV, michael@0: severity: SEVERITY_LOG, michael@0: repeats: 2, michael@0: }, michael@0: { michael@0: name: "console.log 'foo repeat' repeated once", michael@0: category: CATEGORY_WEBDEV, michael@0: severity: SEVERITY_LOG, michael@0: repeats: 1, michael@0: }, michael@0: { michael@0: name: "console.error 'foo repeat' repeated once", michael@0: category: CATEGORY_WEBDEV, michael@0: severity: SEVERITY_ERROR, michael@0: repeats: 1, michael@0: }, michael@0: ], michael@0: }).then(testConsoleRepeats.bind(null, hud)); michael@0: } michael@0: michael@0: function testConsoleRepeats(hud) { michael@0: hud.jsterm.clearOutput(true); michael@0: hud.jsterm.execute("undefined"); michael@0: content.console.log("undefined"); michael@0: michael@0: info("make sure console API messages are not coalesced with jsterm output"); michael@0: michael@0: waitForMessages({ michael@0: webconsole: hud, michael@0: messages: [ michael@0: { michael@0: name: "'undefined' jsterm input message", michael@0: text: "undefined", michael@0: category: CATEGORY_INPUT, michael@0: }, michael@0: { michael@0: name: "'undefined' jsterm output message", michael@0: text: "undefined", michael@0: category: CATEGORY_OUTPUT, michael@0: }, michael@0: { michael@0: name: "'undefined' console.log message", michael@0: text: "undefined", michael@0: category: CATEGORY_WEBDEV, michael@0: repeats: 1, michael@0: }, michael@0: ], michael@0: }).then(finishTest); michael@0: }