Bug 1140032 - Re-enable FTP xpcshell tests by removing dependency on the cache. r=mayhemer
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Tue, 24 Mar 2015 05:11:18 +0900
changeset 263996 530055ae5b49a03c5f30f1b5d17e1e0e603b9ba6
parent 263995 c2ff2f017b176dc640707dfd7d8659d2ff290ea4
child 263997 05f5e4ea3d5487a776b48dc441a23c8e27862508
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer
bugs1140032
milestone39.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 1140032 - Re-enable FTP xpcshell tests by removing dependency on the cache. r=mayhemer
netwerk/test/unit/test_bug365133.js
netwerk/test/unit/test_bug484684.js
netwerk/test/unit/test_bug515583.js
netwerk/test/unit/test_bug543805.js
netwerk/test/unit/xpcshell.ini
--- a/netwerk/test/unit/test_bug365133.js
+++ b/netwerk/test/unit/test_bug365133.js
@@ -57,52 +57,55 @@ const tests = [
     "200: filename content-length last-modified file-type\n" +
     "201: \"file%09\" 1024 Sun%2C%2001%20Jan%202000%2001%3A00%3A00 FILE \n"
   ]
 ]
 
 function checkData(request, data, ctx) {
   do_check_eq(tests[0][1], data);
   tests.shift();
-  next_test();
+  do_execute_soon(next_test);
 }
 
-function storeData(status, entry) {
-  do_check_eq(status, Components.results.NS_OK);
-  entry.setMetaDataElement("servertype", "0");
-  var os = entry.openOutputStream(0);
+function storeData() {
+  var scs = Cc["@mozilla.org/streamConverters;1"].
+            getService(Ci.nsIStreamConverterService);
+  var converter = scs.asyncConvertData("text/ftp-dir", "application/http-index-format",
+                                       new ChannelListener(checkData, null, CL_ALLOW_UNKNOWN_CL), null);
+
+  var stream = Cc["@mozilla.org/io/string-input-stream;1"].
+               createInstance(Ci.nsIStringInputStream);
+  stream.data = tests[0][0];
 
-  var written = os.write(tests[0][0], tests[0][0].length);
-  if (written != tests[0][0].length) {
-    do_throw("os.write has not written all data!\n" +
-             "  Expected: " + written  + "\n" +
-             "  Actual: " + tests[0][0].length + "\n");
-  }
-  os.close();
-  entry.close();
+  var url = {
+    password: "",
+    asciiSpec: URL,
+    QueryInterface: XPCOMUtils.generateQI([Ci.nsIURI])
+  };
 
-  var ios = Components.classes["@mozilla.org/network/io-service;1"].
-            getService(Components.interfaces.nsIIOService);
-  var channel = ios.newChannel2(URL,
-                                "",
-                                null,
-                                null,      // aLoadingNode
-                                Services.scriptSecurityManager.getSystemPrincipal(),
-                                null,      // aTriggeringPrincipal
-                                Ci.nsILoadInfo.SEC_NORMAL,
-                                Ci.nsIContentPolicy.TYPE_OTHER);
-  channel.asyncOpen(new ChannelListener(checkData, null, CL_ALLOW_UNKNOWN_CL), null);
+  var channel = {
+    URI: url,
+    contentLength: -1,
+    pending: true,
+    isPending: function() {
+      return this.pending;
+    },
+    QueryInterface: XPCOMUtils.generateQI([Ci.nsIChannel])
+  };
+
+  converter.onStartRequest(channel, null);
+  converter.onDataAvailable(channel, null, stream, 0, 0);
+  channel.pending = false;
+  converter.onStopRequest(channel, null, Cr.NS_OK);
 }
 
 function next_test() {
   if (tests.length == 0)
     do_test_finished();
   else {
-    asyncOpenCacheEntry(URL,
-                        "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
-                        storeData);
+    storeData();
   }
 }
 
 function run_test() {
   do_execute_soon(next_test);
   do_test_pending();
 }
--- a/netwerk/test/unit/test_bug484684.js
+++ b/netwerk/test/unit/test_bug484684.js
@@ -61,52 +61,55 @@ const tests = [
    "201: \"junction3\"  Sun%2C%2001%20Jan%202000%2001%3A00%3A00 SYMBOLIC-LINK \n" +
    "201: \"file1\" 95077 Sun%2C%2001%20Jan%202000%2001%3A00%3A00 FILE \n" +
    "201: \"file2\" 95077 Sun%2C%2001%20Jan%202000%2001%3A00%3A00 FILE \n"]
 ]
 
 function checkData(request, data, ctx) {
   do_check_eq(tests[0][1], data);
   tests.shift();
-  next_test();
+  do_execute_soon(next_test);
 }
 
 function storeData(status, entry) {
-  do_check_eq(status, Components.results.NS_OK);
-  entry.setMetaDataElement("servertype", "0");
-  var os = entry.openOutputStream(0);
+  var scs = Cc["@mozilla.org/streamConverters;1"].
+            getService(Ci.nsIStreamConverterService);
+  var converter = scs.asyncConvertData("text/ftp-dir", "application/http-index-format",
+                                       new ChannelListener(checkData, null, CL_ALLOW_UNKNOWN_CL), null);
+
+  var stream = Cc["@mozilla.org/io/string-input-stream;1"].
+               createInstance(Ci.nsIStringInputStream);
+  stream.data = tests[0][0];
+
+  var url = {
+    password: "",
+    asciiSpec: URL,
+    QueryInterface: XPCOMUtils.generateQI([Ci.nsIURI])
+  };
 
-  var written = os.write(tests[0][0], tests[0][0].length);
-  if (written != tests[0][0].length) {
-    do_throw("os.write has not written all data!\n" +
-             "  Expected: " + written  + "\n" +
-             "  Actual: " + tests[0][0].length + "\n");
-  }
-  os.close();
-  entry.close();
+  var channel = {
+    URI: url,
+    contentLength: -1,
+    pending: true,
+    isPending: function() {
+      return this.pending;
+    },
+    QueryInterface: XPCOMUtils.generateQI([Ci.nsIChannel])
+  };
 
-  var ios = Components.classes["@mozilla.org/network/io-service;1"].
-            getService(Components.interfaces.nsIIOService);
-  var channel = ios.newChannel2(URL,
-                                "",
-                                null,
-                                null,      // aLoadingNode
-                                Services.scriptSecurityManager.getSystemPrincipal(),
-                                null,      // aTriggeringPrincipal
-                                Ci.nsILoadInfo.SEC_NORMAL,
-                                Ci.nsIContentPolicy.TYPE_OTHER);
-  channel.asyncOpen(new ChannelListener(checkData, null, CL_ALLOW_UNKNOWN_CL), null);
+  converter.onStartRequest(channel, null);
+  converter.onDataAvailable(channel, null, stream, 0, 0);
+  channel.pending = false;
+  converter.onStopRequest(channel, null, Cr.NS_OK);
 }
 
 function next_test() {
   if (tests.length == 0)
     do_test_finished();
   else {
-    asyncOpenCacheEntry(URL,
-                        "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
-                        storeData);
+    storeData();
   }
 }
 
 function run_test() {
   do_execute_soon(next_test);
   do_test_pending();
 }
--- a/netwerk/test/unit/test_bug515583.js
+++ b/netwerk/test/unit/test_bug515583.js
@@ -19,52 +19,55 @@ const tests = [
    ,
    "300: " + URL + "\n" +
    "200: filename content-length last-modified file-type\n"]
 ]
 
 function checkData(request, data, ctx) {
   do_check_eq(tests[0][1], data);
   tests.shift();
-  next_test();
+  do_execute_soon(next_test);
 }
 
 function storeData(status, entry) {
-  do_check_eq(status, Components.results.NS_OK);
-  entry.setMetaDataElement("servertype", "0");
-  var os = entry.openOutputStream(0);
+  var scs = Cc["@mozilla.org/streamConverters;1"].
+            getService(Ci.nsIStreamConverterService);
+  var converter = scs.asyncConvertData("text/ftp-dir", "application/http-index-format",
+                                       new ChannelListener(checkData, null, CL_ALLOW_UNKNOWN_CL), null);
+
+  var stream = Cc["@mozilla.org/io/string-input-stream;1"].
+               createInstance(Ci.nsIStringInputStream);
+  stream.data = tests[0][0];
+
+  var url = {
+    password: "",
+    asciiSpec: URL,
+    QueryInterface: XPCOMUtils.generateQI([Ci.nsIURI])
+  };
 
-  var written = os.write(tests[0][0], tests[0][0].length);
-  if (written != tests[0][0].length) {
-    do_throw("os.write has not written all data!\n" +
-             "  Expected: " + written  + "\n" +
-             "  Actual: " + tests[0][0].length + "\n");
-  }
-  os.close();
-  entry.close();
+  var channel = {
+    URI: url,
+    contentLength: -1,
+    pending: true,
+    isPending: function() {
+      return this.pending;
+    },
+    QueryInterface: XPCOMUtils.generateQI([Ci.nsIChannel])
+  };
 
-  var ios = Components.classes["@mozilla.org/network/io-service;1"].
-            getService(Components.interfaces.nsIIOService);
-  var channel = ios.newChannel2(URL,
-                                "",
-                                null,
-                                null,      // aLoadingNode
-                                Services.scriptSecurityManager.getSystemPrincipal(),
-                                null,      // aTriggeringPrincipal
-                                Ci.nsILoadInfo.SEC_NORMAL,
-                                Ci.nsIContentPolicy.TYPE_OTHER);
-  channel.asyncOpen(new ChannelListener(checkData, null, CL_ALLOW_UNKNOWN_CL), null);
+  converter.onStartRequest(channel, null);
+  converter.onDataAvailable(channel, null, stream, 0, 0);
+  channel.pending = false;
+  converter.onStopRequest(channel, null, Cr.NS_OK);
 }
 
 function next_test() {
   if (tests.length == 0)
     do_test_finished();
   else {
-    asyncOpenCacheEntry(URL,
-                        "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
-                        storeData);
+    storeData();
   }
 }
 
 function run_test() {
   do_execute_soon(next_test);
   do_test_pending();
 }
--- a/netwerk/test/unit/test_bug543805.js
+++ b/netwerk/test/unit/test_bug543805.js
@@ -37,52 +37,55 @@ const tests = [
    "201: \"nodup.file\" 44 Sun%2C%2001%20Jan%20" + year + "%2020%3A19%3A00 FILE \n" +
    "201: \"test.file\" 55 Sun%2C%2001%20Jan%20" + year + "%2020%3A19%3A00 FILE \n" +
    "201: \"test2.file\" 66 Sun%2C%2001%20Apr%202008%2000%3A00%3A00 FILE \n"]
 ]
 
 function checkData(request, data, ctx) {
   do_check_eq(tests[0][1], data);
   tests.shift();
-  next_test();
+  do_execute_soon(next_test);
 }
 
 function storeData(status, entry) {
-  do_check_eq(status, Components.results.NS_OK);
-  entry.setMetaDataElement("servertype", "0");
-  var os = entry.openOutputStream(0);
+  var scs = Cc["@mozilla.org/streamConverters;1"].
+            getService(Ci.nsIStreamConverterService);
+  var converter = scs.asyncConvertData("text/ftp-dir", "application/http-index-format",
+                                       new ChannelListener(checkData, null, CL_ALLOW_UNKNOWN_CL), null);
+
+  var stream = Cc["@mozilla.org/io/string-input-stream;1"].
+               createInstance(Ci.nsIStringInputStream);
+  stream.data = tests[0][0];
+
+  var url = {
+    password: "",
+    asciiSpec: URL,
+    QueryInterface: XPCOMUtils.generateQI([Ci.nsIURI])
+  };
 
-  var written = os.write(tests[0][0], tests[0][0].length);
-  if (written != tests[0][0].length) {
-    do_throw("os.write has not written all data!\n" +
-             "  Expected: " + written  + "\n" +
-             "  Actual: " + tests[0][0].length + "\n");
-  }
-  os.close();
-  entry.close();
+  var channel = {
+    URI: url,
+    contentLength: -1,
+    pending: true,
+    isPending: function() {
+      return this.pending;
+    },
+    QueryInterface: XPCOMUtils.generateQI([Ci.nsIChannel])
+  };
 
-  var ios = Components.classes["@mozilla.org/network/io-service;1"].
-            getService(Components.interfaces.nsIIOService);
-  var channel = ios.newChannel2(URL,
-                                "",
-                                null,
-                                null,      // aLoadingNode
-                                Services.scriptSecurityManager.getSystemPrincipal(),
-                                null,      // aTriggeringPrincipal
-                                Ci.nsILoadInfo.SEC_NORMAL,
-                                Ci.nsIContentPolicy.TYPE_OTHER);
-  channel.asyncOpen(new ChannelListener(checkData, null, CL_ALLOW_UNKNOWN_CL), null);
+  converter.onStartRequest(channel, null);
+  converter.onDataAvailable(channel, null, stream, 0, 0);
+  channel.pending = false;
+  converter.onStopRequest(channel, null, Cr.NS_OK);
 }
 
 function next_test() {
   if (tests.length == 0)
     do_test_finished();
   else {
-    asyncOpenCacheEntry(URL,
-                        "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
-                        storeData);
+    storeData();
   }
 }
 
 function run_test() {
   do_execute_soon(next_test);
   do_test_pending();
 }
--- a/netwerk/test/unit/xpcshell.ini
+++ b/netwerk/test/unit/xpcshell.ini
@@ -87,17 +87,16 @@ skip-if = true
 [test_bug261425.js]
 [test_bug263127.js]
 [test_bug282432.js]
 [test_bug321706.js]
 [test_bug331825.js]
 [test_bug336501.js]
 [test_bug337744.js]
 [test_bug365133.js]
-skip-if = "FTP channel implementation needs to migrate to the new cache backend API"
 [test_bug368702.js]
 [test_bug369787.js]
 [test_bug371473.js]
 [test_bug376660.js]
 [test_bug376844.js]
 [test_bug376865.js]
 [test_bug379034.js]
 [test_bug380994.js]
@@ -114,29 +113,26 @@ skip-if = "FTP channel implementation ne
 [test_bug468426.js]
 [test_bug468594.js]
 [test_bug470716.js]
 [test_bug477578.js]
 [test_bug479413.js]
 [test_bug479485.js]
 [test_bug482601.js]
 [test_bug484684.js]
-skip-if = "FTP channel implementation needs to migrate to the new cache backend API"
 [test_bug490095.js]
 # Bug 675039: intermittent fail on Android-armv6 
 skip-if = os == "android"
 [test_bug504014.js]
 [test_bug510359.js]
 [test_bug515583.js]
-skip-if = "FTP channel implementation needs to migrate to the new cache backend API"
 [test_bug528292.js]
 [test_bug536324_64bit_content_length.js]
 [test_bug540566.js]
 [test_bug543805.js]
-skip-if = "FTP channel implementation needs to migrate to the new cache backend API"
 [test_bug553970.js]
 [test_bug561042.js]
 # Bug 675039: test fails on Android 4.0
 skip-if = os == "android"
 [test_bug561276.js]
 [test_bug580508.js]
 [test_bug586908.js]
 [test_bug596443.js]