Bug 951146 - Fix for intermittent browser_webconsole_console_logging_api.js | Timed out while waiting for: 1 message shown for exception (logging turned on). a=test-only
☠☠ backed out by 9561abd10c52 ☠ ☠
authorMihai Sucan <mihai.sucan@gmail.com>
Thu, 16 Jan 2014 22:49:20 +0200
changeset 175868 47837dce0006d9d2313f0c561781fbab53d35dff
parent 175867 2f8383584178cbe0e4d22b123ddfa5b8d115461f
child 175869 e7e9d99a29650fdddf208d93edb37c5191f8b00a
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstest-only
bugs951146
milestone28.0a2
Bug 951146 - Fix for intermittent browser_webconsole_console_logging_api.js | Timed out while waiting for: 1 message shown for exception (logging turned on). a=test-only
browser/devtools/webconsole/test/browser_webconsole_console_logging_api.js
--- a/browser/devtools/webconsole/test/browser_webconsole_console_logging_api.js
+++ b/browser/devtools/webconsole/test/browser_webconsole_console_logging_api.js
@@ -2,157 +2,108 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // Tests that the basic console.log()-style APIs and filtering work.
 
 const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
 
-let testDriver = null;
-let subtestDriver = null;
+let hud, outputNode;
 
 function test() {
   addTab(TEST_URI);
-
-  browser.addEventListener("DOMContentLoaded", onLoad, false);
-}
-
-function onLoad() {
-  browser.removeEventListener("DOMContentLoaded", onLoad, false);
+  browser.addEventListener("load", function onLoad() {
+    browser.removeEventListener("load", onLoad, true);
+    Task.spawn(runner);
+  }, true);
 
-  openConsole(null, function(aHud) {
-    hud = aHud;
-    hudId = hud.hudId;
+  function* runner() {
+    hud = yield openConsole();
     outputNode = hud.outputNode;
-    testDriver = testGen();
-    testDriver.next();
-  });
+
+    let methods = ["log", "info", "warn", "error", "exception", "debug"];
+    for (let method of methods) {
+      yield testMethod(method);
+    }
+
+    executeSoon(finishTest);
+  }
 }
 
-function testGen() {
-  subtestGen("log");
-  yield undefined;
-
-  subtestGen("info");
-  yield undefined;
-
-  subtestGen("warn");
-  yield undefined;
-
-  subtestGen("error");
-  yield undefined;
-
-  subtestGen("exception");
-  yield undefined;
-
-  subtestGen("debug"); // bug 616742
-  yield undefined;
-
-  testDriver = subtestDriver = null;
-  finishTest();
-
-  yield undefined;
-}
-
-function subtestGen(aMethod) {
-  subtestDriver = testConsoleLoggingAPI(aMethod);
-  subtestDriver.next();
-}
-
-function testConsoleLoggingAPI(aMethod) {
-  let console = content.wrappedJSObject.console;
+function* testMethod(aMethod) {
+  let console = content.console;
 
   hud.jsterm.clearOutput();
 
-  setStringFilter("foo");
   console[aMethod]("foo-bar-baz");
-  console[aMethod]("bar-baz");
-
-  function nextTest() {
-    subtestDriver.next();
-  }
+  console[aMethod]("baar-baz");
 
-  waitForSuccess({
-    name: "1 hidden " + aMethod + " node via string filtering",
-    validatorFn: function()
-    {
-      return outputNode.querySelectorAll(".filtered-by-string").length == 1;
-    },
-    successFn: nextTest,
-    failureFn: nextTest,
+  yield waitForMessages({
+    webconsole: hud,
+    messages: [{
+      text: "foo-bar-baz",
+    }, {
+      text: "baar-baz",
+    }],
   });
 
-  yield undefined;
+  setStringFilter("foo");
+
+  is(outputNode.querySelectorAll(".filtered-by-string").length, 1,
+     "1 hidden " + aMethod + " node via string filtering")
 
   hud.jsterm.clearOutput();
 
   // now toggle the current method off - make sure no visible message
+  // TODO: move all filtering tests into a separate test file: see bug 608135
 
-  // TODO: move all filtering tests into a separate test file: see bug 608135
+  console[aMethod]("foo-bar-baz");
+  yield waitForMessages({
+    webconsole: hud,
+    messages: [{
+      text: "foo-bar-baz",
+    }],
+  });
+
   setStringFilter("");
   let filter;
   switch(aMethod) {
     case "debug":
       filter = "log";
       break;
     case "exception":
       filter = "error";
       break;
     default:
       filter = aMethod;
       break;
   }
+
   hud.setFilterState(filter, false);
-  console[aMethod]("foo-bar-baz");
 
-  waitForSuccess({
-    name: "1 message hidden for " + aMethod + " (logging turned off)",
-    validatorFn: function()
-    {
-      return outputNode.querySelectorAll(".filtered-by-type").length == 1;
-    },
-    successFn: nextTest,
-    failureFn: nextTest,
-  });
+  is(outputNode.querySelectorAll(".filtered-by-type").length, 1,
+     "1 message hidden for " + aMethod + " (logging turned off)")
 
-  yield undefined;
+  hud.setFilterState(filter, true);
+
+  is(outputNode.querySelectorAll(".message:not(.filtered-by-type)").length, 1,
+     "1 message shown for " + aMethod + " (logging turned on)")
 
   hud.jsterm.clearOutput();
-  hud.setFilterState(filter, true);
-  console[aMethod]("foo-bar-baz");
-
-  waitForSuccess({
-    name: "1 message shown for " + aMethod + " (logging turned on)",
-    validatorFn: function()
-    {
-      return outputNode.querySelectorAll(".message:not(.filtered-by-type)").length == 1;
-    },
-    successFn: nextTest,
-    failureFn: nextTest,
-  });
-
-  yield undefined;
-
-  hud.jsterm.clearOutput();
-  setStringFilter("");
 
   // test for multiple arguments.
   console[aMethod]("foo", "bar");
 
-  waitForMessages({
+  yield waitForMessages({
     webconsole: hud,
     messages: [{
       text: '"foo" "bar"',
       category: CATEGORY_WEBDEV,
     }],
-  }).then(nextTest);
-
-  yield undefined;
-  testDriver.next();
-  yield undefined;
+  })
 }
 
 function setStringFilter(aValue) {
   hud.ui.filterBox.value = aValue;
   hud.ui.adjustVisibilityOnSearchStringChange();
 }