diff --git a/browser/devtools/webconsole/test/browser_webconsole_bug_642108_pruneTest.js b/browser/devtools/webconsole/test/browser_webconsole_bug_642108_pruneTest.js index 9c2299d3509..e269b3e9923 100644 --- a/browser/devtools/webconsole/test/browser_webconsole_bug_642108_pruneTest.js +++ b/browser/devtools/webconsole/test/browser_webconsole_bug_642108_pruneTest.js @@ -12,53 +12,45 @@ const TEST_URI = "data:text/html;charset=utf-8,
test for bug 642108."; const LOG_LIMIT = 20; function test() { - addTab(TEST_URI); - browser.addEventListener("load", function onLoad(){ - browser.removeEventListener("load", onLoad, false); + 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"); }); - openConsole(null, testCSSPruning); - }, true); -} + hud = yield openConsole(tab); -function populateConsoleRepeats(aHudRef) { - for (let i = 0; i < 5; i++) { - let node = aHudRef.ui.createMessageNode(CATEGORY_CSS, SEVERITY_WARNING, - "css log x"); - aHudRef.ui.outputMessage(CATEGORY_CSS, node); - } -} + for (let i = 0; i < 5; i++) { + logCSSMessage("css log x"); + } -function populateConsole(aHudRef) { - for (let i = 0; i < LOG_LIMIT + 5; i++) { - let node = aHudRef.ui.createMessageNode(CATEGORY_CSS, SEVERITY_WARNING, - "css log " + i); - aHudRef.ui.outputMessage(CATEGORY_CSS, node); - } -} - -function testCSSPruning(hudRef) { - populateConsoleRepeats(hudRef); - - waitForMessages({ - webconsole: hudRef, - messages: [{ - text: "css log x", - category: CATEGORY_CSS, - severity: SEVERITY_WARNING, - repeats: 5, - }], - }).then(() => { - populateConsole(hudRef); - waitForMessages({ - webconsole: hudRef, + yield waitForMessages({ + webconsole: hud, messages: [{ - text: "css log 0", + 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, }, @@ -67,23 +59,22 @@ function testCSSPruning(hudRef) { category: CATEGORY_CSS, severity: SEVERITY_WARNING, }], - }).then(([result]) => { - is(countMessageNodes(), LOG_LIMIT, "number of messages"); - - is(Object.keys(hudRef.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)"); - - finishTest(); }); - }); -} -function countMessageNodes() { - let outputNode = HUDService.getHudByWindow(content).outputNode; - return outputNode.querySelectorAll(".message").length; + 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); + } }