Bug 1437807 - Enable browser_console_addonsdk_loader_exception.js in new frontend r=jdescottes
authorMichael Ratcliffe <mratcliffe@mozilla.com>
Thu, 01 Mar 2018 18:12:19 +0000
changeset 461741 c132fa7abc4bf0f526be5d21a98bf1c8f1623b4d
parent 461740 4e86684e2bf651c18f0f2261d530f87782e98919
child 461742 880cc555591a971a9b04790a93a694315a293297
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes
bugs1437807
milestone60.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 1437807 - Enable browser_console_addonsdk_loader_exception.js in new frontend r=jdescottes MozReview-Commit-ID: 4vGsRWzuFpn
devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
devtools/client/webconsole/new-console-output/test/mochitest/browser_console_addonsdk_loader_exception.js
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
@@ -162,17 +162,16 @@ support-files =
   !/devtools/client/netmonitor/test/sjs_cors-test-server.sjs
   !/image/test/mochitest/blue.png
   !/devtools/client/framework/test/shared-head.js
   !/devtools/client/shared/test/test-actor.js
   !/devtools/client/shared/test/test-actor-registry.js
 
 [browser_console.js]
 [browser_console_addonsdk_loader_exception.js]
-skip-if = true # Bug 1437807
 [browser_console_clear_method.js]
 skip-if = true # Bug 1437843
 [browser_console_consolejsm_output.js]
 [browser_console_context_menu_entries.js]
 [browser_console_dead_objects.js]
 [browser_console_error_source_click.js]
 [browser_console_filters.js]
 [browser_console_nsiconsolemessage.js]
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_console_addonsdk_loader_exception.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_console_addonsdk_loader_exception.js
@@ -2,93 +2,63 @@
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /* import-globals-from head.js */
 
 // Check that exceptions from scripts loaded with the addon-sdk loader are
 // opened correctly in View Source from the Browser Console.
-// See bug 866950.
 
 "use strict";
 
-const TEST_URI = "data:text/html;charset=utf8,<p>hello world from bug 866950";
-
-function test() {
-  requestLongerTimeout(2);
-
-  let webconsole, browserconsole;
+const TEST_URI =
+  "data:text/html;charset=utf8,<p>browser_console_addonsdk_loader_exception.js</p>";
 
-  Task.spawn(runner).then(finishTest);
+add_task(async function () {
+  let wcHud = await openNewTabAndConsole(TEST_URI);
+  ok(wcHud, "web console opened");
 
-  function* runner() {
-    let {tab} = yield loadTab(TEST_URI);
-    webconsole = yield openConsole(tab);
-    ok(webconsole, "web console opened");
-
-    browserconsole = yield HUDService.toggleBrowserConsole();
-    ok(browserconsole, "browser console opened");
+  let bcHud = await HUDService.toggleBrowserConsole();
+  ok(bcHud, "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;
-    // non-iterable
-    toolbox._toolPanels = {};
+  // Cause an exception in a script loaded with the addon-sdk loader.
+  let toolbox = gDevTools.getToolbox(wcHud.target);
+  let oldPanels = toolbox._toolPanels;
+  // non-iterable
+  toolbox._toolPanels = {};
 
-    function fixToolbox() {
-      toolbox._toolPanels = oldPanels;
-    }
-
-    info("generate exception and wait for message");
+  function fixToolbox() {
+    toolbox._toolPanels = oldPanels;
+  }
 
-    executeSoon(() => {
-      executeSoon(fixToolbox);
-      expectUncaughtException();
-      toolbox.getToolPanels();
-    });
+  info("generate exception and wait for message");
 
-    let [result] = yield waitForMessages({
-      webconsole: browserconsole,
-      messages: [{
-        text: "TypeError: this._toolPanels is not iterable",
-        category: CATEGORY_JS,
-        severity: SEVERITY_ERROR,
-      }],
-    });
+  executeSoon(() => {
+    expectUncaughtException();
+    executeSoon(fixToolbox);
+    toolbox.getToolPanels();
+  });
 
-    fixToolbox();
+  let msg = await waitFor(() => findMessage(bcHud,
+    "TypeError: this._toolPanels is not iterable"));
 
-    let msg = [...result.matched][0];
-    ok(msg, "message element found");
-    let locationNode = msg
-      .querySelector(".message .message-location > .frame-link");
-    ok(locationNode, "message location element found");
+  fixToolbox();
 
-    let url = locationNode.getAttribute("data-url");
-    info("location node url: " + url);
-    ok(url.indexOf("resource://") === 0, "error comes from a subscript");
+  ok(msg, `Message found: "TypeError: this._toolPanels is not iterable"`);
 
-    let viewSource = browserconsole.viewSource;
-    let URL = null;
-    let clickPromise = defer();
-    browserconsole.viewSourceInDebugger = (sourceURL) => {
-      info("browserconsole.viewSourceInDebugger() was invoked: " + sourceURL);
-      URL = sourceURL;
-      clickPromise.resolve(null);
-    };
+  let locationNode = msg.querySelector(".message-location .frame-link-source");
+  ok(locationNode, "Message location link element found");
 
-    msg.scrollIntoView();
-    EventUtils.synthesizeMouse(locationNode, 2, 2, {},
-                               browserconsole.iframeWindow);
+  let url = locationNode.href;
+  info("view-source url: " + url);
+  ok(url, "we have some source URL after the click");
+  ok(url.includes("toolbox.js"), "we have the expected view source URL");
+  ok(!url.includes("->"), "no -> in the URL given to view-source");
 
-    info("wait for click on locationNode");
-    yield clickPromise.promise;
+  let onTabOpen = BrowserTestUtils.waitForNewTab(gBrowser, null, true);
+  locationNode.click();
 
-    info("view-source url: " + 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");
+  let newTab = await onTabOpen;
+  ok(true, "The view source tab was opened in response to clicking the link");
 
-    browserconsole.viewSourceInDebugger = viewSource;
-  }
-}
+  await BrowserTestUtils.removeTab(newTab);
+});