michael@0: const URL = "ftp://localhost/bug543805/"; michael@0: michael@0: var year = new Date().getFullYear().toString(); michael@0: michael@0: const tests = [ michael@0: // AIX ls format michael@0: ["-rw-r--r-- 1 0 11 Jan 1 20:19 nodup.file\r\n" + michael@0: "-rw-r--r-- 1 0 22 Jan 1 20:19 test.blankfile\r\n" + michael@0: "-rw-r--r-- 1 0 33 Apr 1 2008 test2.blankfile\r\n" + michael@0: "-rw-r--r-- 1 0 44 Jan 1 20:19 nodup.file\r\n" + michael@0: "-rw-r--r-- 1 0 55 Jan 1 20:19 test.file\r\n" + michael@0: "-rw-r--r-- 1 0 66 Apr 1 2008 test2.file\r\n", michael@0: michael@0: "300: " + URL + "\n" + michael@0: "200: filename content-length last-modified file-type\n" + michael@0: "201: \"%20nodup.file\" 11 Sun%2C%2001%20Jan%20" + year + "%2020%3A19%3A00 FILE \n" + michael@0: "201: \"%20test.blankfile\" 22 Sun%2C%2001%20Jan%20" + year + "%2020%3A19%3A00 FILE \n" + michael@0: "201: \"%20test2.blankfile\" 33 Sun%2C%2001%20Apr%202008%2000%3A00%3A00 FILE \n" + michael@0: "201: \"nodup.file\" 44 Sun%2C%2001%20Jan%20" + year + "%2020%3A19%3A00 FILE \n" + michael@0: "201: \"test.file\" 55 Sun%2C%2001%20Jan%20" + year + "%2020%3A19%3A00 FILE \n" + michael@0: "201: \"test2.file\" 66 Sun%2C%2001%20Apr%202008%2000%3A00%3A00 FILE \n"], michael@0: michael@0: // standard ls format michael@0: [ michael@0: "-rw-r--r-- 1 500 500 11 Jan 1 20:19 nodup.file\r\n" + michael@0: "-rw-r--r-- 1 500 500 22 Jan 1 20:19 test.blankfile\r\n" + michael@0: "-rw-r--r-- 1 500 500 33 Apr 1 2008 test2.blankfile\r\n" + michael@0: "-rw-r--r-- 1 500 500 44 Jan 1 20:19 nodup.file\r\n" + michael@0: "-rw-r--r-- 1 500 500 55 Jan 1 20:19 test.file\r\n" + michael@0: "-rw-r--r-- 1 500 500 66 Apr 1 2008 test2.file\r\n", michael@0: michael@0: "300: " + URL + "\n" + michael@0: "200: filename content-length last-modified file-type\n" + michael@0: "201: \"%20nodup.file\" 11 Sun%2C%2001%20Jan%20" + year + "%2020%3A19%3A00 FILE \n" + michael@0: "201: \"%20test.blankfile\" 22 Sun%2C%2001%20Jan%20" + year + "%2020%3A19%3A00 FILE \n" + michael@0: "201: \"%20test2.blankfile\" 33 Sun%2C%2001%20Apr%202008%2000%3A00%3A00 FILE \n" + michael@0: "201: \"nodup.file\" 44 Sun%2C%2001%20Jan%20" + year + "%2020%3A19%3A00 FILE \n" + michael@0: "201: \"test.file\" 55 Sun%2C%2001%20Jan%20" + year + "%2020%3A19%3A00 FILE \n" + michael@0: "201: \"test2.file\" 66 Sun%2C%2001%20Apr%202008%2000%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: }