Bug 750817 - Do not rely on xpcomlib in netwerk xpcshell tests. r=jduell
authorGeoff Brown <gbrown@mozilla.com>
Thu, 03 May 2012 06:22:58 -0400
changeset 92979 e56ddb80b93563e8cc1635c41774545bbfd18044
parent 92978 7a4373dd60ed7aed8e4a1e508719d1285a3cea7a
child 92980 6df779e244c3e2b925b1dacf0d2270d4cc5c3e04
push id8917
push userryanvm@gmail.com
push dateThu, 03 May 2012 10:24:10 +0000
treeherdermozilla-inbound@d7271f499b8b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjduell
bugs750817
milestone15.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 750817 - Do not rely on xpcomlib in netwerk xpcshell tests. r=jduell
netwerk/test/unit/test_file_protocol.js
netwerk/test/unit/test_localstreams.js
netwerk/test/unit/test_post.js
--- a/netwerk/test/unit/test_file_protocol.js
+++ b/netwerk/test/unit/test_file_protocol.js
@@ -112,17 +112,17 @@ FileStreamListener.prototype = {
 
     this._closure(this._buffer);
   }
 };
 
 function test_read_file() {
   dump("*** test_read_file\n");
 
-  var file = getFile("XpcomLib");
+  var file = do_get_file("../unit/data/test_readline6.txt");
   var chan = new_file_channel(file);
 
   function on_read_complete(data) {
     dump("*** test_read_file.on_read_complete\n");
 
     // bug 326693
     if (chan.contentType != special_type)
       do_throw("Type mismatch! Is <" + chan.contentType + ">, should be <" +
@@ -169,17 +169,17 @@ function test_read_dir_1() {
 
 function test_read_dir_2() {
   return do_test_read_dir(true, special_type);
 }
 
 function test_upload_file() {
   dump("*** test_upload_file\n");
 
-  var file = getFile("XpcomLib");  // file to upload
+  var file = do_get_file("../unit/data/test_readline6.txt"); // file to upload
   var dest = getFile("TmpD");      // file upload destination
   dest.append("junk.dat");
   dest.createUnique(dest.NORMAL_FILE_TYPE, 0600);
 
   var uploadstream = new_file_input_stream(file, true);
 
   var chan = new_file_channel(dest);
   chan.QueryInterface(Ci.nsIUploadChannel);
--- a/netwerk/test/unit/test_localstreams.js
+++ b/netwerk/test/unit/test_localstreams.js
@@ -1,18 +1,12 @@
 // Tests bug 304414
 
 const PR_RDONLY = 0x1;  // see prio.h
 
-function getDir(key) {
-  var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"]
-                         .getService(Components.interfaces.nsIProperties);
-  return dirSvc.get(key, Components.interfaces.nsILocalFile);
-}
-
 // Does some sanity checks on the stream and returns the number of bytes read
 // when the checks passed.
 function test_stream(stream) {
   // This test only handles blocking streams; that's desired for file streams
   // anyway.
   do_check_eq(stream.isNonBlocking(), false);
 
   // Check that the stream is not buffered
@@ -74,16 +68,16 @@ function stream_from_channel(file) {
   var ios = Components.classes["@mozilla.org/network/io-service;1"]
                       .getService(Components.interfaces.nsIIOService);
   var uri = ios.newFileURI(file);
   return ios.newChannelFromURI(uri).open();
 }
 
 function run_test() {
   // Get a file and a directory in order to do some testing
-  var file = getDir("XpcomLib");
+  var file = do_get_file("../unit/data/test_readline6.txt");
   var len = file.fileSize;
   do_check_eq(test_stream(stream_for_file(file)), len);
   do_check_eq(test_stream(stream_from_channel(file)), len);
   var dir = file.parent;
   test_stream(stream_from_channel(dir)); // Can't do size checking
 }
 
--- a/netwerk/test/unit/test_post.js
+++ b/netwerk/test/unit/test_post.js
@@ -2,17 +2,17 @@
 // POST test
 //
 
 do_load_httpd_js();
 
 var httpserver = new nsHttpServer();
 var testpath = "/simple";
 
-var testfile = getFile("XpcomLib");
+var testfile = do_get_file("../unit/data/test_readline6.txt");
 
 const BOUNDARY = "AaB03x";
 var teststring1 = "--" + BOUNDARY + "\r\n"
                 + "Content-Disposition: form-data; name=\"body\"\r\n\r\n"
                 + "0123456789\r\n"
                 + "--" + BOUNDARY + "\r\n"
                 + "Content-Disposition: form-data; name=\"files\"; filename=\"" + testfile.leafName + "\"\r\n"
                 + "Content-Type: application/octet-stream\r\n"
@@ -84,14 +84,8 @@ function serverHandler(metadata, respons
 	      read_stream(testfile_stream, testfile_stream.available()) +
 	      teststring2,
 	      data);
 }
 
 function checkRequest(request, data, context) {
   httpserver.stop(do_test_finished);
 }
-
-function getFile(key) {
-  var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"]
-                         .getService(Components.interfaces.nsIProperties);
-  return dirSvc.get(key, Components.interfaces.nsILocalFile);
-}