Bug 1297362 - Part 4: Eliminate CPOWs from Netmonitor mochitests L-P r?ochameau draft
authorJarda Snajdr <jsnajdr@gmail.com>
Thu, 25 Aug 2016 13:01:42 +0200
changeset 406768 f298ab0c40b803fb3229c7cd772a58c9d7c2b5b0
parent 406767 1f7243d1809eb4cf641dee6fe6baa7a904d90460
child 406769 e2560e8eae0459a79d94ff2a4892e86441ead72f
push id27819
push userbmo:jsnajdr@gmail.com
push dateMon, 29 Aug 2016 13:56:30 +0000
reviewersochameau
bugs1297362
milestone51.0a1
Bug 1297362 - Part 4: Eliminate CPOWs from Netmonitor mochitests L-P r?ochameau MozReview-Commit-ID: 6MXmmKK6d5r
devtools/client/netmonitor/test/browser_net_large-response.js
devtools/client/netmonitor/test/browser_net_leak_on_tab_close.js
devtools/client/netmonitor/test/browser_net_open_request_in_tab.js
devtools/client/netmonitor/test/browser_net_page-nav.js
devtools/client/netmonitor/test/browser_net_pane-collapse.js
devtools/client/netmonitor/test/browser_net_pane-toggle.js
devtools/client/netmonitor/test/browser_net_persistent_logs.js
devtools/client/netmonitor/test/browser_net_post-data-01.js
devtools/client/netmonitor/test/browser_net_post-data-02.js
devtools/client/netmonitor/test/browser_net_post-data-03.js
devtools/client/netmonitor/test/browser_net_prefs-and-l10n.js
devtools/client/netmonitor/test/browser_net_prefs-reload.js
--- a/devtools/client/netmonitor/test/browser_net_large-response.js
+++ b/devtools/client/netmonitor/test/browser_net_large-response.js
@@ -1,51 +1,55 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 /**
  * Tests if very large response contents are just displayed as plain text.
  */
 
-function test() {
-  initNetMonitor(CUSTOM_GET_URL).then(([aTab, aDebuggee, aMonitor]) => {
-    info("Starting test... ");
+const HTML_LONG_URL = CONTENT_TYPE_SJS + "?fmt=html-long";
+
+add_task(function* () {
+  let [tab, , monitor] = yield initNetMonitor(CUSTOM_GET_URL);
+  info("Starting test... ");
 
-    // This test could potentially be slow because over 100 KB of stuff
-    // is going to be requested and displayed in the source editor.
-    requestLongerTimeout(2);
+  // This test could potentially be slow because over 100 KB of stuff
+  // is going to be requested and displayed in the source editor.
+  requestLongerTimeout(2);
 
-    let { document, Editor, NetMonitorView } = aMonitor.panelWin;
-    let { RequestsMenu } = NetMonitorView;
-
-    RequestsMenu.lazyUpdate = false;
+  let { document, EVENTS, Editor, NetMonitorView } = monitor.panelWin;
+  let { RequestsMenu } = NetMonitorView;
 
-    waitForNetworkEvents(aMonitor, 1).then(() => {
-      verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0),
-        "GET", CONTENT_TYPE_SJS + "?fmt=html-long", {
-          status: 200,
-          statusText: "OK"
-        });
+  RequestsMenu.lazyUpdate = false;
 
-      aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RESPONSE_BODY_DISPLAYED, () => {
-        NetMonitorView.editor("#response-content-textarea").then((aEditor) => {
-          ok(aEditor.getText().match(/^<p>/),
-            "The text shown in the source editor is incorrect.");
-          is(aEditor.getMode(), Editor.modes.text,
-            "The mode active in the source editor is incorrect.");
+  let wait = waitForNetworkEvents(monitor, 1);
+  yield ContentTask.spawn(tab.linkedBrowser, HTML_LONG_URL, function* (url) {
+    content.wrappedJSObject.performRequests(1, url);
+  });
+  yield wait;
 
-          teardown(aMonitor).then(finish);
-        });
-      });
-
-      EventUtils.sendMouseEvent({ type: "mousedown" },
-        document.getElementById("details-pane-toggle"));
-      EventUtils.sendMouseEvent({ type: "mousedown" },
-        document.querySelectorAll("#details-pane tab")[3]);
+  verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0),
+    "GET", CONTENT_TYPE_SJS + "?fmt=html-long", {
+      status: 200,
+      statusText: "OK"
     });
 
-    aDebuggee.performRequests(1, CONTENT_TYPE_SJS + "?fmt=html-long");
-  });
+  let onEvent = monitor.panelWin.once(EVENTS.RESPONSE_BODY_DISPLAYED);
+  EventUtils.sendMouseEvent({ type: "mousedown" },
+    document.getElementById("details-pane-toggle"));
+  EventUtils.sendMouseEvent({ type: "mousedown" },
+    document.querySelectorAll("#details-pane tab")[3]);
+  yield onEvent;
+
+  let editor = yield NetMonitorView.editor("#response-content-textarea");
+  ok(editor.getText().match(/^<p>/),
+    "The text shown in the source editor is incorrect.");
+  is(editor.getMode(), Editor.modes.text,
+    "The mode active in the source editor is incorrect.");
+
+  yield teardown(monitor);
 
   // This test uses a lot of memory, so force a GC to help fragmentation.
   info("Forcing GC after netmonitor test.");
   Cu.forceGC();
-}
+});
--- a/devtools/client/netmonitor/test/browser_net_leak_on_tab_close.js
+++ b/devtools/client/netmonitor/test/browser_net_leak_on_tab_close.js
@@ -9,10 +9,9 @@
 
 add_task(function* () {
   // Tell initNetMonitor to enable cache. Otherwise it will assert that there were more
   // than zero network requests during the page load. But when loading about:config,
   // there are none.
   let [,, monitor] = yield initNetMonitor("about:config", null, true);
   ok(monitor, "The network monitor was opened");
   yield teardown(monitor);
-  finish();
 });
--- a/devtools/client/netmonitor/test/browser_net_open_request_in_tab.js
+++ b/devtools/client/netmonitor/test/browser_net_open_request_in_tab.js
@@ -1,40 +1,37 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 /**
  * Tests if Open in new tab works.
  */
 
-function test() {
-  waitForExplicitFinish();
-
-  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 { NetMonitorView } = aMonitor.panelWin;
-    let { RequestsMenu } = NetMonitorView;
+  let { NetMonitorView } = monitor.panelWin;
+  let { RequestsMenu } = NetMonitorView;
 
-    RequestsMenu.lazyUpdate = false;
-
-    waitForNetworkEvents(aMonitor, 1).then(() => {
-      let requestItem = RequestsMenu.getItemAtIndex(0);
-      RequestsMenu.selectedItem = requestItem;
+  RequestsMenu.lazyUpdate = false;
 
-      gBrowser.tabContainer.addEventListener("TabOpen", function onOpen(event) {
-        ok(true, "A new tab has been opened ");
-        gBrowser.tabContainer.removeEventListener("TabOpen", onOpen, false);
-        cleanUp();
-      }, false);
+  let wait = waitForNetworkEvents(monitor, 1);
+  yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
+    content.wrappedJSObject.performRequests(1);
+  });
+  yield wait;
 
-      RequestsMenu.openRequestInTab();
-    });
+  let requestItem = RequestsMenu.getItemAtIndex(0);
+  RequestsMenu.selectedItem = requestItem;
 
-    aDebuggee.performRequests(1);
-    function cleanUp() {
-      teardown(aMonitor).then(() => {
-        gBrowser.removeCurrentTab();
-        finish();
-      });
-    }
-  });
-}
+  let onTabOpen = once(gBrowser.tabContainer, "TabOpen", false);
+  RequestsMenu.openRequestInTab();
+  yield onTabOpen;
+
+  ok(true, "A new tab has been opened");
+
+  yield teardown(monitor);
+
+  gBrowser.removeCurrentTab();
+});
--- a/devtools/client/netmonitor/test/browser_net_page-nav.js
+++ b/devtools/client/netmonitor/test/browser_net_page-nav.js
@@ -1,68 +1,69 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 /**
  * Tests if page navigation ("close", "navigate", etc.) triggers an appropriate
  * action in the network monitor.
  */
 
-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... ");
 
-    testNavigate(() => testNavigateBack(() => testClose(() => finish())));
+  let { EVENTS } = monitor.panelWin;
 
-    function testNavigate(aCallback) {
-      info("Navigating forward...");
+  yield testNavigate();
+  yield testNavigateBack();
+  yield testClose();
 
-      aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.TARGET_WILL_NAVIGATE, () => {
-        is(aDebuggee.location, SIMPLE_URL,
-          "Target started navigating to the correct location.");
+  function* testNavigate() {
+    info("Navigating forward...");
 
-        aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.TARGET_DID_NAVIGATE, () => {
-          is(aDebuggee.location, NAVIGATE_URL,
-            "Target finished navigating to the correct location.");
+    let onWillNav = monitor.panelWin.once(EVENTS.TARGET_WILL_NAVIGATE);
+    let onDidNav = monitor.panelWin.once(EVENTS.TARGET_DID_NAVIGATE);
+
+    tab.linkedBrowser.loadURI(NAVIGATE_URL);
+    yield onWillNav;
 
-          aCallback();
-        });
-      });
+    is(tab.linkedBrowser.currentURI.spec, SIMPLE_URL,
+      "Target started navigating to the correct location.");
 
-      aDebuggee.location = NAVIGATE_URL;
-    }
+    yield onDidNav;
+    is(tab.linkedBrowser.currentURI.spec, NAVIGATE_URL,
+      "Target finished navigating to the correct location.");
+  }
 
-    function testNavigateBack(aCallback) {
-      info("Navigating backward...");
+  function* testNavigateBack() {
+    info("Navigating backward...");
 
-      aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.TARGET_WILL_NAVIGATE, () => {
-        is(aDebuggee.location, NAVIGATE_URL,
-          "Target started navigating back to the previous location.");
+    let onWillNav = monitor.panelWin.once(EVENTS.TARGET_WILL_NAVIGATE);
+    let onDidNav = monitor.panelWin.once(EVENTS.TARGET_DID_NAVIGATE);
+
+    tab.linkedBrowser.loadURI(SIMPLE_URL);
+    yield onWillNav;
 
-        aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.TARGET_DID_NAVIGATE, () => {
-          is(aDebuggee.location, SIMPLE_URL,
-            "Target finished navigating back to the previous location.");
+    is(tab.linkedBrowser.currentURI.spec, NAVIGATE_URL,
+      "Target started navigating back to the previous location.");
 
-          aCallback();
-        });
-      });
-
-      aDebuggee.location = SIMPLE_URL;
-    }
+    yield onDidNav;
+    is(tab.linkedBrowser.currentURI.spec, SIMPLE_URL,
+      "Target finished navigating back to the previous location.");
+  }
 
-    function testClose(aCallback) {
-      info("Closing...");
+  function* testClose() {
+    info("Closing...");
+
+    let onDestroyed = monitor.once("destroyed");
+    removeTab(tab);
+    yield onDestroyed;
 
-      aMonitor.once("destroyed", () => {
-        ok(!aMonitor._controller.client,
-          "There shouldn't be a client available after destruction.");
-        ok(!aMonitor._controller.tabClient,
-          "There shouldn't be a tabClient available after destruction.");
-        ok(!aMonitor._controller.webConsoleClient,
-          "There shouldn't be a webConsoleClient available after destruction.");
-
-        aCallback();
-      });
-
-      removeTab(aTab);
-    }
-  });
-}
+    ok(!monitor._controller.client,
+      "There shouldn't be a client available after destruction.");
+    ok(!monitor._controller.tabClient,
+      "There shouldn't be a tabClient available after destruction.");
+    ok(!monitor._controller.webConsoleClient,
+      "There shouldn't be a webConsoleClient available after destruction.");
+  }
+});
--- a/devtools/client/netmonitor/test/browser_net_pane-collapse.js
+++ b/devtools/client/netmonitor/test/browser_net_pane-collapse.js
@@ -1,66 +1,67 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 /**
  * Tests if the network monitor panes collapse properly.
  */
 
-function test() {
-  initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
-    info("Starting test... ");
+add_task(function* () {
+  let [,, monitor] = yield initNetMonitor(SIMPLE_URL);
+  info("Starting test... ");
 
-    let { document, Prefs, NetMonitorView } = aMonitor.panelWin;
-    let detailsPane = document.getElementById("details-pane");
-    let detailsPaneToggleButton = document.getElementById("details-pane-toggle");
+  let { document, Prefs, NetMonitorView } = monitor.panelWin;
+  let detailsPane = document.getElementById("details-pane");
+  let detailsPaneToggleButton = document.getElementById("details-pane-toggle");
 
-    ok(detailsPane.classList.contains("pane-collapsed") &&
-       detailsPaneToggleButton.classList.contains("pane-collapsed"),
-      "The details pane should initially be hidden.");
+  ok(detailsPane.classList.contains("pane-collapsed") &&
+     detailsPaneToggleButton.classList.contains("pane-collapsed"),
+    "The details pane should initially be hidden.");
 
-    NetMonitorView.toggleDetailsPane({ visible: true, animated: false });
+  NetMonitorView.toggleDetailsPane({ visible: true, animated: false });
 
-    let width = ~~(detailsPane.getAttribute("width"));
-    is(width, Prefs.networkDetailsWidth,
-      "The details pane has an incorrect width.");
-    is(detailsPane.style.marginLeft, "0px",
-      "The details pane has an incorrect left margin.");
-    is(detailsPane.style.marginRight, "0px",
-      "The details pane has an incorrect right margin.");
-    ok(!detailsPane.hasAttribute("animated"),
-      "The details pane has an incorrect animated attribute.");
-    ok(!detailsPane.classList.contains("pane-collapsed") &&
-       !detailsPaneToggleButton.classList.contains("pane-collapsed"),
-      "The details pane should at this point be visible.");
+  let width = ~~(detailsPane.getAttribute("width"));
+  is(width, Prefs.networkDetailsWidth,
+    "The details pane has an incorrect width.");
+  is(detailsPane.style.marginLeft, "0px",
+    "The details pane has an incorrect left margin.");
+  is(detailsPane.style.marginRight, "0px",
+    "The details pane has an incorrect right margin.");
+  ok(!detailsPane.hasAttribute("animated"),
+    "The details pane has an incorrect animated attribute.");
+  ok(!detailsPane.classList.contains("pane-collapsed") &&
+     !detailsPaneToggleButton.classList.contains("pane-collapsed"),
+    "The details pane should at this point be visible.");
 
-    NetMonitorView.toggleDetailsPane({ visible: false, animated: true });
+  NetMonitorView.toggleDetailsPane({ visible: false, animated: true });
 
-    let margin = -(width + 1) + "px";
-    is(width, Prefs.networkDetailsWidth,
-      "The details pane has an incorrect width after collapsing.");
-    is(detailsPane.style.marginLeft, margin,
-      "The details pane has an incorrect left margin after collapsing.");
-    is(detailsPane.style.marginRight, margin,
-      "The details pane has an incorrect right margin after collapsing.");
-    ok(detailsPane.hasAttribute("animated"),
-      "The details pane has an incorrect attribute after an animated collapsing.");
-    ok(detailsPane.classList.contains("pane-collapsed") &&
-       detailsPaneToggleButton.classList.contains("pane-collapsed"),
-      "The details pane should not be visible after collapsing.");
+  let margin = -(width + 1) + "px";
+  is(width, Prefs.networkDetailsWidth,
+    "The details pane has an incorrect width after collapsing.");
+  is(detailsPane.style.marginLeft, margin,
+    "The details pane has an incorrect left margin after collapsing.");
+  is(detailsPane.style.marginRight, margin,
+    "The details pane has an incorrect right margin after collapsing.");
+  ok(detailsPane.hasAttribute("animated"),
+    "The details pane has an incorrect attribute after an animated collapsing.");
+  ok(detailsPane.classList.contains("pane-collapsed") &&
+     detailsPaneToggleButton.classList.contains("pane-collapsed"),
+    "The details pane should not be visible after collapsing.");
 
-    NetMonitorView.toggleDetailsPane({ visible: true, animated: false });
+  NetMonitorView.toggleDetailsPane({ visible: true, animated: false });
 
-    is(width, Prefs.networkDetailsWidth,
-      "The details pane has an incorrect width after uncollapsing.");
-    is(detailsPane.style.marginLeft, "0px",
-      "The details pane has an incorrect left margin after uncollapsing.");
-    is(detailsPane.style.marginRight, "0px",
-      "The details pane has an incorrect right margin after uncollapsing.");
-    ok(!detailsPane.hasAttribute("animated"),
-      "The details pane has an incorrect attribute after an unanimated uncollapsing.");
-    ok(!detailsPane.classList.contains("pane-collapsed") &&
-       !detailsPaneToggleButton.classList.contains("pane-collapsed"),
-      "The details pane should be visible again after uncollapsing.");
+  is(width, Prefs.networkDetailsWidth,
+    "The details pane has an incorrect width after uncollapsing.");
+  is(detailsPane.style.marginLeft, "0px",
+    "The details pane has an incorrect left margin after uncollapsing.");
+  is(detailsPane.style.marginRight, "0px",
+    "The details pane has an incorrect right margin after uncollapsing.");
+  ok(!detailsPane.hasAttribute("animated"),
+    "The details pane has an incorrect attribute after an unanimated uncollapsing.");
+  ok(!detailsPane.classList.contains("pane-collapsed") &&
+     !detailsPaneToggleButton.classList.contains("pane-collapsed"),
+    "The details pane should be visible again after uncollapsing.");
 
-    teardown(aMonitor).then(finish);
-  });
-}
+  yield teardown(monitor);
+});
--- a/devtools/client/netmonitor/test/browser_net_pane-toggle.js
+++ b/devtools/client/netmonitor/test/browser_net_pane-toggle.js
@@ -24,19 +24,17 @@ add_task(function* () {
     "The pane toggle button should indicate that the details pane is " +
     "collapsed when the frontend is opened.");
   is(NetMonitorView.detailsPaneHidden, true,
     "The details pane should be hidden when the frontend is opened.");
   is(RequestsMenu.selectedItem, null,
     "There should be no selected item in the requests menu.");
 
   let networkEvent = monitor.panelWin.once(NETWORK_EVENT);
-  yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
-    content.location.reload();
-  });
+  tab.linkedBrowser.reload();
   yield networkEvent;
 
   is(toggleButton.hasAttribute("disabled"), false,
     "The pane toggle button should be enabled after the first request.");
   is(toggleButton.classList.contains("pane-collapsed"), true,
     "The pane toggle button should still indicate that the details pane is " +
     "collapsed after the first request.");
   is(NetMonitorView.detailsPaneHidden, true,
--- a/devtools/client/netmonitor/test/browser_net_persistent_logs.js
+++ b/devtools/client/netmonitor/test/browser_net_persistent_logs.js
@@ -1,53 +1,51 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 /**
  * Tests if the network monitor leaks on initialization and sudden destruction.
  * You can also use this initialization format as a template for other tests.
  */
 
-function test() {
-  let monitor, reqMenu;
-  initNetMonitor(SINGLE_GET_URL).then(([aTab, aDebuggee, aMonitor]) => {
-    info("Starting test... ");
+add_task(function* () {
+  let [tab, , monitor] = yield initNetMonitor(SINGLE_GET_URL);
+  info("Starting test... ");
+
+  let { NetMonitorView } = monitor.panelWin;
+  let { RequestsMenu } = NetMonitorView;
+
+  Services.prefs.setBoolPref("devtools.webconsole.persistlog", false);
 
-    monitor = aMonitor;
-    let { document, NetMonitorView, NetMonitorController } = aMonitor.panelWin;
-    let { RequestsMenu, NetworkDetails } = NetMonitorView;
-    reqMenu = RequestsMenu;
+  yield reloadAndWait();
+
+  is(RequestsMenu.itemCount, 2,
+    "The request menu should have two items at this point.");
+
+  yield reloadAndWait();
+
+  // Since the reload clears the log, we still expect two requests in the log
+  is(RequestsMenu.itemCount, 2,
+    "The request menu should still have two items at this point.");
 
-    Services.prefs.setBoolPref("devtools.webconsole.persistlog", false);
-    content.location.reload(true);
-  })
-  .then(() => {
-    return waitForNetworkEvents(monitor, 2);
-  })
-  .then(() => {
-    is(reqMenu.itemCount, 2,
-      "The request menu should have two items at this point.");
-  })
-  .then(() => {
-    content.location.reload(true);
-    return waitForNetworkEvents(monitor, 2);
-  })
-  .then(() => {
-    // Since the reload clears the log, we still expect two requests in the log
-    is(reqMenu.itemCount, 2,
-      "The request menu should still have two items at this point.");
-  })
-  .then(() => {
-    // Now we toggle the persistence logs on
-    Services.prefs.setBoolPref("devtools.webconsole.persistlog", true);
-    content.location.reload(true);
-    return waitForNetworkEvents(monitor, 2);
-  })
-  .then(() => {
-    // Since we togged the persistence logs, we expect four items after the reload
-    is(reqMenu.itemCount, 4,
-      "The request menu should now have four items at this point.");
-  })
-  .then(() => {
-    Services.prefs.setBoolPref("devtools.webconsole.persistlog", false);
-    return teardown(monitor).then(finish);
-  });
-}
+  // Now we toggle the persistence logs on
+  Services.prefs.setBoolPref("devtools.webconsole.persistlog", true);
+
+  yield reloadAndWait();
+
+  // Since we togged the persistence logs, we expect four items after the reload
+  is(RequestsMenu.itemCount, 4,
+    "The request menu should now have four items at this point.");
+
+  Services.prefs.setBoolPref("devtools.webconsole.persistlog", false);
+  return teardown(monitor);
+
+  /**
+   * Reload the page and wait for 2 GET requests. Race-free.
+   */
+  function reloadAndWait() {
+    let wait = waitForNetworkEvents(monitor, 2);
+    tab.linkedBrowser.reload();
+    return wait;
+  }
+});
--- a/devtools/client/netmonitor/test/browser_net_post-data-01.js
+++ b/devtools/client/netmonitor/test/browser_net_post-data-01.js
@@ -1,153 +1,164 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 /**
  * Tests if the POST requests display the correct information in the UI.
  */
 
-function test() {
-  initNetMonitor(POST_DATA_URL).then(([aTab, aDebuggee, aMonitor]) => {
-    info("Starting test... ");
-
-    let { document, L10N, Editor, NetMonitorView } = aMonitor.panelWin;
-    let { RequestsMenu, NetworkDetails } = NetMonitorView;
-
-    RequestsMenu.lazyUpdate = false;
-    NetworkDetails._params.lazyEmpty = false;
+add_task(function* () {
+  let [tab, , monitor] = yield initNetMonitor(POST_DATA_URL);
+  info("Starting test... ");
 
-    waitForNetworkEvents(aMonitor, 0, 2).then(() => {
-      verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0),
-        "POST", SIMPLE_SJS + "?foo=bar&baz=42&type=urlencoded", {
-          status: 200,
-          statusText: "Och Aye",
-          type: "plain",
-          fullMimeType: "text/plain; charset=utf-8",
-          size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 12),
-          time: true
-        });
-      verifyRequestItemTarget(RequestsMenu.getItemAtIndex(1),
-        "POST", SIMPLE_SJS + "?foo=bar&baz=42&type=multipart", {
-          status: 200,
-          statusText: "Och Aye",
-          type: "plain",
-          fullMimeType: "text/plain; charset=utf-8",
-          size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 12),
-          time: true
-        });
+  let { document, EVENTS, L10N, Editor, NetMonitorView } = monitor.panelWin;
+  let { RequestsMenu, NetworkDetails } = NetMonitorView;
 
-      EventUtils.sendMouseEvent({ type: "mousedown" },
-        document.getElementById("details-pane-toggle"));
-      EventUtils.sendMouseEvent({ type: "mousedown" },
-        document.querySelectorAll("#details-pane tab")[2]);
-
-      let TAB_UPDATED = aMonitor.panelWin.EVENTS.TAB_UPDATED;
-      waitFor(aMonitor.panelWin, TAB_UPDATED).then(() =>
-        testParamsTab("urlencoded")
-      ).then(() => {
-        RequestsMenu.selectedIndex = 1;
-        return waitFor(aMonitor.panelWin, TAB_UPDATED);
-      }).then(() => testParamsTab("multipart"))
-        .then(() => teardown(aMonitor))
-        .then(finish);
-
-      function testParamsTab(aType) {
-        let tab = document.querySelectorAll("#details-pane tab")[2];
-        let tabpanel = document.querySelectorAll("#details-pane tabpanel")[2];
+  RequestsMenu.lazyUpdate = false;
+  NetworkDetails._params.lazyEmpty = false;
 
-        is(tab.getAttribute("selected"), "true",
-          "The params tab in the network details pane should be selected.");
-
-        function checkVisibility(aBox) {
-          is(tabpanel.querySelector("#request-params-box")
-            .hasAttribute("hidden"), !aBox.includes("params"),
-            "The request params box doesn't have the indended visibility.");
-          is(tabpanel.querySelector("#request-post-data-textarea-box")
-            .hasAttribute("hidden"), !aBox.includes("textarea"),
-            "The request post data textarea box doesn't have the indended visibility.");
-        }
-
-        is(tabpanel.querySelectorAll(".variables-view-scope").length, 2,
-          "There should be 2 param scopes displayed in this tabpanel.");
-        is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0,
-          "The empty notice should not be displayed in this tabpanel.");
-
-        let queryScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
-        let postScope = tabpanel.querySelectorAll(".variables-view-scope")[1];
+  let wait = waitForNetworkEvents(monitor, 0, 2);
+  yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
+    content.wrappedJSObject.performRequests();
+  });
+  yield wait;
 
-        is(queryScope.querySelector(".name").getAttribute("value"),
-          L10N.getStr("paramsQueryString"),
-          "The query scope doesn't have the correct title.");
-
-        is(postScope.querySelector(".name").getAttribute("value"),
-          L10N.getStr(aType == "urlencoded" ? "paramsFormData" : "paramsPostPayload"),
-          "The post scope doesn't have the correct title.");
-
-        is(queryScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"),
-          "foo", "The first query param name was incorrect.");
-        is(queryScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"),
-          "\"bar\"", "The first query param value was incorrect.");
-        is(queryScope.querySelectorAll(".variables-view-variable .name")[1].getAttribute("value"),
-          "baz", "The second query param name was incorrect.");
-        is(queryScope.querySelectorAll(".variables-view-variable .value")[1].getAttribute("value"),
-          "\"42\"", "The second query param value was incorrect.");
-        is(queryScope.querySelectorAll(".variables-view-variable .name")[2].getAttribute("value"),
-          "type", "The third query param name was incorrect.");
-        is(queryScope.querySelectorAll(".variables-view-variable .value")[2].getAttribute("value"),
-          "\"" + aType + "\"", "The third query param value was incorrect.");
-
-        if (aType == "urlencoded") {
-          checkVisibility("params");
-
-          is(tabpanel.querySelectorAll(".variables-view-variable").length, 5,
-            "There should be 5 param values displayed in this tabpanel.");
-          is(queryScope.querySelectorAll(".variables-view-variable").length, 3,
-            "There should be 3 param values displayed in the query scope.");
-          is(postScope.querySelectorAll(".variables-view-variable").length, 2,
-            "There should be 2 param values displayed in the post scope.");
-
-          is(postScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"),
-            "foo", "The first post param name was incorrect.");
-          is(postScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"),
-            "\"bar\"", "The first post param value was incorrect.");
-          is(postScope.querySelectorAll(".variables-view-variable .name")[1].getAttribute("value"),
-            "baz", "The second post param name was incorrect.");
-          is(postScope.querySelectorAll(".variables-view-variable .value")[1].getAttribute("value"),
-            "\"123\"", "The second post param value was incorrect.");
-
-          return promise.resolve();
-        }
-        else {
-          checkVisibility("params textarea");
-
-          is(tabpanel.querySelectorAll(".variables-view-variable").length, 3,
-            "There should be 3 param values displayed in this tabpanel.");
-          is(queryScope.querySelectorAll(".variables-view-variable").length, 3,
-            "There should be 3 param values displayed in the query scope.");
-          is(postScope.querySelectorAll(".variables-view-variable").length, 0,
-            "There should be 0 param values displayed in the post scope.");
-
-          return NetMonitorView.editor("#request-post-data-textarea").then((aEditor) => {
-            ok(aEditor.getText().includes("Content-Disposition: form-data; name=\"text\""),
-              "The text shown in the source editor is incorrect (1.1).");
-            ok(aEditor.getText().includes("Content-Disposition: form-data; name=\"email\""),
-              "The text shown in the source editor is incorrect (2.1).");
-            ok(aEditor.getText().includes("Content-Disposition: form-data; name=\"range\""),
-              "The text shown in the source editor is incorrect (3.1).");
-            ok(aEditor.getText().includes("Content-Disposition: form-data; name=\"Custom field\""),
-              "The text shown in the source editor is incorrect (4.1).");
-            ok(aEditor.getText().includes("Some text..."),
-              "The text shown in the source editor is incorrect (2.2).");
-            ok(aEditor.getText().includes("42"),
-              "The text shown in the source editor is incorrect (3.2).");
-            ok(aEditor.getText().includes("Extra data"),
-              "The text shown in the source editor is incorrect (4.2).");
-            is(aEditor.getMode(), Editor.modes.text,
-              "The mode active in the source editor is incorrect.");
-          });
-        }
-      }
+  verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0),
+    "POST", SIMPLE_SJS + "?foo=bar&baz=42&type=urlencoded", {
+      status: 200,
+      statusText: "Och Aye",
+      type: "plain",
+      fullMimeType: "text/plain; charset=utf-8",
+      size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 12),
+      time: true
+    });
+  verifyRequestItemTarget(RequestsMenu.getItemAtIndex(1),
+    "POST", SIMPLE_SJS + "?foo=bar&baz=42&type=multipart", {
+      status: 200,
+      statusText: "Och Aye",
+      type: "plain",
+      fullMimeType: "text/plain; charset=utf-8",
+      size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 12),
+      time: true
     });
 
-    aDebuggee.performRequests();
-  });
-}
+  let onEvent = monitor.panelWin.once(EVENTS.TAB_UPDATED);
+  EventUtils.sendMouseEvent({ type: "mousedown" },
+    document.getElementById("details-pane-toggle"));
+  EventUtils.sendMouseEvent({ type: "mousedown" },
+    document.querySelectorAll("#details-pane tab")[2]);
+  yield onEvent;
+  yield testParamsTab("urlencoded");
+
+  onEvent = monitor.panelWin.once(EVENTS.TAB_UPDATED);
+  RequestsMenu.selectedIndex = 1;
+  yield onEvent;
+  yield testParamsTab("multipart");
+
+  return teardown(monitor);
+
+  function* testParamsTab(type) {
+    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 checkVisibility(box) {
+      is(tabpanel.querySelector("#request-params-box")
+        .hasAttribute("hidden"), !box.includes("params"),
+        "The request params box doesn't have the indended visibility.");
+      is(tabpanel.querySelector("#request-post-data-textarea-box")
+        .hasAttribute("hidden"), !box.includes("textarea"),
+        "The request post data textarea box doesn't have the indended visibility.");
+    }
+
+    is(tabpanel.querySelectorAll(".variables-view-scope").length, 2,
+      "There should be 2 param scopes displayed in this tabpanel.");
+    is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0,
+      "The empty notice should not be displayed in this tabpanel.");
+
+    let queryScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
+    let postScope = tabpanel.querySelectorAll(".variables-view-scope")[1];
+
+    is(queryScope.querySelector(".name").getAttribute("value"),
+      L10N.getStr("paramsQueryString"),
+      "The query scope doesn't have the correct title.");
+
+    is(postScope.querySelector(".name").getAttribute("value"),
+      L10N.getStr(type == "urlencoded" ? "paramsFormData" : "paramsPostPayload"),
+      "The post scope doesn't have the correct title.");
+
+    is(queryScope.querySelectorAll(".variables-view-variable .name")[0]
+      .getAttribute("value"),
+      "foo", "The first query param name was incorrect.");
+    is(queryScope.querySelectorAll(".variables-view-variable .value")[0]
+      .getAttribute("value"),
+      "\"bar\"", "The first query param value was incorrect.");
+    is(queryScope.querySelectorAll(".variables-view-variable .name")[1]
+      .getAttribute("value"),
+      "baz", "The second query param name was incorrect.");
+    is(queryScope.querySelectorAll(".variables-view-variable .value")[1]
+      .getAttribute("value"),
+      "\"42\"", "The second query param value was incorrect.");
+    is(queryScope.querySelectorAll(".variables-view-variable .name")[2]
+      .getAttribute("value"),
+      "type", "The third query param name was incorrect.");
+    is(queryScope.querySelectorAll(".variables-view-variable .value")[2]
+      .getAttribute("value"),
+      "\"" + type + "\"", "The third query param value was incorrect.");
+
+    if (type == "urlencoded") {
+      checkVisibility("params");
+
+      is(tabpanel.querySelectorAll(".variables-view-variable").length, 5,
+        "There should be 5 param values displayed in this tabpanel.");
+      is(queryScope.querySelectorAll(".variables-view-variable").length, 3,
+        "There should be 3 param values displayed in the query scope.");
+      is(postScope.querySelectorAll(".variables-view-variable").length, 2,
+        "There should be 2 param values displayed in the post scope.");
+
+      is(postScope.querySelectorAll(".variables-view-variable .name")[0]
+        .getAttribute("value"),
+        "foo", "The first post param name was incorrect.");
+      is(postScope.querySelectorAll(".variables-view-variable .value")[0]
+        .getAttribute("value"),
+        "\"bar\"", "The first post param value was incorrect.");
+      is(postScope.querySelectorAll(".variables-view-variable .name")[1]
+        .getAttribute("value"),
+        "baz", "The second post param name was incorrect.");
+      is(postScope.querySelectorAll(".variables-view-variable .value")[1]
+        .getAttribute("value"),
+        "\"123\"", "The second post param value was incorrect.");
+    } else {
+      checkVisibility("params textarea");
+
+      is(tabpanel.querySelectorAll(".variables-view-variable").length, 3,
+        "There should be 3 param values displayed in this tabpanel.");
+      is(queryScope.querySelectorAll(".variables-view-variable").length, 3,
+        "There should be 3 param values displayed in the query scope.");
+      is(postScope.querySelectorAll(".variables-view-variable").length, 0,
+        "There should be 0 param values displayed in the post scope.");
+
+      let editor = yield NetMonitorView.editor("#request-post-data-textarea");
+      let text = editor.getText();
+
+      ok(text.includes("Content-Disposition: form-data; name=\"text\""),
+        "The text shown in the source editor is incorrect (1.1).");
+      ok(text.includes("Content-Disposition: form-data; name=\"email\""),
+        "The text shown in the source editor is incorrect (2.1).");
+      ok(text.includes("Content-Disposition: form-data; name=\"range\""),
+        "The text shown in the source editor is incorrect (3.1).");
+      ok(text.includes("Content-Disposition: form-data; name=\"Custom field\""),
+        "The text shown in the source editor is incorrect (4.1).");
+      ok(text.includes("Some text..."),
+        "The text shown in the source editor is incorrect (2.2).");
+      ok(text.includes("42"),
+        "The text shown in the source editor is incorrect (3.2).");
+      ok(text.includes("Extra data"),
+        "The text shown in the source editor is incorrect (4.2).");
+      is(editor.getMode(), Editor.modes.text,
+        "The mode active in the source editor is incorrect.");
+    }
+  }
+});
--- a/devtools/client/netmonitor/test/browser_net_post-data-02.js
+++ b/devtools/client/netmonitor/test/browser_net_post-data-02.js
@@ -1,65 +1,71 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 /**
  * Tests if the POST requests display the correct information in the UI,
  * for raw payloads with attached content-type headers.
  */
 
-function test() {
-  initNetMonitor(POST_RAW_URL).then(([aTab, aDebuggee, aMonitor]) => {
-    info("Starting test... ");
-
-    let { document, L10N, NetMonitorView } = aMonitor.panelWin;
-    let { RequestsMenu, NetworkDetails } = NetMonitorView;
+add_task(function* () {
+  let [tab, , monitor] = yield initNetMonitor(POST_RAW_URL);
+  info("Starting test... ");
 
-    RequestsMenu.lazyUpdate = false;
-    NetworkDetails._params.lazyEmpty = false;
+  let { document, EVENTS, L10N, NetMonitorView } = monitor.panelWin;
+  let { RequestsMenu, NetworkDetails } = NetMonitorView;
 
-    waitForNetworkEvents(aMonitor, 0, 1).then(() => {
-      NetMonitorView.toggleDetailsPane({ visible: true }, 2);
-      RequestsMenu.selectedIndex = 0;
+  RequestsMenu.lazyUpdate = false;
+  NetworkDetails._params.lazyEmpty = false;
 
-      let TAB_UPDATED = aMonitor.panelWin.EVENTS.TAB_UPDATED;
-      waitFor(aMonitor.panelWin, TAB_UPDATED).then(() => {
-        let tab = document.querySelectorAll("#event-details-pane tab")[2];
-        let tabpanel = document.querySelectorAll("#event-details-pane tabpanel")[2];
+  let wait = waitForNetworkEvents(monitor, 0, 1);
+  yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
+    content.wrappedJSObject.performRequests();
+  });
+  yield wait;
 
-        is(tab.getAttribute("selected"), "true",
-          "The params tab in the network details pane should be selected.");
+  let onEvent = monitor.panelWin.once(EVENTS.TAB_UPDATED);
+  NetMonitorView.toggleDetailsPane({ visible: true }, 2);
+  RequestsMenu.selectedIndex = 0;
+  yield onEvent;
 
-        is(tabpanel.querySelector("#request-params-box")
-          .hasAttribute("hidden"), false,
-          "The request params box doesn't have the indended visibility.");
-        is(tabpanel.querySelector("#request-post-data-textarea-box")
-          .hasAttribute("hidden"), true,
-          "The request post data textarea box doesn't have the indended visibility.");
+  let tabEl = document.querySelectorAll("#event-details-pane tab")[2];
+  let tabpanel = document.querySelectorAll("#event-details-pane tabpanel")[2];
+
+  is(tabEl.getAttribute("selected"), "true",
+    "The params tab in the network details pane should be selected.");
 
-        is(tabpanel.querySelectorAll(".variables-view-scope").length, 1,
-          "There should be 1 param scopes 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.querySelector("#request-params-box")
+    .hasAttribute("hidden"), false,
+    "The request params box doesn't have the indended visibility.");
+  is(tabpanel.querySelector("#request-post-data-textarea-box")
+    .hasAttribute("hidden"), true,
+    "The request post data textarea box doesn't have the indended visibility.");
 
-        let postScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
-        is(postScope.querySelector(".name").getAttribute("value"),
-          L10N.getStr("paramsFormData"),
-          "The post scope doesn't have the correct title.");
+  is(tabpanel.querySelectorAll(".variables-view-scope").length, 1,
+    "There should be 1 param scopes displayed in this tabpanel.");
+  is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0,
+    "The empty notice should not be displayed in this tabpanel.");
+
+  let postScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
+  is(postScope.querySelector(".name").getAttribute("value"),
+    L10N.getStr("paramsFormData"),
+    "The post scope doesn't have the correct title.");
 
-        is(postScope.querySelectorAll(".variables-view-variable").length, 2,
-          "There should be 2 param values displayed in the post scope.");
-        is(postScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"),
-          "foo", "The first query param name was incorrect.");
-        is(postScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"),
-          "\"bar\"", "The first query param value was incorrect.");
-        is(postScope.querySelectorAll(".variables-view-variable .name")[1].getAttribute("value"),
-          "baz", "The second query param name was incorrect.");
-        is(postScope.querySelectorAll(".variables-view-variable .value")[1].getAttribute("value"),
-          "\"123\"", "The second query param value was incorrect.");
+  is(postScope.querySelectorAll(".variables-view-variable").length, 2,
+    "There should be 2 param values displayed in the post scope.");
+  is(postScope.querySelectorAll(".variables-view-variable .name")[0]
+    .getAttribute("value"),
+    "foo", "The first query param name was incorrect.");
+  is(postScope.querySelectorAll(".variables-view-variable .value")[0]
+    .getAttribute("value"),
+    "\"bar\"", "The first query param value was incorrect.");
+  is(postScope.querySelectorAll(".variables-view-variable .name")[1]
+    .getAttribute("value"),
+    "baz", "The second query param name was incorrect.");
+  is(postScope.querySelectorAll(".variables-view-variable .value")[1]
+    .getAttribute("value"),
+    "\"123\"", "The second query param value was incorrect.");
 
-        teardown(aMonitor).then(finish);
-      });
-    });
-
-    aDebuggee.performRequests();
-  });
-}
+  return teardown(monitor);
+});
--- a/devtools/client/netmonitor/test/browser_net_post-data-03.js
+++ b/devtools/client/netmonitor/test/browser_net_post-data-03.js
@@ -1,87 +1,96 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 /**
  * Tests if the POST requests display the correct information in the UI,
  * for raw payloads with content-type headers attached to the upload stream.
  */
 
-function test() {
-  initNetMonitor(POST_RAW_WITH_HEADERS_URL).then(([aTab, aDebuggee, aMonitor]) => {
-    info("Starting test... ");
+add_task(function* () {
+  let [tab, , monitor] = yield initNetMonitor(POST_RAW_WITH_HEADERS_URL);
+  info("Starting test... ");
+
+  let { document, EVENTS, L10N, NetMonitorView } = monitor.panelWin;
+  let { RequestsMenu } = NetMonitorView;
 
-    let { document, L10N, NetMonitorView } = aMonitor.panelWin;
-    let { RequestsMenu, NetworkDetails } = NetMonitorView;
-    let TAB_UPDATED = aMonitor.panelWin.EVENTS.TAB_UPDATED;
-    RequestsMenu.lazyUpdate = false;
+  RequestsMenu.lazyUpdate = false;
 
-    Task.spawn(function* () {
-      yield waitForNetworkEvents(aMonitor, 0, 1);
-
-      NetMonitorView.toggleDetailsPane({ visible: true });
-      RequestsMenu.selectedIndex = 0;
-
-      yield waitFor(aMonitor.panelWin, TAB_UPDATED);
+  let wait = waitForNetworkEvents(monitor, 0, 1);
+  yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
+    content.wrappedJSObject.performRequests();
+  });
+  yield wait;
 
-      let tab = document.querySelectorAll("#details-pane tab")[0];
-      let tabpanel = document.querySelectorAll("#details-pane tabpanel")[0];
-      let requestFromUploadScope = tabpanel.querySelectorAll(".variables-view-scope")[2];
+  let onEvent = monitor.panelWin.once(EVENTS.TAB_UPDATED);
+  NetMonitorView.toggleDetailsPane({ visible: true });
+  RequestsMenu.selectedIndex = 0;
+  yield onEvent;
+
+  let tabEl = document.querySelectorAll("#details-pane tab")[0];
+  let tabpanel = document.querySelectorAll("#details-pane tabpanel")[0];
+  let requestFromUploadScope = tabpanel.querySelectorAll(".variables-view-scope")[2];
 
-      is(tab.getAttribute("selected"), "true",
-        "The headers tab in the network details pane should be selected.");
-      is(tabpanel.querySelectorAll(".variables-view-scope").length, 3,
-        "There should be 3 header scopes displayed in this tabpanel.");
+  is(tabEl.getAttribute("selected"), "true",
+    "The headers tab in the network details pane should be selected.");
+  is(tabpanel.querySelectorAll(".variables-view-scope").length, 3,
+    "There should be 3 header scopes displayed in this tabpanel.");
 
-      is(requestFromUploadScope.querySelector(".name").getAttribute("value"),
-        L10N.getStr("requestHeadersFromUpload") + " (" +
-        L10N.getFormatStr("networkMenu.sizeKB", L10N.numberWithDecimals(74 / 1024, 3)) + ")",
-        "The request headers from upload scope doesn't have the correct title.");
+  is(requestFromUploadScope.querySelector(".name").getAttribute("value"),
+    L10N.getStr("requestHeadersFromUpload") + " (" +
+    L10N.getFormatStr("networkMenu.sizeKB", L10N.numberWithDecimals(74 / 1024, 3)) + ")",
+    "The request headers from upload scope doesn't have the correct title.");
 
-      is(requestFromUploadScope.querySelectorAll(".variables-view-variable").length, 2,
-        "There should be 2 header values displayed in the request headers from upload scope.");
+  is(requestFromUploadScope.querySelectorAll(".variables-view-variable").length, 2,
+    "There should be 2 headers displayed in the request headers from upload scope.");
 
-      is(requestFromUploadScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"),
-        "content-type", "The first request header name was incorrect.");
-      is(requestFromUploadScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"),
-        "\"application/x-www-form-urlencoded\"", "The first request header value was incorrect.");
-      is(requestFromUploadScope.querySelectorAll(".variables-view-variable .name")[1].getAttribute("value"),
-        "custom-header", "The second request header name was incorrect.");
-      is(requestFromUploadScope.querySelectorAll(".variables-view-variable .value")[1].getAttribute("value"),
-        "\"hello world!\"", "The second request header value was incorrect.");
+  is(requestFromUploadScope.querySelectorAll(".variables-view-variable .name")[0]
+    .getAttribute("value"),
+    "content-type", "The first request header name was incorrect.");
+  is(requestFromUploadScope.querySelectorAll(".variables-view-variable .value")[0]
+    .getAttribute("value"), "\"application/x-www-form-urlencoded\"",
+    "The first request header value was incorrect.");
+  is(requestFromUploadScope.querySelectorAll(".variables-view-variable .name")[1]
+    .getAttribute("value"),
+    "custom-header", "The second request header name was incorrect.");
+  is(requestFromUploadScope.querySelectorAll(".variables-view-variable .value")[1]
+    .getAttribute("value"),
+    "\"hello world!\"", "The second request header value was incorrect.");
 
-      EventUtils.sendMouseEvent({ type: "mousedown" },
-        document.querySelectorAll("#details-pane tab")[2]);
-
-      yield waitFor(aMonitor.panelWin, TAB_UPDATED);
+  onEvent = monitor.panelWin.once(EVENTS.TAB_UPDATED);
+  EventUtils.sendMouseEvent({ type: "mousedown" },
+    document.querySelectorAll("#details-pane tab")[2]);
+  yield onEvent;
 
-      tab = document.querySelectorAll("#details-pane tab")[2];
-      tabpanel = document.querySelectorAll("#details-pane tabpanel")[2];
-      let formDataScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
-
-      is(tab.getAttribute("selected"), "true",
-        "The response tab in the network details pane should be selected.");
-      is(tabpanel.querySelectorAll(".variables-view-scope").length, 1,
-        "There should be 1 header scope displayed in this tabpanel.");
+  tabEl = document.querySelectorAll("#details-pane tab")[2];
+  tabpanel = document.querySelectorAll("#details-pane tabpanel")[2];
+  let formDataScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
 
-      is(formDataScope.querySelector(".name").getAttribute("value"),
-        L10N.getStr("paramsFormData"),
-        "The form data scope doesn't have the correct title.");
+  is(tab.getAttribute("selected"), "true",
+    "The response tab in the network details pane should be selected.");
+  is(tabpanel.querySelectorAll(".variables-view-scope").length, 1,
+    "There should be 1 header scope displayed in this tabpanel.");
 
-      is(formDataScope.querySelectorAll(".variables-view-variable").length, 2,
-        "There should be 2 payload values displayed in the form data scope.");
+  is(formDataScope.querySelector(".name").getAttribute("value"),
+    L10N.getStr("paramsFormData"),
+    "The form data scope doesn't have the correct title.");
+
+  is(formDataScope.querySelectorAll(".variables-view-variable").length, 2,
+    "There should be 2 payload values displayed in the form data scope.");
 
-      is(formDataScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"),
-        "foo", "The first payload param name was incorrect.");
-      is(formDataScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"),
-        "\"bar\"", "The first payload param value was incorrect.");
-      is(formDataScope.querySelectorAll(".variables-view-variable .name")[1].getAttribute("value"),
-        "baz", "The second payload param name was incorrect.");
-      is(formDataScope.querySelectorAll(".variables-view-variable .value")[1].getAttribute("value"),
-        "\"123\"", "The second payload param value was incorrect.");
+  is(formDataScope.querySelectorAll(".variables-view-variable .name")[0]
+    .getAttribute("value"),
+    "foo", "The first payload param name was incorrect.");
+  is(formDataScope.querySelectorAll(".variables-view-variable .value")[0]
+    .getAttribute("value"),
+    "\"bar\"", "The first payload param value was incorrect.");
+  is(formDataScope.querySelectorAll(".variables-view-variable .name")[1]
+    .getAttribute("value"),
+    "baz", "The second payload param name was incorrect.");
+  is(formDataScope.querySelectorAll(".variables-view-variable .value")[1]
+    .getAttribute("value"),
+    "\"123\"", "The second payload param value was incorrect.");
 
-      teardown(aMonitor).then(finish);
-    });
-
-    aDebuggee.performRequests();
-  });
-}
+  return teardown(monitor);
+});
--- a/devtools/client/netmonitor/test/browser_net_prefs-and-l10n.js
+++ b/devtools/client/netmonitor/test/browser_net_prefs-and-l10n.js
@@ -2,55 +2,54 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 /**
  * Tests if the preferences and localization objects work correctly.
  */
 
-function test() {
-  initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
-    info("Starting test... ");
+add_task(function* () {
+  let [,, monitor] = yield initNetMonitor(SIMPLE_URL);
+  info("Starting test... ");
 
-    ok(aMonitor.panelWin.L10N,
-      "Should have a localization object available on the panel window.");
-    ok(aMonitor.panelWin.Prefs,
-      "Should have a preferences object available on the panel window.");
+  ok(monitor.panelWin.L10N,
+    "Should have a localization object available on the panel window.");
+  ok(monitor.panelWin.Prefs,
+    "Should have a preferences object available on the panel window.");
 
-    function testL10N() {
-      let { L10N } = aMonitor.panelWin;
-      is(typeof L10N.getStr("netmonitor.label"), "string",
-        "The getStr() method didn't return a valid string.");
-      is(typeof L10N.getFormatStr("networkMenu.totalMS", "foo"), "string",
-        "The getFormatStr() method didn't return a valid string.");
-    }
+  testL10N();
+  testPrefs();
+
+  return teardown(monitor);
 
-    function testPrefs() {
-      let { Prefs } = aMonitor.panelWin;
-
-      is(Prefs.networkDetailsWidth,
-        Services.prefs.getIntPref("devtools.netmonitor.panes-network-details-width"),
-        "Getting a pref should work correctly.");
+  function testL10N() {
+    let { L10N } = monitor.panelWin;
+    is(typeof L10N.getStr("netmonitor.label"), "string",
+      "The getStr() method didn't return a valid string.");
+    is(typeof L10N.getFormatStr("networkMenu.totalMS", "foo"), "string",
+      "The getFormatStr() method didn't return a valid string.");
+  }
 
-      let previousValue = Prefs.networkDetailsWidth;
-      let bogusValue = ~~(Math.random() * 100);
-      Prefs.networkDetailsWidth = bogusValue;
-      is(Prefs.networkDetailsWidth,
-        Services.prefs.getIntPref("devtools.netmonitor.panes-network-details-width"),
-        "Getting a pref after it has been modified should work correctly.");
-      is(Prefs.networkDetailsWidth, bogusValue,
-        "The pref wasn't updated correctly in the preferences object.");
+  function testPrefs() {
+    let { Prefs } = monitor.panelWin;
+
+    is(Prefs.networkDetailsWidth,
+      Services.prefs.getIntPref("devtools.netmonitor.panes-network-details-width"),
+      "Getting a pref should work correctly.");
 
-      Prefs.networkDetailsWidth = previousValue;
-      is(Prefs.networkDetailsWidth,
-        Services.prefs.getIntPref("devtools.netmonitor.panes-network-details-width"),
-        "Getting a pref after it has been modified again should work correctly.");
-      is(Prefs.networkDetailsWidth, previousValue,
-        "The pref wasn't updated correctly again in the preferences object.");
-    }
+    let previousValue = Prefs.networkDetailsWidth;
+    let bogusValue = ~~(Math.random() * 100);
+    Prefs.networkDetailsWidth = bogusValue;
+    is(Prefs.networkDetailsWidth,
+      Services.prefs.getIntPref("devtools.netmonitor.panes-network-details-width"),
+      "Getting a pref after it has been modified should work correctly.");
+    is(Prefs.networkDetailsWidth, bogusValue,
+      "The pref wasn't updated correctly in the preferences object.");
 
-    testL10N();
-    testPrefs();
-
-    teardown(aMonitor).then(finish);
-  });
-}
+    Prefs.networkDetailsWidth = previousValue;
+    is(Prefs.networkDetailsWidth,
+      Services.prefs.getIntPref("devtools.netmonitor.panes-network-details-width"),
+      "Getting a pref after it has been modified again should work correctly.");
+    is(Prefs.networkDetailsWidth, previousValue,
+      "The pref wasn't updated correctly again in the preferences object.");
+  }
+});
--- a/devtools/client/netmonitor/test/browser_net_prefs-reload.js
+++ b/devtools/client/netmonitor/test/browser_net_prefs-reload.js
@@ -1,233 +1,212 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 /**
  * Tests if the prefs that should survive across tool reloads work.
  */
 
-function test() {
-  initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
-    info("Starting test... ");
+add_task(function* () {
+  let [,, monitor] = yield initNetMonitor(SIMPLE_URL);
+  info("Starting test... ");
 
-    // This test reopens the network monitor a bunch of times, for different
-    // hosts (bottom, side, window). This seems to be slow on debug builds.
-    requestLongerTimeout(3);
+  // This test reopens the network monitor a bunch of times, for different
+  // hosts (bottom, side, window). This seems to be slow on debug builds.
+  requestLongerTimeout(3);
 
-    // Use these getters instead of caching instances inside the panel win,
-    // since the tool is reopened a bunch of times during this test
-    // and the instances will differ.
-    let getView = () => aMonitor.panelWin.NetMonitorView;
-    let getController = () => aMonitor.panelWin.NetMonitorController;
+  // Use these getters instead of caching instances inside the panel win,
+  // since the tool is reopened a bunch of times during this test
+  // and the instances will differ.
+  let getView = () => monitor.panelWin.NetMonitorView;
 
-    let prefsToCheck = {
-      filters: {
-        // A custom new value to be used for the verified preference.
-        newValue: ["html", "css"],
-        // Getter used to retrieve the current value from the frontend, in order
-        // to verify that the pref was applied properly.
-        validateValue: ($) => getView().RequestsMenu._activeFilters,
-        // Predicate used to modify the frontend when setting the new pref value,
-        // before trying to validate the changes.
-        modifyFrontend: ($, aValue) => aValue.forEach(e => getView().RequestsMenu.filterOn(e))
-      },
-      networkDetailsWidth: {
-        newValue: ~~(Math.random() * 200 + 100),
-        validateValue: ($) => ~~$("#details-pane").getAttribute("width"),
-        modifyFrontend: ($, aValue) => $("#details-pane").setAttribute("width", aValue)
-      },
-      networkDetailsHeight: {
-        newValue: ~~(Math.random() * 300 + 100),
-        validateValue: ($) => ~~$("#details-pane").getAttribute("height"),
-        modifyFrontend: ($, aValue) => $("#details-pane").setAttribute("height", aValue)
-      }
-      /* add more prefs here... */
-    };
+  let prefsToCheck = {
+    filters: {
+      // A custom new value to be used for the verified preference.
+      newValue: ["html", "css"],
+      // Getter used to retrieve the current value from the frontend, in order
+      // to verify that the pref was applied properly.
+      validateValue: ($) => getView().RequestsMenu._activeFilters,
+      // Predicate used to modify the frontend when setting the new pref value,
+      // before trying to validate the changes.
+      modifyFrontend: ($, value) => value.forEach(e => getView().RequestsMenu.filterOn(e))
+    },
+    networkDetailsWidth: {
+      newValue: ~~(Math.random() * 200 + 100),
+      validateValue: ($) => ~~$("#details-pane").getAttribute("width"),
+      modifyFrontend: ($, value) => $("#details-pane").setAttribute("width", value)
+    },
+    networkDetailsHeight: {
+      newValue: ~~(Math.random() * 300 + 100),
+      validateValue: ($) => ~~$("#details-pane").getAttribute("height"),
+      modifyFrontend: ($, value) => $("#details-pane").setAttribute("height", value)
+    }
+    /* add more prefs here... */
+  };
 
-    function storeFirstPrefValues() {
-      info("Caching initial pref values.");
+  yield testBottom();
+  yield testSide();
+  yield testWindow();
 
-      for (let name in prefsToCheck) {
-        let currentValue = aMonitor.panelWin.Prefs[name];
-        prefsToCheck[name].firstValue = currentValue;
-      }
-    }
+  info("Moving toolbox back to the bottom...");
+  yield monitor._toolbox.switchHost(Toolbox.HostType.BOTTOM);
+  return teardown(monitor);
 
-    function validateFirstPrefValues() {
-      info("Validating current pref values to the UI elements.");
-
-      for (let name in prefsToCheck) {
-        let currentValue = aMonitor.panelWin.Prefs[name];
-        let firstValue = prefsToCheck[name].firstValue;
-        let validateValue = prefsToCheck[name].validateValue;
+  function storeFirstPrefValues() {
+    info("Caching initial pref values.");
 
-        is(currentValue.toSource(), firstValue.toSource(),
-          "Pref " + name + " should be equal to first value: " + firstValue);
-        is(currentValue.toSource(), validateValue(aMonitor.panelWin.$).toSource(),
-          "Pref " + name + " should validate: " + currentValue);
-      }
+    for (let name in prefsToCheck) {
+      let currentValue = monitor.panelWin.Prefs[name];
+      prefsToCheck[name].firstValue = currentValue;
     }
+  }
 
-    function modifyFrontend() {
-      info("Modifying UI elements to the specified new values.");
+  function validateFirstPrefValues() {
+    info("Validating current pref values to the UI elements.");
 
-      for (let name in prefsToCheck) {
-        let currentValue = aMonitor.panelWin.Prefs[name];
-        let firstValue = prefsToCheck[name].firstValue;
-        let newValue = prefsToCheck[name].newValue;
-        let validateValue = prefsToCheck[name].validateValue;
-        let modifyFrontend = prefsToCheck[name].modifyFrontend;
+    for (let name in prefsToCheck) {
+      let currentValue = monitor.panelWin.Prefs[name];
+      let firstValue = prefsToCheck[name].firstValue;
+      let validateValue = prefsToCheck[name].validateValue;
 
-        modifyFrontend(aMonitor.panelWin.$, newValue);
-        info("Modified UI element affecting " + name + " to: " + newValue);
-
-        is(currentValue.toSource(), firstValue.toSource(),
-          "Pref " + name + " should still be equal to first value: " + firstValue);
-        isnot(currentValue.toSource(), newValue.toSource(),
-          "Pref " + name + " should't yet be equal to second value: " + newValue);
-        is(newValue.toSource(), validateValue(aMonitor.panelWin.$).toSource(),
-          "The UI element affecting " + name + " should validate: " + newValue);
-      }
+      is(currentValue.toSource(), firstValue.toSource(),
+        "Pref " + name + " should be equal to first value: " + firstValue);
+      is(currentValue.toSource(), validateValue(monitor.panelWin.$).toSource(),
+        "Pref " + name + " should validate: " + currentValue);
     }
+  }
 
-    function validateNewPrefValues() {
-      info("Invalidating old pref values to the modified UI elements.");
+  function modifyFrontend() {
+    info("Modifying UI elements to the specified new values.");
 
-      for (let name in prefsToCheck) {
-        let currentValue = aMonitor.panelWin.Prefs[name];
-        let firstValue = prefsToCheck[name].firstValue;
-        let newValue = prefsToCheck[name].newValue;
-        let validateValue = prefsToCheck[name].validateValue;
+    for (let name in prefsToCheck) {
+      let currentValue = monitor.panelWin.Prefs[name];
+      let firstValue = prefsToCheck[name].firstValue;
+      let newValue = prefsToCheck[name].newValue;
+      let validateValue = prefsToCheck[name].validateValue;
+      let modFrontend = prefsToCheck[name].modifyFrontend;
+
+      modFrontend(monitor.panelWin.$, newValue);
+      info("Modified UI element affecting " + name + " to: " + newValue);
 
-        isnot(currentValue.toSource(), firstValue.toSource(),
-          "Pref " + name + " should't be equal to first value: " + firstValue);
-        is(currentValue.toSource(), newValue.toSource(),
-          "Pref " + name + " should now be equal to second value: " + newValue);
-        is(newValue.toSource(), validateValue(aMonitor.panelWin.$).toSource(),
-          "The UI element affecting " + name + " should validate: " + newValue);
-      }
+      is(currentValue.toSource(), firstValue.toSource(),
+        "Pref " + name + " should still be equal to first value: " + firstValue);
+      isnot(currentValue.toSource(), newValue.toSource(),
+        "Pref " + name + " should't yet be equal to second value: " + newValue);
+      is(newValue.toSource(), validateValue(monitor.panelWin.$).toSource(),
+        "The UI element affecting " + name + " should validate: " + newValue);
     }
+  }
 
-    function resetFrontend() {
-      info("Resetting UI elements to the cached initial pref values.");
+  function validateNewPrefValues() {
+    info("Invalidating old pref values to the modified UI elements.");
 
-      for (let name in prefsToCheck) {
-        let currentValue = aMonitor.panelWin.Prefs[name];
-        let firstValue = prefsToCheck[name].firstValue;
-        let newValue = prefsToCheck[name].newValue;
-        let validateValue = prefsToCheck[name].validateValue;
-        let modifyFrontend = prefsToCheck[name].modifyFrontend;
+    for (let name in prefsToCheck) {
+      let currentValue = monitor.panelWin.Prefs[name];
+      let firstValue = prefsToCheck[name].firstValue;
+      let newValue = prefsToCheck[name].newValue;
+      let validateValue = prefsToCheck[name].validateValue;
 
-        modifyFrontend(aMonitor.panelWin.$, firstValue);
-        info("Modified UI element affecting " + name + " to: " + firstValue);
-
-        isnot(currentValue.toSource(), firstValue.toSource(),
-          "Pref " + name + " should't yet be equal to first value: " + firstValue);
-        is(currentValue.toSource(), newValue.toSource(),
-          "Pref " + name + " should still be equal to second value: " + newValue);
-        is(firstValue.toSource(), validateValue(aMonitor.panelWin.$).toSource(),
-          "The UI element affecting " + name + " should validate: " + firstValue);
-      }
+      isnot(currentValue.toSource(), firstValue.toSource(),
+        "Pref " + name + " should't be equal to first value: " + firstValue);
+      is(currentValue.toSource(), newValue.toSource(),
+        "Pref " + name + " should now be equal to second value: " + newValue);
+      is(newValue.toSource(), validateValue(monitor.panelWin.$).toSource(),
+        "The UI element affecting " + name + " should validate: " + newValue);
     }
+  }
 
-    function testBottom() {
-      info("Testing prefs reload for a bottom host.");
-      storeFirstPrefValues();
+  function resetFrontend() {
+    info("Resetting UI elements to the cached initial pref values.");
 
-      // Validate and modify while toolbox is on the bottom.
-      validateFirstPrefValues();
-      modifyFrontend();
+    for (let name in prefsToCheck) {
+      let currentValue = monitor.panelWin.Prefs[name];
+      let firstValue = prefsToCheck[name].firstValue;
+      let newValue = prefsToCheck[name].newValue;
+      let validateValue = prefsToCheck[name].validateValue;
+      let modFrontend = prefsToCheck[name].modifyFrontend;
 
-      return restartNetMonitor(aMonitor)
-        .then(([,, aNewMonitor]) => {
-          aMonitor = aNewMonitor;
+      modFrontend(monitor.panelWin.$, firstValue);
+      info("Modified UI element affecting " + name + " to: " + firstValue);
 
-          // Revalidate and reset frontend while toolbox is on the bottom.
-          validateNewPrefValues();
-          resetFrontend();
+      isnot(currentValue.toSource(), firstValue.toSource(),
+        "Pref " + name + " should't yet be equal to first value: " + firstValue);
+      is(currentValue.toSource(), newValue.toSource(),
+        "Pref " + name + " should still be equal to second value: " + newValue);
+      is(firstValue.toSource(), validateValue(monitor.panelWin.$).toSource(),
+        "The UI element affecting " + name + " should validate: " + firstValue);
+    }
+  }
 
-          return restartNetMonitor(aMonitor);
-        })
-        .then(([,, aNewMonitor]) => {
-          aMonitor = aNewMonitor;
-
-          // Revalidate.
-          validateFirstPrefValues();
-        });
-    }
+  function* testBottom() {
+    info("Testing prefs reload for a bottom host.");
+    storeFirstPrefValues();
 
-    function testSide() {
-      info("Moving toolbox to the side...");
+    // Validate and modify while toolbox is on the bottom.
+    validateFirstPrefValues();
+    modifyFrontend();
 
-      return aMonitor._toolbox.switchHost(Toolbox.HostType.SIDE)
-        .then(() => {
-          info("Testing prefs reload for a side host.");
-          storeFirstPrefValues();
+    let [,, newMonitor] = yield restartNetMonitor(monitor);
+    monitor = newMonitor;
 
-          // Validate and modify frontend while toolbox is on the side.
-          validateFirstPrefValues();
-          modifyFrontend();
+    // Revalidate and reset frontend while toolbox is on the bottom.
+    validateNewPrefValues();
+    resetFrontend();
 
-          return restartNetMonitor(aMonitor);
-        })
-        .then(([,, aNewMonitor]) => {
-          aMonitor = aNewMonitor;
+    let [,, newMonitor2] = yield restartNetMonitor(monitor);
+    monitor = newMonitor2;
 
-          // Revalidate and reset frontend while toolbox is on the side.
-          validateNewPrefValues();
-          resetFrontend();
+    // Revalidate.
+    validateFirstPrefValues();
+  }
 
-          return restartNetMonitor(aMonitor);
-        })
-        .then(([,, aNewMonitor]) => {
-          aMonitor = aNewMonitor;
+  function* testSide() {
+    info("Moving toolbox to the side...");
+
+    yield monitor._toolbox.switchHost(Toolbox.HostType.SIDE);
+    info("Testing prefs reload for a side host.");
+    storeFirstPrefValues();
 
-          // Revalidate.
-          validateFirstPrefValues();
-        });
-    }
+    // Validate and modify frontend while toolbox is on the side.
+    validateFirstPrefValues();
+    modifyFrontend();
 
-    function testWindow() {
-      info("Moving toolbox into a window...");
+    let [,, newMonitor] = yield restartNetMonitor(monitor);
+    monitor = newMonitor;
 
-      return aMonitor._toolbox.switchHost(Toolbox.HostType.WINDOW)
-        .then(() => {
-          info("Testing prefs reload for a window host.");
-          storeFirstPrefValues();
+    // Revalidate and reset frontend while toolbox is on the side.
+    validateNewPrefValues();
+    resetFrontend();
 
-          // Validate and modify frontend while toolbox is in a window.
-          validateFirstPrefValues();
-          modifyFrontend();
+    let [,, newMonitor2] = yield restartNetMonitor(monitor);
+    monitor = newMonitor2;
 
-          return restartNetMonitor(aMonitor);
-        })
-        .then(([,, aNewMonitor]) => {
-          aMonitor = aNewMonitor;
+    // Revalidate.
+    validateFirstPrefValues();
+  }
+
+  function* testWindow() {
+    info("Moving toolbox into a window...");
 
-          // Revalidate and reset frontend while toolbox is in a window.
-          validateNewPrefValues();
-          resetFrontend();
+    yield monitor._toolbox.switchHost(Toolbox.HostType.WINDOW);
+    info("Testing prefs reload for a window host.");
+    storeFirstPrefValues();
 
-          return restartNetMonitor(aMonitor);
-        })
-        .then(([,, aNewMonitor]) => {
-          aMonitor = aNewMonitor;
+    // Validate and modify frontend while toolbox is in a window.
+    validateFirstPrefValues();
+    modifyFrontend();
 
-          // Revalidate.
-          validateFirstPrefValues();
-        });
-    }
+    let [,, newMonitor] = yield restartNetMonitor(monitor);
+    monitor = newMonitor;
 
-    function cleanupAndFinish() {
-      info("Moving toolbox back to the bottom...");
+    // Revalidate and reset frontend while toolbox is in a window.
+    validateNewPrefValues();
+    resetFrontend();
 
-      aMonitor._toolbox.switchHost(Toolbox.HostType.BOTTOM)
-        .then(() => teardown(aMonitor))
-        .then(finish);
-    }
+    let [,, newMonitor2] = yield restartNetMonitor(monitor);
+    monitor = newMonitor2;
 
-    testBottom()
-      .then(testSide)
-      .then(testWindow)
-      .then(cleanupAndFinish);
-  });
-}
+    // Revalidate.
+    validateFirstPrefValues();
+  }
+});