Bug 1297362 - Part 5: Eliminate CPOWs from Netmonitor mochitests R-T r?ochameau draft
authorJarda Snajdr <jsnajdr@gmail.com>
Fri, 26 Aug 2016 13:06:25 +0200
changeset 406769 e2560e8eae0459a79d94ff2a4892e86441ead72f
parent 406768 f298ab0c40b803fb3229c7cd772a58c9d7c2b5b0
child 406770 1f3ba622e2b117343a1b90d5be6b384b2f74a786
push id27819
push userbmo:jsnajdr@gmail.com
push dateMon, 29 Aug 2016 13:56:30 +0000
reviewersochameau
bugs1297362
milestone51.0a1
Bug 1297362 - Part 5: Eliminate CPOWs from Netmonitor mochitests R-T r?ochameau MozReview-Commit-ID: KPkb8wKWwmg
devtools/client/netmonitor/test/browser_net_raw_headers.js
devtools/client/netmonitor/test/browser_net_reload-button.js
devtools/client/netmonitor/test/browser_net_reload-markers.js
devtools/client/netmonitor/test/browser_net_req-resp-bodies.js
devtools/client/netmonitor/test/browser_net_resend.js
devtools/client/netmonitor/test/browser_net_security-details.js
devtools/client/netmonitor/test/browser_net_security-error.js
devtools/client/netmonitor/test/browser_net_security-icon-click.js
devtools/client/netmonitor/test/browser_net_security-redirect.js
devtools/client/netmonitor/test/browser_net_security-state.js
devtools/client/netmonitor/test/browser_net_security-tab-deselect.js
devtools/client/netmonitor/test/browser_net_security-tab-visibility.js
devtools/client/netmonitor/test/browser_net_security-warnings.js
devtools/client/netmonitor/test/browser_net_send-beacon-other-tab.js
devtools/client/netmonitor/test/browser_net_send-beacon.js
devtools/client/netmonitor/test/browser_net_simple-init.js
devtools/client/netmonitor/test/browser_net_simple-request-data.js
devtools/client/netmonitor/test/browser_net_simple-request-details.js
devtools/client/netmonitor/test/browser_net_simple-request.js
devtools/client/netmonitor/test/browser_net_sort-01.js
devtools/client/netmonitor/test/browser_net_sort-02.js
devtools/client/netmonitor/test/browser_net_sort-03.js
devtools/client/netmonitor/test/browser_net_statistics-01.js
devtools/client/netmonitor/test/browser_net_statistics-02.js
devtools/client/netmonitor/test/browser_net_statistics-03.js
devtools/client/netmonitor/test/browser_net_status-codes.js
devtools/client/netmonitor/test/browser_net_streaming-response.js
devtools/client/netmonitor/test/browser_net_throttle.js
devtools/client/netmonitor/test/browser_net_timeline_ticks.js
devtools/client/netmonitor/test/browser_net_timing-division.js
--- a/devtools/client/netmonitor/test/browser_net_raw_headers.js
+++ b/devtools/client/netmonitor/test/browser_net_raw_headers.js
@@ -1,72 +1,70 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
-var gPanelWin;
-var gPanelDoc;
+"use strict";
 
 /**
  * Tests if showing raw headers works.
  */
 
-function test() {
-  initNetMonitor(POST_DATA_URL).then(([aTab, aDebuggee, aMonitor]) => {
-    info("Starting test... ");
+add_task(function* () {
+  let [tab, , monitor] = yield initNetMonitor(POST_DATA_URL);
+  info("Starting test... ");
+
+  let { document, EVENTS, NetMonitorView } = monitor.panelWin;
+  let { RequestsMenu } = NetMonitorView;
 
-    gPanelWin = aMonitor.panelWin;
-    gPanelDoc = gPanelWin.document;
+  RequestsMenu.lazyUpdate = false;
 
-    let { document, Editor, NetMonitorView } = gPanelWin;
-    let { RequestsMenu } = NetMonitorView;
-    let TAB_UPDATED = gPanelWin.EVENTS.TAB_UPDATED;
-
-    RequestsMenu.lazyUpdate = false;
+  let wait = waitForNetworkEvents(monitor, 0, 2);
+  yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
+    content.wrappedJSObject.performRequests();
+  });
+  yield wait;
 
-    waitForNetworkEvents(aMonitor, 0, 2).then(() => {
-      let origItem = RequestsMenu.getItemAtIndex(0);
-      RequestsMenu.selectedItem = origItem;
+  let origItem = RequestsMenu.getItemAtIndex(0);
+
+  let onTabEvent = monitor.panelWin.once(EVENTS.TAB_UPDATED);
+  RequestsMenu.selectedItem = origItem;
+  yield onTabEvent;
 
-      waitFor(aMonitor.panelWin, TAB_UPDATED).then(() => {
-        EventUtils.sendMouseEvent({ type: "click" }, document.getElementById("toggle-raw-headers"));
-        testShowRawHeaders(origItem.attachment);
-        EventUtils.sendMouseEvent({ type: "click" }, document.getElementById("toggle-raw-headers"));
-        testHideRawHeaders(document);
-        finishUp(aMonitor);
-      });
-    });
+  EventUtils.sendMouseEvent({ type: "click" },
+    document.getElementById("toggle-raw-headers"));
+
+  testShowRawHeaders(origItem.attachment);
 
-    aDebuggee.performRequests();
-  });
-}
+  EventUtils.sendMouseEvent({ type: "click" },
+    document.getElementById("toggle-raw-headers"));
+
+  testHideRawHeaders(document);
 
-/*
- * Tests that raw headers were displayed correctly
- */
-function testShowRawHeaders(aData) {
-  let requestHeaders = gPanelDoc.getElementById("raw-request-headers-textarea").value;
-  for (let header of aData.requestHeaders.headers) {
-    ok(requestHeaders.indexOf(header.name + ": " + header.value) >= 0, "textarea contains request headers");
-  }
-  let responseHeaders = gPanelDoc.getElementById("raw-response-headers-textarea").value;
-  for (let header of aData.responseHeaders.headers) {
-    ok(responseHeaders.indexOf(header.name + ": " + header.value) >= 0, "textarea contains response headers");
-  }
-}
+  return teardown(monitor);
 
-/*
- * Tests that raw headers textareas are hidden and empty
- */
-function testHideRawHeaders(document) {
-  let rawHeadersHidden = document.getElementById("raw-headers").getAttribute("hidden");
-  let requestTextarea = document.getElementById("raw-request-headers-textarea");
-  let responseTextare = document.getElementById("raw-response-headers-textarea");
-  ok(rawHeadersHidden, "raw headers textareas are hidden");
-  ok(requestTextarea.value == "", "raw request headers textarea is empty");
-  ok(responseTextare.value == "", "raw response headers textarea is empty");
-}
+  /*
+   * Tests that raw headers were displayed correctly
+   */
+  function testShowRawHeaders(data) {
+    let requestHeaders = document.getElementById("raw-request-headers-textarea").value;
+    for (let header of data.requestHeaders.headers) {
+      ok(requestHeaders.indexOf(header.name + ": " + header.value) >= 0,
+        "textarea contains request headers");
+    }
+    let responseHeaders = document.getElementById("raw-response-headers-textarea").value;
+    for (let header of data.responseHeaders.headers) {
+      ok(responseHeaders.indexOf(header.name + ": " + header.value) >= 0,
+        "textarea contains response headers");
+    }
+  }
 
-function finishUp(aMonitor) {
-  gPanelWin = null;
-  gPanelDoc = null;
-
-  teardown(aMonitor).then(finish);
-}
+  /*
+   * Tests that raw headers textareas are hidden and empty
+   */
+  function testHideRawHeaders() {
+    let rawHeadersHidden = document.getElementById("raw-headers").getAttribute("hidden");
+    let requestTextarea = document.getElementById("raw-request-headers-textarea");
+    let responseTextarea = document.getElementById("raw-response-headers-textarea");
+    ok(rawHeadersHidden, "raw headers textareas are hidden");
+    ok(requestTextarea.value == "", "raw request headers textarea is empty");
+    ok(responseTextarea.value == "", "raw response headers textarea is empty");
+  }
+});
--- a/devtools/client/netmonitor/test/browser_net_reload-button.js
+++ b/devtools/client/netmonitor/test/browser_net_reload-button.js
@@ -1,31 +1,25 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 /**
  * Tests if the empty-requests reload button works.
  */
 
-function test() {
-  let monitor, reqMenu;
-  initNetMonitor(SINGLE_GET_URL).then(([aTab, aDebuggee, aMonitor]) => {
-    info("Starting test... ");
+add_task(function* () {
+  let [,, monitor] = yield initNetMonitor(SINGLE_GET_URL);
+  info("Starting test... ");
 
-    monitor = aMonitor;
-    let { document, NetMonitorView } = aMonitor.panelWin;
-    let { RequestsMenu } = NetMonitorView;
-    reqMenu = RequestsMenu;
+  let { document, NetMonitorView } = monitor.panelWin;
+  let { RequestsMenu } = NetMonitorView;
 
-    let button = document.querySelector("#requests-menu-reload-notice-button");
-    button.click();
-  })
-  .then(() => {
-    return waitForNetworkEvents(monitor, 2);
-  })
-  .then(() => {
-    is(reqMenu.itemCount, 2,
-      "The request menu should have two items after reloading");
-  })
-  .then(() => {
-    return teardown(monitor).then(finish);
-  });
-}
+  let wait = waitForNetworkEvents(monitor, 2);
+  let button = document.querySelector("#requests-menu-reload-notice-button");
+  button.click();
+  yield wait;
+
+  is(RequestsMenu.itemCount, 2, "The request menu should have two items after reloading");
+
+  return teardown(monitor);
+});
--- a/devtools/client/netmonitor/test/browser_net_reload-markers.js
+++ b/devtools/client/netmonitor/test/browser_net_reload-markers.js
@@ -1,45 +1,35 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 /**
  * Tests if the empty-requests reload button works.
  */
 
- add_task(function* () {
-   let [tab, debuggee, monitor] = yield initNetMonitor(SINGLE_GET_URL);
-   info("Starting test... ");
+add_task(function* () {
+  let [,, monitor] = yield initNetMonitor(SINGLE_GET_URL);
+  info("Starting test... ");
 
-   let { document, EVENTS, NetworkEventsHandler } = monitor.panelWin;
-   let button = document.querySelector("#requests-menu-reload-notice-button");
-   button.click();
+  let { document, EVENTS } = monitor.panelWin;
+  let button = document.querySelector("#requests-menu-reload-notice-button");
+  button.click();
 
-   let deferred = promise.defer();
-   let markers = [];
+  let markers = [];
 
-   monitor.panelWin.on(EVENTS.TIMELINE_EVENT, (_, marker) => {
-     markers.push(marker);
-   });
+  monitor.panelWin.on(EVENTS.TIMELINE_EVENT, (_, marker) => {
+    markers.push(marker);
+  });
 
-   yield waitForNetworkEvents(monitor, 2);
-   yield waitUntil(() => markers.length == 2);
+  yield waitForNetworkEvents(monitor, 2);
+  yield waitUntil(() => markers.length == 2);
 
-   ok(true, "Reloading finished");
+  ok(true, "Reloading finished");
 
-   is(markers[0].name, "document::DOMContentLoaded",
+  is(markers[0].name, "document::DOMContentLoaded",
     "The first received marker is correct.");
-   is(markers[1].name, "document::Load",
+  is(markers[1].name, "document::Load",
     "The second received marker is correct.");
 
-   teardown(monitor).then(finish);
- });
-
- function waitUntil(predicate, interval = 10) {
-   if (predicate()) {
-     return Promise.resolve(true);
-   }
-   return new Promise(resolve => {
-     setTimeout(function () {
-       waitUntil(predicate).then(() => resolve(true));
-     }, interval);
-   });
- }
+  return teardown(monitor);
+});
--- a/devtools/client/netmonitor/test/browser_net_req-resp-bodies.js
+++ b/devtools/client/netmonitor/test/browser_net_req-resp-bodies.js
@@ -1,60 +1,66 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 /**
  * Test if request and response body logging stays on after opening the console.
  */
 
-function test() {
-  initNetMonitor(JSON_LONG_URL).then(([aTab, aDebuggee, aMonitor]) => {
-    info("Starting test... ");
+add_task(function* () {
+  let [tab, , monitor] = yield initNetMonitor(JSON_LONG_URL);
+  info("Starting test... ");
 
-    let { L10N, NetMonitorView } = aMonitor.panelWin;
-    let { RequestsMenu } = NetMonitorView;
+  let { L10N, NetMonitorView } = monitor.panelWin;
+  let { RequestsMenu } = NetMonitorView;
 
-    RequestsMenu.lazyUpdate = false;
+  RequestsMenu.lazyUpdate = false;
 
-    function verifyRequest(aOffset) {
-      verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOffset),
-        "GET", CONTENT_TYPE_SJS + "?fmt=json-long", {
-          status: 200,
-          statusText: "OK",
-          type: "json",
-          fullMimeType: "text/json; charset=utf-8",
-          size: L10N.getFormatStr("networkMenu.sizeKB", L10N.numberWithDecimals(85975 / 1024, 2)),
-          time: true
-        });
-    }
+  // Perform first batch of requests.
+  let wait = waitForNetworkEvents(monitor, 1);
+  yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
+    content.wrappedJSObject.performRequests();
+  });
+  yield wait;
+
+  verifyRequest(0);
 
-    waitForNetworkEvents(aMonitor, 1).then(() => {
-      verifyRequest(0);
+  // Switch to the webconsole.
+  let onWebConsole = monitor._toolbox.once("webconsole-selected");
+  monitor._toolbox.selectTool("webconsole");
+  yield onWebConsole;
 
-      aMonitor._toolbox.once("webconsole-selected", () => {
-        aMonitor._toolbox.once("netmonitor-selected", () => {
+  // Switch back to the netmonitor.
+  let onNetMonitor = monitor._toolbox.once("netmonitor-selected");
+  monitor._toolbox.selectTool("netmonitor");
+  yield onNetMonitor;
 
-          waitForNetworkEvents(aMonitor, 1).then(() => {
-            waitForNetworkEvents(aMonitor, 1).then(() => {
-              verifyRequest(1);
-              teardown(aMonitor).then(finish);
-            });
+  // Reload debugee.
+  wait = waitForNetworkEvents(monitor, 1);
+  tab.linkedBrowser.reload();
+  yield wait;
 
-            // Perform another batch of requests.
-            aDebuggee.performRequests();
-          });
+  // Perform another batch of requests.
+  wait = waitForNetworkEvents(monitor, 1);
+  yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
+    content.wrappedJSObject.performRequests();
+  });
+  yield wait;
+
+  verifyRequest(1);
 
-          // Reload debugee.
-          aDebuggee.location.reload();
-        });
-
-        // Switch back to the netmonitor.
-        aMonitor._toolbox.selectTool("netmonitor");
-      });
+  return teardown(monitor);
 
-      // Switch to the webconsole.
-      aMonitor._toolbox.selectTool("webconsole");
-    });
-
-    // Perform first batch of requests.
-    aDebuggee.performRequests();
-  });
-}
+  function verifyRequest(offset) {
+    verifyRequestItemTarget(RequestsMenu.getItemAtIndex(offset),
+      "GET", CONTENT_TYPE_SJS + "?fmt=json-long", {
+        status: 200,
+        statusText: "OK",
+        type: "json",
+        fullMimeType: "text/json; charset=utf-8",
+        size: L10N.getFormatStr("networkMenu.sizeKB",
+          L10N.numberWithDecimals(85975 / 1024, 2)),
+        time: true
+      });
+  }
+});
--- a/devtools/client/netmonitor/test/browser_net_resend.js
+++ b/devtools/client/netmonitor/test/browser_net_resend.js
@@ -1,178 +1,162 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
-var gPanelWin;
-var gPanelDoc;
-
-const ADD_QUERY = "t1=t2";
-const ADD_HEADER = "Test-header: true";
-const ADD_POSTDATA = "t3=t4";
+"use strict";
 
 /**
  * Tests if resending a request works.
  */
 
-function test() {
-  initNetMonitor(POST_DATA_URL).then(([aTab, aDebuggee, aMonitor]) => {
-    info("Starting test... ");
-
-    gPanelWin = aMonitor.panelWin;
-    gPanelDoc = gPanelWin.document;
+const ADD_QUERY = "t1=t2";
+const ADD_HEADER = "Test-header: true";
+const ADD_POSTDATA = "&t3=t4";
 
-    let { NetMonitorView } = gPanelWin;
-    let { RequestsMenu } = NetMonitorView;
-    let TAB_UPDATED = aMonitor.panelWin.EVENTS.TAB_UPDATED;
-    let CUSTOMREQUESTVIEW_POPULATED = aMonitor.panelWin.EVENTS.CUSTOMREQUESTVIEW_POPULATED;
+add_task(function* () {
+  let [tab, , monitor] = yield initNetMonitor(POST_DATA_URL);
+  info("Starting test... ");
 
-    RequestsMenu.lazyUpdate = false;
+  let { panelWin } = monitor;
+  let { document, EVENTS, NetMonitorView } = panelWin;
+  let { RequestsMenu } = NetMonitorView;
 
-    waitForNetworkEvents(aMonitor, 0, 2).then(() => {
-      let origItem = RequestsMenu.getItemAtIndex(0);
-      RequestsMenu.selectedItem = origItem;
+  RequestsMenu.lazyUpdate = false;
 
-      waitFor(aMonitor.panelWin, TAB_UPDATED).then(() => {
-        // add a new custom request cloned from selected request
-        RequestsMenu.cloneSelectedRequest();
-        return waitFor(aMonitor.panelWin, CUSTOMREQUESTVIEW_POPULATED);
-      }).then(() => {
-        testCustomForm(origItem.attachment);
+  let wait = waitForNetworkEvents(monitor, 0, 2);
+  yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
+    content.wrappedJSObject.performRequests();
+  });
+  yield wait;
 
-        let customItem = RequestsMenu.selectedItem;
-        testCustomItem(customItem, origItem);
+  let origItem = RequestsMenu.getItemAtIndex(0);
 
-        // edit the custom request
-        editCustomForm(() => {
-          testCustomItemChanged(customItem, origItem);
+  let onTabUpdated = panelWin.once(EVENTS.TAB_UPDATED);
+  RequestsMenu.selectedItem = origItem;
+  yield onTabUpdated;
 
-          waitForNetworkEvents(aMonitor, 0, 1).then(() => {
-            let sentItem = RequestsMenu.selectedItem;
-            testSentRequest(sentItem.attachment, origItem.attachment);
-            finishUp(aMonitor);
-          });
-          // send the new request
-          RequestsMenu.sendCustomRequest();
-        });
-      });
-    });
+  // add a new custom request cloned from selected request
+  let onPopulated = panelWin.once(EVENTS.CUSTOMREQUESTVIEW_POPULATED);
+  RequestsMenu.cloneSelectedRequest();
+  yield onPopulated;
 
-    aDebuggee.performRequests();
-  });
-}
+  testCustomForm(origItem.attachment);
 
-function testCustomItem(aItem, aOrigItem) {
-  let method = aItem.target.querySelector(".requests-menu-method").value;
-  let origMethod = aOrigItem.target.querySelector(".requests-menu-method").value;
-  is(method, origMethod, "menu item is showing the same method as original request");
+  let customItem = RequestsMenu.selectedItem;
+  testCustomItem(customItem, origItem);
 
-  let file = aItem.target.querySelector(".requests-menu-file").value;
-  let origFile = aOrigItem.target.querySelector(".requests-menu-file").value;
-  is(file, origFile, "menu item is showing the same file name as original request");
+  // edit the custom request
+  yield editCustomForm();
+  testCustomItemChanged(customItem, origItem);
 
-  let domain = aItem.target.querySelector(".requests-menu-domain").value;
-  let origDomain = aOrigItem.target.querySelector(".requests-menu-domain").value;
-  is(domain, origDomain, "menu item is showing the same domain as original request");
-}
+  // send the new request
+  wait = waitForNetworkEvents(monitor, 0, 1);
+  RequestsMenu.sendCustomRequest();
+  yield wait;
 
-function testCustomItemChanged(aItem, aOrigItem) {
-  let file = aItem.target.querySelector(".requests-menu-file").value;
-  let expectedFile = aOrigItem.target.querySelector(".requests-menu-file").value + "&" + ADD_QUERY;
+  let sentItem = RequestsMenu.selectedItem;
+  testSentRequest(sentItem.attachment, origItem.attachment);
 
-  is(file, expectedFile, "menu item is updated to reflect url entered in form");
-}
+  return teardown(monitor);
 
-/*
- * Test that the New Request form was populated correctly
- */
-function testCustomForm(aData) {
-  is(gPanelDoc.getElementById("custom-method-value").value, aData.method,
-     "new request form showing correct method");
+  function testCustomItem(item, orig) {
+    let method = item.target.querySelector(".requests-menu-method").value;
+    let origMethod = orig.target.querySelector(".requests-menu-method").value;
+    is(method, origMethod, "menu item is showing the same method as original request");
 
-  is(gPanelDoc.getElementById("custom-url-value").value, aData.url,
-     "new request form showing correct url");
+    let file = item.target.querySelector(".requests-menu-file").value;
+    let origFile = orig.target.querySelector(".requests-menu-file").value;
+    is(file, origFile, "menu item is showing the same file name as original request");
 
-  let query = gPanelDoc.getElementById("custom-query-value");
-  is(query.value, "foo=bar\nbaz=42\ntype=urlencoded",
-     "new request form showing correct query string");
-
-  let headers = gPanelDoc.getElementById("custom-headers-value").value.split("\n");
-  for (let {name, value} of aData.requestHeaders.headers) {
-    ok(headers.indexOf(name + ": " + value) >= 0, "form contains header from request");
+    let domain = item.target.querySelector(".requests-menu-domain").value;
+    let origDomain = orig.target.querySelector(".requests-menu-domain").value;
+    is(domain, origDomain, "menu item is showing the same domain as original request");
   }
 
-  let postData = gPanelDoc.getElementById("custom-postdata-value");
-  is(postData.value, aData.requestPostData.postData.text,
-     "new request form showing correct post data");
-}
+  function testCustomItemChanged(item, orig) {
+    let file = item.target.querySelector(".requests-menu-file").value;
+    let expectedFile = orig.target.querySelector(".requests-menu-file").value +
+      "&" + ADD_QUERY;
+
+    is(file, expectedFile, "menu item is updated to reflect url entered in form");
+  }
+
+  /*
+   * Test that the New Request form was populated correctly
+   */
+  function testCustomForm(data) {
+    is(document.getElementById("custom-method-value").value, data.method,
+       "new request form showing correct method");
+
+    is(document.getElementById("custom-url-value").value, data.url,
+       "new request form showing correct url");
+
+    let query = document.getElementById("custom-query-value");
+    is(query.value, "foo=bar\nbaz=42\ntype=urlencoded",
+       "new request form showing correct query string");
 
-/*
- * Add some params and headers to the request form
- */
-function editCustomForm(callback) {
-  gPanelWin.focus();
+    let headers = document.getElementById("custom-headers-value").value.split("\n");
+    for (let {name, value} of data.requestHeaders.headers) {
+      ok(headers.indexOf(name + ": " + value) >= 0, "form contains header from request");
+    }
+
+    let postData = document.getElementById("custom-postdata-value");
+    is(postData.value, data.requestPostData.postData.text,
+       "new request form showing correct post data");
+  }
 
-  let query = gPanelDoc.getElementById("custom-query-value");
-  query.addEventListener("focus", function onFocus() {
-    query.removeEventListener("focus", onFocus, false);
+  /*
+   * Add some params and headers to the request form
+   */
+  function* editCustomForm() {
+    panelWin.focus();
+
+    let query = document.getElementById("custom-query-value");
+    let queryFocus = once(query, "focus", false);
+    // Bug 1195825: Due to some unexplained dark-matter with promise,
+    // focus only works if delayed by one tick.
+    executeSoon(() => query.focus());
+    yield queryFocus;
 
     // add params to url query string field
     type(["VK_RETURN"]);
     type(ADD_QUERY);
 
-    let headers = gPanelDoc.getElementById("custom-headers-value");
-    headers.addEventListener("focus", function onFocus() {
-      headers.removeEventListener("focus", onFocus, false);
+    let headers = document.getElementById("custom-headers-value");
+    let headersFocus = once(headers, "focus", false);
+    headers.focus();
+    yield headersFocus;
 
-      // add a header
-      type(["VK_RETURN"]);
-      type(ADD_HEADER);
-
-      let postData = gPanelDoc.getElementById("custom-postdata-value");
-      postData.addEventListener("focus", function onFocus() {
-        postData.removeEventListener("focus", onFocus, false);
+    // add a header
+    type(["VK_RETURN"]);
+    type(ADD_HEADER);
 
-        // add to POST data
-        type(ADD_POSTDATA);
-        callback();
-      }, false);
-      postData.focus();
-    }, false);
-    headers.focus();
-  }, false);
+    let postData = document.getElementById("custom-postdata-value");
+    let postFocus = once(postData, "focus", false);
+    postData.focus();
+    yield postFocus;
 
-  // Bug 1195825: Due to some unexplained dark-matter with promise,
-  // focus only works if delayed by one tick.
-  executeSoon(() => {
-    query.focus();
-  });
-}
+    // add to POST data
+    type(ADD_POSTDATA);
+  }
 
-/*
- * Make sure newly created event matches expected request
- */
-function testSentRequest(aData, aOrigData) {
-  is(aData.method, aOrigData.method, "correct method in sent request");
-  is(aData.url, aOrigData.url + "&" + ADD_QUERY, "correct url in sent request");
+  /*
+   * Make sure newly created event matches expected request
+   */
+  function testSentRequest(data, origData) {
+    is(data.method, origData.method, "correct method in sent request");
+    is(data.url, origData.url + "&" + ADD_QUERY, "correct url in sent request");
 
-  let hasHeader = aData.requestHeaders.headers.some((header) => {
-    return (header.name + ": " + header.value) == ADD_HEADER;
-  });
-  ok(hasHeader, "new header added to sent request");
+    let { headers } = data.requestHeaders;
+    let hasHeader = headers.some(h => `${h.name}: ${h.value}` == ADD_HEADER);
+    ok(hasHeader, "new header added to sent request");
 
-  is(aData.requestPostData.postData.text,
-     aOrigData.requestPostData.postData.text + ADD_POSTDATA,
-     "post data added to sent request");
-}
-
+    is(data.requestPostData.postData.text,
+       origData.requestPostData.postData.text + ADD_POSTDATA,
+       "post data added to sent request");
+  }
 
-function type(aString) {
-  for (let ch of aString) {
-    EventUtils.synthesizeKey(ch, {}, gPanelWin);
+  function type(string) {
+    for (let ch of string) {
+      EventUtils.synthesizeKey(ch, {}, panelWin);
+    }
   }
-}
-
-function finishUp(aMonitor) {
-  gPanelWin = null;
-  gPanelDoc = null;
-
-  teardown(aMonitor).then(finish);
-}
+});
--- a/devtools/client/netmonitor/test/browser_net_security-details.js
+++ b/devtools/client/netmonitor/test/browser_net_security-details.js
@@ -3,25 +3,28 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 "use strict";
 
 /**
  * Test that Security details tab contains the expected data.
  */
 
 add_task(function* () {
-  let [tab, debuggee, monitor] = yield initNetMonitor(CUSTOM_GET_URL);
+  let [tab, , monitor] = yield initNetMonitor(CUSTOM_GET_URL);
   let { $, EVENTS, NetMonitorView } = monitor.panelWin;
   let { RequestsMenu, NetworkDetails } = NetMonitorView;
   RequestsMenu.lazyUpdate = false;
 
   info("Performing a secure request.");
-  debuggee.performRequests(1, "https://example.com" + CORS_SJS_PATH);
-
-  yield waitForNetworkEvents(monitor, 1);
+  const REQUESTS_URL = "https://example.com" + CORS_SJS_PATH;
+  let wait = waitForNetworkEvents(monitor, 1);
+  yield ContentTask.spawn(tab.linkedBrowser, REQUESTS_URL, function* (url) {
+    content.wrappedJSObject.performRequests(1, url);
+  });
+  yield wait;
 
   info("Selecting the request.");
   RequestsMenu.selectedIndex = 0;
 
   info("Waiting for details pane to be updated.");
   yield monitor.panelWin.once(EVENTS.TAB_UPDATED);
 
   info("Selecting security tab.");
--- a/devtools/client/netmonitor/test/browser_net_security-error.js
+++ b/devtools/client/netmonitor/test/browser_net_security-error.js
@@ -3,25 +3,28 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 "use strict";
 
 /**
  * Test that Security details tab shows an error message with broken connections.
  */
 
 add_task(function* () {
-  let [tab, debuggee, monitor] = yield initNetMonitor(CUSTOM_GET_URL);
+  let [tab, , monitor] = yield initNetMonitor(CUSTOM_GET_URL);
   let { $, EVENTS, NetMonitorView } = monitor.panelWin;
   let { RequestsMenu, NetworkDetails } = NetMonitorView;
   RequestsMenu.lazyUpdate = false;
 
   info("Requesting a resource that has a certificate problem.");
-  debuggee.performRequests(1, "https://nocert.example.com");
 
-  yield waitForSecurityBrokenNetworkEvent();
+  let wait = waitForSecurityBrokenNetworkEvent();
+  yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
+    content.wrappedJSObject.performRequests(1, "https://nocert.example.com");
+  });
+  yield wait;
 
   info("Selecting the request.");
   RequestsMenu.selectedIndex = 0;
 
   info("Waiting for details pane to be updated.");
   yield monitor.panelWin.once(EVENTS.TAB_UPDATED);
 
   info("Selecting security tab.");
@@ -34,17 +37,17 @@ add_task(function* () {
   let errormsg = $("#security-error-message");
   let infobox = $("#security-information");
 
   is(errorbox.hidden, false, "Error box is visble.");
   is(infobox.hidden, true, "Information box is hidden.");
 
   isnot(errormsg.value, "", "Error message is not empty.");
 
-  yield teardown(monitor);
+  return teardown(monitor);
 
   /**
    * Returns a promise that's resolved once a request with security issues is
    * completed.
    */
   function waitForSecurityBrokenNetworkEvent() {
     let awaitedEvents = [
       "UPDATING_REQUEST_HEADERS",
--- a/devtools/client/netmonitor/test/browser_net_security-icon-click.js
+++ b/devtools/client/netmonitor/test/browser_net_security-icon-click.js
@@ -3,51 +3,55 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 "use strict";
 
 /**
  * Test that clicking on the security indicator opens the security details tab.
  */
 
 add_task(function* () {
-  let [tab, debuggee, monitor] = yield initNetMonitor(CUSTOM_GET_URL);
+  let [tab, , monitor] = yield initNetMonitor(CUSTOM_GET_URL);
   let { $, EVENTS, NetMonitorView } = monitor.panelWin;
   let { RequestsMenu, NetworkDetails } = NetMonitorView;
   RequestsMenu.lazyUpdate = false;
 
   info("Requesting a resource over HTTPS.");
-  debuggee.performRequests(1, "https://example.com" + CORS_SJS_PATH + "?request_2");
-  yield waitForNetworkEvents(monitor, 1);
-
-  debuggee.performRequests(1, "https://example.com" + CORS_SJS_PATH + "?request_1");
-  yield waitForNetworkEvents(monitor, 1);
+  yield performRequestAndWait("https://example.com" + CORS_SJS_PATH + "?request_2");
+  yield performRequestAndWait("https://example.com" + CORS_SJS_PATH + "?request_1");
 
   is(RequestsMenu.itemCount, 2, "Two events event logged.");
 
   yield clickAndTestSecurityIcon();
 
   info("Selecting headers panel again.");
   NetworkDetails.widget.selectedIndex = 0;
   yield monitor.panelWin.once(EVENTS.TAB_UPDATED);
 
   info("Sorting the items by filename.");
   EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-file-button"));
 
   info("Testing that security icon can be clicked after the items were sorted.");
   yield clickAndTestSecurityIcon();
 
-  yield teardown(monitor);
+  return teardown(monitor);
+
+  function* performRequestAndWait(url) {
+    let wait = waitForNetworkEvents(monitor, 1);
+    yield ContentTask.spawn(tab.linkedBrowser, { url }, function* (args) {
+      content.wrappedJSObject.performRequests(1, args.url);
+    });
+    return wait;
+  }
 
   function* clickAndTestSecurityIcon() {
     let item = RequestsMenu.items[0];
     let icon = $(".requests-security-state-icon", item.target);
 
     info("Clicking security icon of the first request and waiting for the " +
          "panel to update.");
 
     icon.click();
     yield monitor.panelWin.once(EVENTS.TAB_UPDATED);
 
     is(NetworkDetails.widget.selectedPanel, $("#security-tabpanel"),
       "Security tab is selected.");
   }
-
 });
--- a/devtools/client/netmonitor/test/browser_net_security-redirect.js
+++ b/devtools/client/netmonitor/test/browser_net_security-redirect.js
@@ -4,23 +4,26 @@
 "use strict";
 
 /**
  * Test a http -> https redirect shows secure icon only for redirected https
  * request.
  */
 
 add_task(function* () {
-  let [tab, debuggee, monitor] = yield initNetMonitor(CUSTOM_GET_URL);
+  let [tab, , monitor] = yield initNetMonitor(CUSTOM_GET_URL);
   let { $, NetMonitorView } = monitor.panelWin;
   let { RequestsMenu } = NetMonitorView;
   RequestsMenu.lazyUpdate = false;
 
-  debuggee.performRequests(1, HTTPS_REDIRECT_SJS);
-  yield waitForNetworkEvents(monitor, 2);
+  let wait = waitForNetworkEvents(monitor, 2);
+  yield ContentTask.spawn(tab.linkedBrowser, HTTPS_REDIRECT_SJS, function* (url) {
+    content.wrappedJSObject.performRequests(1, url);
+  });
+  yield wait;
 
   is(RequestsMenu.itemCount, 2, "There were two requests due to redirect.");
 
   let initial = RequestsMenu.items[0];
   let redirect = RequestsMenu.items[1];
 
   let initialSecurityIcon = $(".requests-security-state-icon", initial.target);
   let redirectSecurityIcon = $(".requests-security-state-icon", redirect.target);
--- a/devtools/client/netmonitor/test/browser_net_security-state.js
+++ b/devtools/client/netmonitor/test/browser_net_security-state.js
@@ -11,17 +11,17 @@
 add_task(function* () {
   const EXPECTED_SECURITY_STATES = {
     "test1.example.com": "security-state-insecure",
     "example.com": "security-state-secure",
     "nocert.example.com": "security-state-broken",
     "localhost": "security-state-local",
   };
 
-  let [tab, debuggee, monitor] = yield initNetMonitor(CUSTOM_GET_URL);
+  let [tab, , monitor] = yield initNetMonitor(CUSTOM_GET_URL);
   let { $, EVENTS, NetMonitorView } = monitor.panelWin;
   let { RequestsMenu } = NetMonitorView;
   RequestsMenu.lazyUpdate = false;
 
   yield performRequests();
 
   for (let item of RequestsMenu.items) {
     let domain = $(".requests-menu-domain", item.target).value;
@@ -32,54 +32,60 @@ add_task(function* () {
     let classes = $(".requests-security-state-icon", item.target).classList;
     let expectedClass = EXPECTED_SECURITY_STATES[domain];
 
     info("Classes of security state icon are: " + classes);
     info("Security state icon is expected to contain class: " + expectedClass);
     ok(classes.contains(expectedClass), "Icon contained the correct class name.");
   }
 
-  yield teardown(monitor);
+  return teardown(monitor);
 
   /**
    * A helper that performs requests to
    *  - https://nocert.example.com (broken)
    *  - https://example.com (secure)
    *  - http://test1.example.com (insecure)
    *  - http://localhost (local)
    * and waits until NetworkMonitor has handled all packets sent by the server.
    */
   function* performRequests() {
+    function executeRequests(count, url) {
+      return ContentTask.spawn(tab.linkedBrowser, {count, url}, function* (args) {
+        content.wrappedJSObject.performRequests(args.count, args.url);
+      });
+    }
+
     // waitForNetworkEvents does not work for requests with security errors as
     // those only emit 9/13 events of a successful request.
     let done = waitForSecurityBrokenNetworkEvent();
 
     info("Requesting a resource that has a certificate problem.");
-    debuggee.performRequests(1, "https://nocert.example.com");
+    yield executeRequests(1, "https://nocert.example.com");
 
     // Wait for the request to complete before firing another request. Otherwise
     // the request with security issues interfere with waitForNetworkEvents.
     info("Waiting for request to complete.");
     yield done;
 
     // Next perform a request over HTTP. If done the other way around the latter
     // occasionally hangs waiting for event timings that don't seem to appear...
     done = waitForNetworkEvents(monitor, 1);
     info("Requesting a resource over HTTP.");
-    debuggee.performRequests(1, "http://test1.example.com" + CORS_SJS_PATH);
+    yield executeRequests(1, "http://test1.example.com" + CORS_SJS_PATH);
     yield done;
 
     done = waitForNetworkEvents(monitor, 1);
     info("Requesting a resource over HTTPS.");
-    debuggee.performRequests(1, "https://example.com" + CORS_SJS_PATH);
+    yield executeRequests(1, "https://example.com" + CORS_SJS_PATH);
     yield done;
 
     done = waitForSecurityBrokenNetworkEvent(true);
     info("Requesting a resource over HTTP to localhost.");
-    debuggee.performRequests(1, "http://localhost" + CORS_SJS_PATH);
+    yield executeRequests(1, "http://localhost" + CORS_SJS_PATH);
     yield done;
 
     const expectedCount = Object.keys(EXPECTED_SECURITY_STATES).length;
     is(RequestsMenu.itemCount, expectedCount, expectedCount + " events logged.");
   }
 
   /**
    * Returns a promise that's resolved once a request with security issues is
@@ -96,17 +102,17 @@ add_task(function* () {
       "RECEIVED_RESPONSE_CONTENT",
       "UPDATING_EVENT_TIMINGS",
       "RECEIVED_EVENT_TIMINGS",
     ];
 
     // If the reason for breakage is a network error, then the
     // STARTED_RECEIVING_RESPONSE event does not fire.
     if (networkError) {
-      awaitedEvents.splice(4, 1);
+      awaitedEvents = awaitedEvents.filter(e => e !== "STARTED_RECEIVING_RESPONSE");
     }
 
     let promises = awaitedEvents.map((event) => {
       return monitor.panelWin.once(EVENTS[event]);
     });
 
     return Promise.all(promises);
   }
--- a/devtools/client/netmonitor/test/browser_net_security-tab-deselect.js
+++ b/devtools/client/netmonitor/test/browser_net_security-tab-deselect.js
@@ -4,35 +4,43 @@
 "use strict";
 
 /**
  * Test that security details tab is no longer selected if an insecure request
  * is selected.
  */
 
 add_task(function* () {
-  let [tab, debuggee, monitor] = yield initNetMonitor(CUSTOM_GET_URL);
-  let { $, EVENTS, NetMonitorView } = monitor.panelWin;
+  let [tab, , monitor] = yield initNetMonitor(CUSTOM_GET_URL);
+  let { EVENTS, NetMonitorView } = monitor.panelWin;
   let { RequestsMenu, NetworkDetails } = NetMonitorView;
   RequestsMenu.lazyUpdate = false;
 
   info("Performing requests.");
-  debuggee.performRequests(1, "https://example.com" + CORS_SJS_PATH);
-  debuggee.performRequests(1, "http://example.com" + CORS_SJS_PATH);
-  yield waitForNetworkEvents(monitor, 2);
+  let wait = waitForNetworkEvents(monitor, 2);
+  const REQUEST_URLS = [
+    "https://example.com" + CORS_SJS_PATH,
+    "http://example.com" + CORS_SJS_PATH,
+  ];
+  yield ContentTask.spawn(tab.linkedBrowser, REQUEST_URLS, function* (urls) {
+    for (let url of urls) {
+      content.wrappedJSObject.performRequests(1, url);
+    }
+  });
+  yield wait;
 
   info("Selecting secure request.");
   RequestsMenu.selectedIndex = 0;
 
   info("Selecting security tab.");
   NetworkDetails.widget.selectedIndex = 5;
 
   info("Selecting insecure request.");
   RequestsMenu.selectedIndex = 1;
 
   info("Waiting for security tab to be updated.");
   yield monitor.panelWin.once(EVENTS.NETWORKDETAILSVIEW_POPULATED);
 
   is(NetworkDetails.widget.selectedIndex, 0,
     "Selected tab was reset when selected security tab was hidden.");
 
-  yield teardown(monitor);
+  return teardown(monitor);
 });
--- a/devtools/client/netmonitor/test/browser_net_security-tab-visibility.js
+++ b/devtools/client/netmonitor/test/browser_net_security-tab-visibility.js
@@ -26,76 +26,79 @@ add_task(function* () {
       uri: "https://nocert.example.com",
       isBroken: true,
       visibleOnNewEvent: false,
       visibleOnSecurityInfo: true,
       visibleOnceComplete: true,
     }
   ];
 
-  let [tab, debuggee, monitor] = yield initNetMonitor(CUSTOM_GET_URL);
+  let [tab, , monitor] = yield initNetMonitor(CUSTOM_GET_URL);
   let { $, EVENTS, NetMonitorView } = monitor.panelWin;
   let { RequestsMenu } = NetMonitorView;
   RequestsMenu.lazyUpdate = false;
 
   for (let testcase of TEST_DATA) {
     info("Testing Security tab visibility for " + testcase.desc);
     let onNewItem = monitor.panelWin.once(EVENTS.NETWORK_EVENT);
     let onSecurityInfo = monitor.panelWin.once(EVENTS.RECEIVED_SECURITY_INFO);
     let onComplete = testcase.isBroken ?
                        waitForSecurityBrokenNetworkEvent() :
                        waitForNetworkEvents(monitor, 1);
 
-    let tab = $("#security-tab");
+    let tabEl = $("#security-tab");
     let tabpanel = $("#security-tabpanel");
 
     info("Performing a request to " + testcase.uri);
-    debuggee.performRequests(1, testcase.uri);
+    yield ContentTask.spawn(tab.linkedBrowser, testcase.uri, function* (url) {
+      content.wrappedJSObject.performRequests(1, url);
+    });
 
     info("Waiting for new network event.");
     yield onNewItem;
 
     info("Selecting the request.");
     RequestsMenu.selectedIndex = 0;
 
     is(RequestsMenu.selectedItem.attachment.securityState, undefined,
        "Security state has not yet arrived.");
-    is(tab.hidden, !testcase.visibleOnNewEvent,
+    is(tabEl.hidden, !testcase.visibleOnNewEvent,
        "Security tab is " +
         (testcase.visibleOnNewEvent ? "visible" : "hidden") +
        " after new request was added to the menu.");
     is(tabpanel.hidden, false,
       "#security-tabpanel is visible after new request was added to the menu.");
 
     info("Waiting for security information to arrive.");
     yield onSecurityInfo;
 
     ok(RequestsMenu.selectedItem.attachment.securityState,
        "Security state arrived.");
-    is(tab.hidden, !testcase.visibleOnSecurityInfo,
+    is(tabEl.hidden, !testcase.visibleOnSecurityInfo,
        "Security tab is " +
         (testcase.visibleOnSecurityInfo ? "visible" : "hidden") +
        " after security information arrived.");
     is(tabpanel.hidden, false,
       "#security-tabpanel is visible after security information arrived.");
 
     info("Waiting for request to complete.");
     yield onComplete;
-    is(tab.hidden, !testcase.visibleOnceComplete,
+
+    is(tabEl.hidden, !testcase.visibleOnceComplete,
        "Security tab is " +
         (testcase.visibleOnceComplete ? "visible" : "hidden") +
        " after request has been completed.");
     is(tabpanel.hidden, false,
       "#security-tabpanel is visible after request is complete.");
 
     info("Clearing requests.");
     RequestsMenu.clear();
   }
 
-  yield teardown(monitor);
+  return teardown(monitor);
 
   /**
    * Returns a promise that's resolved once a request with security issues is
    * completed.
    */
   function waitForSecurityBrokenNetworkEvent() {
     let awaitedEvents = [
       "UPDATING_REQUEST_HEADERS",
--- a/devtools/client/netmonitor/test/browser_net_security-warnings.js
+++ b/devtools/client/netmonitor/test/browser_net_security-warnings.js
@@ -11,29 +11,32 @@ const TEST_CASES = [
   {
     desc: "no warnings",
     uri: "https://example.com" + CORS_SJS_PATH,
     warnCipher: false,
   },
 ];
 
 add_task(function* () {
-  let [tab, debuggee, monitor] = yield initNetMonitor(CUSTOM_GET_URL);
+  let [tab, , monitor] = yield initNetMonitor(CUSTOM_GET_URL);
   let { $, EVENTS, NetMonitorView } = monitor.panelWin;
   let { RequestsMenu, NetworkDetails } = NetMonitorView;
   RequestsMenu.lazyUpdate = false;
 
   let cipher = $("#security-warning-cipher");
 
   for (let test of TEST_CASES) {
     info("Testing site with " + test.desc);
 
     info("Performing request to " + test.uri);
-    debuggee.performRequests(1, test.uri);
-    yield waitForNetworkEvents(monitor, 1);
+    let wait = waitForNetworkEvents(monitor, 1);
+    yield ContentTask.spawn(tab.linkedBrowser, test.uri, function* (url) {
+      content.wrappedJSObject.performRequests(1, url);
+    });
+    yield wait;
 
     info("Selecting the request.");
     RequestsMenu.selectedIndex = 0;
 
     info("Waiting for details pane to be updated.");
     yield monitor.panelWin.once(EVENTS.TAB_UPDATED);
 
     if (NetworkDetails.widget.selectedIndex !== 5) {
@@ -42,14 +45,12 @@ add_task(function* () {
 
       info("Waiting for details pane to be updated.");
       yield monitor.panelWin.once(EVENTS.TAB_UPDATED);
     }
 
     is(cipher.hidden, !test.warnCipher, "Cipher suite warning is hidden.");
 
     RequestsMenu.clear();
-
   }
 
-  yield teardown(monitor);
-
+  return teardown(monitor);
 });
--- a/devtools/client/netmonitor/test/browser_net_send-beacon-other-tab.js
+++ b/devtools/client/netmonitor/test/browser_net_send-beacon-other-tab.js
@@ -1,31 +1,34 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 /**
  * Tests if beacons from other tabs are properly ignored.
  */
 
-var test = Task.async(function* () {
-  let [, debuggee, monitor] = yield initNetMonitor(SIMPLE_URL);
+add_task(function* () {
+  let [tab, , monitor] = yield initNetMonitor(SIMPLE_URL);
   let { RequestsMenu } = monitor.panelWin.NetMonitorView;
   RequestsMenu.lazyUpdate = false;
 
-  let tab = yield addTab(SEND_BEACON_URL);
-  let beaconDebuggee = tab.linkedBrowser.contentWindow.wrappedJSObject;
+  let beaconTab = yield addTab(SEND_BEACON_URL);
   info("Beacon tab added successfully.");
 
   is(RequestsMenu.itemCount, 0, "The requests menu should be empty.");
 
-  beaconDebuggee.performRequest();
-  debuggee.location.reload();
+  let wait = waitForNetworkEvents(monitor, 1);
+  yield ContentTask.spawn(beaconTab.linkedBrowser, {}, function* () {
+    content.wrappedJSObject.performRequest();
+  });
+  tab.linkedBrowser.reload();
+  yield wait;
 
-  yield waitForNetworkEvents(monitor, 1);
   is(RequestsMenu.itemCount, 1, "Only the reload should be recorded.");
   let request = RequestsMenu.getItemAtIndex(0);
   is(request.attachment.method, "GET", "The method is correct.");
   is(request.attachment.status, "200", "The status is correct.");
 
-  yield teardown(monitor);
-  removeTab(tab);
-  finish();
+  yield removeTab(beaconTab);
+  return teardown(monitor);
 });
--- a/devtools/client/netmonitor/test/browser_net_send-beacon.js
+++ b/devtools/client/netmonitor/test/browser_net_send-beacon.js
@@ -1,27 +1,31 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 /**
  * Tests if beacons are handled correctly.
  */
 
-var test = Task.async(function* () {
-  let [, debuggee, monitor] = yield initNetMonitor(SEND_BEACON_URL);
+add_task(function* () {
+  let [tab, , monitor] = yield initNetMonitor(SEND_BEACON_URL);
   let { RequestsMenu } = monitor.panelWin.NetMonitorView;
 
   RequestsMenu.lazyUpdate = false;
 
   is(RequestsMenu.itemCount, 0, "The requests menu should be empty.");
 
-  debuggee.performRequest();
+  let wait = waitForNetworkEvents(monitor, 1);
+  yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
+    content.wrappedJSObject.performRequest();
+  });
+  yield wait;
 
-  yield waitForNetworkEvents(monitor, 1);
   is(RequestsMenu.itemCount, 1, "The beacon should be recorded.");
   let request = RequestsMenu.getItemAtIndex(0);
   is(request.attachment.method, "POST", "The method is correct.");
   ok(request.attachment.url.endsWith("beacon_request"), "The URL is correct.");
   is(request.attachment.status, "404", "The status is correct.");
 
-  yield teardown(monitor);
-  finish();
+  return teardown(monitor);
 });
--- a/devtools/client/netmonitor/test/browser_net_simple-init.js
+++ b/devtools/client/netmonitor/test/browser_net_simple-init.js
@@ -1,93 +1,93 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 /**
  * Simple check if the network monitor starts up and shuts down properly.
  */
 
 function test() {
   // These test suite functions are removed from the global scope inside a
   // cleanup function. However, we still need them.
   let gInfo = info;
   let gOk = ok;
 
-  initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
+  initNetMonitor(SIMPLE_URL).then(([tab, , monitor]) => {
     info("Starting test... ");
 
-    is(aTab.linkedBrowser.contentWindow.wrappedJSObject.location, SIMPLE_URL,
+    is(tab.linkedBrowser.currentURI.spec, SIMPLE_URL,
       "The current tab's location is the correct one.");
-    is(aDebuggee.location, SIMPLE_URL,
-      "The current debuggee's location is the correct one.");
 
-    function checkIfInitialized(aTag) {
-      info("Checking if initialization is ok (" + aTag + ").");
+    function checkIfInitialized(tag) {
+      info(`Checking if initialization is ok (${tag}).`);
 
-      ok(aMonitor._view,
-        "The network monitor view object exists (" + aTag + ").");
-      ok(aMonitor._controller,
-        "The network monitor controller object exists (" + aTag + ").");
-      ok(aMonitor._controller._startup,
-        "The network monitor controller object exists and is initialized (" + aTag + ").");
+      ok(monitor._view,
+        `The network monitor view object exists (${tag}).`);
+      ok(monitor._controller,
+        `The network monitor controller object exists (${tag}).`);
+      ok(monitor._controller._startup,
+        `The network monitor controller object exists and is initialized (${tag}).`);
 
-      ok(aMonitor.isReady,
-        "The network monitor panel appears to be ready (" + aTag + ").");
+      ok(monitor.isReady,
+        `The network monitor panel appears to be ready (${tag}).`);
 
-      ok(aMonitor._controller.tabClient,
-        "There should be a tabClient available at this point (" + aTag + ").");
-      ok(aMonitor._controller.webConsoleClient,
-        "There should be a webConsoleClient available at this point (" + aTag + ").");
-      ok(aMonitor._controller.timelineFront,
-        "There should be a timelineFront available at this point (" + aTag + ").");
+      ok(monitor._controller.tabClient,
+        `There should be a tabClient available at this point (${tag}).`);
+      ok(monitor._controller.webConsoleClient,
+        `There should be a webConsoleClient available at this point (${tag}).`);
+      ok(monitor._controller.timelineFront,
+        `There should be a timelineFront available at this point (${tag}).`);
     }
 
-    function checkIfDestroyed(aTag) {
+    function checkIfDestroyed(tag) {
       gInfo("Checking if destruction is ok.");
 
-      gOk(aMonitor._view,
-        "The network monitor view object still exists (" + aTag + ").");
-      gOk(aMonitor._controller,
-        "The network monitor controller object still exists (" + aTag + ").");
-      gOk(aMonitor._controller._shutdown,
-        "The network monitor controller object still exists and is destroyed (" + aTag + ").");
+      gOk(monitor._view,
+        `The network monitor view object still exists (${tag}).`);
+      gOk(monitor._controller,
+        `The network monitor controller object still exists (${tag}).`);
+      gOk(monitor._controller._shutdown,
+        `The network monitor controller object still exists and is destroyed (${tag}).`);
 
-      gOk(!aMonitor._controller.tabClient,
-        "There shouldn't be a tabClient available after destruction (" + aTag + ").");
-      gOk(!aMonitor._controller.webConsoleClient,
-        "There shouldn't be a webConsoleClient available after destruction (" + aTag + ").");
-      gOk(!aMonitor._controller.timelineFront,
-        "There shouldn't be a timelineFront available after destruction (" + aTag + ").");
+      gOk(!monitor._controller.tabClient,
+        `There shouldn't be a tabClient available after destruction (${tag}).`);
+      gOk(!monitor._controller.webConsoleClient,
+        `There shouldn't be a webConsoleClient available after destruction (${tag}).`);
+      gOk(!monitor._controller.timelineFront,
+        `There shouldn't be a timelineFront available after destruction (${tag}).`);
     }
 
     executeSoon(() => {
       checkIfInitialized(1);
 
-      aMonitor._controller.startupNetMonitor()
+      monitor._controller.startupNetMonitor()
         .then(() => {
           info("Starting up again shouldn't do anything special.");
           checkIfInitialized(2);
-          return aMonitor._controller.connect();
+          return monitor._controller.connect();
         })
         .then(() => {
           info("Connecting again shouldn't do anything special.");
           checkIfInitialized(3);
-          return teardown(aMonitor);
+          return teardown(monitor);
         })
         .then(finish);
     });
 
     registerCleanupFunction(() => {
       checkIfDestroyed(1);
 
-      aMonitor._controller.shutdownNetMonitor()
+      monitor._controller.shutdownNetMonitor()
         .then(() => {
           gInfo("Shutting down again shouldn't do anything special.");
           checkIfDestroyed(2);
-          return aMonitor._controller.disconnect();
+          return monitor._controller.disconnect();
         })
         .then(() => {
           gInfo("Disconnecting again shouldn't do anything special.");
           checkIfDestroyed(3);
         });
     });
   });
 }
--- a/devtools/client/netmonitor/test/browser_net_simple-request-data.js
+++ b/devtools/client/netmonitor/test/browser_net_simple-request-data.js
@@ -1,38 +1,39 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 /**
  * Tests if requests render correct information in the menu UI.
  */
 
 function test() {
-  initNetMonitor(SIMPLE_SJS).then(([aTab, aDebuggee, aMonitor]) => {
+  initNetMonitor(SIMPLE_SJS).then(([tab, , monitor]) => {
     info("Starting test... ");
 
-    let { L10N, NetMonitorView } = aMonitor.panelWin;
+    let { L10N, NetMonitorView } = monitor.panelWin;
     let { RequestsMenu } = NetMonitorView;
 
     RequestsMenu.lazyUpdate = false;
 
-    waitForNetworkEvents(aMonitor, 1)
-      .then(() => teardown(aMonitor))
+    waitForNetworkEvents(monitor, 1)
+      .then(() => teardown(monitor))
       .then(finish);
 
-    aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.NETWORK_EVENT, () => {
+    monitor.panelWin.once(monitor.panelWin.EVENTS.NETWORK_EVENT, () => {
       is(RequestsMenu.selectedItem, null,
         "There shouldn't be any selected item in the requests menu.");
       is(RequestsMenu.itemCount, 1,
         "The requests menu should not be empty after the first request.");
       is(NetMonitorView.detailsPaneHidden, true,
         "The details pane should still be hidden after the first request.");
 
       let requestItem = RequestsMenu.getItemAtIndex(0);
-      let target = requestItem.target;
 
       is(typeof requestItem.value, "string",
         "The attached request id is incorrect.");
       isnot(requestItem.value, "",
         "The attached request id should not be empty.");
 
       is(typeof requestItem.attachment.startedDeltaMillis, "number",
         "The attached startedDeltaMillis is incorrect.");
@@ -78,71 +79,71 @@ function test() {
       is(requestItem.attachment.totalTime, undefined,
         "The totalTime should not yet be set.");
       is(requestItem.attachment.eventTimings, undefined,
         "The eventTimings should not yet be set.");
 
       verifyRequestItemTarget(requestItem, "GET", SIMPLE_SJS);
     });
 
-    aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RECEIVED_REQUEST_HEADERS, () => {
+    monitor.panelWin.once(monitor.panelWin.EVENTS.RECEIVED_REQUEST_HEADERS, () => {
       let requestItem = RequestsMenu.getItemAtIndex(0);
 
       ok(requestItem.attachment.requestHeaders,
         "There should be a requestHeaders attachment available.");
       is(requestItem.attachment.requestHeaders.headers.length, 9,
         "The requestHeaders attachment has an incorrect |headers| property.");
       isnot(requestItem.attachment.requestHeaders.headersSize, 0,
         "The requestHeaders attachment has an incorrect |headersSize| property.");
       // Can't test for the exact request headers size because the value may
       // vary across platforms ("User-Agent" header differs).
 
       verifyRequestItemTarget(requestItem, "GET", SIMPLE_SJS);
     });
 
-    aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RECEIVED_REQUEST_COOKIES, () => {
+    monitor.panelWin.once(monitor.panelWin.EVENTS.RECEIVED_REQUEST_COOKIES, () => {
       let requestItem = RequestsMenu.getItemAtIndex(0);
 
       ok(requestItem.attachment.requestCookies,
         "There should be a requestCookies attachment available.");
       is(requestItem.attachment.requestCookies.cookies.length, 2,
         "The requestCookies attachment has an incorrect |cookies| property.");
 
       verifyRequestItemTarget(requestItem, "GET", SIMPLE_SJS);
     });
 
-    aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RECEIVED_REQUEST_POST_DATA, () => {
+    monitor.panelWin.once(monitor.panelWin.EVENTS.RECEIVED_REQUEST_POST_DATA, () => {
       ok(false, "Trap listener: this request doesn't have any post data.");
     });
 
-    aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RECEIVED_RESPONSE_HEADERS, () => {
+    monitor.panelWin.once(monitor.panelWin.EVENTS.RECEIVED_RESPONSE_HEADERS, () => {
       let requestItem = RequestsMenu.getItemAtIndex(0);
 
       ok(requestItem.attachment.responseHeaders,
         "There should be a responseHeaders attachment available.");
       is(requestItem.attachment.responseHeaders.headers.length, 10,
         "The responseHeaders attachment has an incorrect |headers| property.");
       is(requestItem.attachment.responseHeaders.headersSize, 330,
         "The responseHeaders attachment has an incorrect |headersSize| property.");
 
       verifyRequestItemTarget(requestItem, "GET", SIMPLE_SJS);
     });
 
-    aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RECEIVED_RESPONSE_COOKIES, () => {
+    monitor.panelWin.once(monitor.panelWin.EVENTS.RECEIVED_RESPONSE_COOKIES, () => {
       let requestItem = RequestsMenu.getItemAtIndex(0);
 
       ok(requestItem.attachment.responseCookies,
         "There should be a responseCookies attachment available.");
       is(requestItem.attachment.responseCookies.cookies.length, 2,
         "The responseCookies attachment has an incorrect |cookies| property.");
 
       verifyRequestItemTarget(requestItem, "GET", SIMPLE_SJS);
     });
 
-    aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.STARTED_RECEIVING_RESPONSE, () => {
+    monitor.panelWin.once(monitor.panelWin.EVENTS.STARTED_RECEIVING_RESPONSE, () => {
       let requestItem = RequestsMenu.getItemAtIndex(0);
 
       is(requestItem.attachment.httpVersion, "HTTP/1.1",
         "The httpVersion attachment has an incorrect value.");
       is(requestItem.attachment.status, "200",
         "The status attachment has an incorrect value.");
       is(requestItem.attachment.statusText, "Och Aye",
         "The statusText attachment has an incorrect value.");
@@ -150,17 +151,17 @@ function test() {
         "The headersSize attachment has an incorrect value.");
 
       verifyRequestItemTarget(requestItem, "GET", SIMPLE_SJS, {
         status: "200",
         statusText: "Och Aye"
       });
     });
 
-    aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.UPDATING_RESPONSE_CONTENT, () => {
+    monitor.panelWin.once(monitor.panelWin.EVENTS.UPDATING_RESPONSE_CONTENT, () => {
       let requestItem = RequestsMenu.getItemAtIndex(0);
 
       is(requestItem.attachment.transferredSize, "12",
         "The transferredSize attachment has an incorrect value.");
       is(requestItem.attachment.contentSize, "12",
         "The contentSize attachment has an incorrect value.");
       is(requestItem.attachment.mimeType, "text/plain; charset=utf-8",
         "The mimeType attachment has an incorrect value.");
@@ -168,37 +169,40 @@ function test() {
       verifyRequestItemTarget(requestItem, "GET", SIMPLE_SJS, {
         type: "plain",
         fullMimeType: "text/plain; charset=utf-8",
         transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.01),
         size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.01),
       });
     });
 
-    aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RECEIVED_RESPONSE_CONTENT, () => {
+    monitor.panelWin.once(monitor.panelWin.EVENTS.RECEIVED_RESPONSE_CONTENT, () => {
       let requestItem = RequestsMenu.getItemAtIndex(0);
 
       ok(requestItem.attachment.responseContent,
         "There should be a responseContent attachment available.");
-      is(requestItem.attachment.responseContent.content.mimeType, "text/plain; charset=utf-8",
+      is(requestItem.attachment.responseContent.content.mimeType,
+        "text/plain; charset=utf-8",
         "The responseContent attachment has an incorrect |content.mimeType| property.");
-      is(requestItem.attachment.responseContent.content.text, "Hello world!",
+      is(requestItem.attachment.responseContent.content.text,
+        "Hello world!",
         "The responseContent attachment has an incorrect |content.text| property.");
-      is(requestItem.attachment.responseContent.content.size, 12,
+      is(requestItem.attachment.responseContent.content.size,
+        12,
         "The responseContent attachment has an incorrect |content.size| property.");
 
       verifyRequestItemTarget(requestItem, "GET", SIMPLE_SJS, {
         type: "plain",
         fullMimeType: "text/plain; charset=utf-8",
         transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.01),
         size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.01),
       });
     });
 
-    aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.UPDATING_EVENT_TIMINGS, () => {
+    monitor.panelWin.once(monitor.panelWin.EVENTS.UPDATING_EVENT_TIMINGS, () => {
       let requestItem = RequestsMenu.getItemAtIndex(0);
 
       is(typeof requestItem.attachment.totalTime, "number",
         "The attached totalTime is incorrect.");
       ok(requestItem.attachment.totalTime >= 0,
         "The attached totalTime should be positive.");
 
       is(typeof requestItem.attachment.endedMillis, "number",
@@ -206,17 +210,17 @@ function test() {
       ok(requestItem.attachment.endedMillis >= 0,
         "The attached endedMillis should be positive.");
 
       verifyRequestItemTarget(requestItem, "GET", SIMPLE_SJS, {
         time: true
       });
     });
 
-    aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RECEIVED_EVENT_TIMINGS, () => {
+    monitor.panelWin.once(monitor.panelWin.EVENTS.RECEIVED_EVENT_TIMINGS, () => {
       let requestItem = RequestsMenu.getItemAtIndex(0);
 
       ok(requestItem.attachment.eventTimings,
         "There should be a eventTimings attachment available.");
       is(typeof requestItem.attachment.eventTimings.timings.blocked, "number",
         "The eventTimings attachment has an incorrect |timings.blocked| property.");
       is(typeof requestItem.attachment.eventTimings.timings.dns, "number",
         "The eventTimings attachment has an incorrect |timings.dns| property.");
@@ -231,11 +235,11 @@ function test() {
       is(typeof requestItem.attachment.eventTimings.totalTime, "number",
         "The eventTimings attachment has an incorrect |totalTime| property.");
 
       verifyRequestItemTarget(requestItem, "GET", SIMPLE_SJS, {
         time: true
       });
     });
 
-    aDebuggee.location.reload();
+    tab.linkedBrowser.reload();
   });
 }
--- a/devtools/client/netmonitor/test/browser_net_simple-request-details.js
+++ b/devtools/client/netmonitor/test/browser_net_simple-request-details.js
@@ -1,244 +1,259 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 /**
  * Tests if requests render correct information in the details UI.
  */
 
-function test() {
-  initNetMonitor(SIMPLE_SJS).then(([aTab, aDebuggee, aMonitor]) => {
-    info("Starting test... ");
+add_task(function* () {
+  let [tab, , monitor] = yield initNetMonitor(SIMPLE_SJS);
+  info("Starting test... ");
 
-    let { document, L10N, Editor, NetMonitorView } = aMonitor.panelWin;
-    let { RequestsMenu, NetworkDetails } = NetMonitorView;
-    let TAB_UPDATED = aMonitor.panelWin.EVENTS.TAB_UPDATED;
-    RequestsMenu.lazyUpdate = false;
+  let { document, EVENTS, L10N, Editor, NetMonitorView } = monitor.panelWin;
+  let { RequestsMenu } = NetMonitorView;
+  RequestsMenu.lazyUpdate = false;
 
-    Task.spawn(function* () {
-      yield waitForNetworkEvents(aMonitor, 1);
-      is(RequestsMenu.selectedItem, null,
-        "There shouldn't be any selected item in the requests menu.");
-      is(RequestsMenu.itemCount, 1,
-        "The requests menu should not be empty after the first request.");
-      is(NetMonitorView.detailsPaneHidden, true,
-        "The details pane should still be hidden after the first request.");
+  let wait = waitForNetworkEvents(monitor, 1);
+  tab.linkedBrowser.reload();
+  yield wait;
 
-      EventUtils.sendMouseEvent({ type: "mousedown" },
-        document.getElementById("details-pane-toggle"));
+  is(RequestsMenu.selectedItem, null,
+    "There shouldn't be any selected item in the requests menu.");
+  is(RequestsMenu.itemCount, 1,
+    "The requests menu should not be empty after the first request.");
+  is(NetMonitorView.detailsPaneHidden, true,
+    "The details pane should still be hidden after the first request.");
 
-      isnot(RequestsMenu.selectedItem, null,
-        "There should be a selected item in the requests menu.");
-      is(RequestsMenu.selectedIndex, 0,
-        "The first item should be selected in the requests menu.");
-      is(NetMonitorView.detailsPaneHidden, false,
-        "The details pane should not be hidden after toggle button was pressed.");
+  let onTabUpdated = monitor.panelWin.once(EVENTS.TAB_UPDATED);
+  EventUtils.sendMouseEvent({ type: "mousedown" },
+    document.getElementById("details-pane-toggle"));
+  yield onTabUpdated;
+
+  isnot(RequestsMenu.selectedItem, null,
+    "There should be a selected item in the requests menu.");
+  is(RequestsMenu.selectedIndex, 0,
+    "The first item should be selected in the requests menu.");
+  is(NetMonitorView.detailsPaneHidden, false,
+    "The details pane should not be hidden after toggle button was pressed.");
 
-      yield waitFor(aMonitor.panelWin, TAB_UPDATED);
-      testHeadersTab();
-      yield testCookiesTab();
-      testParamsTab();
-      yield testResponseTab();
-      testTimingsTab();
-      yield teardown(aMonitor);
-      finish();
-    });
+  testHeadersTab();
+  yield testCookiesTab();
+  testParamsTab();
+  yield testResponseTab();
+  testTimingsTab();
+  return teardown(monitor);
 
-    function testHeadersTab() {
-      let tab = document.querySelectorAll("#details-pane tab")[0];
-      let tabpanel = document.querySelectorAll("#details-pane tabpanel")[0];
+  function testHeadersTab() {
+    let tabEl = document.querySelectorAll("#details-pane tab")[0];
+    let tabpanel = document.querySelectorAll("#details-pane tabpanel")[0];
 
-      is(tab.getAttribute("selected"), "true",
-        "The headers tab in the network details pane should be selected.");
+    is(tabEl.getAttribute("selected"), "true",
+      "The headers tab in the network details pane should be selected.");
 
-      is(tabpanel.querySelector("#headers-summary-url-value").getAttribute("value"),
-        SIMPLE_SJS, "The url summary value is incorrect.");
-      is(tabpanel.querySelector("#headers-summary-url-value").getAttribute("tooltiptext"),
-        SIMPLE_SJS, "The url summary tooltiptext is incorrect.");
-      is(tabpanel.querySelector("#headers-summary-method-value").getAttribute("value"),
-        "GET", "The method summary value is incorrect.");
-      is(tabpanel.querySelector("#headers-summary-address-value").getAttribute("value"),
-        "127.0.0.1:8888", "The remote address summary value is incorrect.");
-      is(tabpanel.querySelector("#headers-summary-status-circle").getAttribute("code"),
-        "200", "The status summary code is incorrect.");
-      is(tabpanel.querySelector("#headers-summary-status-value").getAttribute("value"),
-        "200 Och Aye", "The status summary value is incorrect.");
+    is(tabpanel.querySelector("#headers-summary-url-value").getAttribute("value"),
+      SIMPLE_SJS, "The url summary value is incorrect.");
+    is(tabpanel.querySelector("#headers-summary-url-value").getAttribute("tooltiptext"),
+      SIMPLE_SJS, "The url summary tooltiptext is incorrect.");
+    is(tabpanel.querySelector("#headers-summary-method-value").getAttribute("value"),
+      "GET", "The method summary value is incorrect.");
+    is(tabpanel.querySelector("#headers-summary-address-value").getAttribute("value"),
+      "127.0.0.1:8888", "The remote address summary value is incorrect.");
+    is(tabpanel.querySelector("#headers-summary-status-circle").getAttribute("code"),
+      "200", "The status summary code is incorrect.");
+    is(tabpanel.querySelector("#headers-summary-status-value").getAttribute("value"),
+      "200 Och Aye", "The status summary value is incorrect.");
 
-      is(tabpanel.querySelectorAll(".variables-view-scope").length, 2,
-        "There should be 2 header scopes displayed in this tabpanel.");
-      is(tabpanel.querySelectorAll(".variable-or-property").length, 19,
-        "There should be 19 header values displayed in this tabpanel.");
+    is(tabpanel.querySelectorAll(".variables-view-scope").length, 2,
+      "There should be 2 header scopes displayed in this tabpanel.");
+    is(tabpanel.querySelectorAll(".variable-or-property").length, 19,
+      "There should be 19 header values displayed in this tabpanel.");
+
+    is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0,
+      "The empty notice should not be displayed in this tabpanel.");
 
-      is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0,
-        "The empty notice should not be displayed in this tabpanel.");
+    let responseScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
+    let requestScope = tabpanel.querySelectorAll(".variables-view-scope")[1];
 
-      let responseScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
-      let requestScope = tabpanel.querySelectorAll(".variables-view-scope")[1];
+    is(responseScope.querySelector(".name").getAttribute("value"),
+      L10N.getStr("responseHeaders") + " (" +
+      L10N.getFormatStr("networkMenu.sizeKB",
+        L10N.numberWithDecimals(330 / 1024, 3)) + ")",
+      "The response headers scope doesn't have the correct title.");
 
-      is(responseScope.querySelector(".name").getAttribute("value"),
-        L10N.getStr("responseHeaders") + " (" +
-        L10N.getFormatStr("networkMenu.sizeKB", L10N.numberWithDecimals(330 / 1024, 3)) + ")",
-        "The response headers scope doesn't have the correct title.");
-
-      ok(requestScope.querySelector(".name").getAttribute("value").includes(
-        L10N.getStr("requestHeaders") + " (0"),
-        "The request headers scope doesn't have the correct title.");
-      // Can't test for full request headers title because the size may
-      // vary across platforms ("User-Agent" header differs). We're pretty
-      // sure it's smaller than 1 MB though, so it starts with a 0.
+    ok(requestScope.querySelector(".name").getAttribute("value").includes(
+      L10N.getStr("requestHeaders") + " (0"),
+      "The request headers scope doesn't have the correct title.");
+    // Can't test for full request headers title because the size may
+    // vary across platforms ("User-Agent" header differs). We're pretty
+    // sure it's smaller than 1 MB though, so it starts with a 0.
 
-      is(responseScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"),
-        "Cache-Control", "The first response header name was incorrect.");
-      is(responseScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"),
-        "\"no-cache, no-store, must-revalidate\"", "The first response header value was incorrect.");
-      is(responseScope.querySelectorAll(".variables-view-variable .name")[1].getAttribute("value"),
-        "Connection", "The second response header name was incorrect.");
-      is(responseScope.querySelectorAll(".variables-view-variable .value")[1].getAttribute("value"),
-        "\"close\"", "The second response header value was incorrect.");
-      is(responseScope.querySelectorAll(".variables-view-variable .name")[2].getAttribute("value"),
-        "Content-Length", "The third response header name was incorrect.");
-      is(responseScope.querySelectorAll(".variables-view-variable .value")[2].getAttribute("value"),
-        "\"12\"", "The third response header value was incorrect.");
-      is(responseScope.querySelectorAll(".variables-view-variable .name")[3].getAttribute("value"),
-        "Content-Type", "The fourth response header name was incorrect.");
-      is(responseScope.querySelectorAll(".variables-view-variable .value")[3].getAttribute("value"),
-        "\"text/plain; charset=utf-8\"", "The fourth response header value was incorrect.");
-      is(responseScope.querySelectorAll(".variables-view-variable .name")[9].getAttribute("value"),
-        "foo-bar", "The last response header name was incorrect.");
-      is(responseScope.querySelectorAll(".variables-view-variable .value")[9].getAttribute("value"),
-        "\"baz\"", "The last response header value was incorrect.");
+    is(responseScope.querySelectorAll(".variables-view-variable .name")[0]
+      .getAttribute("value"),
+      "Cache-Control", "The first response header name was incorrect.");
+    is(responseScope.querySelectorAll(".variables-view-variable .value")[0]
+      .getAttribute("value"),
+      "\"no-cache, no-store, must-revalidate\"",
+      "The first response header value was incorrect.");
+    is(responseScope.querySelectorAll(".variables-view-variable .name")[1]
+      .getAttribute("value"),
+      "Connection", "The second response header name was incorrect.");
+    is(responseScope.querySelectorAll(".variables-view-variable .value")[1]
+      .getAttribute("value"),
+      "\"close\"", "The second response header value was incorrect.");
+    is(responseScope.querySelectorAll(".variables-view-variable .name")[2]
+      .getAttribute("value"),
+      "Content-Length", "The third response header name was incorrect.");
+    is(responseScope.querySelectorAll(".variables-view-variable .value")[2]
+      .getAttribute("value"),
+      "\"12\"", "The third response header value was incorrect.");
+    is(responseScope.querySelectorAll(".variables-view-variable .name")[3]
+      .getAttribute("value"),
+      "Content-Type", "The fourth response header name was incorrect.");
+    is(responseScope.querySelectorAll(".variables-view-variable .value")[3]
+      .getAttribute("value"),
+      "\"text/plain; charset=utf-8\"", "The fourth response header value was incorrect.");
+    is(responseScope.querySelectorAll(".variables-view-variable .name")[9]
+      .getAttribute("value"),
+      "foo-bar", "The last response header name was incorrect.");
+    is(responseScope.querySelectorAll(".variables-view-variable .value")[9]
+      .getAttribute("value"),
+      "\"baz\"", "The last response header value was incorrect.");
 
-      is(requestScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"),
-        "Host", "The first request header name was incorrect.");
-      is(requestScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"),
-        "\"example.com\"", "The first request header value was incorrect.");
-      is(requestScope.querySelectorAll(".variables-view-variable .name")[6].getAttribute("value"),
-        "Connection", "The ante-penultimate request header name was incorrect.");
-      is(requestScope.querySelectorAll(".variables-view-variable .value")[6].getAttribute("value"),
-        "\"keep-alive\"", "The ante-penultimate request header value was incorrect.");
-      is(requestScope.querySelectorAll(".variables-view-variable .name")[7].getAttribute("value"),
-        "Pragma", "The penultimate request header name was incorrect.");
-      is(requestScope.querySelectorAll(".variables-view-variable .value")[7].getAttribute("value"),
-        "\"no-cache\"", "The penultimate request header value was incorrect.");
-      is(requestScope.querySelectorAll(".variables-view-variable .name")[8].getAttribute("value"),
-        "Cache-Control", "The last request header name was incorrect.");
-      is(requestScope.querySelectorAll(".variables-view-variable .value")[8].getAttribute("value"),
-        "\"no-cache\"", "The last request header value was incorrect.");
-    }
-
-    function testCookiesTab() {
-      EventUtils.sendMouseEvent({ type: "mousedown" },
-        document.querySelectorAll("#details-pane tab")[1]);
-
-      return Task.spawn(function* () {
-        yield waitFor(aMonitor.panelWin, TAB_UPDATED);
-
-        let tab = document.querySelectorAll("#details-pane tab")[1];
-        let tabpanel = document.querySelectorAll("#details-pane tabpanel")[1];
-
-        is(tab.getAttribute("selected"), "true",
-          "The cookies tab in the network details pane should be selected.");
+    is(requestScope.querySelectorAll(".variables-view-variable .name")[0]
+      .getAttribute("value"),
+      "Host", "The first request header name was incorrect.");
+    is(requestScope.querySelectorAll(".variables-view-variable .value")[0]
+      .getAttribute("value"),
+      "\"example.com\"", "The first request header value was incorrect.");
+    is(requestScope.querySelectorAll(".variables-view-variable .name")[6]
+      .getAttribute("value"),
+      "Connection", "The ante-penultimate request header name was incorrect.");
+    is(requestScope.querySelectorAll(".variables-view-variable .value")[6]
+      .getAttribute("value"),
+      "\"keep-alive\"", "The ante-penultimate request header value was incorrect.");
+    is(requestScope.querySelectorAll(".variables-view-variable .name")[7]
+      .getAttribute("value"),
+      "Pragma", "The penultimate request header name was incorrect.");
+    is(requestScope.querySelectorAll(".variables-view-variable .value")[7]
+      .getAttribute("value"),
+      "\"no-cache\"", "The penultimate request header value was incorrect.");
+    is(requestScope.querySelectorAll(".variables-view-variable .name")[8]
+      .getAttribute("value"),
+      "Cache-Control", "The last request header name was incorrect.");
+    is(requestScope.querySelectorAll(".variables-view-variable .value")[8]
+      .getAttribute("value"),
+      "\"no-cache\"", "The last request header value was incorrect.");
+  }
 
-        is(tabpanel.querySelectorAll(".variables-view-scope").length, 2,
-          "There should be 2 cookie scopes displayed in this tabpanel.");
-        is(tabpanel.querySelectorAll(".variable-or-property").length, 6,
-          "There should be 6 cookie values displayed in this tabpanel.");
-      });
-    }
+  function* testCookiesTab() {
+    let onEvent = monitor.panelWin.once(EVENTS.TAB_UPDATED);
+    EventUtils.sendMouseEvent({ type: "mousedown" },
+      document.querySelectorAll("#details-pane tab")[1]);
+    yield onEvent;
 
-    function testParamsTab() {
-      EventUtils.sendMouseEvent({ type: "mousedown" },
-        document.querySelectorAll("#details-pane tab")[2]);
+    let tabEl = document.querySelectorAll("#details-pane tab")[1];
+    let tabpanel = document.querySelectorAll("#details-pane tabpanel")[1];
 
-      let tab = document.querySelectorAll("#details-pane tab")[2];
-      let tabpanel = document.querySelectorAll("#details-pane tabpanel")[2];
-
-      is(tab.getAttribute("selected"), "true",
-        "The params tab in the network details pane should be selected.");
+    is(tabEl.getAttribute("selected"), "true",
+      "The cookies tab in the network details pane should be selected.");
 
-      is(tabpanel.querySelectorAll(".variables-view-scope").length, 0,
-        "There should be no param scopes displayed in this tabpanel.");
-      is(tabpanel.querySelectorAll(".variable-or-property").length, 0,
-        "There should be no param values displayed in this tabpanel.");
-      is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 1,
-        "The empty notice should be displayed in this tabpanel.");
+    is(tabpanel.querySelectorAll(".variables-view-scope").length, 2,
+      "There should be 2 cookie scopes displayed in this tabpanel.");
+    is(tabpanel.querySelectorAll(".variable-or-property").length, 6,
+      "There should be 6 cookie values displayed in this tabpanel.");
+  }
+
+  function testParamsTab() {
+    EventUtils.sendMouseEvent({ type: "mousedown" },
+      document.querySelectorAll("#details-pane tab")[2]);
 
-      is(tabpanel.querySelector("#request-params-box")
-        .hasAttribute("hidden"), false,
-        "The request params box should not be hidden.");
-      is(tabpanel.querySelector("#request-post-data-textarea-box")
-        .hasAttribute("hidden"), true,
-        "The request post data textarea box should be hidden.");
-    }
+    let tabEl = document.querySelectorAll("#details-pane tab")[2];
+    let tabpanel = document.querySelectorAll("#details-pane tabpanel")[2];
+
+    is(tabEl.getAttribute("selected"), "true",
+      "The params tab in the network details pane should be selected.");
 
-    function testResponseTab() {
-      EventUtils.sendMouseEvent({ type: "mousedown" },
-        document.querySelectorAll("#details-pane tab")[3]);
+    is(tabpanel.querySelectorAll(".variables-view-scope").length, 0,
+      "There should be no param scopes displayed in this tabpanel.");
+    is(tabpanel.querySelectorAll(".variable-or-property").length, 0,
+      "There should be no param values displayed in this tabpanel.");
+    is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 1,
+      "The empty notice should be displayed in this tabpanel.");
 
-      return Task.spawn(function* () {
-        yield waitFor(aMonitor.panelWin, TAB_UPDATED);
+    is(tabpanel.querySelector("#request-params-box")
+      .hasAttribute("hidden"), false,
+      "The request params box should not be hidden.");
+    is(tabpanel.querySelector("#request-post-data-textarea-box")
+      .hasAttribute("hidden"), true,
+      "The request post data textarea box should be hidden.");
+  }
 
-        let tab = document.querySelectorAll("#details-pane tab")[3];
-        let tabpanel = document.querySelectorAll("#details-pane tabpanel")[3];
-
-        is(tab.getAttribute("selected"), "true",
-          "The response tab in the network details pane should be selected.");
+  function* testResponseTab() {
+    let onEvent = monitor.panelWin.once(EVENTS.TAB_UPDATED);
+    EventUtils.sendMouseEvent({ type: "mousedown" },
+      document.querySelectorAll("#details-pane tab")[3]);
+    yield onEvent;
 
-        is(tabpanel.querySelector("#response-content-info-header")
-          .hasAttribute("hidden"), true,
-          "The response info header should be hidden.");
-        is(tabpanel.querySelector("#response-content-json-box")
-          .hasAttribute("hidden"), true,
-          "The response content json box should be hidden.");
-        is(tabpanel.querySelector("#response-content-textarea-box")
-          .hasAttribute("hidden"), false,
-          "The response content textarea box should not be hidden.");
-        is(tabpanel.querySelector("#response-content-image-box")
-          .hasAttribute("hidden"), true,
-          "The response content image box should be hidden.");
+    let tabEl = document.querySelectorAll("#details-pane tab")[3];
+    let tabpanel = document.querySelectorAll("#details-pane tabpanel")[3];
+
+    is(tabEl.getAttribute("selected"), "true",
+      "The response tab in the network details pane should be selected.");
 
-        let aEditor = yield NetMonitorView.editor("#response-content-textarea");
-        is(aEditor.getText(), "Hello world!",
-          "The text shown in the source editor is incorrect.");
-        is(aEditor.getMode(), Editor.modes.text,
-          "The mode active in the source editor is incorrect.");
-      });
-    }
-
-    function testTimingsTab() {
-      EventUtils.sendMouseEvent({ type: "mousedown" },
-        document.querySelectorAll("#details-pane tab")[4]);
+    is(tabpanel.querySelector("#response-content-info-header")
+      .hasAttribute("hidden"), true,
+      "The response info header should be hidden.");
+    is(tabpanel.querySelector("#response-content-json-box")
+      .hasAttribute("hidden"), true,
+      "The response content json box should be hidden.");
+    is(tabpanel.querySelector("#response-content-textarea-box")
+      .hasAttribute("hidden"), false,
+      "The response content textarea box should not be hidden.");
+    is(tabpanel.querySelector("#response-content-image-box")
+      .hasAttribute("hidden"), true,
+      "The response content image box should be hidden.");
 
-      let tab = document.querySelectorAll("#details-pane tab")[4];
-      let tabpanel = document.querySelectorAll("#details-pane tabpanel")[4];
-
-      is(tab.getAttribute("selected"), "true",
-        "The timings tab in the network details pane should be selected.");
+    let editor = yield NetMonitorView.editor("#response-content-textarea");
+    is(editor.getText(), "Hello world!",
+      "The text shown in the source editor is incorrect.");
+    is(editor.getMode(), Editor.modes.text,
+      "The mode active in the source editor is incorrect.");
+  }
 
-      ok(tabpanel.querySelector("#timings-summary-blocked .requests-menu-timings-total")
-        .getAttribute("value").match(/[0-9]+/),
-        "The blocked timing info does not appear to be correct.");
+  function testTimingsTab() {
+    EventUtils.sendMouseEvent({ type: "mousedown" },
+      document.querySelectorAll("#details-pane tab")[4]);
+
+    let tabEl = document.querySelectorAll("#details-pane tab")[4];
+    let tabpanel = document.querySelectorAll("#details-pane tabpanel")[4];
 
-      ok(tabpanel.querySelector("#timings-summary-dns .requests-menu-timings-total")
-        .getAttribute("value").match(/[0-9]+/),
-        "The dns timing info does not appear to be correct.");
+    is(tabEl.getAttribute("selected"), "true",
+      "The timings tab in the network details pane should be selected.");
+
+    ok(tabpanel.querySelector("#timings-summary-blocked .requests-menu-timings-total")
+      .getAttribute("value").match(/[0-9]+/),
+      "The blocked timing info does not appear to be correct.");
 
-      ok(tabpanel.querySelector("#timings-summary-connect .requests-menu-timings-total")
-        .getAttribute("value").match(/[0-9]+/),
-        "The connect timing info does not appear to be correct.");
+    ok(tabpanel.querySelector("#timings-summary-dns .requests-menu-timings-total")
+      .getAttribute("value").match(/[0-9]+/),
+      "The dns timing info does not appear to be correct.");
 
-      ok(tabpanel.querySelector("#timings-summary-send .requests-menu-timings-total")
-        .getAttribute("value").match(/[0-9]+/),
-        "The send timing info does not appear to be correct.");
+    ok(tabpanel.querySelector("#timings-summary-connect .requests-menu-timings-total")
+      .getAttribute("value").match(/[0-9]+/),
+      "The connect timing info does not appear to be correct.");
 
-      ok(tabpanel.querySelector("#timings-summary-wait .requests-menu-timings-total")
-        .getAttribute("value").match(/[0-9]+/),
-        "The wait timing info does not appear to be correct.");
+    ok(tabpanel.querySelector("#timings-summary-send .requests-menu-timings-total")
+      .getAttribute("value").match(/[0-9]+/),
+      "The send timing info does not appear to be correct.");
 
-      ok(tabpanel.querySelector("#timings-summary-receive .requests-menu-timings-total")
-        .getAttribute("value").match(/[0-9]+/),
-        "The receive timing info does not appear to be correct.");
-    }
+    ok(tabpanel.querySelector("#timings-summary-wait .requests-menu-timings-total")
+      .getAttribute("value").match(/[0-9]+/),
+      "The wait timing info does not appear to be correct.");
 
-    aDebuggee.location.reload();
-  });
-}
+    ok(tabpanel.querySelector("#timings-summary-receive .requests-menu-timings-total")
+      .getAttribute("value").match(/[0-9]+/),
+      "The receive timing info does not appear to be correct.");
+  }
+});
--- a/devtools/client/netmonitor/test/browser_net_simple-request.js
+++ b/devtools/client/netmonitor/test/browser_net_simple-request.js
@@ -6,74 +6,67 @@
  * Test whether the UI state properly reflects existence of requests
  * displayed in the Net panel. The following parts of the UI are
  * tested:
  * 1) Side panel visibility
  * 2) Side panel toggle button
  * 3) Empty user message visibility
  * 4) Number of requests displayed
  */
-function test() {
-  initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
-    info("Starting test... ");
+add_task(function* () {
+  let [tab, , monitor] = yield initNetMonitor(SIMPLE_URL);
+  info("Starting test... ");
 
-    let { document, NetMonitorView } = aMonitor.panelWin;
-    let { RequestsMenu } = NetMonitorView;
+  let { document, NetMonitorView } = monitor.panelWin;
+  let { RequestsMenu } = NetMonitorView;
 
-    RequestsMenu.lazyUpdate = false;
+  RequestsMenu.lazyUpdate = false;
 
-    is(document.querySelector("#details-pane-toggle")
-      .hasAttribute("disabled"), true,
-      "The pane toggle button should be disabled when the frontend is opened.");
-    is(document.querySelector("#requests-menu-empty-notice")
-      .hasAttribute("hidden"), false,
-      "An empty notice should be displayed when the frontend is opened.");
-    is(RequestsMenu.itemCount, 0,
-      "The requests menu should be empty when the frontend is opened.");
-    is(NetMonitorView.detailsPaneHidden, true,
-      "The details pane should be hidden when the frontend is opened.");
+  is(document.querySelector("#details-pane-toggle").hasAttribute("disabled"), true,
+    "The pane toggle button should be disabled when the frontend is opened.");
+  is(document.querySelector("#requests-menu-empty-notice").hasAttribute("hidden"), false,
+    "An empty notice should be displayed when the frontend is opened.");
+  is(RequestsMenu.itemCount, 0,
+    "The requests menu should be empty when the frontend is opened.");
+  is(NetMonitorView.detailsPaneHidden, true,
+    "The details pane should be hidden when the frontend is opened.");
 
-    waitForNetworkEvents(aMonitor, 1).then(() => {
-      is(document.querySelector("#details-pane-toggle")
-        .hasAttribute("disabled"), false,
-        "The pane toggle button should be enabled after the first request.");
-      is(document.querySelector("#requests-menu-empty-notice")
-        .hasAttribute("hidden"), true,
-        "The empty notice should be hidden after the first request.");
-      is(RequestsMenu.itemCount, 1,
-        "The requests menu should not be empty after the first request.");
-      is(NetMonitorView.detailsPaneHidden, true,
-        "The details pane should still be hidden after the first request.");
+  yield reloadAndWait();
+
+  is(document.querySelector("#details-pane-toggle").hasAttribute("disabled"), false,
+    "The pane toggle button should be enabled after the first request.");
+  is(document.querySelector("#requests-menu-empty-notice").hasAttribute("hidden"), true,
+    "The empty notice should be hidden after the first request.");
+  is(RequestsMenu.itemCount, 1,
+    "The requests menu should not be empty after the first request.");
+  is(NetMonitorView.detailsPaneHidden, true,
+    "The details pane should still be hidden after the first request.");
 
-      waitForNetworkEvents(aMonitor, 1).then(() => {
-        is(document.querySelector("#details-pane-toggle")
-          .hasAttribute("disabled"), false,
-          "The pane toggle button should be still be enabled after a reload.");
-        is(document.querySelector("#requests-menu-empty-notice")
-          .hasAttribute("hidden"), true,
-          "The empty notice should be still hidden after a reload.");
-        is(RequestsMenu.itemCount, 1,
-          "The requests menu should not be empty after a reload.");
-        is(NetMonitorView.detailsPaneHidden, true,
-          "The details pane should still be hidden after a reload.");
+  yield reloadAndWait();
 
-        RequestsMenu.clear();
+  is(document.querySelector("#details-pane-toggle").hasAttribute("disabled"), false,
+    "The pane toggle button should be still be enabled after a reload.");
+  is(document.querySelector("#requests-menu-empty-notice").hasAttribute("hidden"), true,
+    "The empty notice should be still hidden after a reload.");
+  is(RequestsMenu.itemCount, 1,
+    "The requests menu should not be empty after a reload.");
+  is(NetMonitorView.detailsPaneHidden, true,
+    "The details pane should still be hidden after a reload.");
+
+  RequestsMenu.clear();
 
-        is(document.querySelector("#details-pane-toggle")
-          .hasAttribute("disabled"), true,
-          "The pane toggle button should be disabled when after clear.");
-        is(document.querySelector("#requests-menu-empty-notice")
-          .hasAttribute("hidden"), false,
-          "An empty notice should be displayed again after clear.");
-        is(RequestsMenu.itemCount, 0,
-          "The requests menu should be empty after clear.");
-        is(NetMonitorView.detailsPaneHidden, true,
-          "The details pane should be hidden after clear.");
+  is(document.querySelector("#details-pane-toggle").hasAttribute("disabled"), true,
+    "The pane toggle button should be disabled when after clear.");
+  is(document.querySelector("#requests-menu-empty-notice").hasAttribute("hidden"), false,
+    "An empty notice should be displayed again after clear.");
+  is(RequestsMenu.itemCount, 0,
+    "The requests menu should be empty after clear.");
+  is(NetMonitorView.detailsPaneHidden, true,
+    "The details pane should be hidden after clear.");
 
-        teardown(aMonitor).then(finish);
-      });
+  return teardown(monitor);
 
-      aDebuggee.location.reload();
-    });
-
-    aDebuggee.location.reload();
-  });
-}
+  function* reloadAndWait() {
+    let wait = waitForNetworkEvents(monitor, 1);
+    tab.linkedBrowser.reload();
+    return wait;
+  }
+});
--- a/devtools/client/netmonitor/test/browser_net_sort-01.js
+++ b/devtools/client/netmonitor/test/browser_net_sort-01.js
@@ -1,255 +1,228 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 /**
  * Test if the sorting mechanism works correctly.
  */
 
-function test() {
-  initNetMonitor(STATUS_CODES_URL).then(([aTab, aDebuggee, aMonitor]) => {
-    info("Starting test... ");
+add_task(function* () {
+  let [tab, , monitor] = yield initNetMonitor(STATUS_CODES_URL);
+  info("Starting test... ");
+
+  let { $all, L10N, NetMonitorView } = monitor.panelWin;
+  let { RequestsMenu } = NetMonitorView;
+
+  RequestsMenu.lazyUpdate = false;
+
+  let wait = waitForNetworkEvents(monitor, 5);
+  yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
+    content.wrappedJSObject.performRequests();
+  });
+  yield wait;
+
+  testContents([0, 1, 2, 3, 4]);
+
+  info("Testing swap(0, 0)");
+  RequestsMenu.swapItemsAtIndices(0, 0);
+  RequestsMenu.refreshZebra();
+  testContents([0, 1, 2, 3, 4]);
+
+  info("Testing swap(0, 1)");
+  RequestsMenu.swapItemsAtIndices(0, 1);
+  RequestsMenu.refreshZebra();
+  testContents([1, 0, 2, 3, 4]);
+
+  info("Testing swap(0, 2)");
+  RequestsMenu.swapItemsAtIndices(0, 2);
+  RequestsMenu.refreshZebra();
+  testContents([1, 2, 0, 3, 4]);
+
+  info("Testing swap(0, 3)");
+  RequestsMenu.swapItemsAtIndices(0, 3);
+  RequestsMenu.refreshZebra();
+  testContents([1, 2, 3, 0, 4]);
+
+  info("Testing swap(0, 4)");
+  RequestsMenu.swapItemsAtIndices(0, 4);
+  RequestsMenu.refreshZebra();
+  testContents([1, 2, 3, 4, 0]);
+
+  info("Testing swap(1, 0)");
+  RequestsMenu.swapItemsAtIndices(1, 0);
+  RequestsMenu.refreshZebra();
+  testContents([0, 2, 3, 4, 1]);
+
+  info("Testing swap(1, 1)");
+  RequestsMenu.swapItemsAtIndices(1, 1);
+  RequestsMenu.refreshZebra();
+  testContents([0, 2, 3, 4, 1]);
 
-    let { $all, L10N, NetMonitorView } = aMonitor.panelWin;
-    let { RequestsMenu } = NetMonitorView;
+  info("Testing swap(1, 2)");
+  RequestsMenu.swapItemsAtIndices(1, 2);
+  RequestsMenu.refreshZebra();
+  testContents([0, 1, 3, 4, 2]);
+
+  info("Testing swap(1, 3)");
+  RequestsMenu.swapItemsAtIndices(1, 3);
+  RequestsMenu.refreshZebra();
+  testContents([0, 3, 1, 4, 2]);
+
+  info("Testing swap(1, 4)");
+  RequestsMenu.swapItemsAtIndices(1, 4);
+  RequestsMenu.refreshZebra();
+  testContents([0, 3, 4, 1, 2]);
+
+  info("Testing swap(2, 0)");
+  RequestsMenu.swapItemsAtIndices(2, 0);
+  RequestsMenu.refreshZebra();
+  testContents([2, 3, 4, 1, 0]);
+
+  info("Testing swap(2, 1)");
+  RequestsMenu.swapItemsAtIndices(2, 1);
+  RequestsMenu.refreshZebra();
+  testContents([1, 3, 4, 2, 0]);
 
-    RequestsMenu.lazyUpdate = false;
+  info("Testing swap(2, 2)");
+  RequestsMenu.swapItemsAtIndices(2, 2);
+  RequestsMenu.refreshZebra();
+  testContents([1, 3, 4, 2, 0]);
+
+  info("Testing swap(2, 3)");
+  RequestsMenu.swapItemsAtIndices(2, 3);
+  RequestsMenu.refreshZebra();
+  testContents([1, 2, 4, 3, 0]);
+
+  info("Testing swap(2, 4)");
+  RequestsMenu.swapItemsAtIndices(2, 4);
+  RequestsMenu.refreshZebra();
+  testContents([1, 4, 2, 3, 0]);
+
+  info("Testing swap(3, 0)");
+  RequestsMenu.swapItemsAtIndices(3, 0);
+  RequestsMenu.refreshZebra();
+  testContents([1, 4, 2, 0, 3]);
+
+  info("Testing swap(3, 1)");
+  RequestsMenu.swapItemsAtIndices(3, 1);
+  RequestsMenu.refreshZebra();
+  testContents([3, 4, 2, 0, 1]);
+
+  info("Testing swap(3, 2)");
+  RequestsMenu.swapItemsAtIndices(3, 2);
+  RequestsMenu.refreshZebra();
+  testContents([2, 4, 3, 0, 1]);
 
-    waitForNetworkEvents(aMonitor, 5).then(() => {
-      testContents([0, 1, 2, 3, 4])
-        .then(() => {
-          info("Testing swap(0, 0)");
-          RequestsMenu.swapItemsAtIndices(0, 0);
-          RequestsMenu.refreshZebra();
-          return testContents([0, 1, 2, 3, 4]);
-        })
-        .then(() => {
-          info("Testing swap(0, 1)");
-          RequestsMenu.swapItemsAtIndices(0, 1);
-          RequestsMenu.refreshZebra();
-          return testContents([1, 0, 2, 3, 4]);
-        })
-        .then(() => {
-          info("Testing swap(0, 2)");
-          RequestsMenu.swapItemsAtIndices(0, 2);
-          RequestsMenu.refreshZebra();
-          return testContents([1, 2, 0, 3, 4]);
-        })
-        .then(() => {
-          info("Testing swap(0, 3)");
-          RequestsMenu.swapItemsAtIndices(0, 3);
-          RequestsMenu.refreshZebra();
-          return testContents([1, 2, 3, 0, 4]);
-        })
-        .then(() => {
-          info("Testing swap(0, 4)");
-          RequestsMenu.swapItemsAtIndices(0, 4);
-          RequestsMenu.refreshZebra();
-          return testContents([1, 2, 3, 4, 0]);
-        })
-        .then(() => {
-          info("Testing swap(1, 0)");
-          RequestsMenu.swapItemsAtIndices(1, 0);
-          RequestsMenu.refreshZebra();
-          return testContents([0, 2, 3, 4, 1]);
-        })
-        .then(() => {
-          info("Testing swap(1, 1)");
-          RequestsMenu.swapItemsAtIndices(1, 1);
-          RequestsMenu.refreshZebra();
-          return testContents([0, 2, 3, 4, 1]);
-        })
-        .then(() => {
-          info("Testing swap(1, 2)");
-          RequestsMenu.swapItemsAtIndices(1, 2);
-          RequestsMenu.refreshZebra();
-          return testContents([0, 1, 3, 4, 2]);
-        })
-        .then(() => {
-          info("Testing swap(1, 3)");
-          RequestsMenu.swapItemsAtIndices(1, 3);
-          RequestsMenu.refreshZebra();
-          return testContents([0, 3, 1, 4, 2]);
-        })
-        .then(() => {
-          info("Testing swap(1, 4)");
-          RequestsMenu.swapItemsAtIndices(1, 4);
-          RequestsMenu.refreshZebra();
-          return testContents([0, 3, 4, 1, 2]);
-        })
-        .then(() => {
-          info("Testing swap(2, 0)");
-          RequestsMenu.swapItemsAtIndices(2, 0);
-          RequestsMenu.refreshZebra();
-          return testContents([2, 3, 4, 1, 0]);
-        })
-        .then(() => {
-          info("Testing swap(2, 1)");
-          RequestsMenu.swapItemsAtIndices(2, 1);
-          RequestsMenu.refreshZebra();
-          return testContents([1, 3, 4, 2, 0]);
-        })
-        .then(() => {
-          info("Testing swap(2, 2)");
-          RequestsMenu.swapItemsAtIndices(2, 2);
-          RequestsMenu.refreshZebra();
-          return testContents([1, 3, 4, 2, 0]);
-        })
-        .then(() => {
-          info("Testing swap(2, 3)");
-          RequestsMenu.swapItemsAtIndices(2, 3);
-          RequestsMenu.refreshZebra();
-          return testContents([1, 2, 4, 3, 0]);
-        })
-        .then(() => {
-          info("Testing swap(2, 4)");
-          RequestsMenu.swapItemsAtIndices(2, 4);
-          RequestsMenu.refreshZebra();
-          return testContents([1, 4, 2, 3, 0]);
-        })
-        .then(() => {
-          info("Testing swap(3, 0)");
-          RequestsMenu.swapItemsAtIndices(3, 0);
-          RequestsMenu.refreshZebra();
-          return testContents([1, 4, 2, 0, 3]);
-        })
-        .then(() => {
-          info("Testing swap(3, 1)");
-          RequestsMenu.swapItemsAtIndices(3, 1);
-          RequestsMenu.refreshZebra();
-          return testContents([3, 4, 2, 0, 1]);
-        })
-        .then(() => {
-          info("Testing swap(3, 2)");
-          RequestsMenu.swapItemsAtIndices(3, 2);
-          RequestsMenu.refreshZebra();
-          return testContents([2, 4, 3, 0, 1]);
-        })
-        .then(() => {
-          info("Testing swap(3, 3)");
-          RequestsMenu.swapItemsAtIndices(3, 3);
-          RequestsMenu.refreshZebra();
-          return testContents([2, 4, 3, 0, 1]);
-        })
-        .then(() => {
-          info("Testing swap(3, 4)");
-          RequestsMenu.swapItemsAtIndices(3, 4);
-          RequestsMenu.refreshZebra();
-          return testContents([2, 3, 4, 0, 1]);
-        })
-        .then(() => {
-          info("Testing swap(4, 0)");
-          RequestsMenu.swapItemsAtIndices(4, 0);
-          RequestsMenu.refreshZebra();
-          return testContents([2, 3, 0, 4, 1]);
-        })
-        .then(() => {
-          info("Testing swap(4, 1)");
-          RequestsMenu.swapItemsAtIndices(4, 1);
-          RequestsMenu.refreshZebra();
-          return testContents([2, 3, 0, 1, 4]);
-        })
-        .then(() => {
-          info("Testing swap(4, 2)");
-          RequestsMenu.swapItemsAtIndices(4, 2);
-          RequestsMenu.refreshZebra();
-          return testContents([4, 3, 0, 1, 2]);
-        })
-        .then(() => {
-          info("Testing swap(4, 3)");
-          RequestsMenu.swapItemsAtIndices(4, 3);
-          RequestsMenu.refreshZebra();
-          return testContents([3, 4, 0, 1, 2]);
-        })
-        .then(() => {
-          info("Testing swap(4, 4)");
-          RequestsMenu.swapItemsAtIndices(4, 4);
-          RequestsMenu.refreshZebra();
-          return testContents([3, 4, 0, 1, 2]);
-        })
-        .then(() => {
-          info("Clearing sort.");
-          RequestsMenu.sortBy();
-          return testContents([0, 1, 2, 3, 4]);
-        })
-        .then(() => {
-          return teardown(aMonitor);
-        })
-        .then(finish);
-    });
+  info("Testing swap(3, 3)");
+  RequestsMenu.swapItemsAtIndices(3, 3);
+  RequestsMenu.refreshZebra();
+  testContents([2, 4, 3, 0, 1]);
+
+  info("Testing swap(3, 4)");
+  RequestsMenu.swapItemsAtIndices(3, 4);
+  RequestsMenu.refreshZebra();
+  testContents([2, 3, 4, 0, 1]);
+
+  info("Testing swap(4, 0)");
+  RequestsMenu.swapItemsAtIndices(4, 0);
+  RequestsMenu.refreshZebra();
+  testContents([2, 3, 0, 4, 1]);
+
+  info("Testing swap(4, 1)");
+  RequestsMenu.swapItemsAtIndices(4, 1);
+  RequestsMenu.refreshZebra();
+  testContents([2, 3, 0, 1, 4]);
+
+  info("Testing swap(4, 2)");
+  RequestsMenu.swapItemsAtIndices(4, 2);
+  RequestsMenu.refreshZebra();
+  testContents([4, 3, 0, 1, 2]);
+
+  info("Testing swap(4, 3)");
+  RequestsMenu.swapItemsAtIndices(4, 3);
+  RequestsMenu.refreshZebra();
+  testContents([3, 4, 0, 1, 2]);
+
+  info("Testing swap(4, 4)");
+  RequestsMenu.swapItemsAtIndices(4, 4);
+  RequestsMenu.refreshZebra();
+  testContents([3, 4, 0, 1, 2]);
+
+  info("Clearing sort.");
+  RequestsMenu.sortBy();
+  testContents([0, 1, 2, 3, 4]);
+
+  return teardown(monitor);
+
+  function testContents([a, b, c, d, e]) {
+    is(RequestsMenu.items.length, 5,
+      "There should be a total of 5 items in the requests menu.");
+    is(RequestsMenu.visibleItems.length, 5,
+      "There should be a total of 5 visbile items in the requests menu.");
+    is($all(".side-menu-widget-item").length, 5,
+      "The visible items in the requests menu are, in fact, visible!");
 
-    function testContents([a, b, c, d, e]) {
-      is(RequestsMenu.items.length, 5,
-        "There should be a total of 5 items in the requests menu.");
-      is(RequestsMenu.visibleItems.length, 5,
-        "There should be a total of 5 visbile items in the requests menu.");
-      is($all(".side-menu-widget-item").length, 5,
-        "The visible items in the requests menu are, in fact, visible!");
-
-      is(RequestsMenu.getItemAtIndex(0), RequestsMenu.items[0],
-        "The requests menu items aren't ordered correctly. First item is misplaced.");
-      is(RequestsMenu.getItemAtIndex(1), RequestsMenu.items[1],
-        "The requests menu items aren't ordered correctly. Second item is misplaced.");
-      is(RequestsMenu.getItemAtIndex(2), RequestsMenu.items[2],
-        "The requests menu items aren't ordered correctly. Third item is misplaced.");
-      is(RequestsMenu.getItemAtIndex(3), RequestsMenu.items[3],
-        "The requests menu items aren't ordered correctly. Fourth item is misplaced.");
-      is(RequestsMenu.getItemAtIndex(4), RequestsMenu.items[4],
-        "The requests menu items aren't ordered correctly. Fifth item is misplaced.");
+    is(RequestsMenu.getItemAtIndex(0), RequestsMenu.items[0],
+      "The requests menu items aren't ordered correctly. First item is misplaced.");
+    is(RequestsMenu.getItemAtIndex(1), RequestsMenu.items[1],
+      "The requests menu items aren't ordered correctly. Second item is misplaced.");
+    is(RequestsMenu.getItemAtIndex(2), RequestsMenu.items[2],
+      "The requests menu items aren't ordered correctly. Third item is misplaced.");
+    is(RequestsMenu.getItemAtIndex(3), RequestsMenu.items[3],
+      "The requests menu items aren't ordered correctly. Fourth item is misplaced.");
+    is(RequestsMenu.getItemAtIndex(4), RequestsMenu.items[4],
+      "The requests menu items aren't ordered correctly. Fifth item is misplaced.");
 
-      verifyRequestItemTarget(RequestsMenu.getItemAtIndex(a),
-        "GET", STATUS_CODES_SJS + "?sts=100", {
-          status: 101,
-          statusText: "Switching Protocols",
-          type: "plain",
-          fullMimeType: "text/plain; charset=utf-8",
-          transferred: L10N.getStr("networkMenu.sizeUnavailable"),
-          size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 0),
-          time: true
-        });
-      verifyRequestItemTarget(RequestsMenu.getItemAtIndex(b),
-        "GET", STATUS_CODES_SJS + "?sts=200", {
-          status: 202,
-          statusText: "Created",
-          type: "plain",
-          fullMimeType: "text/plain; charset=utf-8",
-          transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
-          size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
-          time: true
-        });
-      verifyRequestItemTarget(RequestsMenu.getItemAtIndex(c),
-        "GET", STATUS_CODES_SJS + "?sts=300", {
-          status: 303,
-          statusText: "See Other",
-          type: "plain",
-          fullMimeType: "text/plain; charset=utf-8",
-          transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
-          size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 0),
-          time: true
-        });
-      verifyRequestItemTarget(RequestsMenu.getItemAtIndex(d),
-        "GET", STATUS_CODES_SJS + "?sts=400", {
-          status: 404,
-          statusText: "Not Found",
-          type: "plain",
-          fullMimeType: "text/plain; charset=utf-8",
-          transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
-          size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
-          time: true
-        });
-      verifyRequestItemTarget(RequestsMenu.getItemAtIndex(e),
-        "GET", STATUS_CODES_SJS + "?sts=500", {
-          status: 501,
-          statusText: "Not Implemented",
-          type: "plain",
-          fullMimeType: "text/plain; charset=utf-8",
-          transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
-          size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
-          time: true
-        });
-
-      return promise.resolve(null);
-    }
-
-    aDebuggee.performRequests();
-  });
-}
+    verifyRequestItemTarget(RequestsMenu.getItemAtIndex(a),
+      "GET", STATUS_CODES_SJS + "?sts=100", {
+        status: 101,
+        statusText: "Switching Protocols",
+        type: "plain",
+        fullMimeType: "text/plain; charset=utf-8",
+        transferred: L10N.getStr("networkMenu.sizeUnavailable"),
+        size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 0),
+        time: true
+      });
+    verifyRequestItemTarget(RequestsMenu.getItemAtIndex(b),
+      "GET", STATUS_CODES_SJS + "?sts=200", {
+        status: 202,
+        statusText: "Created",
+        type: "plain",
+        fullMimeType: "text/plain; charset=utf-8",
+        transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
+        size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
+        time: true
+      });
+    verifyRequestItemTarget(RequestsMenu.getItemAtIndex(c),
+      "GET", STATUS_CODES_SJS + "?sts=300", {
+        status: 303,
+        statusText: "See Other",
+        type: "plain",
+        fullMimeType: "text/plain; charset=utf-8",
+        transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
+        size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 0),
+        time: true
+      });
+    verifyRequestItemTarget(RequestsMenu.getItemAtIndex(d),
+      "GET", STATUS_CODES_SJS + "?sts=400", {
+        status: 404,
+        statusText: "Not Found",
+        type: "plain",
+        fullMimeType: "text/plain; charset=utf-8",
+        transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
+        size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
+        time: true
+      });
+    verifyRequestItemTarget(RequestsMenu.getItemAtIndex(e),
+      "GET", STATUS_CODES_SJS + "?sts=500", {
+        status: 501,
+        statusText: "Not Implemented",
+        type: "plain",
+        fullMimeType: "text/plain; charset=utf-8",
+        transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
+        size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
+        time: true
+      });
+  }
+});
--- a/devtools/client/netmonitor/test/browser_net_sort-02.js
+++ b/devtools/client/netmonitor/test/browser_net_sort-02.js
@@ -1,296 +1,270 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 /**
  * Test if sorting columns in the network table works correctly.
  */
 
-function test() {
-  initNetMonitor(SORTING_URL).then(([aTab, aDebuggee, aMonitor]) => {
-    info("Starting test... ");
+add_task(function* () {
+  let [,, monitor] = yield initNetMonitor(SORTING_URL);
+  info("Starting test... ");
+
+  // It seems that this test may be slow on debug builds. This could be because
+  // of the heavy dom manipulation associated with sorting.
+  requestLongerTimeout(2);
+
+  let { $, $all, L10N, NetMonitorView } = monitor.panelWin;
+  let { RequestsMenu } = NetMonitorView;
 
-    // It seems that this test may be slow on debug builds. This could be because
-    // of the heavy dom manipulation associated with sorting.
-    requestLongerTimeout(2);
+  // Loading the frame script and preparing the xhr request URLs so we can
+  // generate some requests later.
+  loadCommonFrameScript();
+  let requests = [{
+    url: "sjs_sorting-test-server.sjs?index=1&" + Math.random(),
+    method: "GET1"
+  }, {
+    url: "sjs_sorting-test-server.sjs?index=5&" + Math.random(),
+    method: "GET5"
+  }, {
+    url: "sjs_sorting-test-server.sjs?index=2&" + Math.random(),
+    method: "GET2"
+  }, {
+    url: "sjs_sorting-test-server.sjs?index=4&" + Math.random(),
+    method: "GET4"
+  }, {
+    url: "sjs_sorting-test-server.sjs?index=3&" + Math.random(),
+    method: "GET3"
+  }];
 
-    let { $, $all, L10N, NetMonitorView } = aMonitor.panelWin;
-    let { RequestsMenu } = NetMonitorView;
+  RequestsMenu.lazyUpdate = false;
+
+  let wait = waitForNetworkEvents(monitor, 5);
+  yield performRequestsInContent(requests);
+  yield wait;
+
+  EventUtils.sendMouseEvent({ type: "mousedown" }, $("#details-pane-toggle"));
 
-    // Loading the frame script and preparing the xhr request URLs so we can
-    // generate some requests later.
-    loadCommonFrameScript();
-    let requests = [{
-      url: "sjs_sorting-test-server.sjs?index=1&" + Math.random(),
-      method: "GET1"
-    }, {
-      url: "sjs_sorting-test-server.sjs?index=5&" + Math.random(),
-      method: "GET5"
-    }, {
-      url: "sjs_sorting-test-server.sjs?index=2&" + Math.random(),
-      method: "GET2"
-    }, {
-      url: "sjs_sorting-test-server.sjs?index=4&" + Math.random(),
-      method: "GET4"
-    }, {
-      url: "sjs_sorting-test-server.sjs?index=3&" + Math.random(),
-      method: "GET3"
-    }];
+  isnot(RequestsMenu.selectedItem, null,
+    "There should be a selected item in the requests menu.");
+  is(RequestsMenu.selectedIndex, 0,
+    "The first item should be selected in the requests menu.");
+  is(NetMonitorView.detailsPaneHidden, false,
+    "The details pane should not be hidden after toggle button was pressed.");
+
+  testHeaders();
+  testContents([0, 2, 4, 3, 1]);
+
+  info("Testing status sort, ascending.");
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
+  testHeaders("status", "ascending");
+  testContents([0, 1, 2, 3, 4]);
+
+  info("Testing status sort, descending.");
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
+  testHeaders("status", "descending");
+  testContents([4, 3, 2, 1, 0]);
 
-    RequestsMenu.lazyUpdate = false;
+  info("Testing status sort, ascending. Checking sort loops correctly.");
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
+  testHeaders("status", "ascending");
+  testContents([0, 1, 2, 3, 4]);
 
-    waitForNetworkEvents(aMonitor, 5).then(() => {
-      EventUtils.sendMouseEvent({ type: "mousedown" }, $("#details-pane-toggle"));
+  info("Testing method sort, ascending.");
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-method-button"));
+  testHeaders("method", "ascending");
+  testContents([0, 1, 2, 3, 4]);
 
-      isnot(RequestsMenu.selectedItem, null,
-        "There should be a selected item in the requests menu.");
-      is(RequestsMenu.selectedIndex, 0,
-        "The first item should be selected in the requests menu.");
-      is(NetMonitorView.detailsPaneHidden, false,
-        "The details pane should not be hidden after toggle button was pressed.");
+  info("Testing method sort, descending.");
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-method-button"));
+  testHeaders("method", "descending");
+  testContents([4, 3, 2, 1, 0]);
+
+  info("Testing method sort, ascending. Checking sort loops correctly.");
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-method-button"));
+  testHeaders("method", "ascending");
+  testContents([0, 1, 2, 3, 4]);
+
+  info("Testing file sort, ascending.");
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-file-button"));
+  testHeaders("file", "ascending");
+  testContents([0, 1, 2, 3, 4]);
 
-      testHeaders();
-      testContents([0, 2, 4, 3, 1])
-        .then(() => {
-          info("Testing status sort, ascending.");
-          EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
-          testHeaders("status", "ascending");
-          return testContents([0, 1, 2, 3, 4]);
-        })
-        .then(() => {
-          info("Testing status sort, descending.");
-          EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
-          testHeaders("status", "descending");
-          return testContents([4, 3, 2, 1, 0]);
-        })
-        .then(() => {
-          info("Testing status sort, ascending. Checking sort loops correctly.");
-          EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
-          testHeaders("status", "ascending");
-          return testContents([0, 1, 2, 3, 4]);
-        })
-        .then(() => {
-          info("Testing method sort, ascending.");
-          EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-method-button"));
-          testHeaders("method", "ascending");
-          return testContents([0, 1, 2, 3, 4]);
-        })
-        .then(() => {
-          info("Testing method sort, descending.");
-          EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-method-button"));
-          testHeaders("method", "descending");
-          return testContents([4, 3, 2, 1, 0]);
-        })
-        .then(() => {
-          info("Testing method sort, ascending. Checking sort loops correctly.");
-          EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-method-button"));
-          testHeaders("method", "ascending");
-          return testContents([0, 1, 2, 3, 4]);
-        })
-        .then(() => {
-          info("Testing file sort, ascending.");
-          EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-file-button"));
-          testHeaders("file", "ascending");
-          return testContents([0, 1, 2, 3, 4]);
-        })
-        .then(() => {
-          info("Testing file sort, descending.");
-          EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-file-button"));
-          testHeaders("file", "descending");
-          return testContents([4, 3, 2, 1, 0]);
-        })
-        .then(() => {
-          info("Testing file sort, ascending. Checking sort loops correctly.");
-          EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-file-button"));
-          testHeaders("file", "ascending");
-          return testContents([0, 1, 2, 3, 4]);
-        })
-        .then(() => {
-          info("Testing type sort, ascending.");
-          EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-type-button"));
-          testHeaders("type", "ascending");
-          return testContents([0, 1, 2, 3, 4]);
-        })
-        .then(() => {
-          info("Testing type sort, descending.");
-          EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-type-button"));
-          testHeaders("type", "descending");
-          return testContents([4, 3, 2, 1, 0]);
-        })
-        .then(() => {
-          info("Testing type sort, ascending. Checking sort loops correctly.");
-          EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-type-button"));
-          testHeaders("type", "ascending");
-          return testContents([0, 1, 2, 3, 4]);
-        })
-        .then(() => {
-          info("Testing transferred sort, ascending.");
-          EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-transferred-button"));
-          testHeaders("transferred", "ascending");
-          return testContents([0, 1, 2, 3, 4]);
-        })
-        .then(() => {
-          info("Testing transferred sort, descending.");
-          EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-transferred-button"));
-          testHeaders("transferred", "descending");
-          return testContents([4, 3, 2, 1, 0]);
-        })
-        .then(() => {
-          info("Testing transferred sort, ascending. Checking sort loops correctly.");
-          EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-transferred-button"));
-          testHeaders("transferred", "ascending");
-          return testContents([0, 1, 2, 3, 4]);
-        })
-        .then(() => {
-          info("Testing size sort, ascending.");
-          EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-size-button"));
-          testHeaders("size", "ascending");
-          return testContents([0, 1, 2, 3, 4]);
-        })
-        .then(() => {
-          info("Testing size sort, descending.");
-          EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-size-button"));
-          testHeaders("size", "descending");
-          return testContents([4, 3, 2, 1, 0]);
-        })
-        .then(() => {
-          info("Testing size sort, ascending. Checking sort loops correctly.");
-          EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-size-button"));
-          testHeaders("size", "ascending");
-          return testContents([0, 1, 2, 3, 4]);
-        })
-        .then(() => {
-          info("Testing waterfall sort, ascending.");
-          EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-waterfall-button"));
-          testHeaders("waterfall", "ascending");
-          return testContents([0, 2, 4, 3, 1]);
-        })
-        .then(() => {
-          info("Testing waterfall sort, descending.");
-          EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-waterfall-button"));
-          testHeaders("waterfall", "descending");
-          return testContents([4, 2, 0, 1, 3]);
-        })
-        .then(() => {
-          info("Testing waterfall sort, ascending. Checking sort loops correctly.");
-          EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-waterfall-button"));
-          testHeaders("waterfall", "ascending");
-          return testContents([0, 2, 4, 3, 1]);
-        })
-        .then(() => {
-          return teardown(aMonitor);
-        })
-        .then(finish);
-    });
+  info("Testing file sort, descending.");
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-file-button"));
+  testHeaders("file", "descending");
+  testContents([4, 3, 2, 1, 0]);
+
+  info("Testing file sort, ascending. Checking sort loops correctly.");
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-file-button"));
+  testHeaders("file", "ascending");
+  testContents([0, 1, 2, 3, 4]);
+
+  info("Testing type sort, ascending.");
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-type-button"));
+  testHeaders("type", "ascending");
+  testContents([0, 1, 2, 3, 4]);
+
+  info("Testing type sort, descending.");
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-type-button"));
+  testHeaders("type", "descending");
+  testContents([4, 3, 2, 1, 0]);
+
+  info("Testing type sort, ascending. Checking sort loops correctly.");
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-type-button"));
+  testHeaders("type", "ascending");
+  testContents([0, 1, 2, 3, 4]);
+
+  info("Testing transferred sort, ascending.");
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-transferred-button"));
+  testHeaders("transferred", "ascending");
+  testContents([0, 1, 2, 3, 4]);
+
+  info("Testing transferred sort, descending.");
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-transferred-button"));
+  testHeaders("transferred", "descending");
+  testContents([4, 3, 2, 1, 0]);
+
+  info("Testing transferred sort, ascending. Checking sort loops correctly.");
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-transferred-button"));
+  testHeaders("transferred", "ascending");
+  testContents([0, 1, 2, 3, 4]);
+
+  info("Testing size sort, ascending.");
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-size-button"));
+  testHeaders("size", "ascending");
+  testContents([0, 1, 2, 3, 4]);
 
-    function testHeaders(aSortType, aDirection) {
-      let doc = aMonitor.panelWin.document;
-      let target = doc.querySelector("#requests-menu-" + aSortType + "-button");
-      let headers = doc.querySelectorAll(".requests-menu-header-button");
+  info("Testing size sort, descending.");
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-size-button"));
+  testHeaders("size", "descending");
+  testContents([4, 3, 2, 1, 0]);
+
+  info("Testing size sort, ascending. Checking sort loops correctly.");
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-size-button"));
+  testHeaders("size", "ascending");
+  testContents([0, 1, 2, 3, 4]);
+
+  info("Testing waterfall sort, ascending.");
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-waterfall-button"));
+  testHeaders("waterfall", "ascending");
+  testContents([0, 2, 4, 3, 1]);
+
+  info("Testing waterfall sort, descending.");
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-waterfall-button"));
+  testHeaders("waterfall", "descending");
+  testContents([4, 2, 0, 1, 3]);
 
-      for (let header of headers) {
-        if (header != target) {
-          is(header.hasAttribute("sorted"), false,
-            "The " + header.id + " header should not have a 'sorted' attribute.");
-          is(header.hasAttribute("tooltiptext"), false,
-            "The " + header.id + " header should not have a 'tooltiptext' attribute.");
-        } else {
-          is(header.getAttribute("sorted"), aDirection,
-            "The " + header.id + " header has an incorrect 'sorted' attribute.");
-          is(header.getAttribute("tooltiptext"), aDirection == "ascending"
-            ? L10N.getStr("networkMenu.sortedAsc")
-            : L10N.getStr("networkMenu.sortedDesc"),
-            "The " + header.id + " has an incorrect 'tooltiptext' attribute.");
-        }
+  info("Testing waterfall sort, ascending. Checking sort loops correctly.");
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-waterfall-button"));
+  testHeaders("waterfall", "ascending");
+  testContents([0, 2, 4, 3, 1]);
+
+  return teardown(monitor);
+
+  function testHeaders(sortType, direction) {
+    let doc = monitor.panelWin.document;
+    let target = doc.querySelector("#requests-menu-" + sortType + "-button");
+    let headers = doc.querySelectorAll(".requests-menu-header-button");
+
+    for (let header of headers) {
+      if (header != target) {
+        is(header.hasAttribute("sorted"), false,
+          "The " + header.id + " header should not have a 'sorted' attribute.");
+        is(header.hasAttribute("tooltiptext"), false,
+          "The " + header.id + " header should not have a 'tooltiptext' attribute.");
+      } else {
+        is(header.getAttribute("sorted"), direction,
+          "The " + header.id + " header has an incorrect 'sorted' attribute.");
+        is(header.getAttribute("tooltiptext"), direction == "ascending"
+          ? L10N.getStr("networkMenu.sortedAsc")
+          : L10N.getStr("networkMenu.sortedDesc"),
+          "The " + header.id + " has an incorrect 'tooltiptext' attribute.");
       }
     }
+  }
 
-    function testContents([a, b, c, d, e]) {
-      isnot(RequestsMenu.selectedItem, null,
-        "There should still be a selected item after sorting.");
-      is(RequestsMenu.selectedIndex, a,
-        "The first item should be still selected after sorting.");
-      is(NetMonitorView.detailsPaneHidden, false,
-        "The details pane should still be visible after sorting.");
+  function testContents([a, b, c, d, e]) {
+    isnot(RequestsMenu.selectedItem, null,
+      "There should still be a selected item after sorting.");
+    is(RequestsMenu.selectedIndex, a,
+      "The first item should be still selected after sorting.");
+    is(NetMonitorView.detailsPaneHidden, false,
+      "The details pane should still be visible after sorting.");
 
-      is(RequestsMenu.items.length, 5,
-        "There should be a total of 5 items in the requests menu.");
-      is(RequestsMenu.visibleItems.length, 5,
-        "There should be a total of 5 visbile items in the requests menu.");
-      is($all(".side-menu-widget-item").length, 5,
-        "The visible items in the requests menu are, in fact, visible!");
+    is(RequestsMenu.items.length, 5,
+      "There should be a total of 5 items in the requests menu.");
+    is(RequestsMenu.visibleItems.length, 5,
+      "There should be a total of 5 visbile items in the requests menu.");
+    is($all(".side-menu-widget-item").length, 5,
+      "The visible items in the requests menu are, in fact, visible!");
 
-      is(RequestsMenu.getItemAtIndex(0), RequestsMenu.items[0],
-        "The requests menu items aren't ordered correctly. First item is misplaced.");
-      is(RequestsMenu.getItemAtIndex(1), RequestsMenu.items[1],
-        "The requests menu items aren't ordered correctly. Second item is misplaced.");
-      is(RequestsMenu.getItemAtIndex(2), RequestsMenu.items[2],
-        "The requests menu items aren't ordered correctly. Third item is misplaced.");
-      is(RequestsMenu.getItemAtIndex(3), RequestsMenu.items[3],
-        "The requests menu items aren't ordered correctly. Fourth item is misplaced.");
-      is(RequestsMenu.getItemAtIndex(4), RequestsMenu.items[4],
-        "The requests menu items aren't ordered correctly. Fifth item is misplaced.");
+    is(RequestsMenu.getItemAtIndex(0), RequestsMenu.items[0],
+      "The requests menu items aren't ordered correctly. First item is misplaced.");
+    is(RequestsMenu.getItemAtIndex(1), RequestsMenu.items[1],
+      "The requests menu items aren't ordered correctly. Second item is misplaced.");
+    is(RequestsMenu.getItemAtIndex(2), RequestsMenu.items[2],
+      "The requests menu items aren't ordered correctly. Third item is misplaced.");
+    is(RequestsMenu.getItemAtIndex(3), RequestsMenu.items[3],
+      "The requests menu items aren't ordered correctly. Fourth item is misplaced.");
+    is(RequestsMenu.getItemAtIndex(4), RequestsMenu.items[4],
+      "The requests menu items aren't ordered correctly. Fifth item is misplaced.");
 
-      verifyRequestItemTarget(RequestsMenu.getItemAtIndex(a),
-        "GET1", SORTING_SJS + "?index=1", {
-          fuzzyUrl: true,
-          status: 101,
-          statusText: "Meh",
-          type: "1",
-          fullMimeType: "text/1",
-          transferred: L10N.getStr("networkMenu.sizeUnavailable"),
-          size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 0),
-          time: true
-        });
-      verifyRequestItemTarget(RequestsMenu.getItemAtIndex(b),
-        "GET2", SORTING_SJS + "?index=2", {
-          fuzzyUrl: true,
-          status: 200,
-          statusText: "Meh",
-          type: "2",
-          fullMimeType: "text/2",
-          transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 19),
-          size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 19),
-          time: true
-        });
-      verifyRequestItemTarget(RequestsMenu.getItemAtIndex(c),
-        "GET3", SORTING_SJS + "?index=3", {
-          fuzzyUrl: true,
-          status: 300,
-          statusText: "Meh",
-          type: "3",
-          fullMimeType: "text/3",
-          transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 29),
-          size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 29),
-          time: true
-        });
-      verifyRequestItemTarget(RequestsMenu.getItemAtIndex(d),
-        "GET4", SORTING_SJS + "?index=4", {
-          fuzzyUrl: true,
-          status: 400,
-          statusText: "Meh",
-          type: "4",
-          fullMimeType: "text/4",
-          transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 39),
-          size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 39),
-          time: true
-        });
-      verifyRequestItemTarget(RequestsMenu.getItemAtIndex(e),
-        "GET5", SORTING_SJS + "?index=5", {
-          fuzzyUrl: true,
-          status: 500,
-          statusText: "Meh",
-          type: "5",
-          fullMimeType: "text/5",
-          transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 49),
-          size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 49),
-          time: true
-        });
-
-      return promise.resolve(null);
-    }
-
-    performRequestsInContent(requests).then(null, e => {
-      ok(false, e);
-    });
-  });
-}
+    verifyRequestItemTarget(RequestsMenu.getItemAtIndex(a),
+      "GET1", SORTING_SJS + "?index=1", {
+        fuzzyUrl: true,
+        status: 101,
+        statusText: "Meh",
+        type: "1",
+        fullMimeType: "text/1",
+        transferred: L10N.getStr("networkMenu.sizeUnavailable"),
+        size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 0),
+        time: true
+      });
+    verifyRequestItemTarget(RequestsMenu.getItemAtIndex(b),
+      "GET2", SORTING_SJS + "?index=2", {
+        fuzzyUrl: true,
+        status: 200,
+        statusText: "Meh",
+        type: "2",
+        fullMimeType: "text/2",
+        transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 19),
+        size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 19),
+        time: true
+      });
+    verifyRequestItemTarget(RequestsMenu.getItemAtIndex(c),
+      "GET3", SORTING_SJS + "?index=3", {
+        fuzzyUrl: true,
+        status: 300,
+        statusText: "Meh",
+        type: "3",
+        fullMimeType: "text/3",
+        transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 29),
+        size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 29),
+        time: true
+      });
+    verifyRequestItemTarget(RequestsMenu.getItemAtIndex(d),
+      "GET4", SORTING_SJS + "?index=4", {
+        fuzzyUrl: true,
+        status: 400,
+        statusText: "Meh",
+        type: "4",
+        fullMimeType: "text/4",
+        transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 39),
+        size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 39),
+        time: true
+      });
+    verifyRequestItemTarget(RequestsMenu.getItemAtIndex(e),
+      "GET5", SORTING_SJS + "?index=5", {
+        fuzzyUrl: true,
+        status: 500,
+        statusText: "Meh",
+        type: "5",
+        fullMimeType: "text/5",
+        transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 49),
+        size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 49),
+        time: true
+      });
+  }
+});
--- a/devtools/client/netmonitor/test/browser_net_sort-03.js
+++ b/devtools/client/netmonitor/test/browser_net_sort-03.js
@@ -1,220 +1,207 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 /**
  * Test if sorting columns in the network table works correctly with new requests.
  */
 
-function test() {
-  initNetMonitor(SORTING_URL).then(([aTab, aDebuggee, aMonitor]) => {
-    info("Starting test... ");
+add_task(function* () {
+  let [,, monitor] = yield initNetMonitor(SORTING_URL);
+  info("Starting test... ");
 
-    // It seems that this test may be slow on debug builds. This could be because
-    // of the heavy dom manipulation associated with sorting.
-    requestLongerTimeout(2);
+  // It seems that this test may be slow on debug builds. This could be because
+  // of the heavy dom manipulation associated with sorting.
+  requestLongerTimeout(2);
 
-    let { $, $all, L10N, NetMonitorView } = aMonitor.panelWin;
-    let { RequestsMenu } = NetMonitorView;
+  let { $, $all, L10N, NetMonitorView } = monitor.panelWin;
+  let { RequestsMenu } = NetMonitorView;
 
-    // Loading the frame script and preparing the xhr request URLs so we can
-    // generate some requests later.
-    loadCommonFrameScript();
-    let requests = [{
-      url: "sjs_sorting-test-server.sjs?index=1&" + Math.random(),
-      method: "GET1"
-    }, {
-      url: "sjs_sorting-test-server.sjs?index=5&" + Math.random(),
-      method: "GET5"
-    }, {
-      url: "sjs_sorting-test-server.sjs?index=2&" + Math.random(),
-      method: "GET2"
-    }, {
-      url: "sjs_sorting-test-server.sjs?index=4&" + Math.random(),
-      method: "GET4"
-    }, {
-      url: "sjs_sorting-test-server.sjs?index=3&" + Math.random(),
-      method: "GET3"
-    }];
+  // Loading the frame script and preparing the xhr request URLs so we can
+  // generate some requests later.
+  loadCommonFrameScript();
+  let requests = [{
+    url: "sjs_sorting-test-server.sjs?index=1&" + Math.random(),
+    method: "GET1"
+  }, {
+    url: "sjs_sorting-test-server.sjs?index=5&" + Math.random(),
+    method: "GET5"
+  }, {
+    url: "sjs_sorting-test-server.sjs?index=2&" + Math.random(),
+    method: "GET2"
+  }, {
+    url: "sjs_sorting-test-server.sjs?index=4&" + Math.random(),
+    method: "GET4"
+  }, {
+    url: "sjs_sorting-test-server.sjs?index=3&" + Math.random(),
+    method: "GET3"
+  }];
 
-    RequestsMenu.lazyUpdate = false;
+  RequestsMenu.lazyUpdate = false;
 
-    waitForNetworkEvents(aMonitor, 5).then(() => {
-      EventUtils.sendMouseEvent({ type: "mousedown" }, $("#details-pane-toggle"));
+  let wait = waitForNetworkEvents(monitor, 5);
+  yield performRequestsInContent(requests);
+  yield wait;
+
+  EventUtils.sendMouseEvent({ type: "mousedown" }, $("#details-pane-toggle"));
 
-      isnot(RequestsMenu.selectedItem, null,
-        "There should be a selected item in the requests menu.");
-      is(RequestsMenu.selectedIndex, 0,
-        "The first item should be selected in the requests menu.");
-      is(NetMonitorView.detailsPaneHidden, false,
-        "The details pane should not be hidden after toggle button was pressed.");
+  isnot(RequestsMenu.selectedItem, null,
+    "There should be a selected item in the requests menu.");
+  is(RequestsMenu.selectedIndex, 0,
+    "The first item should be selected in the requests menu.");
+  is(NetMonitorView.detailsPaneHidden, false,
+    "The details pane should not be hidden after toggle button was pressed.");
+
+  testHeaders();
+  testContents([0, 2, 4, 3, 1], 0);
+
+  info("Testing status sort, ascending.");
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
+  testHeaders("status", "ascending");
+  testContents([0, 1, 2, 3, 4], 0);
 
-      testHeaders();
-      testContents([0, 2, 4, 3, 1], 0)
-        .then(() => {
-          info("Testing status sort, ascending.");
-          EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
-          testHeaders("status", "ascending");
-          return testContents([0, 1, 2, 3, 4], 0);
-        })
-        .then(() => {
-          info("Performing more requests.");
-          performRequestsInContent(requests);
-          return waitForNetworkEvents(aMonitor, 5);
-        })
-        .then(() => {
-          info("Testing status sort again, ascending.");
-          testHeaders("status", "ascending");
-          return testContents([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 0);
-        })
-        .then(() => {
-          info("Testing status sort, descending.");
-          EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
-          testHeaders("status", "descending");
-          return testContents([9, 8, 7, 6, 5, 4, 3, 2, 1, 0], 9);
-        })
-        .then(() => {
-          info("Performing more requests.");
-          performRequestsInContent(requests);
-          return waitForNetworkEvents(aMonitor, 5);
-        })
-        .then(() => {
-          info("Testing status sort again, descending.");
-          testHeaders("status", "descending");
-          return testContents([14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], 14);
-        })
-        .then(() => {
-          info("Testing status sort yet again, ascending.");
-          EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
-          testHeaders("status", "ascending");
-          return testContents([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], 0);
-        })
-        .then(() => {
-          info("Testing status sort yet again, descending.");
-          EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
-          testHeaders("status", "descending");
-          return testContents([14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], 14);
-        })
-        .then(() => {
-          return teardown(aMonitor);
-        })
-        .then(finish, e => {
-          ok(false, e);
-        });
-    }, e => {
-      ok(false, e);
-    });
+  info("Performing more requests.");
+  wait = waitForNetworkEvents(monitor, 5);
+  yield performRequestsInContent(requests);
+  yield wait;
+
+  info("Testing status sort again, ascending.");
+  testHeaders("status", "ascending");
+  testContents([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 0);
+
+  info("Testing status sort, descending.");
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
+  testHeaders("status", "descending");
+  testContents([9, 8, 7, 6, 5, 4, 3, 2, 1, 0], 9);
+
+  info("Performing more requests.");
+  wait = waitForNetworkEvents(monitor, 5);
+  yield performRequestsInContent(requests);
+  yield wait;
+
+  info("Testing status sort again, descending.");
+  testHeaders("status", "descending");
+  testContents([14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], 14);
 
-    function testHeaders(aSortType, aDirection) {
-      let doc = aMonitor.panelWin.document;
-      let target = doc.querySelector("#requests-menu-" + aSortType + "-button");
-      let headers = doc.querySelectorAll(".requests-menu-header-button");
+  info("Testing status sort yet again, ascending.");
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
+  testHeaders("status", "ascending");
+  testContents([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], 0);
+
+  info("Testing status sort yet again, descending.");
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
+  testHeaders("status", "descending");
+  testContents([14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], 14);
+
+  return teardown(monitor);
 
-      for (let header of headers) {
-        if (header != target) {
-          is(header.hasAttribute("sorted"), false,
-            "The " + header.id + " header should not have a 'sorted' attribute.");
-          is(header.hasAttribute("tooltiptext"), false,
-            "The " + header.id + " header should not have a 'tooltiptext' attribute.");
-        } else {
-          is(header.getAttribute("sorted"), aDirection,
-            "The " + header.id + " header has an incorrect 'sorted' attribute.");
-          is(header.getAttribute("tooltiptext"), aDirection == "ascending"
-            ? L10N.getStr("networkMenu.sortedAsc")
-            : L10N.getStr("networkMenu.sortedDesc"),
-            "The " + header.id + " has an incorrect 'tooltiptext' attribute.");
-        }
+  function testHeaders(sortType, direction) {
+    let doc = monitor.panelWin.document;
+    let target = doc.querySelector("#requests-menu-" + sortType + "-button");
+    let headers = doc.querySelectorAll(".requests-menu-header-button");
+
+    for (let header of headers) {
+      if (header != target) {
+        is(header.hasAttribute("sorted"), false,
+          "The " + header.id + " header should not have a 'sorted' attribute.");
+        is(header.hasAttribute("tooltiptext"), false,
+          "The " + header.id + " header should not have a 'tooltiptext' attribute.");
+      } else {
+        is(header.getAttribute("sorted"), direction,
+          "The " + header.id + " header has an incorrect 'sorted' attribute.");
+        is(header.getAttribute("tooltiptext"), direction == "ascending"
+          ? L10N.getStr("networkMenu.sortedAsc")
+          : L10N.getStr("networkMenu.sortedDesc"),
+          "The " + header.id + " has an incorrect 'tooltiptext' attribute.");
       }
     }
-
-    function testContents(aOrder, aSelection) {
-      isnot(RequestsMenu.selectedItem, null,
-        "There should still be a selected item after sorting.");
-      is(RequestsMenu.selectedIndex, aSelection,
-        "The first item should be still selected after sorting.");
-      is(NetMonitorView.detailsPaneHidden, false,
-        "The details pane should still be visible after sorting.");
+  }
 
-      is(RequestsMenu.items.length, aOrder.length,
-        "There should be a specific number of items in the requests menu.");
-      is(RequestsMenu.visibleItems.length, aOrder.length,
-        "There should be a specific number of visbile items in the requests menu.");
-      is($all(".side-menu-widget-item").length, aOrder.length,
-        "The visible items in the requests menu are, in fact, visible!");
-
-      for (let i = 0; i < aOrder.length; i++) {
-        is(RequestsMenu.getItemAtIndex(i), RequestsMenu.items[i],
-          "The requests menu items aren't ordered correctly. Misplaced item " + i + ".");
-      }
+  function testContents(order, selection) {
+    isnot(RequestsMenu.selectedItem, null,
+      "There should still be a selected item after sorting.");
+    is(RequestsMenu.selectedIndex, selection,
+      "The first item should be still selected after sorting.");
+    is(NetMonitorView.detailsPaneHidden, false,
+      "The details pane should still be visible after sorting.");
 
-      for (let i = 0, len = aOrder.length / 5; i < len; i++) {
-        verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i]),
-          "GET1", SORTING_SJS + "?index=1", {
-            fuzzyUrl: true,
-            status: 101,
-            statusText: "Meh",
-            type: "1",
-            fullMimeType: "text/1",
-            transferred: L10N.getStr("networkMenu.sizeUnavailable"),
-            size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 0),
-            time: true
-          });
-      }
-      for (let i = 0, len = aOrder.length / 5; i < len; i++) {
-        verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i + len]),
-          "GET2", SORTING_SJS + "?index=2", {
-            fuzzyUrl: true,
-            status: 200,
-            statusText: "Meh",
-            type: "2",
-            fullMimeType: "text/2",
-            transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 19),
-            size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 19),
-            time: true
-          });
-      }
-      for (let i = 0, len = aOrder.length / 5; i < len; i++) {
-        verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i + len * 2]),
-          "GET3", SORTING_SJS + "?index=3", {
-            fuzzyUrl: true,
-            status: 300,
-            statusText: "Meh",
-            type: "3",
-            fullMimeType: "text/3",
-            transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 29),
-            size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 29),
-            time: true
-          });
-      }
-      for (let i = 0, len = aOrder.length / 5; i < len; i++) {
-        verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i + len * 3]),
-          "GET4", SORTING_SJS + "?index=4", {
-            fuzzyUrl: true,
-            status: 400,
-            statusText: "Meh",
-            type: "4",
-            fullMimeType: "text/4",
-            transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 39),
-            size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 39),
-            time: true
-          });
-      }
-      for (let i = 0, len = aOrder.length / 5; i < len; i++) {
-        verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i + len * 4]),
-          "GET5", SORTING_SJS + "?index=5", {
-            fuzzyUrl: true,
-            status: 500,
-            statusText: "Meh",
-            type: "5",
-            fullMimeType: "text/5",
-            transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 49),
-            size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 49),
-            time: true
-          });
-      }
+    is(RequestsMenu.items.length, order.length,
+      "There should be a specific number of items in the requests menu.");
+    is(RequestsMenu.visibleItems.length, order.length,
+      "There should be a specific number of visbile items in the requests menu.");
+    is($all(".side-menu-widget-item").length, order.length,
+      "The visible items in the requests menu are, in fact, visible!");
 
-      return promise.resolve(null);
+    for (let i = 0; i < order.length; i++) {
+      is(RequestsMenu.getItemAtIndex(i), RequestsMenu.items[i],
+        "The requests menu items aren't ordered correctly. Misplaced item " + i + ".");
     }
 
-    performRequestsInContent(requests).then(null, e => console.error(e));
-  });
-}
+    for (let i = 0, len = order.length / 5; i < len; i++) {
+      verifyRequestItemTarget(RequestsMenu.getItemAtIndex(order[i]),
+        "GET1", SORTING_SJS + "?index=1", {
+          fuzzyUrl: true,
+          status: 101,
+          statusText: "Meh",
+          type: "1",
+          fullMimeType: "text/1",
+          transferred: L10N.getStr("networkMenu.sizeUnavailable"),
+          size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 0),
+          time: true
+        });
+    }
+    for (let i = 0, len = order.length / 5; i < len; i++) {
+      verifyRequestItemTarget(RequestsMenu.getItemAtIndex(order[i + len]),
+        "GET2", SORTING_SJS + "?index=2", {
+          fuzzyUrl: true,
+          status: 200,
+          statusText: "Meh",
+          type: "2",
+          fullMimeType: "text/2",
+          transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 19),
+          size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 19),
+          time: true
+        });
+    }
+    for (let i = 0, len = order.length / 5; i < len; i++) {
+      verifyRequestItemTarget(RequestsMenu.getItemAtIndex(order[i + len * 2]),
+        "GET3", SORTING_SJS + "?index=3", {
+          fuzzyUrl: true,
+          status: 300,
+          statusText: "Meh",
+          type: "3",
+          fullMimeType: "text/3",
+          transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 29),
+          size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 29),
+          time: true
+        });
+    }
+    for (let i = 0, len = order.length / 5; i < len; i++) {
+      verifyRequestItemTarget(RequestsMenu.getItemAtIndex(order[i + len * 3]),
+        "GET4", SORTING_SJS + "?index=4", {
+          fuzzyUrl: true,
+          status: 400,
+          statusText: "Meh",
+          type: "4",
+          fullMimeType: "text/4",
+          transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 39),
+          size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 39),
+          time: true
+        });
+    }
+    for (let i = 0, len = order.length / 5; i < len; i++) {
+      verifyRequestItemTarget(RequestsMenu.getItemAtIndex(order[i + len * 4]),
+        "GET5", SORTING_SJS + "?index=5", {
+          fuzzyUrl: true,
+          status: 500,
+          statusText: "Meh",
+          type: "5",
+          fullMimeType: "text/5",
+          transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 49),
+          size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 49),
+          time: true
+        });
+    }
+  }
+});
--- a/devtools/client/netmonitor/test/browser_net_statistics-01.js
+++ b/devtools/client/netmonitor/test/browser_net_statistics-01.js
@@ -17,20 +17,20 @@ add_task(function* () {
     "The initial frontend mode is correct.");
 
   is($("#primed-cache-chart").childNodes.length, 0,
     "There should be no primed cache chart created yet.");
   is($("#empty-cache-chart").childNodes.length, 0,
     "There should be no empty cache chart created yet.");
 
   let onChartDisplayed = Promise.all([
-    waitFor(panel, EVENTS.PRIMED_CACHE_CHART_DISPLAYED),
-    waitFor(panel, EVENTS.EMPTY_CACHE_CHART_DISPLAYED)
+    panel.once(EVENTS.PRIMED_CACHE_CHART_DISPLAYED),
+    panel.once(EVENTS.EMPTY_CACHE_CHART_DISPLAYED)
   ]);
-  let onPlaceholderDisplayed = waitFor(panel, EVENTS.PLACEHOLDER_CHARTS_DISPLAYED);
+  let onPlaceholderDisplayed = panel.once(EVENTS.PLACEHOLDER_CHARTS_DISPLAYED);
 
   info("Displaying statistics view");
   NetMonitorView.toggleFrontendMode();
   is(NetMonitorView.currentFrontendMode, "network-statistics-view",
     "The current frontend mode is correct.");
 
   info("Waiting for placeholder to display");
   yield onPlaceholderDisplayed;
@@ -46,30 +46,18 @@ add_task(function* () {
 
   info("Waiting for chart to display");
   yield onChartDisplayed;
   is($("#primed-cache-chart").childNodes.length, 1,
     "There should be a real primed cache chart created now.");
   is($("#empty-cache-chart").childNodes.length, 1,
     "There should be a real empty cache chart created now.");
 
-  yield until(() => $all(".pie-chart-container:not([placeholder=true])").length == 2);
+  yield waitUntil(
+    () => $all(".pie-chart-container:not([placeholder=true])").length == 2);
   ok(true, "Two real pie charts appear to be rendered correctly.");
 
-  yield until(() => $all(".table-chart-container:not([placeholder=true])").length == 2);
+  yield waitUntil(
+    () => $all(".table-chart-container:not([placeholder=true])").length == 2);
   ok(true, "Two real table charts appear to be rendered correctly.");
 
   yield teardown(monitor);
 });
-
-function waitForTick() {
-  let deferred = promise.defer();
-  executeSoon(deferred.resolve);
-  return deferred.promise;
-}
-
-function until(predicate) {
-  return Task.spawn(function* () {
-    while (!predicate()) {
-      yield waitForTick();
-    }
-  });
-}
--- a/devtools/client/netmonitor/test/browser_net_statistics-02.js
+++ b/devtools/client/netmonitor/test/browser_net_statistics-02.js
@@ -4,39 +4,39 @@
 "use strict";
 
 /**
  * Tests if the network inspector view is shown when the target navigates
  * away while in the statistics view.
  */
 
 add_task(function* () {
-  let [, debuggee, monitor] = yield initNetMonitor(STATISTICS_URL);
+  let [tab, , monitor] = yield initNetMonitor(STATISTICS_URL);
   info("Starting test... ");
 
   let panel = monitor.panelWin;
   let { EVENTS, NetMonitorView } = panel;
   is(NetMonitorView.currentFrontendMode, "network-inspector-view",
       "The initial frontend mode is correct.");
 
   let onChartDisplayed = Promise.all([
-    waitFor(panel, EVENTS.PRIMED_CACHE_CHART_DISPLAYED),
-    waitFor(panel, EVENTS.EMPTY_CACHE_CHART_DISPLAYED)
+    panel.once(EVENTS.PRIMED_CACHE_CHART_DISPLAYED),
+    panel.once(EVENTS.EMPTY_CACHE_CHART_DISPLAYED)
   ]);
 
   info("Displaying statistics view");
   NetMonitorView.toggleFrontendMode();
   yield onChartDisplayed;
   is(NetMonitorView.currentFrontendMode, "network-statistics-view",
         "The frontend mode is currently in the statistics view.");
 
   info("Reloading page");
-  let onWillNavigate = waitFor(panel, EVENTS.TARGET_WILL_NAVIGATE);
-  let onDidNavigate = waitFor(panel, EVENTS.TARGET_DID_NAVIGATE);
-  debuggee.location.reload();
+  let onWillNavigate = panel.once(EVENTS.TARGET_WILL_NAVIGATE);
+  let onDidNavigate = panel.once(EVENTS.TARGET_DID_NAVIGATE);
+  tab.linkedBrowser.reload();
   yield onWillNavigate;
   is(NetMonitorView.currentFrontendMode, "network-inspector-view",
           "The frontend mode switched back to the inspector view.");
   yield onDidNavigate;
   is(NetMonitorView.currentFrontendMode, "network-inspector-view",
             "The frontend mode is still in the inspector view.");
   yield teardown(monitor);
 });
--- a/devtools/client/netmonitor/test/browser_net_statistics-03.js
+++ b/devtools/client/netmonitor/test/browser_net_statistics-03.js
@@ -1,37 +1,38 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 /**
  * Test if the correct filtering predicates are used when filtering from
  * the performance analysis view.
  */
 
-function test() {
-  initNetMonitor(FILTERING_URL).then(([aTab, aDebuggee, aMonitor]) => {
-    info("Starting test... ");
-
-    let panel = aMonitor.panelWin;
-    let { $, EVENTS, NetMonitorView } = panel;
+add_task(function* () {
+  let [,, monitor] = yield initNetMonitor(FILTERING_URL);
+  info("Starting test... ");
 
-    EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-html-button"));
-    EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-css-button"));
-    EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-js-button"));
-    EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-ws-button"));
-    EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-other-button"));
-    testFilterButtonsCustom(aMonitor, [0, 1, 1, 1, 0, 0, 0, 0, 0, 1]);
-    ok(true, "The correct filtering predicates are used before entering perf. analysis mode.");
+  let panel = monitor.panelWin;
+  let { $, EVENTS, NetMonitorView } = panel;
 
-    promise.all([
-      waitFor(panel, EVENTS.PRIMED_CACHE_CHART_DISPLAYED),
-      waitFor(panel, EVENTS.EMPTY_CACHE_CHART_DISPLAYED)
-    ]).then(() => {
-      EventUtils.sendMouseEvent({ type: "click" }, $(".pie-chart-slice"));
-      testFilterButtons(aMonitor, "html");
-      ok(true, "The correct filtering predicate is used when exiting perf. analysis mode.");
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-html-button"));
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-css-button"));
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-js-button"));
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-ws-button"));
+  EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-other-button"));
+  testFilterButtonsCustom(monitor, [0, 1, 1, 1, 0, 0, 0, 0, 0, 1]);
+  info("The correct filtering predicates are used before entering perf. analysis mode.");
 
-      teardown(aMonitor).then(finish);
-    });
+  let onEvents = promise.all([
+    panel.once(EVENTS.PRIMED_CACHE_CHART_DISPLAYED),
+    panel.once(EVENTS.EMPTY_CACHE_CHART_DISPLAYED)
+  ]);
+  NetMonitorView.toggleFrontendMode();
+  yield onEvents;
 
-    NetMonitorView.toggleFrontendMode();
-  });
-}
+  EventUtils.sendMouseEvent({ type: "click" }, $(".pie-chart-slice"));
+  testFilterButtons(monitor, "html");
+  info("The correct filtering predicate is used when exiting perf. analysis mode.");
+
+  yield teardown(monitor);
+});
--- a/devtools/client/netmonitor/test/browser_net_status-codes.js
+++ b/devtools/client/netmonitor/test/browser_net_status-codes.js
@@ -2,100 +2,108 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 "use strict";
 
 /**
  * Tests if requests display the correct status code and text in the UI.
  */
 
-var test = Task.async(function* () {
-  let [tab, debuggee, monitor] = yield initNetMonitor(STATUS_CODES_URL);
+add_task(function* () {
+  let [tab, , monitor] = yield initNetMonitor(STATUS_CODES_URL);
 
   info("Starting test... ");
 
-  let { document, L10N, NetMonitorView } = monitor.panelWin;
+  let { document, EVENTS, L10N, NetMonitorView } = monitor.panelWin;
   let { RequestsMenu, NetworkDetails } = NetMonitorView;
   let requestItems = [];
 
   RequestsMenu.lazyUpdate = false;
   NetworkDetails._params.lazyEmpty = false;
 
   const REQUEST_DATA = [
-    { // request #0
+    {
+      // request #0
       method: "GET",
       uri: STATUS_CODES_SJS + "?sts=100",
       details: {
         status: 101,
         statusText: "Switching Protocols",
         type: "plain",
         fullMimeType: "text/plain; charset=utf-8",
         size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 0),
         time: true
       }
     },
-    { // request #1
+    {
+      // request #1
       method: "GET",
       uri: STATUS_CODES_SJS + "?sts=200",
       details: {
         status: 202,
         statusText: "Created",
         type: "plain",
         fullMimeType: "text/plain; charset=utf-8",
         size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
         time: true
       }
     },
-    { // request #2
+    {
+      // request #2
       method: "GET",
       uri: STATUS_CODES_SJS + "?sts=300",
       details: {
         status: 303,
         statusText: "See Other",
         type: "plain",
         fullMimeType: "text/plain; charset=utf-8",
         size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 0),
         time: true
       }
     },
-    { // request #3
+    {
+      // request #3
       method: "GET",
       uri: STATUS_CODES_SJS + "?sts=400",
       details: {
         status: 404,
         statusText: "Not Found",
         type: "plain",
         fullMimeType: "text/plain; charset=utf-8",
         size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
         time: true
       }
     },
-    { // request #4
+    {
+      // request #4
       method: "GET",
       uri: STATUS_CODES_SJS + "?sts=500",
       details: {
         status: 501,
         statusText: "Not Implemented",
         type: "plain",
         fullMimeType: "text/plain; charset=utf-8",
         size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
         time: true
       }
     }
   ];
 
-  debuggee.performRequests();
-  yield waitForNetworkEvents(monitor, 5);
+  let wait = waitForNetworkEvents(monitor, 5);
+  yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
+    content.wrappedJSObject.performRequests();
+  });
+  yield wait;
+
   info("Performing tests");
   yield verifyRequests();
   yield testTab(0, testSummary);
   yield testTab(2, testParams);
 
-  yield teardown(monitor);
-  finish();
+  return teardown(monitor);
 
   /**
    * A helper that verifies all requests show the correct information and caches
    * RequestsMenu items to requestItems array.
    */
   function* verifyRequests() {
     info("Verifying requests contain correct information.");
     let index = 0;
@@ -109,45 +117,44 @@ var test = Task.async(function* () {
       index++;
     }
   }
 
   /**
    * A helper that opens a given tab of request details pane, selects and passes
    * all requests to the given test function.
    *
-   * @param Number tab
+   * @param Number tabIdx
    *               The index of NetworkDetails tab to activate.
    * @param Function testFn(requestItem)
    *        A function that should perform all necessary tests. It's called once
    *        for every item of REQUEST_DATA with that item being selected in the
    *        NetworkMonitor.
    */
-  function* testTab(tab, testFn) {
-    info("Testing tab #" + tab);
+  function* testTab(tabIdx, testFn) {
+    info("Testing tab #" + tabIdx);
     EventUtils.sendMouseEvent({ type: "mousedown" },
-          document.querySelectorAll("#details-pane tab")[tab]);
+          document.querySelectorAll("#details-pane tab")[tabIdx]);
 
     let counter = 0;
     for (let item of REQUEST_DATA) {
-      info("Waiting tab #" + tab + " to update with request #" + counter);
+      info("Waiting tab #" + tabIdx + " to update with request #" + counter);
       yield chooseRequest(counter);
 
       info("Tab updated. Performing checks");
       yield testFn(item);
 
       counter++;
     }
   }
 
   /**
    * A function that tests "Summary" contains correct information.
    */
   function* testSummary(data) {
-    let tab = document.querySelectorAll("#details-pane tab")[0];
     let tabpanel = document.querySelectorAll("#details-pane tabpanel")[0];
 
     let { method, uri, details: { status, statusText } } = data;
     is(tabpanel.querySelector("#headers-summary-url-value").getAttribute("value"),
       uri, "The url summary value is incorrect.");
     is(tabpanel.querySelector("#headers-summary-method-value").getAttribute("value"),
       method, "The method summary value is incorrect.");
     is(tabpanel.querySelector("#headers-summary-status-circle").getAttribute("code"),
@@ -155,17 +162,16 @@ var test = Task.async(function* () {
     is(tabpanel.querySelector("#headers-summary-status-value").getAttribute("value"),
       status + " " + statusText, "The status summary value is incorrect.");
   }
 
   /**
    * A function that tests "Params" tab contains correct information.
    */
   function* testParams(data) {
-    let tab = document.querySelectorAll("#details-pane tab")[2];
     let tabpanel = document.querySelectorAll("#details-pane tabpanel")[2];
     let statusParamValue = data.uri.split("=").pop();
     let statusParamShownValue = "\"" + statusParamValue + "\"";
 
     is(tabpanel.querySelectorAll(".variables-view-scope").length, 1,
       "There should be 1 param scope displayed in this tabpanel.");
     is(tabpanel.querySelectorAll(".variable-or-property").length, 1,
       "There should be 1 param value displayed in this tabpanel.");
@@ -173,30 +179,33 @@ var test = Task.async(function* () {
       "The empty notice should not be displayed in this tabpanel.");
 
     let paramsScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
 
     is(paramsScope.querySelector(".name").getAttribute("value"),
       L10N.getStr("paramsQueryString"),
       "The params scope doesn't have the correct title.");
 
-    is(paramsScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"),
+    is(paramsScope.querySelectorAll(".variables-view-variable .name")[0]
+      .getAttribute("value"),
       "sts", "The param name was incorrect.");
-    is(paramsScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"),
+    is(paramsScope.querySelectorAll(".variables-view-variable .value")[0]
+      .getAttribute("value"),
       statusParamShownValue, "The param value was incorrect.");
 
     is(tabpanel.querySelector("#request-params-box")
       .hasAttribute("hidden"), false,
       "The request params box should not be hidden.");
     is(tabpanel.querySelector("#request-post-data-textarea-box")
       .hasAttribute("hidden"), true,
       "The request post data textarea box should be hidden.");
   }
 
   /**
    * A helper that clicks on a specified request and returns a promise resolved
    * when NetworkDetails has been populated with the data of the given request.
    */
   function chooseRequest(index) {
+    let onTabUpdated = monitor.panelWin.once(EVENTS.TAB_UPDATED);
     EventUtils.sendMouseEvent({ type: "mousedown" }, requestItems[index].target);
-    return waitFor(monitor.panelWin, monitor.panelWin.EVENTS.TAB_UPDATED);
+    return onTabUpdated;
   }
 });
--- a/devtools/client/netmonitor/test/browser_net_streaming-response.js
+++ b/devtools/client/netmonitor/test/browser_net_streaming-response.js
@@ -1,65 +1,69 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 /**
  * Tests if reponses from streaming content types (MPEG-DASH, HLS) are
  * displayed as XML or plain text
  */
 
-function test() {
-  Task.spawn(function* () {
-    let [tab, debuggee, monitor] = yield initNetMonitor(CUSTOM_GET_URL);
-
-    info("Starting test... ");
-    let { panelWin } = monitor;
-    let { document, Editor, NetMonitorView } = panelWin;
-    let { RequestsMenu } = NetMonitorView;
+add_task(function* () {
+  let [tab, , monitor] = yield initNetMonitor(CUSTOM_GET_URL);
 
-    const REQUESTS = [
-      [ "hls-m3u8", /^#EXTM3U/, Editor.modes.text ],
-      [ "mpeg-dash", /^<\?xml/, Editor.modes.html ]
-    ];
+  info("Starting test... ");
+  let { panelWin } = monitor;
+  let { document, Editor, NetMonitorView } = panelWin;
+  let { RequestsMenu } = NetMonitorView;
 
-    RequestsMenu.lazyUpdate = false;
+  const REQUESTS = [
+    [ "hls-m3u8", /^#EXTM3U/, Editor.modes.text ],
+    [ "mpeg-dash", /^<\?xml/, Editor.modes.html ]
+  ];
 
-    REQUESTS.forEach(([ fmt ]) => {
-      debuggee.performRequests(1, CONTENT_TYPE_SJS + "?fmt=" + fmt);
-    });
-
-    yield waitForNetworkEvents(monitor, REQUESTS.length);
+  RequestsMenu.lazyUpdate = false;
 
-    REQUESTS.forEach(([ fmt ], i) => {
-      verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i),
-        "GET", CONTENT_TYPE_SJS + "?fmt=" + fmt, {
-          status: 200,
-          statusText: "OK"
-        });
+  let wait = waitForNetworkEvents(monitor, REQUESTS.length);
+  for (let [fmt] of REQUESTS) {
+    let url = CONTENT_TYPE_SJS + "?fmt=" + fmt;
+    yield ContentTask.spawn(tab.linkedBrowser, { url }, function* (args) {
+      content.wrappedJSObject.performRequests(1, args.url);
     });
-
-    EventUtils.sendMouseEvent({ type: "mousedown" },
-      document.getElementById("details-pane-toggle"));
-    EventUtils.sendMouseEvent({ type: "mousedown" },
-      document.querySelectorAll("#details-pane tab")[3]);
+  }
+  yield wait;
 
-    yield panelWin.once(panelWin.EVENTS.RESPONSE_BODY_DISPLAYED);
-    let editor = yield NetMonitorView.editor("#response-content-textarea");
-
-    testEditorContent(editor, REQUESTS[0]); // the hls-m3u8 part
-
-    RequestsMenu.selectedIndex = 1;
-    yield panelWin.once(panelWin.EVENTS.TAB_UPDATED);
-    yield panelWin.once(panelWin.EVENTS.RESPONSE_BODY_DISPLAYED);
-
-    testEditorContent(editor, REQUESTS[1]); // the mpeg-dash part
-
-    yield teardown(monitor);
-    finish();
+  REQUESTS.forEach(([ fmt ], i) => {
+    verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i),
+      "GET", CONTENT_TYPE_SJS + "?fmt=" + fmt, {
+        status: 200,
+        statusText: "OK"
+      });
   });
 
-  function testEditorContent(editor, [ fmt, textRe, mode ]) {
-    ok(editor.getText().match(textRe),
-      "The text shown in the source editor for " + fmt + " is incorrect.");
-    is(editor.getMode(), mode,
-      "The mode active in the source editor for " + fmt + " is incorrect.");
+  EventUtils.sendMouseEvent({ type: "mousedown" },
+    document.getElementById("details-pane-toggle"));
+  EventUtils.sendMouseEvent({ type: "mousedown" },
+    document.querySelectorAll("#details-pane tab")[3]);
+
+  yield panelWin.once(panelWin.EVENTS.RESPONSE_BODY_DISPLAYED);
+  let editor = yield NetMonitorView.editor("#response-content-textarea");
+
+  // the hls-m3u8 part
+  testEditorContent(editor, REQUESTS[0]);
+
+  RequestsMenu.selectedIndex = 1;
+  yield panelWin.once(panelWin.EVENTS.TAB_UPDATED);
+  yield panelWin.once(panelWin.EVENTS.RESPONSE_BODY_DISPLAYED);
+
+  // the mpeg-dash part
+  testEditorContent(editor, REQUESTS[1]);
+
+  return teardown(monitor);
+
+  function testEditorContent(e, [ fmt, textRe, mode ]) {
+    ok(e.getText().match(textRe),
+      "The text shown in the source editor for " + fmt + " is correct.");
+    is(e.getMode(), mode,
+      "The mode active in the source editor for " + fmt + " is correct.");
   }
-}
+});
--- a/devtools/client/netmonitor/test/browser_net_throttle.js
+++ b/devtools/client/netmonitor/test/browser_net_throttle.js
@@ -9,18 +9,17 @@ add_task(function* () {
   yield throttleTest(true);
   yield throttleTest(false);
 });
 
 function* throttleTest(actuallyThrottle) {
   requestLongerTimeout(2);
 
   let [, , monitor] = yield initNetMonitor(SIMPLE_URL);
-  const {ACTIVITY_TYPE, NetMonitorController, NetMonitorView} =
-        monitor.panelWin;
+  const {ACTIVITY_TYPE, EVENTS, NetMonitorController, NetMonitorView} = monitor.panelWin;
 
   info("Starting test... (actuallyThrottle = " + actuallyThrottle + ")");
 
   // When throttling, must be smaller than the length of the content
   // of SIMPLE_URL in bytes.
   const size = actuallyThrottle ? 200 : 0;
 
   const request = {
@@ -37,22 +36,20 @@ function* throttleTest(actuallyThrottle)
 
   info("sending throttle request");
   let deferred = promise.defer();
   client.setPreferences(request, response => {
     deferred.resolve(response);
   });
   yield deferred.promise;
 
-  let eventPromise =
-      monitor.panelWin.once(monitor.panelWin.EVENTS.RECEIVED_EVENT_TIMINGS);
-  yield NetMonitorController
-    .triggerActivity(ACTIVITY_TYPE.RELOAD.WITH_CACHE_DISABLED);
+  let eventPromise = monitor.panelWin.once(EVENTS.RECEIVED_EVENT_TIMINGS);
+  yield NetMonitorController.triggerActivity(ACTIVITY_TYPE.RELOAD.WITH_CACHE_DISABLED);
+  yield eventPromise;
 
-  yield eventPromise;
   let requestItem = NetMonitorView.RequestsMenu.getItemAtIndex(0);
   const reportedOneSecond = requestItem.attachment.eventTimings.timings.receive > 1000;
   if (actuallyThrottle) {
     ok(reportedOneSecond, "download reported as taking more than one second");
   } else {
     ok(!reportedOneSecond, "download reported as taking less than one second");
   }
 
--- a/devtools/client/netmonitor/test/browser_net_timeline_ticks.js
+++ b/devtools/client/netmonitor/test/browser_net_timeline_ticks.js
@@ -1,146 +1,140 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 /**
  * Tests if timeline correctly displays interval divisions.
  */
 
-function test() {
-  initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
-    info("Starting test... ");
-
-    let { document, L10N, NetMonitorView, NetMonitorController } = aMonitor.panelWin;
-    let { RequestsMenu } = NetMonitorView;
+add_task(function* () {
+  let [tab, , monitor] = yield initNetMonitor(SIMPLE_URL);
+  info("Starting test... ");
 
-    // Disable transferred size column support for this test.
-    // Without this, the waterfall only has enough room for one division, which
-    // would remove most of the value of this test.
-    document.querySelector("#requests-menu-transferred-header-box").hidden = true;
-    document.querySelector("#requests-menu-item-template .requests-menu-transferred").hidden = true;
+  let { $, $all, L10N, NetMonitorView, NetMonitorController } = monitor.panelWin;
+  let { RequestsMenu } = NetMonitorView;
 
-    RequestsMenu.lazyUpdate = false;
+  // Disable transferred size column support for this test.
+  // Without this, the waterfall only has enough room for one division, which
+  // would remove most of the value of this test.
+  $("#requests-menu-transferred-header-box").hidden = true;
+  $("#requests-menu-item-template .requests-menu-transferred").hidden = true;
 
-    ok(document.querySelector("#requests-menu-waterfall-label"),
-      "An timeline label should be displayed when the frontend is opened.");
-    ok(document.querySelectorAll(".requests-menu-timings-division").length == 0,
-      "No tick labels should be displayed when the frontend is opened.");
+  RequestsMenu.lazyUpdate = false;
+
+  ok($("#requests-menu-waterfall-label"),
+    "An timeline label should be displayed when the frontend is opened.");
+  ok($all(".requests-menu-timings-division").length == 0,
+    "No tick labels should be displayed when the frontend is opened.");
 
-    ok(!RequestsMenu._canvas,
-      "No canvas should be created when the frontend is opened.");
-    ok(!RequestsMenu._ctx,
-      "No 2d context should be created when the frontend is opened.");
+  ok(!RequestsMenu._canvas, "No canvas should be created when the frontend is opened.");
+  ok(!RequestsMenu._ctx, "No 2d context should be created when the frontend is opened.");
 
-    waitForNetworkEvents(aMonitor, 1).then(() => {
-      // Make sure the DOMContentLoaded and load markers don't interfere with
-      // this test by removing them and redrawing the waterfall (bug 1224088).
-      NetMonitorController.NetworkEventsHandler.clearMarkers();
-      RequestsMenu._flushWaterfallViews(true);
+  let wait = waitForNetworkEvents(monitor, 1);
+  tab.linkedBrowser.reload();
+  yield wait;
 
-      ok(!document.querySelector("#requests-menu-waterfall-label"),
-        "The timeline label should be hidden after the first request.");
-      ok(document.querySelectorAll(".requests-menu-timings-division").length >= 3,
-        "There should be at least 3 tick labels in the network requests header.");
+  // Make sure the DOMContentLoaded and load markers don't interfere with
+  // this test by removing them and redrawing the waterfall (bug 1224088).
+  NetMonitorController.NetworkEventsHandler.clearMarkers();
+  RequestsMenu._flushWaterfallViews(true);
 
-      is(document.querySelectorAll(".requests-menu-timings-division")[0]
-        .getAttribute("value"), L10N.getFormatStr("networkMenu.millisecond", 0),
-        "The first tick label has an incorrect value");
-      is(document.querySelectorAll(".requests-menu-timings-division")[1]
-        .getAttribute("value"), L10N.getFormatStr("networkMenu.millisecond", 80),
-        "The second tick label has an incorrect value");
-      is(document.querySelectorAll(".requests-menu-timings-division")[2]
-        .getAttribute("value"), L10N.getFormatStr("networkMenu.millisecond", 160),
-        "The third tick label has an incorrect value");
+  ok(!$("#requests-menu-waterfall-label"),
+    "The timeline label should be hidden after the first request.");
+  ok($all(".requests-menu-timings-division").length >= 3,
+    "There should be at least 3 tick labels in the network requests header.");
 
-      is(document.querySelectorAll(".requests-menu-timings-division")[0]
-        .style.transform, "translateX(0px)",
-        "The first tick label has an incorrect translation");
-      is(document.querySelectorAll(".requests-menu-timings-division")[1]
-        .style.transform, "translateX(80px)",
-        "The second tick label has an incorrect translation");
-      is(document.querySelectorAll(".requests-menu-timings-division")[2]
-        .style.transform, "translateX(160px)",
-        "The third tick label has an incorrect translation");
+  is($all(".requests-menu-timings-division")[0].getAttribute("value"),
+    L10N.getFormatStr("networkMenu.millisecond", 0),
+    "The first tick label has an incorrect value");
+  is($all(".requests-menu-timings-division")[1].getAttribute("value"),
+    L10N.getFormatStr("networkMenu.millisecond", 80),
+    "The second tick label has an incorrect value");
+  is($all(".requests-menu-timings-division")[2].getAttribute("value"),
+    L10N.getFormatStr("networkMenu.millisecond", 160),
+    "The third tick label has an incorrect value");
 
-      ok(RequestsMenu._canvas,
-        "A canvas should be created after the first request.");
-      ok(RequestsMenu._ctx,
-        "A 2d context should be created after the first request.");
+  is($all(".requests-menu-timings-division")[0].style.transform, "translateX(0px)",
+    "The first tick label has an incorrect translation");
+  is($all(".requests-menu-timings-division")[1].style.transform, "translateX(80px)",
+    "The second tick label has an incorrect translation");
+  is($all(".requests-menu-timings-division")[2].style.transform, "translateX(160px)",
+    "The third tick label has an incorrect translation");
 
-      let imageData = RequestsMenu._ctx.getImageData(0, 0, 161, 1);
-      ok(imageData, "The image data should have been created.");
+  ok(RequestsMenu._canvas, "A canvas should be created after the first request.");
+  ok(RequestsMenu._ctx, "A 2d context should be created after the first request.");
 
-      let data = imageData.data;
-      ok(data, "The image data should contain a pixel array.");
+  let imageData = RequestsMenu._ctx.getImageData(0, 0, 161, 1);
+  ok(imageData, "The image data should have been created.");
+
+  let data = imageData.data;
+  ok(data, "The image data should contain a pixel array.");
 
-      ok(hasPixelAt(0), "The tick at 0 is should not be empty.");
-      ok(!hasPixelAt(1), "The tick at 1 is should be empty.");
-      ok(!hasPixelAt(19), "The tick at 19 is should be empty.");
-      ok(hasPixelAt(20), "The tick at 20 is should not be empty.");
-      ok(!hasPixelAt(21), "The tick at 21 is should be empty.");
-      ok(!hasPixelAt(39), "The tick at 39 is should be empty.");
-      ok(hasPixelAt(40), "The tick at 40 is should not be empty.");
-      ok(!hasPixelAt(41), "The tick at 41 is should be empty.");
-      ok(!hasPixelAt(59), "The tick at 59 is should be empty.");
-      ok(hasPixelAt(60), "The tick at 60 is should not be empty.");
-      ok(!hasPixelAt(61), "The tick at 61 is should be empty.");
-      ok(!hasPixelAt(79), "The tick at 79 is should be empty.");
-      ok(hasPixelAt(80), "The tick at 80 is should not be empty.");
-      ok(!hasPixelAt(81), "The tick at 81 is should be empty.");
-      ok(!hasPixelAt(159), "The tick at 159 is should be empty.");
-      ok(hasPixelAt(160), "The tick at 160 is should not be empty.");
-      ok(!hasPixelAt(161), "The tick at 161 is should be empty.");
+  ok(hasPixelAt(0), "The tick at 0 is should not be empty.");
+  ok(!hasPixelAt(1), "The tick at 1 is should be empty.");
+  ok(!hasPixelAt(19), "The tick at 19 is should be empty.");
+  ok(hasPixelAt(20), "The tick at 20 is should not be empty.");
+  ok(!hasPixelAt(21), "The tick at 21 is should be empty.");
+  ok(!hasPixelAt(39), "The tick at 39 is should be empty.");
+  ok(hasPixelAt(40), "The tick at 40 is should not be empty.");
+  ok(!hasPixelAt(41), "The tick at 41 is should be empty.");
+  ok(!hasPixelAt(59), "The tick at 59 is should be empty.");
+  ok(hasPixelAt(60), "The tick at 60 is should not be empty.");
+  ok(!hasPixelAt(61), "The tick at 61 is should be empty.");
+  ok(!hasPixelAt(79), "The tick at 79 is should be empty.");
+  ok(hasPixelAt(80), "The tick at 80 is should not be empty.");
+  ok(!hasPixelAt(81), "The tick at 81 is should be empty.");
+  ok(!hasPixelAt(159), "The tick at 159 is should be empty.");
+  ok(hasPixelAt(160), "The tick at 160 is should not be empty.");
+  ok(!hasPixelAt(161), "The tick at 161 is should be empty.");
 
-      ok(isPixelBrighterAtThan(0, 20),
-        "The tick at 0 should be brighter than the one at 20");
-      ok(isPixelBrighterAtThan(40, 20),
-        "The tick at 40 should be brighter than the one at 20");
-      ok(isPixelBrighterAtThan(40, 60),
-        "The tick at 40 should be brighter than the one at 60");
-      ok(isPixelBrighterAtThan(80, 60),
-        "The tick at 80 should be brighter than the one at 60");
-
-      ok(isPixelBrighterAtThan(80, 100),
-        "The tick at 80 should be brighter than the one at 100");
-      ok(isPixelBrighterAtThan(120, 100),
-        "The tick at 120 should be brighter than the one at 100");
-      ok(isPixelBrighterAtThan(120, 140),
-        "The tick at 120 should be brighter than the one at 140");
-      ok(isPixelBrighterAtThan(160, 140),
-        "The tick at 160 should be brighter than the one at 140");
+  ok(isPixelBrighterAtThan(0, 20),
+    "The tick at 0 should be brighter than the one at 20");
+  ok(isPixelBrighterAtThan(40, 20),
+    "The tick at 40 should be brighter than the one at 20");
+  ok(isPixelBrighterAtThan(40, 60),
+    "The tick at 40 should be brighter than the one at 60");
+  ok(isPixelBrighterAtThan(80, 60),
+    "The tick at 80 should be brighter than the one at 60");
 
-      ok(isPixelEquallyBright(20, 60),
-        "The tick at 20 should be equally bright to the one at 60");
-      ok(isPixelEquallyBright(100, 140),
-        "The tick at 100 should be equally bright to the one at 140");
-
-      ok(isPixelEquallyBright(40, 120),
-        "The tick at 40 should be equally bright to the one at 120");
+  ok(isPixelBrighterAtThan(80, 100),
+    "The tick at 80 should be brighter than the one at 100");
+  ok(isPixelBrighterAtThan(120, 100),
+    "The tick at 120 should be brighter than the one at 100");
+  ok(isPixelBrighterAtThan(120, 140),
+    "The tick at 120 should be brighter than the one at 140");
+  ok(isPixelBrighterAtThan(160, 140),
+    "The tick at 160 should be brighter than the one at 140");
 
-      ok(isPixelEquallyBright(0, 80),
-        "The tick at 80 should be equally bright to the one at 160");
-      ok(isPixelEquallyBright(80, 160),
-        "The tick at 80 should be equally bright to the one at 160");
+  ok(isPixelEquallyBright(20, 60),
+    "The tick at 20 should be equally bright to the one at 60");
+  ok(isPixelEquallyBright(100, 140),
+    "The tick at 100 should be equally bright to the one at 140");
 
-      function hasPixelAt(x) {
-        let i = (x | 0) * 4;
-        return data[i] && data[i + 1] && data[i + 2] && data[i + 3];
-      }
+  ok(isPixelEquallyBright(40, 120),
+    "The tick at 40 should be equally bright to the one at 120");
 
-      function isPixelBrighterAtThan(x1, x2) {
-        let i = (x1 | 0) * 4;
-        let j = (x2 | 0) * 4;
-        return data[i + 3] > data [j + 3];
-      }
+  ok(isPixelEquallyBright(0, 80),
+    "The tick at 80 should be equally bright to the one at 160");
+  ok(isPixelEquallyBright(80, 160),
+    "The tick at 80 should be equally bright to the one at 160");
+
+  function hasPixelAt(x) {
+    let i = (x | 0) * 4;
+    return data[i] && data[i + 1] && data[i + 2] && data[i + 3];
+  }
 
-      function isPixelEquallyBright(x1, x2) {
-        let i = (x1 | 0) * 4;
-        let j = (x2 | 0) * 4;
-        return data[i + 3] == data [j + 3];
-      }
+  function isPixelBrighterAtThan(x1, x2) {
+    let i = (x1 | 0) * 4;
+    let j = (x2 | 0) * 4;
+    return data[i + 3] > data [j + 3];
+  }
 
-      teardown(aMonitor).then(finish);
-    });
+  function isPixelEquallyBright(x1, x2) {
+    let i = (x1 | 0) * 4;
+    let j = (x2 | 0) * 4;
+    return data[i + 3] == data [j + 3];
+  }
 
-    aDebuggee.location.reload();
-  });
-}
+  return teardown(monitor);
+});
--- a/devtools/client/netmonitor/test/browser_net_timing-division.js
+++ b/devtools/client/netmonitor/test/browser_net_timing-division.js
@@ -1,58 +1,61 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 /**
  * Tests if timing intervals are divided againts seconds when appropriate.
  */
 
-function test() {
-  initNetMonitor(CUSTOM_GET_URL).then(([aTab, aDebuggee, aMonitor]) => {
-    info("Starting test... ");
+add_task(function* () {
+  let [tab, , monitor] = yield initNetMonitor(CUSTOM_GET_URL);
+  info("Starting test... ");
 
-    let { $all, NetMonitorView } = aMonitor.panelWin;
-    let { RequestsMenu } = NetMonitorView;
+  let { $all, NetMonitorView } = monitor.panelWin;
+  let { RequestsMenu } = NetMonitorView;
 
-    RequestsMenu.lazyUpdate = false;
+  RequestsMenu.lazyUpdate = false;
 
-    waitForNetworkEvents(aMonitor, 2).then(() => {
-      let millisecondDivs = $all(".requests-menu-timings-division[division-scale=millisecond]");
-      let secondDivs = $all(".requests-menu-timings-division[division-scale=second]");
-      let minuteDivs = $all(".requests-menu-timings-division[division-scale=minute]");
+  let wait = waitForNetworkEvents(monitor, 2);
+  // Timeout needed for having enough divisions on the time scale.
+  yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
+    content.wrappedJSObject.performRequests(2, null, 3000);
+  });
+  yield wait;
 
-      info("Number of millisecond divisions: " + millisecondDivs.length);
-      info("Number of second divisions: " + secondDivs.length);
-      info("Number of minute divisions: " + minuteDivs.length);
+  let milDivs = $all(".requests-menu-timings-division[division-scale=millisecond]");
+  let secDivs = $all(".requests-menu-timings-division[division-scale=second]");
+  let minDivs = $all(".requests-menu-timings-division[division-scale=minute]");
+
+  info("Number of millisecond divisions: " + milDivs.length);
+  info("Number of second divisions: " + secDivs.length);
+  info("Number of minute divisions: " + minDivs.length);
 
-      for (let div of millisecondDivs) {
-        info("Millisecond division: " + div.getAttribute("value"));
-      }
-      for (let div of secondDivs) {
-        info("Second division: " + div.getAttribute("value"));
-      }
-      for (let div of minuteDivs) {
-        info("Minute division: " + div.getAttribute("value"));
-      }
+  for (let div of milDivs) {
+    info("Millisecond division: " + div.getAttribute("value"));
+  }
+  for (let div of secDivs) {
+    info("Second division: " + div.getAttribute("value"));
+  }
+  for (let div of minDivs) {
+    info("Minute division: " + div.getAttribute("value"));
+  }
 
-      is(RequestsMenu.itemCount, 2,
-        "There should be only two requests made.");
-
-      let firstRequest = RequestsMenu.getItemAtIndex(0);
-      let lastRequest = RequestsMenu.getItemAtIndex(1);
+  is(RequestsMenu.itemCount, 2,
+    "There should be only two requests made.");
 
-      info("First request happened at: " +
-        firstRequest.attachment.responseHeaders.headers.find(e => e.name == "Date").value);
-      info("Last request happened at: " +
-        lastRequest.attachment.responseHeaders.headers.find(e => e.name == "Date").value);
+  let firstRequest = RequestsMenu.getItemAtIndex(0);
+  let lastRequest = RequestsMenu.getItemAtIndex(1);
+
+  info("First request happened at: " +
+    firstRequest.attachment.responseHeaders.headers.find(e => e.name == "Date").value);
+  info("Last request happened at: " +
+    lastRequest.attachment.responseHeaders.headers.find(e => e.name == "Date").value);
 
-      ok(secondDivs.length,
-        "There should be at least one division on the seconds time scale.");
-      ok(secondDivs[0].getAttribute("value").match(/\d+\.\d{2}\s\w+/),
-        "The division on the seconds time scale looks legit.");
+  ok(secDivs.length,
+    "There should be at least one division on the seconds time scale.");
+  ok(secDivs[0].getAttribute("value").match(/\d+\.\d{2}\s\w+/),
+    "The division on the seconds time scale looks legit.");
 
-      teardown(aMonitor).then(finish);
-    });
-
-      // Timeout needed for having enough divisions on the time scale.
-    aDebuggee.performRequests(2, null, 3000);
-  });
-}
+  return teardown(monitor);
+});