Bug 1297362 - Part 6: Eliminate CPOWs from Netmonitor mochitests HAR r=ochameau
authorJarda Snajdr <jsnajdr@gmail.com>
Fri, 26 Aug 2016 15:47:30 +0200
changeset 311742 a3467eb2df378cf4d65cfdf79070b85079d422d6
parent 311741 dc188ac077e9dba6070e3d1017ce74cd9ecfd981
child 311743 03104edc024dbf197d5cdcf482e0997407a52ec9
push id20417
push userryanvm@gmail.com
push dateTue, 30 Aug 2016 13:55:34 +0000
treeherderfx-team@b18c8bcdc116 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1297362
milestone51.0a1
Bug 1297362 - Part 6: Eliminate CPOWs from Netmonitor mochitests HAR r=ochameau MozReview-Commit-ID: LoomRfTAvOU
devtools/client/netmonitor/har/test/browser_net_har_copy_all_as_har.js
devtools/client/netmonitor/har/test/browser_net_har_post_data.js
devtools/client/netmonitor/har/test/browser_net_har_throttle_upload.js
--- a/devtools/client/netmonitor/har/test/browser_net_har_copy_all_as_har.js
+++ b/devtools/client/netmonitor/har/test/browser_net_har_copy_all_as_har.js
@@ -2,30 +2,29 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 /**
  * Basic tests for exporting Network panel content into HAR format.
  */
 add_task(function* () {
-  // The first 'tab' isn't necessary so, don't create a var for it
-  // to avoid eslint warning.
-  let [ , debuggee, monitor ] = yield initNetMonitor(SIMPLE_URL);
+  let [tab, , monitor ] = yield initNetMonitor(SIMPLE_URL);
 
   info("Starting test... ");
 
   let { NetMonitorView } = monitor.panelWin;
   let { RequestsMenu } = NetMonitorView;
 
   RequestsMenu.lazyUpdate = false;
 
-  debuggee.location.reload();
+  let wait = waitForNetworkEvents(monitor, 1);
+  tab.linkedBrowser.reload();
+  yield wait;
 
-  yield waitForNetworkEvents(monitor, 1);
   yield RequestsMenu.copyAllAsHar();
 
   let jsonString = SpecialPowers.getClipboardData("text/unicode");
   let har = JSON.parse(jsonString);
 
   // Check out HAR log
   isnot(har.log, null, "The HAR log must exist");
   is(har.log.creator.name, "Firefox", "The creator field must be set");
@@ -41,10 +40,10 @@ add_task(function* () {
   is(entry.response.statusText, "OK", "Check response status text");
   is(entry.response.headers.length, 6, "Check number of response headers");
   is(entry.response.content.mimeType, // eslint-disable-line
     "text/html", "Check response content type"); // eslint-disable-line
   isnot(entry.response.content.text, undefined, // eslint-disable-line
     "Check response body");
   isnot(entry.timings, undefined, "Check timings");
 
-  teardown(monitor).then(finish);
+  return teardown(monitor);
 });
--- a/devtools/client/netmonitor/har/test/browser_net_har_post_data.js
+++ b/devtools/client/netmonitor/har/test/browser_net_har_post_data.js
@@ -2,31 +2,32 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 /**
  * Tests for exporting POST data into HAR format.
  */
 add_task(function* () {
-  // The first 'tab' isn't necessary so, don't create a var for it
-  // to avoid eslint warning.
-  let [ , debuggee, monitor ] = yield initNetMonitor(
+  let [tab, , monitor ] = yield initNetMonitor(
     HAR_EXAMPLE_URL + "html_har_post-data-test-page.html");
 
   info("Starting test... ");
 
   let { NetMonitorView } = monitor.panelWin;
   let { RequestsMenu } = NetMonitorView;
 
   RequestsMenu.lazyUpdate = false;
 
   // Execute one POST request on the page and wait till its done.
-  debuggee.executeTest();
-  yield waitForNetworkEvents(monitor, 0, 1);
+  let wait = waitForNetworkEvents(monitor, 0, 1);
+  yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
+    content.wrappedJSObject.executeTest();
+  });
+  yield wait;
 
   // Copy HAR into the clipboard (asynchronous).
   let jsonString = yield RequestsMenu.copyAllAsHar();
   let har = JSON.parse(jsonString);
 
   // Check out the HAR log.
   isnot(har.log, null, "The HAR log must exist");
   is(har.log.pages.length, 1, "There must be one page");
@@ -34,10 +35,10 @@ add_task(function* () {
 
   let entry = har.log.entries[0];
   is(entry.request.postData.mimeType, "application/json",
     "Check post data content type");
   is(entry.request.postData.text, "{'first': 'John', 'last': 'Doe'}",
     "Check post data payload");
 
   // Clean up
-  teardown(monitor).then(finish);
+  return teardown(monitor);
 });
--- a/devtools/client/netmonitor/har/test/browser_net_har_throttle_upload.js
+++ b/devtools/client/netmonitor/har/test/browser_net_har_throttle_upload.js
@@ -6,17 +6,17 @@
 "use strict";
 
 add_task(function* () {
   yield throttleUploadTest(true);
   yield throttleUploadTest(false);
 });
 
 function* throttleUploadTest(actuallyThrottle) {
-  let [ , debuggee, monitor ] = yield initNetMonitor(
+  let [tab, , monitor ] = yield initNetMonitor(
     HAR_EXAMPLE_URL + "html_har_post-data-test-page.html");
 
   info("Starting test... (actuallyThrottle = " + actuallyThrottle + ")");
 
   let { NetMonitorView } = monitor.panelWin;
   let { RequestsMenu } = NetMonitorView;
 
   const size = 4096;
@@ -39,18 +39,21 @@ function* throttleUploadTest(actuallyThr
   client.setPreferences(request, response => {
     deferred.resolve(response);
   });
   yield deferred.promise;
 
   RequestsMenu.lazyUpdate = false;
 
   // Execute one POST request on the page and wait till its done.
-  debuggee.executeTest2(size);
-  yield waitForNetworkEvents(monitor, 0, 1);
+  let wait = waitForNetworkEvents(monitor, 0, 1);
+  yield ContentTask.spawn(tab.linkedBrowser, { size }, function* (args) {
+    content.wrappedJSObject.executeTest2(args.size);
+  });
+  yield wait;
 
   // Copy HAR into the clipboard (asynchronous).
   let jsonString = yield RequestsMenu.copyAllAsHar();
   let har = JSON.parse(jsonString);
 
   // Check out the HAR log.
   isnot(har.log, null, "The HAR log must exist");
   is(har.log.pages.length, 1, "There must be one page");