Bug 963977 - Fix for intermittent browser_console_addonsdk_loader_exception.js | Test timed out. r=me, a=test-only
authorMihai Sucan <mihai.sucan@gmail.com>
Fri, 07 Feb 2014 20:00:41 +0200
changeset 182756 f93b0e5dc32770e35be5e304e7bef547e12b9655
parent 182755 9e81f20df0b0a2f7612a1db20c3ef8a3e0204a39
child 182757 63f12087568075a95efe5b67e529e756d38a842e
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
bugs963977
milestone29.0a2
Bug 963977 - Fix for intermittent browser_console_addonsdk_loader_exception.js | Test timed out. r=me, a=test-only
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();
   }
 }