Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
michael@0 | 1 | const URL = "ftp://localhost/bug464884/"; |
michael@0 | 2 | |
michael@0 | 3 | const tests = [ |
michael@0 | 4 | // standard ls unix format |
michael@0 | 5 | ["-rw-rw-r-- 1 500 500 0 Jan 01 2000 file1\r\n" + |
michael@0 | 6 | "-rw-rw-r-- 1 500 500 0 Jan 01 2000 file2\r\n", |
michael@0 | 7 | |
michael@0 | 8 | "300: " + URL + "\n" + |
michael@0 | 9 | "200: filename content-length last-modified file-type\n" + |
michael@0 | 10 | "201: \"file1\" 0 Sun%2C%2001%20Jan%202000%2000%3A00%3A00 FILE \n" + |
michael@0 | 11 | "201: \"%20file2\" 0 Sun%2C%2001%20Jan%202000%2000%3A00%3A00 FILE \n"], |
michael@0 | 12 | // old Hellsoft unix format |
michael@0 | 13 | ["-[RWCEMFA] supervisor 214059 Jan 01 2000 file1\r\n" + |
michael@0 | 14 | "-[RWCEMFA] supervisor 214059 Jan 01 2000 file2\r\n", |
michael@0 | 15 | |
michael@0 | 16 | "300: " + URL + "\n" + |
michael@0 | 17 | "200: filename content-length last-modified file-type\n" + |
michael@0 | 18 | "201: \"file1\" 214059 Sun%2C%2001%20Jan%202000%2000%3A00%3A00 FILE \n" + |
michael@0 | 19 | "201: \"file2\" 214059 Sun%2C%2001%20Jan%202000%2000%3A00%3A00 FILE \n"], |
michael@0 | 20 | // new Hellsoft unix format |
michael@0 | 21 | ["- [RWCEAFMS] jrd 192 Jan 01 2000 file1\r\n"+ |
michael@0 | 22 | "- [RWCEAFMS] jrd 192 Jan 01 2000 file2\r\n", |
michael@0 | 23 | |
michael@0 | 24 | "300: " + URL + "\n" + |
michael@0 | 25 | "200: filename content-length last-modified file-type\n" + |
michael@0 | 26 | "201: \"file1\" 192 Sun%2C%2001%20Jan%202000%2000%3A00%3A00 FILE \n" + |
michael@0 | 27 | "201: \"%20file2\" 192 Sun%2C%2001%20Jan%202000%2000%3A00%3A00 FILE \n"], |
michael@0 | 28 | // DOS format with correct offsets |
michael@0 | 29 | ["01-01-00 01:00AM <DIR> dir1\r\n" + |
michael@0 | 30 | "01-01-00 01:00AM <JUNCTION> junction1 -> foo1\r\n" + |
michael@0 | 31 | "01-01-00 01:00AM 95077 file1\r\n" + |
michael@0 | 32 | "01-01-00 01:00AM <DIR> dir2\r\n" + |
michael@0 | 33 | "01-01-00 01:00AM <JUNCTION> junction2 -> foo2\r\n" + |
michael@0 | 34 | "01-01-00 01:00AM 95077 file2\r\n", |
michael@0 | 35 | |
michael@0 | 36 | "300: " + URL + "\n" + |
michael@0 | 37 | "200: filename content-length last-modified file-type\n" + |
michael@0 | 38 | "201: \"dir1\" 0 Sun%2C%2001%20Jan%202000%2001%3A00%3A00 DIRECTORY \n" + |
michael@0 | 39 | "201: \"junction1\" Sun%2C%2001%20Jan%202000%2001%3A00%3A00 SYMBOLIC-LINK \n" + |
michael@0 | 40 | "201: \"file1\" 95077 Sun%2C%2001%20Jan%202000%2001%3A00%3A00 FILE \n" + |
michael@0 | 41 | "201: \"%20dir2\" 0 Sun%2C%2001%20Jan%202000%2001%3A00%3A00 DIRECTORY \n" + |
michael@0 | 42 | "201: \"%20junction2\" Sun%2C%2001%20Jan%202000%2001%3A00%3A00 SYMBOLIC-LINK \n" + |
michael@0 | 43 | "201: \"%20file2\" 95077 Sun%2C%2001%20Jan%202000%2001%3A00%3A00 FILE \n"], |
michael@0 | 44 | // DOS format with wrong offsets |
michael@0 | 45 | ["01-01-00 01:00AM <DIR> dir1\r\n" + |
michael@0 | 46 | "01-01-00 01:00AM <DIR> dir2\r\n" + |
michael@0 | 47 | "01-01-00 01:00AM <DIR> dir3\r\n" + |
michael@0 | 48 | "01-01-00 01:00AM <JUNCTION> junction1 -> foo1\r\n" + |
michael@0 | 49 | "01-01-00 01:00AM <JUNCTION> junction2 -> foo2\r\n" + |
michael@0 | 50 | "01-01-00 01:00AM <JUNCTION> junction3 -> foo3\r\n" + |
michael@0 | 51 | "01-01-00 01:00AM 95077 file1\r\n" + |
michael@0 | 52 | "01-01-00 01:00AM 95077 file2\r\n", |
michael@0 | 53 | |
michael@0 | 54 | "300: " + URL + "\n" + |
michael@0 | 55 | "200: filename content-length last-modified file-type\n" + |
michael@0 | 56 | "201: \"dir1\" 0 Sun%2C%2001%20Jan%202000%2001%3A00%3A00 DIRECTORY \n" + |
michael@0 | 57 | "201: \"dir2\" 0 Sun%2C%2001%20Jan%202000%2001%3A00%3A00 DIRECTORY \n" + |
michael@0 | 58 | "201: \"dir3\" 0 Sun%2C%2001%20Jan%202000%2001%3A00%3A00 DIRECTORY \n" + |
michael@0 | 59 | "201: \"junction1\" Sun%2C%2001%20Jan%202000%2001%3A00%3A00 SYMBOLIC-LINK \n" + |
michael@0 | 60 | "201: \"junction2\" Sun%2C%2001%20Jan%202000%2001%3A00%3A00 SYMBOLIC-LINK \n" + |
michael@0 | 61 | "201: \"junction3\" Sun%2C%2001%20Jan%202000%2001%3A00%3A00 SYMBOLIC-LINK \n" + |
michael@0 | 62 | "201: \"file1\" 95077 Sun%2C%2001%20Jan%202000%2001%3A00%3A00 FILE \n" + |
michael@0 | 63 | "201: \"file2\" 95077 Sun%2C%2001%20Jan%202000%2001%3A00%3A00 FILE \n"] |
michael@0 | 64 | ] |
michael@0 | 65 | |
michael@0 | 66 | function checkData(request, data, ctx) { |
michael@0 | 67 | do_check_eq(tests[0][1], data); |
michael@0 | 68 | tests.shift(); |
michael@0 | 69 | next_test(); |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | function storeData(status, entry) { |
michael@0 | 73 | do_check_eq(status, Components.results.NS_OK); |
michael@0 | 74 | entry.setMetaDataElement("servertype", "0"); |
michael@0 | 75 | var os = entry.openOutputStream(0); |
michael@0 | 76 | |
michael@0 | 77 | var written = os.write(tests[0][0], tests[0][0].length); |
michael@0 | 78 | if (written != tests[0][0].length) { |
michael@0 | 79 | do_throw("os.write has not written all data!\n" + |
michael@0 | 80 | " Expected: " + written + "\n" + |
michael@0 | 81 | " Actual: " + tests[0][0].length + "\n"); |
michael@0 | 82 | } |
michael@0 | 83 | os.close(); |
michael@0 | 84 | entry.close(); |
michael@0 | 85 | |
michael@0 | 86 | var ios = Components.classes["@mozilla.org/network/io-service;1"]. |
michael@0 | 87 | getService(Components.interfaces.nsIIOService); |
michael@0 | 88 | var channel = ios.newChannel(URL, "", null); |
michael@0 | 89 | channel.asyncOpen(new ChannelListener(checkData, null, CL_ALLOW_UNKNOWN_CL), null); |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | function next_test() { |
michael@0 | 93 | if (tests.length == 0) |
michael@0 | 94 | do_test_finished(); |
michael@0 | 95 | else { |
michael@0 | 96 | asyncOpenCacheEntry(URL, |
michael@0 | 97 | "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, |
michael@0 | 98 | storeData); |
michael@0 | 99 | } |
michael@0 | 100 | } |
michael@0 | 101 | |
michael@0 | 102 | function run_test() { |
michael@0 | 103 | do_execute_soon(next_test); |
michael@0 | 104 | do_test_pending(); |
michael@0 | 105 | } |