diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /devtools/client/webconsole/test/browser_webconsole_bug_642108_pruneTest.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/webconsole/test/browser_webconsole_bug_642108_pruneTest.js')
-rw-r--r-- | devtools/client/webconsole/test/browser_webconsole_bug_642108_pruneTest.js | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/devtools/client/webconsole/test/browser_webconsole_bug_642108_pruneTest.js b/devtools/client/webconsole/test/browser_webconsole_bug_642108_pruneTest.js new file mode 100644 index 000000000..caaa73628 --- /dev/null +++ b/devtools/client/webconsole/test/browser_webconsole_bug_642108_pruneTest.js @@ -0,0 +1,81 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +// Tests that the Web Console limits the number of lines displayed according to +// the user's preferences. + +"use strict"; + +const TEST_URI = "data:text/html;charset=utf-8,<p>test for bug 642108."; +const LOG_LIMIT = 20; + +function test() { + let hud; + + Task.spawn(runner).then(finishTest); + + function* runner() { + let {tab} = yield loadTab(TEST_URI); + + Services.prefs.setIntPref("devtools.hud.loglimit.cssparser", LOG_LIMIT); + Services.prefs.setBoolPref("devtools.webconsole.filter.cssparser", true); + + registerCleanupFunction(function () { + Services.prefs.clearUserPref("devtools.hud.loglimit.cssparser"); + Services.prefs.clearUserPref("devtools.webconsole.filter.cssparser"); + }); + + hud = yield openConsole(tab); + + for (let i = 0; i < 5; i++) { + logCSSMessage("css log x"); + } + + yield waitForMessages({ + webconsole: hud, + messages: [{ + text: "css log x", + category: CATEGORY_CSS, + severity: SEVERITY_WARNING, + repeats: 5, + }], + }); + + for (let i = 0; i < LOG_LIMIT + 5; i++) { + logCSSMessage("css log " + i); + } + + let [result] = yield waitForMessages({ + webconsole: hud, + messages: [{ + text: "css log 5", + category: CATEGORY_CSS, + severity: SEVERITY_WARNING, + }, + { + // LOG_LIMIT + 5 + text: "css log 24", + category: CATEGORY_CSS, + severity: SEVERITY_WARNING, + }], + }); + + is(hud.ui.outputNode.querySelectorAll(".message").length, LOG_LIMIT, + "number of messages"); + + is(Object.keys(hud.ui._repeatNodes).length, LOG_LIMIT, + "repeated nodes pruned from repeatNodes"); + + let msg = [...result.matched][0]; + let repeats = msg.querySelector(".message-repeats"); + is(repeats.getAttribute("value"), 1, + "repeated nodes pruned from repeatNodes (confirmed)"); + } + + function logCSSMessage(msg) { + let node = hud.ui.createMessageNode(CATEGORY_CSS, SEVERITY_WARNING, msg); + hud.ui.outputMessage(CATEGORY_CSS, node); + } +} |