Bug 1217316 - Remove for-each from netwerk/. r=jduell
authorTooru Fujisawa <arai_a@mac.com>
Mon, 19 Oct 2015 02:19:02 +0900
changeset 304356 5a2e0308a5f362e6303fb11b7573cda1b62fb899
parent 304355 05bb7ca32591b299a15588ac01440ad9a91f67f8
child 304357 14f30674828dedf0437111a88b43e3522a1f4a42
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjduell
bugs1217316
milestone44.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 1217316 - Remove for-each from netwerk/. r=jduell
netwerk/test/unit/socks_client_subprocess.js
netwerk/test/unit/test_bug337744.js
netwerk/test/unit/test_bug380994.js
netwerk/test/unit/test_bug396389.js
netwerk/test/unit/test_file_partial_inputstream.js
netwerk/test/unit/test_gre_resources.js
netwerk/test/unit/test_readline.js
netwerk/test/unit/test_socks.js
netwerk/test/unit/test_standardurl.js
--- a/netwerk/test/unit/socks_client_subprocess.js
+++ b/netwerk/test/unit/socks_client_subprocess.js
@@ -29,14 +29,14 @@ function launchConnection(socks_vers, so
     output.write('PONG!', 5);
   } else {
     print('client: wrong data from server:', data);
     output.write('Error: wrong data received.', 27);
   }
   output.close();
 }
 
-for each (var arg in arguments) {
+for (var arg of arguments) {
   print('client: running test', arg);
   test = arg.split('|');
   launchConnection(test[0], parseInt(test[1]), test[2],
        parseInt(test[3]), test[4]);
 }
--- a/netwerk/test/unit/test_bug337744.js
+++ b/netwerk/test/unit/test_bug337744.js
@@ -30,12 +30,12 @@ function check_for_exception(spec)
   catch (e) {
     return;
   }
 
   do_throw("Successfully opened invalid URI: '" + spec + "'");
 }
 
 function run_test() {
-  for each (spec in specs) {
+  for (var spec of specs) {
     check_for_exception(spec);
   }
 }
--- a/netwerk/test/unit/test_bug380994.js
+++ b/netwerk/test/unit/test_bug380994.js
@@ -9,14 +9,14 @@ const specs = [
   "resource:///..%2f..%2f..%2f..",
   "resource:///%2e%2e"
 ];
 
 function run_test() {
   var ios = Cc["@mozilla.org/network/io-service;1"].
             getService(Ci.nsIIOService);
 
-  for each (spec in specs) {
+  for (var spec of specs) {
     var uri = ios.newURI(spec, null, null);
     if (uri.spec.indexOf("..") != -1)
       do_throw("resource: traversal remains: '"+spec+"' ==> '"+uri.spec+"'");
   }
 }
--- a/netwerk/test/unit/test_bug396389.js
+++ b/netwerk/test/unit/test_bug396389.js
@@ -38,17 +38,17 @@ function run_test() {
 
   var uri3 = round_trip(uri1);
   do_check_true(uri3 instanceof Ci.nsIFileURL);
   do_check_true(uri1.equals(uri3));
 
   // Make sure our prefs are set such that this test actually means something
   var prefs = Cc["@mozilla.org/preferences-service;1"].
               getService(Ci.nsIPrefBranch);
-  for each (var pref in prefData) {
+  for (var pref of prefData) {
     try {
       pref.oldVal = prefs.getBoolPref(pref.name);
     } catch(e) {
     }
     prefs.setBoolPref(pref.name, pref.newVal);
   }
   
   try {
@@ -58,14 +58,14 @@ function run_test() {
     do_check_eq(uri4.asciiHost, "xn--jos-dma.example.net.ch");
     do_check_eq(uri4.host, "jos\u00e9.example.net.ch");
     
     var uri5 = round_trip(uri4);
     do_check_true(uri4.equals(uri5));
     do_check_eq(uri4.host, uri5.host);
     do_check_eq(uri4.asciiHost, uri5.asciiHost);
   } finally {
-    for each (var pref in prefData) {
+    for (var pref of prefData) {
       if (prefs.prefHasUserValue(pref.name))
         prefs.clearUserPref(pref.name);
     }
   }
 }
--- a/netwerk/test/unit/test_file_partial_inputstream.js
+++ b/netwerk/test/unit/test_file_partial_inputstream.js
@@ -141,17 +141,17 @@ function test_binary_portion(start, leng
 
   let streamTests = [
     test_4k_read,
     test_max_read,
     test_seek,
     test_seek_then_read,
   ];
 
-  for each(test in streamTests) {
+  for (var test of streamTests) {
     let fileStream = new_file_input_stream(subFile);
     let partialStream = new_partial_file_input_stream(do_get_file(binary_test_file_name),
                                                       start, length);
     test(fileStream, partialStream, length);
     fileStream.close();
     partialStream.close();
   }
 }
@@ -202,17 +202,17 @@ const SET = Ci.nsISeekableStream.NS_SEEK
 const CUR = Ci.nsISeekableStream.NS_SEEK_CUR;
 const END = Ci.nsISeekableStream.NS_SEEK_END;
 function test_seek(dummy, partialFileStream, size) {
   // We can't test the "real" filestream here as our existing file streams
   // are very broken and allows searching past the end of the file.
 
   partialFileStream.QueryInterface(Ci.nsISeekableStream);
 
-  tests = [
+  var tests = [
     [SET, 0],
     [SET, 5],
     [SET, 1000],
     [SET, size-10],
     [SET, size-5],
     [SET, size-1],
     [SET, size],
     [SET, size+10],
@@ -254,17 +254,17 @@ function test_seek(dummy, partialFileStr
     [END, -1000],
     [CUR, 100],
     [CUR, 900],
     [CUR, 100],
     [CUR, 100],
   ];
 
   let pos = 0;
-  for each(test in tests) {
+  for (var test of tests) {
     let didThrow = false;
     try {
       partialFileStream.seek(test[0], test[1]);
     }
     catch (ex) {
       didThrow = true;
     }
 
@@ -293,17 +293,17 @@ function test_seek_then_read(fileStreamA
 
   fileStreamA.QueryInterface(Ci.nsISeekableStream);
   fileStreamB.QueryInterface(Ci.nsISeekableStream);
   let streamA = new BinaryInputStream(fileStreamA);
   let streamB = new BinaryInputStream(fileStreamB);
 
   let read = {};
 
-  tests = [
+  var tests = [
     [SET, 0],
     [read, 1000],
     [read, 1000],
     [SET, 5],
     [read, 1000],
     [read, 5000],
     [CUR, 100],
     [read, 1000],
@@ -319,17 +319,17 @@ function test_seek_then_read(fileStreamA
     [CUR, -100],
     [read, 10],
     [SET, 0],
     [read, 20000],
     [read, 1],
     [read, 100],
   ];
 
-  for each(test in tests) {
+  for (var test of tests) {
     if (test[0] === read) {
   
       let didThrowA = false;
       let didThrowB = false;
 
       let bytesA, bytesB;
       try {
         bytesA = streamA.readBytes(test[1]);
@@ -359,17 +359,17 @@ function test_seek_then_read(fileStreamA
 function test_text_portion(start, length) {
   let subFile = create_temp_file(test_file_data.substr(start, length));
 
   let streamTests = [
     test_readline,
     test_seek_then_readline,
   ];
 
-  for each(test in streamTests) {
+  for (var test of streamTests) {
     let fileStream = new_file_input_stream(subFile)
                      .QueryInterface(Ci.nsILineInputStream);
     let partialStream = new_partial_file_input_stream(do_get_file(binary_test_file_name),
                                                       start, length)
                         .QueryInterface(Ci.nsILineInputStream);
     test(fileStream, partialStream, length);
     fileStream.close();
     partialStream.close();
@@ -395,17 +395,17 @@ function test_seek_then_readline(fileStr
     return;
   }
 
   fileStreamA.QueryInterface(Ci.nsISeekableStream);
   fileStreamB.QueryInterface(Ci.nsISeekableStream);
 
   let read = {};
 
-  tests = [
+  var tests = [
     [SET, 0],
     [read, 5],
     [read, 5],
     [SET, 5],
     [read, 5],
     [read, 15],
     [CUR, 100],
     [read, 5],
@@ -425,17 +425,17 @@ function test_seek_then_readline(fileStr
     [SET, 0],
     [read, 10000],
     [read, 1],
     [read, 1],
     [SET, 0],
     [read, 1],
   ];
 
-  for each(test in tests) {
+  for (var test of tests) {
     if (test[0] === read) {
 
       for (let i = 0; i < test[1]; ++i) {
         let didThrowA = false;
         let didThrowB = false;
 
         let lineA, lineB, moreA, moreB;
         try {
--- a/netwerk/test/unit/test_gre_resources.js
+++ b/netwerk/test/unit/test_gre_resources.js
@@ -25,11 +25,11 @@ function check_file(file) {
     let instr = wrapInputStream(channel.open());
     do_check_true(instr.read(1024).length > 0)
   } catch (e) {
     do_throw("Failed to read " + file + " from gre-resources:"+e)
   }
 }
 
 function run_test() {
-  for each(let file in ["ua.css"])
+  for (let file of ["ua.css"])
     check_file(file)
 }
--- a/netwerk/test/unit/test_readline.js
+++ b/netwerk/test/unit/test_readline.js
@@ -29,23 +29,23 @@ var test_array = [
 ];
 
 function err(file, lineNo, msg) {
   do_throw("\""+file+"\" line "+lineNo+", "+msg);
 }
 
 function run_test()
 {
-  for each (var test in test_array) {
+  for (var test of test_array) {
     var lineStream = new_line_input_stream(test.file);
     var lineNo = 0;
     var more = false;
     var line = {};
     more = lineStream.readLine(line);
-    for each (var check in test.lines) {
+    for (var check of test.lines) {
       ++lineNo;
       if (lineNo == test.lines.length) {
         if (more) err(test.file, lineNo, "There should be no more data after the last line");
       }
       else {
         if (!more) err(test.file, lineNo, "There should be more data after this line");
       }
       if (line.value != check)
--- a/netwerk/test/unit/test_socks.js
+++ b/netwerk/test/unit/test_socks.js
@@ -423,17 +423,17 @@ SocksTestServer.prototype = {
     }
   },
 
   runClientSubprocess: function()
   {
     var argv = [];
 
     // marshaled: socks_ver|server_port|dest_host|dest_port|<remote|local>
-    for each (var test in this.test_cases) {
+    for (var test of this.test_cases) {
       var arg = test.type + '|' +
         String(socks_listen_port) + '|' +
         test.host + '|' + test.port + '|';
       if (test.remote_dns)
         arg += 'remote';
       else
         arg += 'local';
       print('server: using test case', arg);  
@@ -462,17 +462,17 @@ SocksTestServer.prototype = {
     if (this.client_subprocess) {
       try {
         this.client_subprocess.kill();      
       } catch (x) {
         do_note_exception(x, 'Killing subprocess failed');
       }
       this.client_subprocess = null;
     }
-    for each (var client in this.client_connections)
+    for (var client of this.client_connections)
       client.close();
     this.client_connections = [];
     if (this.listener) {
       this.listener.close();
       this.listener = null;
     }
   }
 };
--- a/netwerk/test/unit/test_standardurl.js
+++ b/netwerk/test/unit/test_standardurl.js
@@ -45,17 +45,17 @@ function test_setEmptyPath()
      ["http://example.com", "http://example.com/tests/dom/tests"],
      ["http://example.com:80", "http://example.com/tests/dom/tests"],
      ["http://example.com:80/", "http://example.com/tests/dom/test"],
      ["http://example.com/", "http://example.com/tests/dom/tests"],
      ["http://example.com/a", "http://example.com/tests/dom/tests"],
      ["http://example.com:80/a", "http://example.com/tests/dom/tests"],
     ].map(pairToURLs);
 
-  for each (var [provided, target] in pairs)
+  for (var [provided, target] of pairs)
   {
     symmetricEquality(false, target, provided);
 
     provided.path = "";
     target.path = "";
 
     do_check_eq(provided.spec, target.spec);
     symmetricEquality(true, target, provided);
@@ -72,17 +72,17 @@ function test_setQuery()
      ["http://example.com/#bar", "http://example.com/?foo#bar"],
      ["http://example.com/?longerthanfoo#bar", "http://example.com/?foo#bar"],
      ["http://example.com/?longerthanfoo", "http://example.com/?foo"],
      /* And one that's nonempty but shorter than "foo" */
      ["http://example.com/?f#bar", "http://example.com/?foo#bar"],
      ["http://example.com/?f", "http://example.com/?foo"],
     ].map(pairToURLs);
 
-  for each (var [provided, target] in pairs) {
+  for (var [provided, target] of pairs) {
     symmetricEquality(false, provided, target);
 
     provided.query = "foo";
 
     do_check_eq(provided.spec, target.spec);
     symmetricEquality(true, provided, target);
   }
 
@@ -130,17 +130,17 @@ function test_setRef()
      ["http://example.com",      "xxxxxxxxxxxxxx", "http://example.com/#xxxxxxxxxxxxxx"],
      ["http://example.com:80",   "xxxxxxxxxxxxxx", "http://example.com:80/#xxxxxxxxxxxxxx"],
      ["http://example.com:80/",  "xxxxxxxxxxxxxx", "http://example.com:80/#xxxxxxxxxxxxxx"],
      ["http://example.com/",     "xxxxxxxxxxxxxx", "http://example.com/#xxxxxxxxxxxxxx"],
      ["http://example.com/a",    "xxxxxxxxxxxxxx", "http://example.com/a#xxxxxxxxxxxxxx"],
      ["http://example.com:80/a", "xxxxxxxxxxxxxx", "http://example.com:80/a#xxxxxxxxxxxxxx"],
     ];
 
-  for each (var [before, ref, result] in tests)
+  for (var [before, ref, result] of tests)
   {
     /* Test1: starting with empty ref */
     var a = stringToURL(before);
     a.ref = ref;
     var b = stringToURL(result);
 
     do_check_eq(a.spec, b.spec);
     do_check_eq(ref, b.ref);