Bug 1497545 - Use getInspector in devtools/server/tests/mochitest r=ochameau
authoryulia <ystartsev@mozilla.com>
Mon, 15 Oct 2018 12:56:28 +0000
changeset 489852 2ed2e01ecdef6ac55541754551b1dc706ec370af
parent 489851 cb7c1a49aa0f706ee44229a0aa39294761656753
child 489853 229ac4221d11345be4ee0fc82b4877dca3dcd524
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersochameau
bugs1497545
milestone64.0a1
Bug 1497545 - Use getInspector in devtools/server/tests/mochitest r=ochameau This patch converts all getInspector locations Depends on D8369 Differential Revision: https://phabricator.services.mozilla.com/D8372
devtools/server/tests/mochitest/test_animation_actor-lifetime.html
devtools/server/tests/mochitest/test_css-properties.html
devtools/server/tests/mochitest/test_inspector-anonymous.html
devtools/server/tests/mochitest/test_inspector-changeattrs.html
devtools/server/tests/mochitest/test_inspector-changevalue.html
devtools/server/tests/mochitest/test_inspector-dead-nodes.html
devtools/server/tests/mochitest/test_inspector-display-type.html
devtools/server/tests/mochitest/test_inspector-duplicate-node.html
devtools/server/tests/mochitest/test_inspector-hide.html
devtools/server/tests/mochitest/test_inspector-insert.html
devtools/server/tests/mochitest/test_inspector-mutations-attr.html
devtools/server/tests/mochitest/test_inspector-mutations-childlist.html
devtools/server/tests/mochitest/test_inspector-mutations-events.html
devtools/server/tests/mochitest/test_inspector-mutations-frameload.html
devtools/server/tests/mochitest/test_inspector-mutations-value.html
devtools/server/tests/mochitest/test_inspector-pick-color.html
devtools/server/tests/mochitest/test_inspector-pseudoclass-lock.html
devtools/server/tests/mochitest/test_inspector-release.html
devtools/server/tests/mochitest/test_inspector-reload.html
devtools/server/tests/mochitest/test_inspector-remove.html
devtools/server/tests/mochitest/test_inspector-resize.html
devtools/server/tests/mochitest/test_inspector-resolve-url.html
devtools/server/tests/mochitest/test_inspector-retain.html
devtools/server/tests/mochitest/test_inspector-scroll-into-view.html
devtools/server/tests/mochitest/test_inspector-search-front.html
devtools/server/tests/mochitest/test_inspector-search.html
devtools/server/tests/mochitest/test_inspector-template.html
devtools/server/tests/mochitest/test_inspector-traversal.html
devtools/server/tests/mochitest/test_inspector_getImageData-wait-for-load.html
devtools/server/tests/mochitest/test_inspector_getImageData.html
devtools/server/tests/mochitest/test_inspector_getImageDataFromURL.html
devtools/server/tests/mochitest/test_inspector_getNodeFromActor.html
devtools/server/tests/mochitest/test_inspector_getOffsetParent.html
devtools/server/tests/mochitest/test_styles-applied.html
devtools/server/tests/mochitest/test_styles-computed.html
devtools/server/tests/mochitest/test_styles-layout.html
devtools/server/tests/mochitest/test_styles-matched.html
devtools/server/tests/mochitest/test_styles-modify.html
devtools/server/tests/mochitest/test_styles-svg.html
--- a/devtools/server/tests/mochitest/test_animation_actor-lifetime.html
+++ b/devtools/server/tests/mochitest/test_animation_actor-lifetime.html
@@ -9,38 +9,32 @@ https://bugzilla.mozilla.org/show_bug.cg
 
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
   <script type="application/javascript" src="inspector-helpers.js"></script>
   <script type="application/javascript">
 "use strict";
 
 window.onload = function() {
-  const {AnimationsFront} = require("devtools/shared/fronts/animation");
-  const {InspectorFront} = require("devtools/shared/fronts/inspector");
-
   SimpleTest.waitForExplicitFinish();
 
   let gWalker = null;
   let animationsFront = null;
 
-  addTest(function setup() {
+  addTest(async function setup() {
     info("Setting up inspector and animation actors.");
 
     const url = document.getElementById("animationContent").href;
-    attachURL(url, function(err, client, tab, doc) {
-      const inspector = InspectorFront(client, tab);
 
-      animationsFront = new AnimationsFront(client, tab);
-
-      promiseDone(inspector.getWalker().then(walker => {
-        ok(walker, "getWalker() should return an actor.");
-        gWalker = walker;
-      }).then(runNextTest));
-    });
+    const { target } = await attachURL(url);
+    const inspector = target.getInspector();
+    animationsFront = target.getFront("animations");
+    gWalker = await inspector.getWalker();
+    ok(gWalker, "getWalker() should return an actor.");
+    runNextTest();
   });
 
   addAsyncTest(async function testActorLifetime() {
     info("Testing animated node actor");
     const animatedNodeActor = await gWalker.querySelector(gWalker.rootNode,
       ".animated");
     await animationsFront.getAnimationPlayersForNode(animatedNodeActor);
 
--- a/devtools/server/tests/mochitest/test_css-properties.html
+++ b/devtools/server/tests/mochitest/test_css-properties.html
@@ -10,71 +10,48 @@ Bug 1265798 - Replace inIDOMUtils.cssPro
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
   <script type="application/javascript" src="inspector-helpers.js"></script>
   <script type="application/javascript">
 "use strict";
 
 window.onload = function() {
   const { initCssProperties, getCssProperties } =
     require("devtools/shared/fronts/css-properties");
-  const { getFront } =
-    require("devtools/shared/protocol");
-
-  function promiseAttachUrl(url) {
-    return new Promise((resolve, reject) => {
-      attachURL(url, function(err, client, tab, doc) {
-        if (err) {
-          return reject(err);
-        }
-        return resolve({client, tab, doc});
-      });
-    });
-  }
 
   function toSortedString(array) {
     return JSON.stringify(array.sort());
   }
 
+  // Return some mocked values for a tab. Override hasActor with the
+  // options passed into the test. A second property is used
+  // during these tests: `win` for css-properties.js's getClientBrowserVersion.
+  async function getTabProperties(url, useActor) {
+    const { target, win } = await attachURL(url);
+    target.hasActor = () => useActor;
+    return { target, win };
+  }
+
   const runCssPropertiesTests = async function(url, useActor) {
     info(`Opening two tabs ${useActor ? "with" : "without"} CssPropertiesActor support.`);
 
-    const attachmentA = await promiseAttachUrl(url);
-    const attachmentB = await promiseAttachUrl(url);
+    // Open a new tab. The only property we are interested in is `target`.
+    const tabA = await getTabProperties(url, useActor);
+    const tabB = await getTabProperties(url, useActor);
 
-    const toolboxMockA = {
-      target: {
-        hasActor: () => useActor,
-        client: attachmentA.client,
-        form: attachmentA.tab,
-        getFront: typeName => getFront(attachmentA.client, typeName, attachmentA.tab)
-      },
-      // Fake the window for css-properties.js's getClientBrowserVersion to work
-      win: window
-    };
-    const toolboxMockB = {
-      target: {
-        hasActor: () => useActor,
-        client: attachmentB.client,
-        form: attachmentB.tab,
-        getFront: typeName => getFront(attachmentB.client, typeName, attachmentB.tab)
-      },
-      win: window
-    };
+    await initCssProperties(tabA);
+    await initCssProperties(tabB);
 
-    await initCssProperties(toolboxMockA);
-    await initCssProperties(toolboxMockB);
-
-    const cssProperties = getCssProperties(toolboxMockA);
-    const cssPropertiesA = getCssProperties(toolboxMockA);
-    const cssPropertiesB = getCssProperties(toolboxMockB);
+    const cssProperties = getCssProperties(tabA);
+    const cssPropertiesA = getCssProperties(tabA);
+    const cssPropertiesB = getCssProperties(tabB);
 
     is(cssProperties, cssPropertiesA,
-       "Multiple calls with the same toolbox returns the same object.");
+       "Multiple calls with the same target returns the same object.");
     isnot(cssProperties, cssPropertiesB,
-       "Multiple calls with the different toolboxes return different " +
+       "Multiple calls with the different target return different " +
        " objects.");
 
     ok(cssProperties.isKnown("border"),
       "The `border` shorthand property is known.");
     ok(cssProperties.isKnown("display"),
       "The `display` property is known.");
     ok(!cssProperties.isKnown("foobar"),
       "A fake property is not known.");
--- a/devtools/server/tests/mochitest/test_inspector-anonymous.html
+++ b/devtools/server/tests/mochitest/test_inspector-anonymous.html
@@ -9,45 +9,42 @@ https://bugzilla.mozilla.org/show_bug.cg
 
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
   <script type="application/javascript" src="inspector-helpers.js"></script>
   <script type="application/javascript">
 "use strict";
 
 window.onload = function() {
-  const {InspectorFront} =
-    require("devtools/shared/fronts/inspector");
   const {DocumentWalker: _documentWalker} =
     require("devtools/server/actors/inspector/document-walker");
 
   const nodeFilterConstants =
     require("devtools/shared/dom-node-filter-constants");
   const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 
   SpecialPowers.pushPrefEnv({"set": [
     ["dom.webcomponents.shadowdom.enabled", true]
   ]});
   SimpleTest.waitForExplicitFinish();
 
   let gWalker = null;
   let gInspectee = null;
 
-  addTest(function setup() {
+  addTest(async function setup() {
     info("Setting up inspector and walker actors.");
 
     const url = document.getElementById("inspectorContent").href;
-    attachURL(url, function(err, client, tab, doc) {
-      gInspectee = doc;
-      const inspector = InspectorFront(client, tab);
-      promiseDone(inspector.getWalker().then(walker => {
-        ok(walker, "getWalker() should return an actor.");
-        gWalker = walker;
-      }).then(runNextTest));
-    });
+    const { target, doc } = await attachURL(url);
+    gInspectee = doc;
+    const inspector = target.getInspector();
+    const walker = await inspector.getWalker();
+    ok(walker, "getWalker() should return an actor.");
+    gWalker = walker;
+    runNextTest();
   });
 
   addAsyncTest(async function testXBLAnonymousInHTMLDocument() {
     info("Testing XBL anonymous in an HTML document.");
     const rawToolbarbutton = gInspectee.createElementNS(XUL_NS, "toolbarbutton");
     gInspectee.documentElement.appendChild(rawToolbarbutton);
 
     const toolbarbutton = await gWalker.querySelector(gWalker.rootNode, "toolbarbutton");
--- a/devtools/server/tests/mochitest/test_inspector-changeattrs.html
+++ b/devtools/server/tests/mochitest/test_inspector-changeattrs.html
@@ -16,27 +16,24 @@ https://bugzilla.mozilla.org/show_bug.cg
 window.onload = function() {
   SimpleTest.waitForExplicitFinish();
   runNextTest();
 };
 
 let gInspectee = null;
 let gWalker = null;
 
-addTest(function setup() {
+addTest(async function setup() {
   const url = document.getElementById("inspectorContent").href;
-  attachURL(url, function(err, client, tab, doc) {
-    gInspectee = doc;
-    const {InspectorFront} = require("devtools/shared/fronts/inspector");
-    const inspector = InspectorFront(client, tab);
-    promiseDone(inspector.getWalker().then(walker => {
-      ok(walker, "getWalker() should return an actor.");
-      gWalker = walker;
-    }).then(runNextTest));
-  });
+  const { target, doc } = await attachURL(url);
+  gInspectee = doc;
+  const inspector = target.getInspector();
+  gWalker = await inspector.getWalker();
+  ok(gWalker, "getWalker() should return an actor.");
+  runNextTest();
 });
 
 addTest(function testChangeAttrs() {
   const attrNode = gInspectee.querySelector("#a");
   let attrFront;
   promiseDone(gWalker.querySelector(gWalker.rootNode, "#a").then(front => {
     attrFront = front;
     dump("attrFront is: " + attrFront + "\n");
--- a/devtools/server/tests/mochitest/test_inspector-changevalue.html
+++ b/devtools/server/tests/mochitest/test_inspector-changevalue.html
@@ -16,27 +16,25 @@ https://bugzilla.mozilla.org/show_bug.cg
 window.onload = function() {
   SimpleTest.waitForExplicitFinish();
   runNextTest();
 };
 
 let gInspectee = null;
 let gWalker = null;
 
-addTest(function setup() {
+addTest(async function setup() {
   const url = document.getElementById("inspectorContent").href;
-  attachURL(url, function(err, client, tab, doc) {
-    gInspectee = doc;
-    const {InspectorFront} = require("devtools/shared/fronts/inspector");
-    const inspector = InspectorFront(client, tab);
-    promiseDone(inspector.getWalker().then(walker => {
-      ok(walker, "getWalker() should return an actor.");
-      gWalker = walker;
-    }).then(runNextTest));
-  });
+  const { target, doc } = await attachURL(url);
+  gInspectee = doc;
+  const inspector = target.getInspector();
+  const walker = await inspector.getWalker();
+  ok(walker, "getWalker() should return an actor.");
+  gWalker = walker;
+  runNextTest();
 });
 
 addTest(function testChangeValue() {
   const contentNode = gInspectee.querySelector("#a").firstChild;
   let nodeFront;
   promiseDone(gWalker.querySelector(gWalker.rootNode, "#a").then(front => {
     // Get the text child
     return gWalker.children(front, { maxNodes: 1 });
--- a/devtools/server/tests/mochitest/test_inspector-dead-nodes.html
+++ b/devtools/server/tests/mochitest/test_inspector-dead-nodes.html
@@ -18,29 +18,20 @@ window.onload = function() {
   runNextTest();
 };
 
 let gWalker = null;
 let gDoc = null;
 
 addAsyncTest(async function() {
   const url = document.getElementById("inspectorContent").href;
-
-  const attachURLPromise = new Promise(resolve => {
-    attachURL(url, function(err, client, tab, doc) {
-      resolve({client, tab, doc});
-    });
-  });
-  const {client, tab, doc} = await attachURLPromise;
+  const { target, doc } = await attachURL(url);
   gDoc = doc;
-
-  const {InspectorFront} = require("devtools/shared/fronts/inspector");
-  const inspector = InspectorFront(client, tab);
+  const inspector = target.getInspector();
   gWalker = await inspector.getWalker();
-
   runNextTest();
 });
 
 addAsyncTest(async function() {
   info("Getting a nodeFront, reloading the page, and calling " +
     "walker.children(nodeFront) before the load completes shouldn't fail");
 
   const nodeFront = await gWalker.querySelector(gWalker.rootNode, "body");
--- a/devtools/server/tests/mochitest/test_inspector-display-type.html
+++ b/devtools/server/tests/mochitest/test_inspector-display-type.html
@@ -15,26 +15,22 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 window.onload = function() {
   SimpleTest.waitForExplicitFinish();
   runNextTest();
 };
 
 var gWalker;
 
-addTest(function setup() {
+addTest(async function setup() {
   const url = document.getElementById("inspectorContent").href;
-  attachURL(url, function(err, client, tab, doc) {
-    const {InspectorFront} = require("devtools/shared/fronts/inspector");
-    const inspector = InspectorFront(client, tab);
-
-    promiseDone(inspector.getWalker().then(walker => {
-      gWalker = walker;
-    }).then(runNextTest));
-  });
+  const { target } = await attachURL(url);
+  const inspector = target.getInspector();
+  gWalker = await inspector.getWalker();
+  runNextTest();
 });
 
 addAsyncTest(async function testInlineBlockDisplayType() {
   info("Test getting the display type of an inline block element.");
   const node = await gWalker.querySelector(gWalker.rootNode, "#inline-block");
   const displayType = node.displayType;
   is(displayType, "inline-block", "The node has a display type of 'inline-block'.");
   runNextTest();
--- a/devtools/server/tests/mochitest/test_inspector-duplicate-node.html
+++ b/devtools/server/tests/mochitest/test_inspector-duplicate-node.html
@@ -15,26 +15,23 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 window.onload = function() {
   SimpleTest.waitForExplicitFinish();
   runNextTest();
 };
 
 let gWalker = null;
 
-addTest(function setup() {
+addTest(async function setup() {
   const url = document.getElementById("inspectorContent").href;
-  attachURL(url, function(err, client, tab, doc) {
-    const {InspectorFront} = require("devtools/shared/fronts/inspector");
-    const inspector = InspectorFront(client, tab);
-    promiseDone(inspector.getWalker().then(walker => {
-      ok(walker, "getWalker() should return an actor.");
-      gWalker = walker;
-    }).then(runNextTest));
-  });
+  const { target } = await attachURL(url);
+  const inspector = target.getInspector();
+  gWalker = await inspector.getWalker();
+  ok(gWalker, "getWalker() should return an actor.");
+  runNextTest();
 });
 
 addTest(async function testDuplicateNode() {
   const className = ".node-to-duplicate";
   let matches = await gWalker.querySelectorAll(gWalker.rootNode, className);
   is(matches.length, 1, "There should initially be one node to duplicate.");
 
   const nodeFront = await gWalker.querySelector(gWalker.rootNode, className);
--- a/devtools/server/tests/mochitest/test_inspector-hide.html
+++ b/devtools/server/tests/mochitest/test_inspector-hide.html
@@ -16,27 +16,24 @@ https://bugzilla.mozilla.org/show_bug.cg
 window.onload = function() {
   SimpleTest.waitForExplicitFinish();
   runNextTest();
 };
 
 let gWalker = null;
 let gInspectee = null;
 
-addTest(function setup() {
+addTest(async function setup() {
   const url = document.getElementById("inspectorContent").href;
-  attachURL(url, function(err, client, tab, doc) {
-    gInspectee = doc;
-    const {InspectorFront} = require("devtools/shared/fronts/inspector");
-    const inspector = InspectorFront(client, tab);
-    promiseDone(inspector.getWalker().then(walker => {
-      ok(walker, "getWalker() should return an actor.");
-      gWalker = walker;
-    }).then(runNextTest));
-  });
+  const { target, doc } = await attachURL(url);
+  const inspector = target.getInspector();
+  gInspectee = doc;
+  gWalker = await inspector.getWalker();
+  ok(gWalker, "getWalker() should return an actor.");
+  runNextTest();
 });
 
 addTest(function testRearrange() {
   let listFront = null;
   const listNode = gInspectee.querySelector("#longlist");
 
   promiseDone(gWalker.querySelector(gWalker.rootNode, "#longlist").then(front => {
     listFront = front;
--- a/devtools/server/tests/mochitest/test_inspector-insert.html
+++ b/devtools/server/tests/mochitest/test_inspector-insert.html
@@ -18,27 +18,25 @@ const {DocumentWalker} = require("devtoo
 window.onload = function() {
   SimpleTest.waitForExplicitFinish();
   runNextTest();
 };
 
 let gWalker = null;
 let gInspectee = null;
 
-addTest(function setup() {
+addTest(async function setup() {
   const url = document.getElementById("inspectorContent").href;
-  attachURL(url, function(err, client, tab, doc) {
-    gInspectee = doc;
-    const {InspectorFront} = require("devtools/shared/fronts/inspector");
-    const inspectorFront = InspectorFront(client, tab);
-    promiseDone(inspectorFront.getWalker().then(walker => {
-      ok(walker, "getWalker() should return an actor.");
-      gWalker = walker;
-    }).then(runNextTest));
-  });
+  const { target, doc } = await attachURL(url);
+  gInspectee = doc;
+  const inspector = target.getInspector();
+  const walker = await inspector.getWalker();
+  ok(walker, "getWalker() should return an actor.");
+  gWalker = walker;
+  runNextTest();
 });
 
 addAsyncTest(async function testRearrange() {
   const longlist = await gWalker.querySelector(gWalker.rootNode, "#longlist");
   let children = await gWalker.children(longlist);
   const nodeA = children.nodes[0];
   is(nodeA.id, "a", "Got the expected node.");
 
--- a/devtools/server/tests/mochitest/test_inspector-mutations-attr.html
+++ b/devtools/server/tests/mochitest/test_inspector-mutations-attr.html
@@ -18,27 +18,24 @@ window.onload = function() {
   runNextTest();
 };
 
 let gInspectee = null;
 let gWalker = null;
 let attrNode;
 let attrFront;
 
-addTest(function setup() {
+addTest(async function setup() {
   const url = document.getElementById("inspectorContent").href;
-  attachURL(url, function(err, client, tab, doc) {
-    gInspectee = doc;
-    const {InspectorFront} = require("devtools/shared/fronts/inspector");
-    const inspector = InspectorFront(client, tab);
-    promiseDone(inspector.getWalker().then(walker => {
-      ok(walker, "getWalker() should return an actor.");
-      gWalker = walker;
-    }).then(runNextTest));
-  });
+  const { target, doc } = await attachURL(url);
+  const inspector = target.getInspector();
+  gInspectee = doc;
+  gWalker = await inspector.getWalker();
+  ok(gWalker, "getWalker() should return an actor.");
+  runNextTest();
 });
 
 addTest(setupAttrTest);
 addTest(testAddAttribute);
 addTest(testChangeAttribute);
 addTest(testRemoveAttribute);
 addTest(testQueuedMutations);
 addTest(setupFrameAttrTest);
--- a/devtools/server/tests/mochitest/test_inspector-mutations-childlist.html
+++ b/devtools/server/tests/mochitest/test_inspector-mutations-childlist.html
@@ -17,26 +17,25 @@ window.onload = function() {
   SimpleTest.waitForExplicitFinish();
   runNextTest();
 };
 
 let gInspectee = null;
 let gWalker = null;
 let gCleanupConnection = null;
 
-function setup(callback) {
+async function setup(callback) {
   const url = document.getElementById("inspectorContent").href;
-  gCleanupConnection = attachURL(url, function(err, client, tab, doc) {
-    gInspectee = doc;
-    const {InspectorFront} = require("devtools/shared/fronts/inspector");
-    const inspector = InspectorFront(client, tab);
-    promiseDone(inspector.getWalker().then(walker => {
-      gWalker = walker;
-    }).then(callback));
-  });
+  const { target, doc, cleanup } = await attachURL(url);
+  gInspectee = doc;
+  const inspector = target.getInspector();
+  gWalker = await inspector.getWalker();
+  ok(gWalker, "getWalker() should return an actor.");
+  gCleanupConnection = cleanup;
+  callback();
 }
 
 function teardown() {
   gWalker = null;
   gInspectee = null;
   if (gCleanupConnection) {
     gCleanupConnection();
     gCleanupConnection = null;
--- a/devtools/server/tests/mochitest/test_inspector-mutations-events.html
+++ b/devtools/server/tests/mochitest/test_inspector-mutations-events.html
@@ -8,43 +8,34 @@ https://bugzilla.mozilla.org/show_bug.cg
   <title>Test for Bug 1157469</title>
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
   <script type="application/javascript" src="inspector-helpers.js"></script>
   <script type="application/javascript">
 "use strict";
 
 window.onload = function() {
-  const {require} = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
-  const {InspectorFront} = require("devtools/shared/fronts/inspector");
-
   SimpleTest.waitForExplicitFinish();
 
   let inspectee = null;
   let inspector = null;
   let walker = null;
   const eventListener1 = function() {};
   const eventListener2 = function() {};
   let eventNode1;
   let eventNode2;
   let eventFront1;
   let eventFront2;
 
   addAsyncTest(async function setup() {
     info("Setting up inspector and walker actors.");
     const url = document.getElementById("inspectorContent").href;
-
-    await new Promise(resolve => {
-      attachURL(url, function(err, client, tab, doc) {
-        inspectee = doc;
-        inspector = InspectorFront(client, tab);
-        resolve();
-      });
-    });
-
+    const { target, doc } = await attachURL(url);
+    inspectee = doc;
+    inspector = target.getInspector();
     walker = await inspector.getWalker();
     ok(walker, "getWalker() should return an actor.");
 
     runNextTest();
   });
 
   addAsyncTest(async function setupEventTest() {
     eventNode1 = inspectee.querySelector("#a");
--- a/devtools/server/tests/mochitest/test_inspector-mutations-frameload.html
+++ b/devtools/server/tests/mochitest/test_inspector-mutations-frameload.html
@@ -18,27 +18,25 @@ window.onload = function() {
   runNextTest();
 };
 
 let gInspectee = null;
 let gWalker = null;
 let gClient = null;
 let gCleanupConnection = null;
 
-function setup(callback) {
+async function setup(callback) {
   const url = document.getElementById("inspectorContent").href;
-  gCleanupConnection = attachURL(url, function(err, client, tab, doc) {
-    gInspectee = doc;
-    const {InspectorFront} = require("devtools/shared/fronts/inspector");
-    const inspector = InspectorFront(client, tab);
-    promiseDone(inspector.getWalker().then(walker => {
-      gClient = client;
-      gWalker = walker;
-    }).then(callback));
-  });
+  const { client, target, doc, cleanup } = await attachURL(url);
+  gInspectee = doc;
+  gClient = client;
+  const inspector = target.getInspector();
+  gWalker = await inspector.getWalker();
+  gCleanupConnection = cleanup;
+  await callback();
 }
 
 function teardown() {
   gWalker = null;
   gClient = null;
   gInspectee = null;
   if (gCleanupConnection) {
     gCleanupConnection();
--- a/devtools/server/tests/mochitest/test_inspector-mutations-value.html
+++ b/devtools/server/tests/mochitest/test_inspector-mutations-value.html
@@ -30,27 +30,24 @@ let gInspectee = null;
 let gWalker = null;
 let valueNode;
 var valueFront;
 var longStringFront;
 var longString = "stringstringstringstringstringstringstringstringstringstringstring";
 var shortString = "str";
 var shortString2 = "str2";
 
-addTest(function setup() {
+addTest(async function setup() {
   const url = document.getElementById("inspectorContent").href;
-  attachURL(url, function(err, client, tab, doc) {
-    gInspectee = doc;
-    const {InspectorFront} = require("devtools/shared/fronts/inspector");
-    const inspectorFront = InspectorFront(client, tab);
-    promiseDone(inspectorFront.getWalker().then(walker => {
-      ok(walker, "getWalker() should return an actor.");
-      gWalker = walker;
-    }).then(runNextTest));
-  });
+  const { target, doc } = await attachURL(url);
+  const inspector = target.getInspector();
+  gInspectee = doc;
+  gWalker = await inspector.getWalker();
+  ok(gWalker, "getWalker() should return an actor.");
+  runNextTest();
 });
 
 addTest(setupValueTest);
 addTest(testKeepLongValue);
 addTest(testSetShortValue);
 addTest(testKeepShortValue);
 addTest(testSetLongValue);
 addTest(setupFrameValueTest);
--- a/devtools/server/tests/mochitest/test_inspector-pick-color.html
+++ b/devtools/server/tests/mochitest/test_inspector-pick-color.html
@@ -11,36 +11,28 @@ https://bugzilla.mozilla.org/show_bug.cg
   <title>Test for Bug 1262439</title>
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
   <script type="application/javascript" src="inspector-helpers.js"></script>
   <script type="application/javascript">
 "use strict";
 
 window.onload = function() {
-  const {InspectorFront} = require("devtools/shared/fronts/inspector");
-
   SimpleTest.waitForExplicitFinish();
 
   let win = null;
   let inspector = null;
 
   addAsyncTest(async function() {
     info("Setting up inspector actor");
 
     const url = document.getElementById("inspectorContent").href;
-
-    await new Promise(resolve => {
-      attachURL(url, function(err, client, tab, doc) {
-        win = doc.defaultView;
-        inspector = InspectorFront(client, tab);
-        resolve();
-      });
-    });
-
+    const { target, doc } = await attachURL(url);
+    inspector = target.getInspector();
+    win = doc.defaultView;
     runNextTest();
   });
 
   addAsyncTest(async function() {
     info("Start picking a color from the page");
     await inspector.pickColorFromPage();
 
     info("Click in the page and make sure a color-picked event is received");
--- a/devtools/server/tests/mochitest/test_inspector-pseudoclass-lock.html
+++ b/devtools/server/tests/mochitest/test_inspector-pseudoclass-lock.html
@@ -21,26 +21,26 @@ window.onload = function() {
 };
 
 const InspectorUtils = require("InspectorUtils");
 
 let gInspectee = null;
 let gWalker = null;
 let gCleanupConnection = null;
 
-function setup(callback) {
+async function setup(callback) {
   const url = document.getElementById("inspectorContent").href;
-  gCleanupConnection = attachURL(url, function(err, client, tab, doc) {
-    gInspectee = doc;
-    const {InspectorFront} = require("devtools/shared/fronts/inspector");
-    const inspector = InspectorFront(client, tab);
-    promiseDone(inspector.getWalker().then(walker => {
-      gWalker = walker;
-    }).then(callback));
-  });
+  const { target, doc, cleanup } = await attachURL(url);
+  gInspectee = doc;
+  const inspector = target.getInspector();
+  const walker = await inspector.getWalker();
+  ok(walker, "getWalker() should return an actor.");
+  gWalker = walker;
+  gCleanupConnection = cleanup;
+  runNextTest();
 }
 
 function teardown() {
   gWalker = null;
   gInspectee = null;
   if (gCleanupConnection) {
     gCleanupConnection();
     gCleanupConnection = null;
--- a/devtools/server/tests/mochitest/test_inspector-release.html
+++ b/devtools/server/tests/mochitest/test_inspector-release.html
@@ -20,27 +20,24 @@ window.onload = function() {
 
 let gWalker = null;
 let gClient = null;
 
 function assertOwnership() {
   return assertOwnershipTrees(gWalker);
 }
 
-addTest(function setup() {
+addTest(async function setup() {
   const url = document.getElementById("inspectorContent").href;
-  attachURL(url, function(err, client, tab, doc) {
-    const {InspectorFront} = require("devtools/shared/fronts/inspector");
-    const inspector = InspectorFront(client, tab);
-    promiseDone(inspector.getWalker().then(walker => {
-      ok(walker, "getWalker() should return an actor.");
-      gClient = client;
-      gWalker = walker;
-    }).then(runNextTest));
-  });
+  const { client, target } = await attachURL(url);
+  const inspector = target.getInspector();
+  gClient = client;
+  gWalker = await inspector.getWalker();
+  ok(gWalker, "getWalker() should return an actor.");
+  runNextTest();
 });
 
 addTest(function testReleaseSubtree() {
   let originalOwnershipSize = 0;
   let longlist = null;
   let firstChild = null;
   promiseDone(gWalker.querySelectorAll(gWalker.rootNode, "#longlist div").then(list => {
     // Make sure we have the 26 children of longlist in our ownership tree.
--- a/devtools/server/tests/mochitest/test_inspector-reload.html
+++ b/devtools/server/tests/mochitest/test_inspector-reload.html
@@ -16,31 +16,27 @@ https://bugzilla.mozilla.org/show_bug.cg
 window.onload = function() {
   SimpleTest.waitForExplicitFinish();
   runNextTest();
 };
 
 let gInspectee = null;
 let gWalker = null;
 
-addTest(function setup() {
+addTest(async function setup() {
   const url = document.getElementById("inspectorContent").href;
-  attachURL(url, function(err, client, tab, doc) {
-    gInspectee = doc;
-    const {InspectorFront} = require("devtools/shared/fronts/inspector");
-    const inspector = InspectorFront(client, tab);
-    promiseDone(inspector.getWalker().then(walker => {
-      ok(walker, "getWalker() should return an actor.");
-      gWalker = walker;
-      return inspector.getWalker();
-    }).then(walker => {
-      dump(walker.actorID + "\n");
-      ok(walker === gWalker, "getWalker() twice should return the same walker.");
-    }).then(runNextTest));
-  });
+  const { target, doc } = await attachURL(url);
+  const inspector = target.getInspector();
+  gInspectee = doc;
+  const walker = await inspector.getWalker();
+  ok(walker, "getWalker() should return an actor.");
+  dump(walker.actorID + "\n");
+  gWalker = await inspector.getWalker();
+  ok(walker === gWalker, "getWalker() twice should return the same walker.");
+  runNextTest();
 });
 
 addTest(function testReload() {
   const oldRootID = gWalker.rootNode.actorID;
   // Load a node to populate the tree a bit.
   promiseDone(gWalker.querySelector(gWalker.rootNode, "#a").then(front => {
     gInspectee.defaultView.location.reload();
     return waitForMutation(gWalker, isNewRoot);
--- a/devtools/server/tests/mochitest/test_inspector-remove.html
+++ b/devtools/server/tests/mochitest/test_inspector-remove.html
@@ -27,28 +27,25 @@ function assertOwnership() {
 }
 
 function ignoreNode(node) {
   // Duplicate the walker logic to skip blank nodes...
   return node.nodeType === Node.TEXT_NODE &&
     !/[^\s]/.test(node.nodeValue);
 }
 
-addTest(function setup() {
+addTest(async function setup() {
   const url = document.getElementById("inspectorContent").href;
-  attachURL(url, function(err, client, tab, doc) {
-    gInspectee = doc;
-    const {InspectorFront} = require("devtools/shared/fronts/inspector");
-    const inspector = InspectorFront(client, tab);
-    promiseDone(inspector.getWalker().then(walker => {
-      ok(walker, "getWalker() should return an actor.");
-      gClient = client;
-      gWalker = walker;
-    }).then(runNextTest));
-  });
+  const { client, target, doc } = await attachURL(url);
+  gInspectee = doc;
+  const inspector = target.getInspector();
+  gWalker = await inspector.getWalker();
+  ok(gWalker, "getWalker() should return an actor.");
+  gClient = client;
+  runNextTest();
 });
 
 addTest(function testRemoveSubtree() {
   let originalOwnershipSize = 0;
   let longlist = null;
   let longlistID = null;
 
   let nextSibling = gInspectee.querySelector("#longlist").nextSibling;
--- a/devtools/server/tests/mochitest/test_inspector-resize.html
+++ b/devtools/server/tests/mochitest/test_inspector-resize.html
@@ -9,38 +9,29 @@ https://bugzilla.mozilla.org/show_bug.cg
   <title>Test for Bug 1222409</title>
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
   <script type="application/javascript" src="inspector-helpers.js"></script>
   <script type="application/javascript">
 "use strict";
 
 window.onload = function() {
-  const {require} = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
-  const {InspectorFront} = require("devtools/shared/fronts/inspector");
-
   SimpleTest.waitForExplicitFinish();
 
   let win = null;
   let inspector = null;
 
   addAsyncTest(async function setup() {
     info("Setting up inspector and walker actors.");
 
     const url = document.getElementById("inspectorContent").href;
 
-    // eslint-disable-next-line new-cap
-    await new Promise(resolve => {
-      attachURL(url, function(err, client, tab, doc) {
-        win = doc.defaultView;
-        inspector = InspectorFront(client, tab);
-        resolve();
-      });
-    });
-
+    const { target, doc } = await attachURL(url);
+    inspector = target.getInspector();
+    win = doc.defaultView;
     runNextTest();
   });
 
   addAsyncTest(async function() {
     const walker = await inspector.getWalker();
 
     // We can't receive events from the walker if we haven't first executed a
     // method on the actor to initialize it.
--- a/devtools/server/tests/mochitest/test_inspector-resolve-url.html
+++ b/devtools/server/tests/mochitest/test_inspector-resolve-url.html
@@ -16,24 +16,22 @@ https://bugzilla.mozilla.org/show_bug.cg
 window.onload = function() {
   SimpleTest.waitForExplicitFinish();
   runNextTest();
 };
 
 let gInspector;
 let gDoc;
 
-addTest(function() {
+addTest(async function() {
   const url = document.getElementById("inspectorContent").href;
-  attachURL(url, function(err, client, tab, doc) {
-    gDoc = doc;
-    const {InspectorFront} = require("devtools/shared/fronts/inspector");
-    gInspector = InspectorFront(client, tab);
-    runNextTest();
-  });
+  const { target, doc } = await attachURL(url);
+  gInspector = target.getInspector();
+  gDoc = doc;
+  runNextTest();
 });
 
 addTest(function() {
   info("Resolve a relative URL without providing a context node");
   gInspector.resolveRelativeURL("test.png?id=4#wow").then(url => {
     is(url, "chrome://mochitests/content/chrome/devtools/server/tests/" +
             "mochitest/test.png?id=4#wow");
     runNextTest();
--- a/devtools/server/tests/mochitest/test_inspector-retain.html
+++ b/devtools/server/tests/mochitest/test_inspector-retain.html
@@ -20,27 +20,23 @@ window.onload = function() {
 
 let gWalker = null;
 let gInspectee = null;
 
 function assertOwnership() {
   return assertOwnershipTrees(gWalker);
 }
 
-addTest(function setup() {
+addTest(async function setup() {
   const url = document.getElementById("inspectorContent").href;
-  attachURL(url, function(err, client, tab, doc) {
-    gInspectee = doc;
-    const {InspectorFront} = require("devtools/shared/fronts/inspector");
-    const inspector = InspectorFront(client, tab);
-    promiseDone(inspector.getWalker().then(walker => {
-      ok(walker, "getWalker() should return an actor.");
-      gWalker = walker;
-    }).then(runNextTest));
-  });
+  const { target, doc } = await attachURL(url);
+  const inspector = target.getInspector();
+  gInspectee = doc;
+  gWalker = await inspector.getWalker();
+  runNextTest();
 });
 
 // Retain a node, and a second-order child (in another document, for kicks)
 // Release the parent of the top item, which should cause one retained orphan.
 
 // Then unretain the top node, which should retain the orphan.
 
 // Then change the source of the iframe, which should kill that orphan.
--- a/devtools/server/tests/mochitest/test_inspector-scroll-into-view.html
+++ b/devtools/server/tests/mochitest/test_inspector-scroll-into-view.html
@@ -16,27 +16,24 @@ https://bugzilla.mozilla.org/show_bug.cg
 window.onload = function() {
   SimpleTest.waitForExplicitFinish();
   runNextTest();
 };
 
 let gInspectee = null;
 let gWalker = null;
 
-addTest(function setup() {
+addTest(async function setup() {
   const url = document.getElementById("inspectorContent").href;
-  attachURL(url, function(err, client, tab, doc) {
-    gInspectee = doc;
-    const {InspectorFront} = require("devtools/shared/fronts/inspector");
-    const inspector = InspectorFront(client, tab);
-    promiseDone(inspector.getWalker().then(walker => {
-      ok(walker, "getWalker() should return an actor.");
-      gWalker = walker;
-    }).then(runNextTest));
-  });
+  const { target, doc } = await attachURL(url);
+  gInspectee = doc;
+  const inspector = target.getInspector();
+  gWalker = await inspector.getWalker();
+  ok(gWalker, "getWalker() should return an actor.");
+  runNextTest();
 });
 
 addTest(async function testScrollIntoView() {
   const id = "#scroll-into-view";
   let rect = gInspectee.querySelector(id).getBoundingClientRect();
   const nodeFront = await gWalker.querySelector(gWalker.rootNode, id);
   let inViewport = rect.x >= 0 &&
                    rect.y >= 0 &&
--- a/devtools/server/tests/mochitest/test_inspector-search-front.html
+++ b/devtools/server/tests/mochitest/test_inspector-search-front.html
@@ -8,42 +8,33 @@ https://bugzilla.mozilla.org/show_bug.cg
   <title>Test for Bug 835896</title>
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
   <script type="application/javascript" src="inspector-helpers.js"></script>
   <script type="application/javascript">
 "use strict";
 
 window.onload = function() {
-  const {require} = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
-  const {InspectorFront} = require("devtools/shared/fronts/inspector");
-
   SimpleTest.waitForExplicitFinish();
 
   let walkerFront = null;
   let inspector = null;
 
   // WalkerFront specific tests.  These aren't to excercise search
   // edge cases so much as to test the state the Front maintains between
   // searches.
   // See also test_inspector-search.html
 
   addAsyncTest(async function setup() {
     info("Setting up inspector and walker actors.");
 
     const url = document.getElementById("inspectorContent").href;
 
-    // eslint-disable-next-line new-cap
-    await new Promise(resolve => {
-      attachURL(url, function(err, client, tab, doc) {
-        inspector = InspectorFront(client, tab);
-        resolve();
-      });
-    });
-
+    const { target } = await attachURL(url);
+    inspector = target.getInspector();
     walkerFront = await inspector.getWalker();
     ok(walkerFront, "getWalker() should return an actor.");
 
     runNextTest();
   });
 
   addAsyncTest(async function testWalkerFrontDefaults() {
     info("Testing search API using WalkerFront.");
--- a/devtools/server/tests/mochitest/test_inspector-search.html
+++ b/devtools/server/tests/mochitest/test_inspector-search.html
@@ -9,17 +9,16 @@ https://bugzilla.mozilla.org/show_bug.cg
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
   <script type="application/javascript" src="inspector-helpers.js"></script>
   <script type="application/javascript">
 "use strict";
 
 window.onload = function() {
   const {require} = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
-  const {InspectorFront} = require("devtools/shared/fronts/inspector");
   const {WalkerSearch, WalkerIndex} =
     require("devtools/server/actors/utils/walker-search");
 
   SimpleTest.waitForExplicitFinish();
 
   let walkerActor = null;
   let walkerSearch = null;
   let inspectee = null;
@@ -29,24 +28,19 @@ window.onload = function() {
   // coming back as expected.
   // See also test_inspector-search-front.html.
 
   addAsyncTest(async function setup() {
     info("Setting up inspector and walker actors.");
 
     const url = document.getElementById("inspectorContent").href;
 
-    // eslint-disable-next-line new-cap
-    await new Promise(resolve => {
-      attachURL(url, function(err, client, tab, doc) {
-        inspectee = doc;
-        inspector = InspectorFront(client, tab);
-        resolve();
-      });
-    });
+    const { target, doc } = await attachURL(url);
+    inspectee = doc;
+    inspector = target.getInspector();
 
     const walkerFront = await inspector.getWalker();
     ok(walkerFront, "getWalker() should return an actor.");
 
     walkerActor = DebuggerServer.searchAllConnectionsForActor(walkerFront.actorID);
     ok(walkerActor,
       "Got a reference to the walker actor (" + walkerFront.actorID + ")");
 
--- a/devtools/server/tests/mochitest/test_inspector-template.html
+++ b/devtools/server/tests/mochitest/test_inspector-template.html
@@ -17,24 +17,18 @@ Display template tag content in inspecto
 window.onload = function() {
   SimpleTest.waitForExplicitFinish();
 
   let gWalker = null;
 
   addAsyncTest(async function setup() {
     const url = document.getElementById("inspectorContent").href;
 
-    const {client, tab} = await new Promise(resolve => {
-      attachURL(url, function(err, _client, _tab, doc) {
-        resolve({ client: _client, tab: _tab });
-      });
-    });
-
-    const {InspectorFront} = require("devtools/shared/fronts/inspector");
-    const inspector = InspectorFront(client, tab);
+    const { target } = await attachURL(url);
+    const inspector = target.getInspector();
     gWalker = await inspector.getWalker();
 
     runNextTest();
   });
 
   addAsyncTest(async function testWalker() {
     const nodeFront = await gWalker.querySelector(gWalker.rootNode, "template");
 
--- a/devtools/server/tests/mochitest/test_inspector-traversal.html
+++ b/devtools/server/tests/mochitest/test_inspector-traversal.html
@@ -21,28 +21,25 @@ window.onload = function() {
 let gInspectee = null;
 let gClient = null;
 let gWalker = null;
 const checkActorIDs = [];
 
 function assertOwnership() {
   assertOwnershipTrees(gWalker);
 }
-addTest(function setup() {
+addTest(async function setup() {
   const url = document.getElementById("inspectorContent").href;
-  attachURL(url, function(err, client, tab, doc) {
-    gInspectee = doc;
-    const {InspectorFront} = require("devtools/shared/fronts/inspector");
-    const inspector = InspectorFront(client, tab);
-    promiseDone(inspector.getWalker().then(walker => {
-      ok(walker, "getWalker() should return an actor.");
-      gClient = client;
-      gWalker = walker;
-    }).then(runNextTest));
-  });
+  const { client, target, doc } = await attachURL(url);
+  const inspector = target.getInspector();
+  gInspectee = doc;
+  gClient = client;
+  gWalker = await inspector.getWalker();
+  ok(gWalker, "getWalker() should return an actor.");
+  runNextTest();
 });
 
 addTest(function testWalkerRoot() {
   // Make sure that refetching the root document of the walker returns the same
   // actor as the getWalker returned.
   promiseDone(gWalker.document().then(root => {
     ok(root === gWalker.rootNode,
        "Re-fetching the document node should match the root document node.");
--- a/devtools/server/tests/mochitest/test_inspector_getImageData-wait-for-load.html
+++ b/devtools/server/tests/mochitest/test_inspector_getImageData-wait-for-load.html
@@ -36,34 +36,26 @@ function pushPref(preferenceName, value)
     SpecialPowers.pushPrefEnv(options, resolve);
   });
 }
 
 let gImg = null;
 let gNodeFront = null;
 let gWalker = null;
 
-addTest(function setup() {
+addTest(async function setup() {
   const url = document.getElementById("inspectorContent").href;
-  attachURL(url, function(err, client, tab, doc) {
-    const {InspectorFront} = require("devtools/shared/fronts/inspector");
-    const inspector = InspectorFront(client, tab);
-
-    promiseDone(inspector.getWalker().then(walker => {
-      gWalker = walker;
-      // eslint-disable-next-line max-nested-callbacks
-      return walker.querySelector(gWalker.rootNode, "img.custom").then(img => {
-        gNodeFront = img;
-        gImg = doc.querySelector("img.custom");
-
-        ok(gNodeFront, "Got the image NodeFront.");
-        ok(gImg, "Got the image Node.");
-      });
-    }).then(runNextTest));
-  });
+  const { target, doc } = await attachURL(url);
+  const inspector = target.getInspector();
+  gWalker = await inspector.getWalker();
+  gNodeFront = await gWalker.querySelector(gWalker.rootNode, "img.custom");
+  gImg = doc.querySelector("img.custom");
+  ok(gNodeFront, "Got the image NodeFront.");
+  ok(gImg, "Got the image Node.");
+  runNextTest();
 });
 
 addTest(async function testTimeout() {
   info("Testing that the method aborts if the image takes too long to load.");
 
   // imageToImageData() only times out when flags.testing is not set.
   await pushPref("devtools.testing", false);
 
--- a/devtools/server/tests/mochitest/test_inspector_getImageData.html
+++ b/devtools/server/tests/mochitest/test_inspector_getImageData.html
@@ -15,26 +15,22 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 window.onload = function() {
   SimpleTest.waitForExplicitFinish();
   runNextTest();
 };
 
 let gWalker = null;
 
-addTest(function setup() {
+addTest(async function setup() {
   const url = document.getElementById("inspectorContent").href;
-  attachURL(url, function(err, client, tab, doc) {
-    const {InspectorFront} = require("devtools/shared/fronts/inspector");
-    const inspector = InspectorFront(client, tab);
-
-    promiseDone(inspector.getWalker().then(walker => {
-      gWalker = walker;
-    }).then(runNextTest));
-  });
+  const { target } = await attachURL(url);
+  const inspector = target.getInspector();
+  gWalker = await inspector.getWalker();
+  runNextTest();
 });
 
 addTest(function testLargeImage() {
   // Select the image node from the test page
   gWalker.querySelector(gWalker.rootNode, ".big-horizontal").then(img => {
     ok(img, "Image node found in the test page");
     ok(img.getImageData, "Image node has the getImageData function");
 
--- a/devtools/server/tests/mochitest/test_inspector_getImageDataFromURL.html
+++ b/devtools/server/tests/mochitest/test_inspector_getImageDataFromURL.html
@@ -33,23 +33,21 @@ function pushPref(preferenceName, value)
   return new Promise(resolve => {
     const options = {"set": [[preferenceName, value]]};
     SpecialPowers.pushPrefEnv(options, resolve);
   });
 }
 
 let gInspector = null;
 
-addTest(function setup() {
+addTest(async function setup() {
   const url = document.getElementById("inspectorContent").href;
-  attachURL(url, function(err, client, tab, doc) {
-    const {InspectorFront} = require("devtools/shared/fronts/inspector");
-    gInspector = InspectorFront(client, tab);
-    runNextTest();
-  });
+  const { target } = await attachURL(url);
+  gInspector = target.getInspector();
+  runNextTest();
 });
 
 addTest(async function testTimeout() {
   info("Testing that the method aborts if the image takes too long to load.");
 
   // imageToImageData() only times out when flags.testing is not set.
   await pushPref("devtools.testing", false);
 
--- a/devtools/server/tests/mochitest/test_inspector_getNodeFromActor.html
+++ b/devtools/server/tests/mochitest/test_inspector_getNodeFromActor.html
@@ -15,26 +15,23 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 window.onload = function() {
   SimpleTest.waitForExplicitFinish();
   runNextTest();
 };
 
 let gWalker;
 
-addTest(function() {
+addTest(async function() {
   const url = document.getElementById("inspectorContent").href;
-  attachURL(url, function(err, client, tab, doc) {
-    const {InspectorFront} = require("devtools/shared/fronts/inspector");
-    const inspector = InspectorFront(client, tab);
-
-    promiseDone(inspector.getWalker().then(walker => {
-      gWalker = walker;
-    }).then(runNextTest));
-  });
+  const { target } = await attachURL(url);
+  const inspector = target.getInspector();
+  gWalker = await inspector.getWalker();
+  ok(gWalker, "getWalker() should return an actor.");
+  runNextTest();
 });
 
 addTest(function() {
   info("Try to get a NodeFront from an invalid actorID");
   gWalker.getNodeFromActor("invalid", ["node"]).then(node => {
     ok(!node, "The node returned is null");
     runNextTest();
   });
--- a/devtools/server/tests/mochitest/test_inspector_getOffsetParent.html
+++ b/devtools/server/tests/mochitest/test_inspector_getOffsetParent.html
@@ -17,32 +17,24 @@ window.onload = function() {
   SimpleTest.waitForExplicitFinish();
   runNextTest();
 };
 
 var gWalker;
 var gHTMLNode;
 var gBodyNode;
 
-addTest(function setup() {
+addTest(async function setup() {
   const url = document.getElementById("inspectorContent").href;
-  attachURL(url, function(err, client, tab, doc) {
-    const {InspectorFront} = require("devtools/shared/fronts/inspector");
-    const inspector = InspectorFront(client, tab);
-
-    promiseDone(inspector.getWalker().then(walker => {
-      gWalker = walker;
-      return gWalker.querySelector(gWalker.rootNode, "body");
-    }).then(node => {
-      gBodyNode = node;
-      return gWalker.querySelector(gWalker.rootNode, "html");
-    }).then(node => {
-      gHTMLNode = node;
-    }).then(runNextTest));
-  });
+  const { target } = await attachURL(url);
+  const inspector = target.getInspector();
+  gWalker = await inspector.getWalker();
+  gBodyNode = await gWalker.querySelector(gWalker.rootNode, "body");
+  gHTMLNode = await gWalker.querySelector(gWalker.rootNode, "html");
+  runNextTest();
 });
 
 addTest(function() {
   info("Try to get the offset parent for a dead node (null)");
   gWalker.getOffsetParent(null).then(offsetParent => {
     ok(!offsetParent, "No offset parent found");
     runNextTest();
   });
--- a/devtools/server/tests/mochitest/test_styles-applied.html
+++ b/devtools/server/tests/mochitest/test_styles-applied.html
@@ -16,29 +16,24 @@ https://bugzilla.mozilla.org/show_bug.cg
 window.onload = function() {
   SimpleTest.waitForExplicitFinish();
   runNextTest();
 };
 
 let gWalker = null;
 let gStyles = null;
 
-addTest(function setup() {
+addTest(async function setup() {
   const url = document.getElementById("inspectorContent").href;
-  attachURL(url, function(err, client, tab, doc) {
-    const {InspectorFront} = require("devtools/shared/fronts/inspector");
-    const inspector = InspectorFront(client, tab);
-    promiseDone(inspector.getWalker().then(walker => {
-      ok(walker, "getWalker() should return an actor.");
-      gWalker = walker;
-      return inspector.getPageStyle();
-    }).then(styles => {
-      gStyles = styles;
-    }).then(runNextTest));
-  });
+  const { target } = await attachURL(url);
+  const inspector = target.getInspector();
+  gWalker = await inspector.getWalker();
+  ok(gWalker, "getWalker() should return an actor.");
+  gStyles = await inspector.getPageStyle();
+  runNextTest();
 });
 
 addTest(function inheritedUserStyles() {
   promiseDone(gWalker.querySelector(gWalker.rootNode, "#test-node").then(node => {
     return gStyles.getApplied(node, { inherited: true, filter: "user" });
   }).then(applied => {
     ok(!applied[0].inherited, "Entry 0 should be uninherited");
     is(applied[0].rule.type, 100, "Entry 0 should be an element style");
--- a/devtools/server/tests/mochitest/test_styles-computed.html
+++ b/devtools/server/tests/mochitest/test_styles-computed.html
@@ -16,29 +16,24 @@ https://bugzilla.mozilla.org/show_bug.cg
 window.onload = function() {
   SimpleTest.waitForExplicitFinish();
   runNextTest();
 };
 
 let gWalker = null;
 let gStyles = null;
 
-addTest(function setup() {
+addTest(async function setup() {
   const url = document.getElementById("inspectorContent").href;
-  attachURL(url, function(err, client, tab, doc) {
-    const {InspectorFront} = require("devtools/shared/fronts/inspector");
-    const inspector = InspectorFront(client, tab);
-    promiseDone(inspector.getWalker().then(walker => {
-      ok(walker, "getWalker() should return an actor.");
-      gWalker = walker;
-      return inspector.getPageStyle();
-    }).then(styles => {
-      gStyles = styles;
-    }).then(runNextTest));
-  });
+  const { target } = await attachURL(url);
+  const inspector = target.getInspector();
+  gWalker = await inspector.getWalker();
+  ok(gWalker, "getWalker() should return an actor.");
+  gStyles = await inspector.getPageStyle();
+  runNextTest();
 });
 
 addTest(function testComputed() {
   promiseDone(
     gWalker.querySelector(gWalker.rootNode, "#computed-test-node").then(node => {
       return gStyles.getComputed(node, {});
     }).then(computed => {
       // Test a smattering of properties that include some system-defined
--- a/devtools/server/tests/mochitest/test_styles-layout.html
+++ b/devtools/server/tests/mochitest/test_styles-layout.html
@@ -12,29 +12,25 @@
 window.onload = function() {
   SimpleTest.waitForExplicitFinish();
   runNextTest();
 };
 
 let gWalker = null;
 let gStyles = null;
 
-addTest(function() {
+addTest(async function() {
   const url = document.getElementById("inspectorContent").href;
-  attachURL(url, function(err, client, tab, doc) {
-    const {InspectorFront} = require("devtools/shared/fronts/inspector");
-    const inspector = InspectorFront(client, tab);
-    promiseDone(inspector.getWalker().then(walker => {
-      ok(walker, "getWalker() should return an actor.");
-      gWalker = walker;
-      return inspector.getPageStyle();
-    }).then(styles => {
-      gStyles = styles;
-    }).then(runNextTest));
-  });
+  const { target } = await attachURL(url);
+  const inspector = target.getInspector();
+  const walker = await inspector.getWalker();
+  ok(walker, "getWalker() should return an actor.");
+  gWalker = walker;
+  gStyles = await inspector.getPageStyle();
+  runNextTest();
 });
 
 addTest(function() {
   ok(gStyles.getLayout, "The PageStyleActor has a getLayout method");
   runNextTest();
 });
 
 addAsyncTest(async function() {
--- a/devtools/server/tests/mochitest/test_styles-matched.html
+++ b/devtools/server/tests/mochitest/test_styles-matched.html
@@ -19,30 +19,25 @@ window.onload = function() {
   SimpleTest.waitForExplicitFinish();
   runNextTest();
 };
 
 let gWalker = null;
 let gStyles = null;
 let gInspectee = null;
 
-addTest(function setup() {
+addTest(async function setup() {
   const url = document.getElementById("inspectorContent").href;
-  attachURL(url, function(err, client, tab, doc) {
-    gInspectee = doc;
-    const {InspectorFront} = require("devtools/shared/fronts/inspector");
-    const inspector = InspectorFront(client, tab);
-    promiseDone(inspector.getWalker().then(walker => {
-      ok(walker, "getWalker() should return an actor.");
-      gWalker = walker;
-      return inspector.getPageStyle();
-    }).then(styles => {
-      gStyles = styles;
-    }).then(runNextTest));
-  });
+  const { target, doc } = await attachURL(url);
+  gInspectee = doc;
+  const inspector = target.getInspector();
+  gWalker = await inspector.getWalker();
+  ok(gWalker, "getWalker() should return an actor.");
+  gStyles = await inspector.getPageStyle();
+  runNextTest();
 });
 
 addTest(function testMatchedStyles() {
   promiseDone(gWalker.querySelector(gWalker.rootNode, "#matched-test-node").then(node => {
     return gStyles.getMatchedSelectors(node, "font-size", {});
   }).then(matched => {
     is(matched[0].sourceText, "this.style", "First match comes from the element style");
     is(matched[0].selector, "@element.style", "Element style has a special selector");
--- a/devtools/server/tests/mochitest/test_styles-modify.html
+++ b/devtools/server/tests/mochitest/test_styles-modify.html
@@ -21,26 +21,20 @@ window.onload = function() {
 };
 
 var gWalker = null;
 var gStyles = null;
 var gInspectee = null;
 
 addAsyncTest(async function setup() {
   const url = document.getElementById("inspectorContent").href;
-  let inspector;
 
-  await new Promise(resolve => {
-    attachURL(url, function(err, client, tab, doc) {
-      gInspectee = doc;
-      const {InspectorFront} = require("devtools/shared/fronts/inspector");
-      inspector = InspectorFront(client, tab);
-      resolve();
-    });
-  });
+  const { target, doc } = await attachURL(url);
+  const inspector = target.getInspector();
+  gInspectee = doc;
 
   gWalker = await inspector.getWalker();
   gStyles = await inspector.getPageStyle();
 
   runNextTest();
 });
 
 addAsyncTest(async function modifyProperties() {
--- a/devtools/server/tests/mochitest/test_styles-svg.html
+++ b/devtools/server/tests/mochitest/test_styles-svg.html
@@ -17,29 +17,24 @@ Bug 921191 - allow inspection/editing of
 window.onload = function() {
   SimpleTest.waitForExplicitFinish();
   runNextTest();
 };
 
 let gWalker = null;
 let gStyles = null;
 
-addTest(function setup() {
+addTest(async function setup() {
   const url = document.getElementById("inspectorContent").href;
-  attachURL(url, function(err, client, tab, doc) {
-    const {InspectorFront} = require("devtools/shared/fronts/inspector");
-    const inspector = InspectorFront(client, tab);
-    promiseDone(inspector.getWalker().then(walker => {
-      ok(walker, "getWalker() should return an actor.");
-      gWalker = walker;
-      return inspector.getPageStyle();
-    }).then(styles => {
-      gStyles = styles;
-    }).then(runNextTest));
-  });
+  const { target } = await attachURL(url);
+  const inspector = target.getInspector();
+  gWalker = await inspector.getWalker();
+  ok(gWalker, "getWalker() should return an actor.");
+  gStyles = await inspector.getPageStyle();
+  runNextTest();
 });
 
 addTest(function inheritedUserStyles() {
   promiseDone(gWalker.querySelector(gWalker.rootNode, "#svgcontent rect").then(node => {
     return gStyles.getApplied(node, { inherited: true, filter: "user" });
   }).then(applied => {
     is(applied.length, 2, "Should have 2 rules");
     is(applied[1].rule.cssText, "fill: rgb(1, 2, 3);", "cssText is right");