Bug 963977 - Fix for intermittent browser_console_addonsdk_loader_exception.js | Test timed out; r=me
authorMihai Sucan <mihai.sucan@gmail.com>
Fri, 07 Feb 2014 20:00:41 +0200
changeset 167837 aded6366c9fb531d5345e087c1c9d762090a87af
parent 167836 a1b47aeca0cee75fcddeb19553a45ca79bb11b48
child 167838 f5726434eedc1897fabddcbc066544c4d9de6278
push id26189
push userryanvm@gmail.com
push dateMon, 10 Feb 2014 20:32:33 +0000
treeherdermozilla-central@f5726434eedc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs963977
milestone30.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 963977 - Fix for intermittent browser_console_addonsdk_loader_exception.js | Test timed out; r=me
browser/devtools/webconsole/test/browser_console_addonsdk_loader_exception.js
--- a/browser/devtools/webconsole/test/browser_console_addonsdk_loader_exception.js
+++ b/browser/devtools/webconsole/test/browser_console_addonsdk_loader_exception.js
@@ -10,86 +10,79 @@
 const TEST_URI = "data:text/html;charset=utf8,<p>hello world from bug 866950";
 
 function test()
 {
   requestLongerTimeout(2);
 
   let webconsole, browserconsole;
 
-  addTab(TEST_URI);
-  browser.addEventListener("load", function onLoad() {
-    browser.removeEventListener("load", onLoad, true);
-
-    openConsole(null, consoleOpened);
-  }, true);
+  Task.spawn(runner).then(finishTest);
 
-  function consoleOpened(hud)
-  {
-    ok(hud, "web console opened");
-    webconsole = hud;
-    HUDService.toggleBrowserConsole().then(browserConsoleOpened);
-  }
+  function* runner() {
+    let {tab} = yield loadTab(TEST_URI);
+    webconsole = yield openConsole(tab);
+    ok(webconsole, "web console opened");
 
-  function browserConsoleOpened(hud)
-  {
-    ok(hud, "browser console opened");
-    browserconsole = hud;
+    browserconsole = yield HUDService.toggleBrowserConsole();
+    ok(browserconsole, "browser console opened");
 
     // Cause an exception in a script loaded with the addon-sdk loader.
     let toolbox = gDevTools.getToolbox(webconsole.target);
     let oldPanels = toolbox._toolPanels;
     toolbox._toolPanels = null;
-    function fixToolbox()
-    {
+
+    function fixToolbox() {
       toolbox._toolPanels = oldPanels;
     }
 
     info("generate exception and wait for message");
 
     executeSoon(() => {
       executeSoon(fixToolbox);
       expectUncaughtException();
       toolbox.getToolPanels();
     });
 
-    waitForMessages({
-      webconsole: hud,
-      messages: [
-        {
-          text: "TypeError: can't convert null to object",
-          category: CATEGORY_JS,
-          severity: SEVERITY_ERROR,
-        },
-      ],
-    }).then((results) => {
-      fixToolbox();
-      onMessageFound(results);
+    let [result] = yield waitForMessages({
+      webconsole: browserconsole,
+      messages: [{
+        text: "TypeError: can't convert null to object",
+        category: CATEGORY_JS,
+        severity: SEVERITY_ERROR,
+      }],
     });
-  }
 
-  function onMessageFound(results)
-  {
-    let msg = [...results[0].matched][0];
+    fixToolbox();
+
+    let msg = [...result.matched][0];
     ok(msg, "message element found");
     let locationNode = msg.querySelector(".message-location");
     ok(locationNode, "message location element found");
 
     let title = locationNode.getAttribute("title");
     info("location node title: " + title);
     isnot(title.indexOf(" -> "), -1, "error comes from a subscript");
 
     let viewSource = browserconsole.viewSource;
     let URL = null;
-    browserconsole.viewSource = (aURL) => URL = aURL;
+    let clickPromise = promise.defer();
+    browserconsole.viewSource = (aURL) => {
+      info("browserconsole.viewSource() was invoked: " + aURL);
+      URL = aURL;
+      clickPromise.resolve(null);
+    };
 
+    msg.scrollIntoView();
     EventUtils.synthesizeMouse(locationNode, 2, 2, {},
                                browserconsole.iframeWindow);
 
+    info("wait for click on locationNode");
+    yield clickPromise;
+
     info("view-source url: " + URL);
-    isnot(URL.indexOf("toolbox.js"), -1, "expected view source URL");
+    ok(URL, "we have some source URL after the click");
+    isnot(URL.indexOf("toolbox.js"), -1, "we have the expected view source URL");
     is(URL.indexOf("->"), -1, "no -> in the URL given to view-source");
 
     browserconsole.viewSource = viewSource;
-
-    finishTest();
   }
 }