Bug 1446833: Part 2 - Stop using Task.jsm in xpcshell/head.js. r=florian
authorKris Maglione <maglione.k@gmail.com>
Sun, 18 Mar 2018 15:27:04 -0700
changeset 409129 e2a78fa784c69656b837b9034d008046576fa60f
parent 409128 bd915117e71156d6518ee948f61105263dd5bb4a
child 409130 1f99f10985f541a9e192ffe3c59b06ef91dce1f1
push id33676
push usertoros@mozilla.com
push dateWed, 21 Mar 2018 10:03:44 +0000
treeherdermozilla-central@e636edf00e6f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflorian
bugs1446833
milestone61.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 1446833: Part 2 - Stop using Task.jsm in xpcshell/head.js. r=florian MozReview-Commit-ID: 6vSpwih9Fnr
netwerk/test/unit/test_NetUtil.js
netwerk/test/unit/test_file_protocol.js
netwerk/test/unit/test_predictor.js
netwerk/test/unit/test_reopen.js
security/manager/ssl/tests/unit/test_cert_blocklist.js
services/crypto/tests/unit/test_jwcrypto.js
testing/xpcshell/head.js
testing/xpcshell/selftest.py
toolkit/components/places/tests/unit/test_sql_guid_functions.js
--- a/netwerk/test/unit/test_NetUtil.js
+++ b/netwerk/test/unit/test_NetUtil.js
@@ -572,16 +572,17 @@ function test_newChannel_with_options()
 
   function checkEqualToIOSChannel(channel) {
     Assert.ok(iosChannel.URI.equals(channel.URI));  
   }
 
   checkEqualToIOSChannel(NetUtil.newChannel({
     uri,
     loadingPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+    securityFlags: Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
     contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER,
   }));
 
   checkEqualToIOSChannel(NetUtil.newChannel({
     uri,
     loadUsingSystemPrincipal: true,
   }));
 
@@ -593,27 +594,32 @@ function test_newChannel_with_wrong_opti
   let uri = "data:text/plain,";
   let systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
 
   Assert.throws(() => {
     NetUtil.newChannel({ uri, loadUsingSystemPrincipal: true }, null, null);
   }, /requires a single object argument/);
 
   Assert.throws(() => {
-    NetUtil.newChannel({});
+    NetUtil.newChannel({ loadUsingSystemPrincipal: true });
   }, /requires the 'uri' property/);
 
   Assert.throws(() => {
-    NetUtil.newChannel({ uri });
+    NetUtil.newChannel({ uri, loadingNode: true });
+  }, /requires the 'securityFlags'/);
+
+  Assert.throws(() => {
+    NetUtil.newChannel({ uri, securityFlags: 0 });
   }, /requires at least one of the 'loadingNode'/);
 
   Assert.throws(() => {
     NetUtil.newChannel({
       uri,
       loadingPrincipal: systemPrincipal,
+      securityFlags: 0,
     });
   }, /requires the 'contentPolicyType'/);
 
   Assert.throws(() => {
     NetUtil.newChannel({
       uri,
       loadUsingSystemPrincipal: systemPrincipal,
     });
@@ -850,16 +856,16 @@ function test_readInputStreamToString_in
   test_deprecated_newChannel_API_with_nsIFile,
   test_readInputStreamToString,
   test_readInputStreamToString_no_input_stream,
   test_readInputStreamToString_no_bytes_arg,
   test_readInputStreamToString_blocking_stream,
   test_readInputStreamToString_too_many_bytes,
   test_readInputStreamToString_with_charset,
   test_readInputStreamToString_invalid_sequence,
-].forEach(add_test);
+].forEach(f => add_test(f));
 var index = 0;
 
 function run_test()
 {
   run_next_test();
 }
 
--- a/netwerk/test/unit/test_file_protocol.js
+++ b/netwerk/test/unit/test_file_protocol.js
@@ -8,17 +8,17 @@ const special_type = "application/x-our-
 
 [
   test_read_file,
   test_read_dir_1,
   test_read_dir_2,
   test_upload_file,
   test_load_replace,
   do_test_finished
-].forEach(add_test);
+].forEach(f => add_test(f));
 
 function getFile(key) {
   var dirSvc = Cc["@mozilla.org/file/directory_service;1"]
                  .getService(Ci.nsIProperties);
   return dirSvc.get(key, Ci.nsIFile);
 }
 
 function new_file_input_stream(file, buffered) {
--- a/netwerk/test/unit/test_predictor.js
+++ b/netwerk/test/unit/test_predictor.js
@@ -593,17 +593,17 @@ function registerObserver() {
   Services.obs.addObserver(observer, "predictor-reset-complete");
 }
 
 function unregisterObserver() {
   Services.obs.removeObserver(observer, "predictor-reset-complete");
 }
 
 function run_test_real() {
-  tests.forEach(add_test);
+  tests.forEach(f => add_test(f));
   do_get_profile();
 
   Services.prefs.setBoolPref("network.predictor.enabled", true);
   Services.prefs.setBoolPref("network.predictor.cleaned-up", true);
   Services.prefs.setBoolPref("network.predictor.doing-tests", true);
 
   predictor = Cc["@mozilla.org/network/predictor;1"].getService(Ci.nsINetworkPredictor);
 
--- a/netwerk/test/unit/test_reopen.js
+++ b/netwerk/test/unit/test_reopen.js
@@ -18,17 +18,17 @@ var httpserv = null;
 
 [
   test_data_channel,
   test_http_channel,
   test_file_channel,
   // Commented by default as it relies on external ressources
   //test_ftp_channel,
   end
-].forEach(add_test);
+].forEach(f => add_test(f));
 
 // Utility functions
 
 function makeChan(url) {
   return chan = NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true})
                        .QueryInterface(Ci.nsIChannel);
 }
 
--- a/security/manager/ssl/tests/unit/test_cert_blocklist.js
+++ b/security/manager/ssl/tests/unit/test_cert_blocklist.js
@@ -348,18 +348,18 @@ function run_test() {
     // Check the cert validates before we load the blocklist
     file = "test_onecrl/same-issuer-ee.pem";
     verify_cert(file, PRErrorCodeSuccess);
 
     run_next_test();
   });
 
   // blocklist load is async so we must use add_test from here
-  add_task(function* () {
-    yield fetch_blocklist();
+  add_task(function () {
+    return fetch_blocklist();
   });
 
   add_test(function() {
     // The blocklist will be loaded now. Let's check the data is sane.
     // In particular, we should still have the revoked issuer / serial pair
     // that was in both revocations.txt and the blocklist.
     ok(test_is_revoked(certList, "another imaginary issuer", "serial2."),
       "issuer / serial pair should be blocked");
--- a/services/crypto/tests/unit/test_jwcrypto.js
+++ b/services/crypto/tests/unit/test_jwcrypto.js
@@ -266,9 +266,9 @@ var TESTS = [
   test_get_assertion,
   test_get_assertion_with_offset,
   test_assertion_lifetime,
   test_audience_encoding_bug972582,
 ];
 
 TESTS = TESTS.concat([test_rsa, test_dsa]);
 
-TESTS.forEach(add_test);
+TESTS.forEach(f => add_test(f));
--- a/testing/xpcshell/head.js
+++ b/testing/xpcshell/head.js
@@ -566,26 +566,26 @@ function _execute_test() {
     _testLogger.error(_exception_message(ex),
                       {
                         stack: _format_stack(stack),
                         source_file: filename
                       });
   };
 
   let complete = _cleanupFunctions.length == 0;
-  _Task.spawn(function* () {
+  (async () => {
     for (let func of _cleanupFunctions.reverse()) {
       try {
-        yield func();
+        await func();
       } catch (ex) {
         reportCleanupError(ex);
       }
     }
     _cleanupFunctions = [];
-  }).catch(reportCleanupError).then(() => complete = true);
+  })().catch(reportCleanupError).then(() => complete = true);
   _Services.tm.spinEventLoopUntil(() => complete);
 
   // Restore idle service to avoid leaks.
   _fakeIdleService.deactivate();
 
   if (_profileInitialized) {
     // Since we have a profile, we will notify profile shutdown topics at
     // the end of the current test, to ensure correct cleanup on shutdown.
@@ -1398,17 +1398,17 @@ function run_next_test() {
                                "SKIP",
                                _message);
         executeSoon(run_next_test);
         return;
       }
 
       if (_properties.isTask) {
         _gTaskRunning = true;
-        _Task.spawn(_gRunningTest).then(() => {
+        (async () => _gRunningTest())().then(() => {
           _gTaskRunning = false;
           run_next_test();
         }, ex => {
           _gTaskRunning = false;
           try {
             do_report_unexpected_exception(ex);
           } catch (ex) {
             // The above throws NS_ERROR_ABORT and we don't want this to show up
--- a/testing/xpcshell/selftest.py
+++ b/testing/xpcshell/selftest.py
@@ -182,28 +182,28 @@ add_task(function* test_2() {
 });
 '''
 
 ADD_TASK_REJECTED = '''
 Components.utils.import("resource://gre/modules/Promise.jsm");
 
 function run_test() { run_next_test(); }
 
-add_task(function* test_failing() {
-  yield Promise.reject(new Error("I fail."));
+add_task(async function test_failing() {
+  await Promise.reject(new Error("I fail."));
 });
 '''
 
 ADD_TASK_FAILURE_INSIDE = '''
 Components.utils.import("resource://gre/modules/Promise.jsm");
 
 function run_test() { run_next_test(); }
 
-add_task(function* test() {
-  let result = yield Promise.resolve(false);
+add_task(async function test() {
+  let result = await Promise.resolve(false);
 
   Assert.ok(result);
 });
 '''
 
 ADD_TASK_RUN_NEXT_TEST = '''
 function run_test() { run_next_test(); }
 
@@ -214,19 +214,19 @@ add_task(function () {
 });
 '''
 
 ADD_TASK_STACK_TRACE = '''
 Components.utils.import("resource://gre/modules/Promise.jsm", this);
 
 function run_test() { run_next_test(); }
 
-add_task(function* this_test_will_fail() {
+add_task(async function this_test_will_fail() {
   for (let i = 0; i < 10; ++i) {
-    yield Promise.resolve();
+    await Promise.resolve();
   }
   Assert.ok(false);
 });
 '''
 
 ADD_TASK_SKIP = '''
 add_task(async function skipMeNot1() {
   Assert.ok(true, "Well well well.");
@@ -343,18 +343,18 @@ function run_test() {
     checkpoints.push(6);
   });
 
   registerCleanupFunction(async function async_cleanup_4() {
     await undefined;
     checkpoints.push(5);
   });
 
-  registerCleanupFunction(function* async_cleanup_3() {
-    yield undefined;
+  registerCleanupFunction(async function async_cleanup_3() {
+    await undefined;
     checkpoints.push(4);
   });
 
   registerCleanupFunction(function async_cleanup_2() {
     let deferred = Promise.defer();
     executeSoon(deferred.resolve);
     return deferred.promise.then(function() {
       checkpoints.push(3);
--- a/toolkit/components/places/tests/unit/test_sql_guid_functions.js
+++ b/toolkit/components/places/tests/unit/test_sql_guid_functions.js
@@ -89,9 +89,9 @@ function test_guid_on_background() {
   stmt.finalize();
 }
 
 // Test Runner
 
 [
   test_guid_invariants,
   test_guid_on_background,
-].forEach(add_test);
+].forEach(fn => add_test(fn));