Bug 1329245 - Part 1: remove moot add_task.js since bug 1078657 gave us SpawnTask.js. r=bkelly
authorAndrew Sutherland <asutherland@asutherland.org>
Sun, 04 Jun 2017 19:52:29 -0400
changeset 410577 49836ef36f6745a0071c5d35ee0fc34ce328cae8
parent 410576 6c45d8772e0bda999aa590b78463844ed847fe17
child 410578 81eec5831af85c68447179ee3933e63fe054ef21
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbkelly
bugs1329245, 1078657
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1329245 - Part 1: remove moot add_task.js since bug 1078657 gave us SpawnTask.js. r=bkelly The use of add_task.js was ever only intended to be temporary until bug 1078657 landed.
dom/network/tests/add_task.js
dom/network/tests/chrome.ini
dom/network/tests/mochitest.ini
dom/network/tests/test_tcpsocket_client_and_server_basics.html
dom/network/tests/test_tcpsocket_jsm.html
deleted file mode 100644
--- a/dom/network/tests/add_task.js
+++ /dev/null
@@ -1,83 +0,0 @@
-// Temporary implementation of add_task for mochitest-plain until bug 1078657 is
-// implemented.
-SimpleTest.waitForExplicitFinish();
-(function(scope) {
-  var pendingTasks = [];
-  var pendingPromise = null;
-
-  // Strict spawn function that takes a known generatorFunc and assumes that
-  // every yielded value will be a Promise.  If nesting is desired, then yield*
-  // should be used!
-  function spawn(generatorFunc) {
-    return new Promise(function(resolve, reject) {
-      try {
-        var iterator = generatorFunc();
-      }
-      catch (ex) {
-        ok(false, 'Problem invoking generator func: ' + ex + ': ' + ex.stack);
-        return;
-      }
-      var stepResolved = function(result) {
-        try {
-          var iterStep = iterator.next(result);
-        }
-        catch (ex) {
-          ok(false, 'Problem invoking iterator step: ' + ex + ': ' + ex.stack);
-          return;
-        }
-        if (iterStep.done) {
-          resolve(iterStep.value);
-          return;
-        }
-        if (!iterStep.value || !iterStep.value.then) {
-          ok(false, 'Iterator step returned non-Promise: ' + iterStep.value);
-        }
-        iterStep.value.then(stepResolved, generalErrback);
-      };
-      stepResolved();
-    });
-  }
-
-  function maybeSpawn(promiseOrGenerator) {
-    if (promiseOrGenerator.then) {
-      return promiseOrGenerator;
-    }
-    return spawn(promiseOrGenerator);
-  }
-
-  scope.add_task = function(thing) {
-    pendingTasks.push(thing);
-  };
-
-  function generalErrback(ex) {
-    ok(false,
-       'A rejection happened: ' +
-       (ex ? (ex + ': ' + ex.stack) : ''));
-  }
-
-  function runNextTask() {
-    if (pendingTasks.length) {
-      pendingPromise = maybeSpawn(pendingTasks.shift());
-      pendingPromise.then(runNextTask, generalErrback);
-    } else {
-      SimpleTest.finish();
-    }
-  }
-
-  // Trigger runNextTask after we think all JS files have been loaded.
-  // The primary goal is that we can call SimpleTest.finish() after all test
-  // code has been loaded and run.  We gate this based on the document's
-  // readyState.
-  var running = false;
-  function maybeStartRunning() {
-    if (!running && document.readyState === 'complete') {
-      running = true;
-      document.removeEventListener('readystateChange', maybeStartRunning);
-      // Defer to a subsequent turn of the event loop to let micro-tasks and any
-      // other clever setTimeout(0) instances run first.
-      window.setTimeout(runNextTask, 0);
-    }
-  }
-  document.addEventListener('readystatechange', maybeStartRunning);
-  maybeStartRunning();
-})(this);
--- a/dom/network/tests/chrome.ini
+++ b/dom/network/tests/chrome.ini
@@ -1,12 +1,11 @@
 [DEFAULT]
 support-files =
   tcpsocket_test.jsm
   test_tcpsocket_client_and_server_basics.js
-  add_task.js
   file_udpsocket_iframe.html
 
 [test_tcpsocket_jsm.html]
 [test_tcpsocket_client_and_server_basics.html]
 [test_tcpsocket_enabled_with_perm.html]
 [test_tcpsocket_legacy.html]
 [test_udpsocket.html]
--- a/dom/network/tests/mochitest.ini
+++ b/dom/network/tests/mochitest.ini
@@ -1,11 +1,10 @@
 [DEFAULT]
 support-files =
-  add_task.js
   worker_network_basics.js
 
 [test_network_basics.html]
 skip-if = toolkit == 'android'
 [test_network_basics_worker.html]
 skip-if = toolkit == 'android'
 [test_tcpsocket_default_permissions.html]
 [test_tcpsocket_enabled_no_perm.html]
--- a/dom/network/tests/test_tcpsocket_client_and_server_basics.html
+++ b/dom/network/tests/test_tcpsocket_client_and_server_basics.html
@@ -6,18 +6,18 @@ separate xpcshell incarnations.  This mi
 of bug 1084245 in order to get coverage of the tests from content.
 
 https://bugzilla.mozilla.org/show_bug.cgi?id=1084245
 -->
 <head>
   <meta charset="utf-8">
   <title>Test for Bug 1084245</title>
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
-  <script type="application/javascript" src="add_task.js"></script>
   <script type="application/javascript">
     function createServer(port, options, backlog) {
       return new TCPServerSocket(port, options, backlog);
     }
 
     function createSocket(host, port, options) {
       return new TCPSocket(host, port, options);
     }
--- a/dom/network/tests/test_tcpsocket_jsm.html
+++ b/dom/network/tests/test_tcpsocket_jsm.html
@@ -1,21 +1,21 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 -->
 <head>
   <meta charset="utf-8">
   <title>Test for 1207090</title>
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
   <script type="application/javascript">
     Components.utils.import("chrome://mochitests/content/chrome/dom/network/tests/tcpsocket_test.jsm");
   </script>
-  <script type="application/javascript" src="add_task.js"></script>
   <script type="application/javascript" src="test_tcpsocket_client_and_server_basics.js"></script>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1207090">Mozilla Bug 1207090</a>
 <p id="display"></p>
 <div id="content" style="display: none">
 </div>
 <pre id="test">