Bug 964684 - Fix for intermittent TEST-UNEXPECTED-FAIL | browser_webconsole_bug_642108_pruneTest.js | Test timed out. r=me, a=test-only
authorMihai Sucan <mihai.sucan@gmail.com>
Mon, 10 Feb 2014 21:29:13 +0200
changeset 182778 b124044cd60bf6715577992c8b04ae2b8327208e
parent 182777 59bf63f4e48d5697ed4893ba7bb1cfcaec0253b3
child 182779 c5af36178cb9fd6dc7c7c05b9f116627cfcf56f1
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme, test-only
bugs964684
milestone29.0a2
Bug 964684 - Fix for intermittent TEST-UNEXPECTED-FAIL | browser_webconsole_bug_642108_pruneTest.js | Test timed out. r=me, a=test-only
browser/devtools/webconsole/test/browser_webconsole_bug_642108_pruneTest.js
--- a/browser/devtools/webconsole/test/browser_webconsole_bug_642108_pruneTest.js
+++ b/browser/devtools/webconsole/test/browser_webconsole_bug_642108_pruneTest.js
@@ -7,83 +7,74 @@
 
 // Tests that the Web Console limits the number of lines displayed according to
 // the user's preferences.
 
 const TEST_URI = "data:text/html;charset=utf-8,<p>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);
+    yield waitForMessages({
+      webconsole: hud,
+      messages: [{
+        text: "css log x",
+        category: CATEGORY_CSS,
+        severity: SEVERITY_WARNING,
+        repeats: 5,
+      }],
+    });
 
-  waitForMessages({
-    webconsole: hudRef,
-    messages: [{
-      text: "css log x",
-      category: CATEGORY_CSS,
-      severity: SEVERITY_WARNING,
-      repeats: 5,
-    }],
-  }).then(() => {
-    populateConsole(hudRef);
-    waitForMessages({
-      webconsole: hudRef,
+    for (let i = 0; i < LOG_LIMIT + 5; i++) {
+      logCSSMessage("css log " + i);
+    }
+
+    let [result] = yield waitForMessages({
+      webconsole: hud,
       messages: [{
-        text: "css log 0",
+        text: "css log 5",
         category: CATEGORY_CSS,
         severity: SEVERITY_WARNING,
       },
       {
         text: "css log 24", // LOG_LIMIT + 5
         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");
+    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)");
+    let msg = [...result.matched][0];
+    let repeats = msg.querySelector(".message-repeats");
+    is(repeats.getAttribute("value"), 1,
+       "repeated nodes pruned from repeatNodes (confirmed)");
+  }
 
-      finishTest();
-    });
-  });
+  function logCSSMessage(msg) {
+    let node = hud.ui.createMessageNode(CATEGORY_CSS, SEVERITY_WARNING, msg);
+    hud.ui.outputMessage(CATEGORY_CSS, node);
+  }
 }
-
-function countMessageNodes() {
-  let outputNode = HUDService.getHudByWindow(content).outputNode;
-  return outputNode.querySelectorAll(".message").length;
-}