michael@0: const URL = "ftp://localhost/bug365133/"; michael@0: michael@0: const tests = [ michael@0: [ /* Unix style listing, space at the end of filename */ michael@0: "drwxrwxr-x 2 500 500 4096 Jan 01 2000 a \r\n" michael@0: , michael@0: "300: " + URL + "\n" + michael@0: "200: filename content-length last-modified file-type\n" + michael@0: "201: \"a%20\" 0 Sun%2C%2001%20Jan%202000%2000%3A00%3A00 DIRECTORY \n" michael@0: ], michael@0: [ /* Unix style listing, space at the end of link name */ michael@0: "lrwxrwxrwx 1 500 500 2 Jan 01 2000 l -> a \r\n" michael@0: , michael@0: "300: " + URL + "\n" + michael@0: "200: filename content-length last-modified file-type\n" + michael@0: "201: \"l%20\" 2 Sun%2C%2001%20Jan%202000%2000%3A00%3A00 SYMBOLIC-LINK \n" michael@0: ], michael@0: [ /* Unix style listing, regular file with " -> " in name */ michael@0: "-rw-rw-r-- 1 500 500 0 Jan 01 2000 arrow -> in name \r\n" michael@0: , michael@0: "300: " + URL + "\n" + michael@0: "200: filename content-length last-modified file-type\n" + michael@0: "201: \"arrow%20-%3E%20in%20name%20\" 0 Sun%2C%2001%20Jan%202000%2000%3A00%3A00 FILE \n" michael@0: ], michael@0: [ /* Unix style listing, tab at the end of filename */ michael@0: "drwxrwxrwx 2 500 500 4096 Jan 01 2000 t \r\n" michael@0: , michael@0: "300: " + URL + "\n" + michael@0: "200: filename content-length last-modified file-type\n" + michael@0: "201: \"t%09\" 0 Sun%2C%2001%20Jan%202000%2000%3A00%3A00 DIRECTORY \n" michael@0: ], michael@0: [ /* Unix style listing, multiple " -> " in filename */ michael@0: "lrwxrwxrwx 1 500 500 26 Jan 01 2000 symlink with arrow -> in name -> file with arrow -> in name\r\n" michael@0: , michael@0: "300: " + URL + "\n" + michael@0: "200: filename content-length last-modified file-type\n" + michael@0: "201: \"symlink%20with%20arrow%20-%3E%20in%20name\" 26 Sun%2C%2001%20Jan%202000%2000%3A00%3A00 SYMBOLIC-LINK \n" michael@0: ], michael@0: [ /* Unix style listing, multiple " -> " in filename, incorrect filesize */ michael@0: "lrwxrwxrwx 1 500 500 0 Jan 01 2000 symlink with arrow -> in name -> file with arrow -> in name\r\n" michael@0: , michael@0: "300: " + URL + "\n" + michael@0: "200: filename content-length last-modified file-type\n" + michael@0: "201: \"symlink%20with%20arrow%20-%3E%20in%20name%20-%3E%20file%20with%20arrow\" 0 Sun%2C%2001%20Jan%202000%2000%3A00%3A00 SYMBOLIC-LINK \n" michael@0: ], michael@0: [ /* DOS style listing, space at the end of filename, year 1999 */ michael@0: "01-01-99 01:00AM 1024 file \r\n" michael@0: , michael@0: "300: " + URL + "\n" + michael@0: "200: filename content-length last-modified file-type\n" + michael@0: "201: \"file%20\" 1024 Sun%2C%2001%20Jan%201999%2001%3A00%3A00 FILE \n" michael@0: ], michael@0: [ /* DOS style listing, tab at the end of filename, year 2000 */ michael@0: "01-01-00 01:00AM 1024 file \r\n" michael@0: , michael@0: "300: " + URL + "\n" + michael@0: "200: filename content-length last-modified file-type\n" + michael@0: "201: \"file%09\" 1024 Sun%2C%2001%20Jan%202000%2001%3A00%3A00 FILE \n" michael@0: ] 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: }