michael@0: const URL = "ftp://localhost/bug464884/"; michael@0: michael@0: const tests = [ michael@0: // standard ls unix format michael@0: ["-rw-rw-r-- 1 500 500 0 Jan 01 2000 file1\r\n" + michael@0: "-rw-rw-r-- 1 500 500 0 Jan 01 2000 file2\r\n", michael@0: michael@0: "300: " + URL + "\n" + michael@0: "200: filename content-length last-modified file-type\n" + michael@0: "201: \"file1\" 0 Sun%2C%2001%20Jan%202000%2000%3A00%3A00 FILE \n" + michael@0: "201: \"%20file2\" 0 Sun%2C%2001%20Jan%202000%2000%3A00%3A00 FILE \n"], michael@0: // old Hellsoft unix format michael@0: ["-[RWCEMFA] supervisor 214059 Jan 01 2000 file1\r\n" + michael@0: "-[RWCEMFA] supervisor 214059 Jan 01 2000 file2\r\n", michael@0: michael@0: "300: " + URL + "\n" + michael@0: "200: filename content-length last-modified file-type\n" + michael@0: "201: \"file1\" 214059 Sun%2C%2001%20Jan%202000%2000%3A00%3A00 FILE \n" + michael@0: "201: \"file2\" 214059 Sun%2C%2001%20Jan%202000%2000%3A00%3A00 FILE \n"], michael@0: // new Hellsoft unix format michael@0: ["- [RWCEAFMS] jrd 192 Jan 01 2000 file1\r\n"+ michael@0: "- [RWCEAFMS] jrd 192 Jan 01 2000 file2\r\n", michael@0: michael@0: "300: " + URL + "\n" + michael@0: "200: filename content-length last-modified file-type\n" + michael@0: "201: \"file1\" 192 Sun%2C%2001%20Jan%202000%2000%3A00%3A00 FILE \n" + michael@0: "201: \"%20file2\" 192 Sun%2C%2001%20Jan%202000%2000%3A00%3A00 FILE \n"], michael@0: // DOS format with correct offsets michael@0: ["01-01-00 01:00AM dir1\r\n" + michael@0: "01-01-00 01:00AM junction1 -> foo1\r\n" + michael@0: "01-01-00 01:00AM 95077 file1\r\n" + michael@0: "01-01-00 01:00AM dir2\r\n" + michael@0: "01-01-00 01:00AM junction2 -> foo2\r\n" + michael@0: "01-01-00 01:00AM 95077 file2\r\n", michael@0: michael@0: "300: " + URL + "\n" + michael@0: "200: filename content-length last-modified file-type\n" + michael@0: "201: \"dir1\" 0 Sun%2C%2001%20Jan%202000%2001%3A00%3A00 DIRECTORY \n" + michael@0: "201: \"junction1\" Sun%2C%2001%20Jan%202000%2001%3A00%3A00 SYMBOLIC-LINK \n" + michael@0: "201: \"file1\" 95077 Sun%2C%2001%20Jan%202000%2001%3A00%3A00 FILE \n" + michael@0: "201: \"%20dir2\" 0 Sun%2C%2001%20Jan%202000%2001%3A00%3A00 DIRECTORY \n" + michael@0: "201: \"%20junction2\" Sun%2C%2001%20Jan%202000%2001%3A00%3A00 SYMBOLIC-LINK \n" + michael@0: "201: \"%20file2\" 95077 Sun%2C%2001%20Jan%202000%2001%3A00%3A00 FILE \n"], michael@0: // DOS format with wrong offsets michael@0: ["01-01-00 01:00AM dir1\r\n" + michael@0: "01-01-00 01:00AM dir2\r\n" + michael@0: "01-01-00 01:00AM dir3\r\n" + michael@0: "01-01-00 01:00AM junction1 -> foo1\r\n" + michael@0: "01-01-00 01:00AM junction2 -> foo2\r\n" + michael@0: "01-01-00 01:00AM junction3 -> foo3\r\n" + michael@0: "01-01-00 01:00AM 95077 file1\r\n" + michael@0: "01-01-00 01:00AM 95077 file2\r\n", michael@0: michael@0: "300: " + URL + "\n" + michael@0: "200: filename content-length last-modified file-type\n" + michael@0: "201: \"dir1\" 0 Sun%2C%2001%20Jan%202000%2001%3A00%3A00 DIRECTORY \n" + michael@0: "201: \"dir2\" 0 Sun%2C%2001%20Jan%202000%2001%3A00%3A00 DIRECTORY \n" + michael@0: "201: \"dir3\" 0 Sun%2C%2001%20Jan%202000%2001%3A00%3A00 DIRECTORY \n" + michael@0: "201: \"junction1\" Sun%2C%2001%20Jan%202000%2001%3A00%3A00 SYMBOLIC-LINK \n" + michael@0: "201: \"junction2\" Sun%2C%2001%20Jan%202000%2001%3A00%3A00 SYMBOLIC-LINK \n" + michael@0: "201: \"junction3\" Sun%2C%2001%20Jan%202000%2001%3A00%3A00 SYMBOLIC-LINK \n" + michael@0: "201: \"file1\" 95077 Sun%2C%2001%20Jan%202000%2001%3A00%3A00 FILE \n" + michael@0: "201: \"file2\" 95077 Sun%2C%2001%20Jan%202000%2001%3A00%3A00 FILE \n"] michael@0: ] michael@0: michael@0: function checkData(request, data, ctx) { michael@0: do_check_eq(tests[0][1], data); michael@0: tests.shift(); michael@0: next_test(); michael@0: } michael@0: michael@0: function storeData(status, entry) { michael@0: do_check_eq(status, Components.results.NS_OK); michael@0: entry.setMetaDataElement("servertype", "0"); michael@0: var os = entry.openOutputStream(0); michael@0: michael@0: var written = os.write(tests[0][0], tests[0][0].length); michael@0: if (written != tests[0][0].length) { michael@0: do_throw("os.write has not written all data!\n" + michael@0: " Expected: " + written + "\n" + michael@0: " Actual: " + tests[0][0].length + "\n"); michael@0: } michael@0: os.close(); michael@0: entry.close(); michael@0: michael@0: var ios = Components.classes["@mozilla.org/network/io-service;1"]. michael@0: getService(Components.interfaces.nsIIOService); michael@0: var channel = ios.newChannel(URL, "", null); michael@0: channel.asyncOpen(new ChannelListener(checkData, null, CL_ALLOW_UNKNOWN_CL), null); michael@0: } michael@0: michael@0: function next_test() { michael@0: if (tests.length == 0) michael@0: do_test_finished(); michael@0: else { michael@0: asyncOpenCacheEntry(URL, michael@0: "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, michael@0: storeData); michael@0: } michael@0: } michael@0: michael@0: function run_test() { michael@0: do_execute_soon(next_test); michael@0: do_test_pending(); michael@0: }