Bug 1297362 - Part 6: Eliminate CPOWs from Netmonitor mochitests HAR r?ochameau draft
authorJarda Snajdr <jsnajdr@gmail.com>
Fri, 26 Aug 2016 15:47:30 +0200
changeset 406770 1f3ba622e2b117343a1b90d5be6b384b2f74a786
parent 406769 e2560e8eae0459a79d94ff2a4892e86441ead72f
child 406771 c5ea28cfda0bc2894719a5aa656348c2278687d3
push id27819
push userbmo:jsnajdr@gmail.com
push dateMon, 29 Aug 2016 13:56:30 +0000
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");