2011-03-28 13:19:37 -07:00
|
|
|
/* vim:set ts=2 sw=2 sts=2 et: */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Any copyright is dedicated to the Public Domain.
|
|
|
|
* http://creativecommons.org/publicdomain/zero/1.0/
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
// Tests that the Web Console limits the number of lines displayed according to
|
|
|
|
// the user's preferences.
|
|
|
|
|
2012-03-24 04:34:42 -07:00
|
|
|
const TEST_URI = "data:text/html;charset=utf-8,<p>test for bug 642108.";
|
2011-03-28 13:19:37 -07:00
|
|
|
const LOG_LIMIT = 20;
|
|
|
|
const CATEGORY_CSS = 1;
|
|
|
|
const SEVERITY_WARNING = 1;
|
|
|
|
|
|
|
|
function test() {
|
|
|
|
addTab(TEST_URI);
|
2012-06-12 04:25:07 -07:00
|
|
|
browser.addEventListener("load", function onLoad(){
|
|
|
|
browser.removeEventListener("load", onLoad, false);
|
|
|
|
|
|
|
|
Services.prefs.setIntPref("devtools.hud.loglimit.cssparser", LOG_LIMIT);
|
|
|
|
|
|
|
|
registerCleanupFunction(function() {
|
|
|
|
Services.prefs.clearUserPref("devtools.hud.loglimit.cssparser");
|
|
|
|
});
|
|
|
|
|
|
|
|
openConsole(null, testCSSPruning);
|
|
|
|
}, true);
|
2011-03-28 13:19:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function populateConsoleRepeats(aHudRef) {
|
2012-01-23 07:50:11 -08:00
|
|
|
for (let i = 0; i < 5; i++) {
|
2012-07-26 08:06:04 -07:00
|
|
|
let node = aHudRef.ui.createMessageNode(CATEGORY_CSS, SEVERITY_WARNING,
|
|
|
|
"css log x");
|
|
|
|
aHudRef.ui.outputMessage(CATEGORY_CSS, node);
|
2011-03-28 13:19:37 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function populateConsole(aHudRef) {
|
2012-01-23 07:50:11 -08:00
|
|
|
for (let i = 0; i < LOG_LIMIT + 5; i++) {
|
2012-07-26 08:06:04 -07:00
|
|
|
let node = aHudRef.ui.createMessageNode(CATEGORY_CSS, SEVERITY_WARNING,
|
|
|
|
"css log " + i);
|
|
|
|
aHudRef.ui.outputMessage(CATEGORY_CSS, node);
|
2011-03-28 13:19:37 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-12 04:25:07 -07:00
|
|
|
function testCSSPruning(hudRef) {
|
2011-03-28 13:19:37 -07:00
|
|
|
populateConsoleRepeats(hudRef);
|
|
|
|
|
2012-06-12 04:25:07 -07:00
|
|
|
let waitForNoRepeatedNodes = {
|
|
|
|
name: "number of nodes is LOG_LIMIT",
|
|
|
|
validatorFn: function()
|
|
|
|
{
|
|
|
|
return countMessageNodes() == LOG_LIMIT;
|
|
|
|
},
|
|
|
|
successFn: function()
|
|
|
|
{
|
2012-07-26 08:06:04 -07:00
|
|
|
ok(!hudRef.ui._cssNodes["css log x"],
|
|
|
|
"repeated nodes pruned from cssNodes");
|
2012-06-12 04:25:07 -07:00
|
|
|
finishTest();
|
|
|
|
},
|
|
|
|
failureFn: finishTest,
|
|
|
|
};
|
|
|
|
|
|
|
|
waitForSuccess({
|
|
|
|
name: "repeated nodes in cssNodes",
|
|
|
|
validatorFn: function()
|
|
|
|
{
|
2012-07-26 08:06:04 -07:00
|
|
|
return hudRef.ui._cssNodes["css log x"];
|
2012-06-12 04:25:07 -07:00
|
|
|
},
|
|
|
|
successFn: function()
|
|
|
|
{
|
|
|
|
populateConsole(hudRef);
|
|
|
|
waitForSuccess(waitForNoRepeatedNodes);
|
|
|
|
},
|
|
|
|
failureFn: finishTest,
|
|
|
|
});
|
2011-03-28 13:19:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function countMessageNodes() {
|
2011-07-07 04:06:06 -07:00
|
|
|
let outputNode = HUDService.getHudByWindow(content).outputNode;
|
|
|
|
return outputNode.querySelectorAll(".hud-msg-node").length;
|
2011-03-28 13:19:37 -07:00
|
|
|
}
|