michael@0: /* vim:set ts=2 sw=2 sts=2 et: */ michael@0: /* ***** BEGIN LICENSE BLOCK ***** michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: * michael@0: * ***** END LICENSE BLOCK ***** */ michael@0: michael@0: // Tests that the Web Console limits the number of lines displayed according to michael@0: // the user's preferences. michael@0: michael@0: const TEST_URI = "data:text/html;charset=utf-8,
test for bug 642108."; michael@0: const LOG_LIMIT = 20; michael@0: michael@0: function test() { michael@0: let hud; michael@0: michael@0: Task.spawn(runner).then(finishTest); michael@0: michael@0: function* runner() { michael@0: let {tab} = yield loadTab(TEST_URI); michael@0: michael@0: Services.prefs.setIntPref("devtools.hud.loglimit.cssparser", LOG_LIMIT); michael@0: Services.prefs.setBoolPref("devtools.webconsole.filter.cssparser", true); michael@0: michael@0: registerCleanupFunction(function() { michael@0: Services.prefs.clearUserPref("devtools.hud.loglimit.cssparser"); michael@0: Services.prefs.clearUserPref("devtools.webconsole.filter.cssparser"); michael@0: }); michael@0: michael@0: hud = yield openConsole(tab); michael@0: michael@0: for (let i = 0; i < 5; i++) { michael@0: logCSSMessage("css log x"); michael@0: } michael@0: michael@0: yield waitForMessages({ michael@0: webconsole: hud, michael@0: messages: [{ michael@0: text: "css log x", michael@0: category: CATEGORY_CSS, michael@0: severity: SEVERITY_WARNING, michael@0: repeats: 5, michael@0: }], michael@0: }); michael@0: michael@0: for (let i = 0; i < LOG_LIMIT + 5; i++) { michael@0: logCSSMessage("css log " + i); michael@0: } michael@0: michael@0: let [result] = yield waitForMessages({ michael@0: webconsole: hud, michael@0: messages: [{ michael@0: text: "css log 5", michael@0: category: CATEGORY_CSS, michael@0: severity: SEVERITY_WARNING, michael@0: }, michael@0: { michael@0: text: "css log 24", // LOG_LIMIT + 5 michael@0: category: CATEGORY_CSS, michael@0: severity: SEVERITY_WARNING, michael@0: }], michael@0: }); michael@0: michael@0: is(hud.ui.outputNode.querySelectorAll(".message").length, LOG_LIMIT, michael@0: "number of messages"); michael@0: michael@0: is(Object.keys(hud.ui._repeatNodes).length, LOG_LIMIT, michael@0: "repeated nodes pruned from repeatNodes"); michael@0: michael@0: let msg = [...result.matched][0]; michael@0: let repeats = msg.querySelector(".message-repeats"); michael@0: is(repeats.getAttribute("value"), 1, michael@0: "repeated nodes pruned from repeatNodes (confirmed)"); michael@0: } michael@0: michael@0: function logCSSMessage(msg) { michael@0: let node = hud.ui.createMessageNode(CATEGORY_CSS, SEVERITY_WARNING, msg); michael@0: hud.ui.outputMessage(CATEGORY_CSS, node); michael@0: } michael@0: }