Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | const URL = "ftp://localhost/bug365133/"; |
michael@0 | 2 | |
michael@0 | 3 | const tests = [ |
michael@0 | 4 | [ /* Unix style listing, space at the end of filename */ |
michael@0 | 5 | "drwxrwxr-x 2 500 500 4096 Jan 01 2000 a \r\n" |
michael@0 | 6 | , |
michael@0 | 7 | "300: " + URL + "\n" + |
michael@0 | 8 | "200: filename content-length last-modified file-type\n" + |
michael@0 | 9 | "201: \"a%20\" 0 Sun%2C%2001%20Jan%202000%2000%3A00%3A00 DIRECTORY \n" |
michael@0 | 10 | ], |
michael@0 | 11 | [ /* Unix style listing, space at the end of link name */ |
michael@0 | 12 | "lrwxrwxrwx 1 500 500 2 Jan 01 2000 l -> a \r\n" |
michael@0 | 13 | , |
michael@0 | 14 | "300: " + URL + "\n" + |
michael@0 | 15 | "200: filename content-length last-modified file-type\n" + |
michael@0 | 16 | "201: \"l%20\" 2 Sun%2C%2001%20Jan%202000%2000%3A00%3A00 SYMBOLIC-LINK \n" |
michael@0 | 17 | ], |
michael@0 | 18 | [ /* Unix style listing, regular file with " -> " in name */ |
michael@0 | 19 | "-rw-rw-r-- 1 500 500 0 Jan 01 2000 arrow -> in name \r\n" |
michael@0 | 20 | , |
michael@0 | 21 | "300: " + URL + "\n" + |
michael@0 | 22 | "200: filename content-length last-modified file-type\n" + |
michael@0 | 23 | "201: \"arrow%20-%3E%20in%20name%20\" 0 Sun%2C%2001%20Jan%202000%2000%3A00%3A00 FILE \n" |
michael@0 | 24 | ], |
michael@0 | 25 | [ /* Unix style listing, tab at the end of filename */ |
michael@0 | 26 | "drwxrwxrwx 2 500 500 4096 Jan 01 2000 t \r\n" |
michael@0 | 27 | , |
michael@0 | 28 | "300: " + URL + "\n" + |
michael@0 | 29 | "200: filename content-length last-modified file-type\n" + |
michael@0 | 30 | "201: \"t%09\" 0 Sun%2C%2001%20Jan%202000%2000%3A00%3A00 DIRECTORY \n" |
michael@0 | 31 | ], |
michael@0 | 32 | [ /* Unix style listing, multiple " -> " in filename */ |
michael@0 | 33 | "lrwxrwxrwx 1 500 500 26 Jan 01 2000 symlink with arrow -> in name -> file with arrow -> in name\r\n" |
michael@0 | 34 | , |
michael@0 | 35 | "300: " + URL + "\n" + |
michael@0 | 36 | "200: filename content-length last-modified file-type\n" + |
michael@0 | 37 | "201: \"symlink%20with%20arrow%20-%3E%20in%20name\" 26 Sun%2C%2001%20Jan%202000%2000%3A00%3A00 SYMBOLIC-LINK \n" |
michael@0 | 38 | ], |
michael@0 | 39 | [ /* Unix style listing, multiple " -> " in filename, incorrect filesize */ |
michael@0 | 40 | "lrwxrwxrwx 1 500 500 0 Jan 01 2000 symlink with arrow -> in name -> file with arrow -> in name\r\n" |
michael@0 | 41 | , |
michael@0 | 42 | "300: " + URL + "\n" + |
michael@0 | 43 | "200: filename content-length last-modified file-type\n" + |
michael@0 | 44 | "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 | 45 | ], |
michael@0 | 46 | [ /* DOS style listing, space at the end of filename, year 1999 */ |
michael@0 | 47 | "01-01-99 01:00AM 1024 file \r\n" |
michael@0 | 48 | , |
michael@0 | 49 | "300: " + URL + "\n" + |
michael@0 | 50 | "200: filename content-length last-modified file-type\n" + |
michael@0 | 51 | "201: \"file%20\" 1024 Sun%2C%2001%20Jan%201999%2001%3A00%3A00 FILE \n" |
michael@0 | 52 | ], |
michael@0 | 53 | [ /* DOS style listing, tab at the end of filename, year 2000 */ |
michael@0 | 54 | "01-01-00 01:00AM 1024 file \r\n" |
michael@0 | 55 | , |
michael@0 | 56 | "300: " + URL + "\n" + |
michael@0 | 57 | "200: filename content-length last-modified file-type\n" + |
michael@0 | 58 | "201: \"file%09\" 1024 Sun%2C%2001%20Jan%202000%2001%3A00%3A00 FILE \n" |
michael@0 | 59 | ] |
michael@0 | 60 | ] |
michael@0 | 61 | |
michael@0 | 62 | function checkData(request, data, ctx) { |
michael@0 | 63 | do_check_eq(tests[0][1], data); |
michael@0 | 64 | tests.shift(); |
michael@0 | 65 | next_test(); |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | function storeData(status, entry) { |
michael@0 | 69 | do_check_eq(status, Components.results.NS_OK); |
michael@0 | 70 | entry.setMetaDataElement("servertype", "0"); |
michael@0 | 71 | var os = entry.openOutputStream(0); |
michael@0 | 72 | |
michael@0 | 73 | var written = os.write(tests[0][0], tests[0][0].length); |
michael@0 | 74 | if (written != tests[0][0].length) { |
michael@0 | 75 | do_throw("os.write has not written all data!\n" + |
michael@0 | 76 | " Expected: " + written + "\n" + |
michael@0 | 77 | " Actual: " + tests[0][0].length + "\n"); |
michael@0 | 78 | } |
michael@0 | 79 | os.close(); |
michael@0 | 80 | entry.close(); |
michael@0 | 81 | |
michael@0 | 82 | var ios = Components.classes["@mozilla.org/network/io-service;1"]. |
michael@0 | 83 | getService(Components.interfaces.nsIIOService); |
michael@0 | 84 | var channel = ios.newChannel(URL, "", null); |
michael@0 | 85 | channel.asyncOpen(new ChannelListener(checkData, null, CL_ALLOW_UNKNOWN_CL), null); |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | function next_test() { |
michael@0 | 89 | if (tests.length == 0) |
michael@0 | 90 | do_test_finished(); |
michael@0 | 91 | else { |
michael@0 | 92 | asyncOpenCacheEntry(URL, |
michael@0 | 93 | "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, |
michael@0 | 94 | storeData); |
michael@0 | 95 | } |
michael@0 | 96 | } |
michael@0 | 97 | |
michael@0 | 98 | function run_test() { |
michael@0 | 99 | do_execute_soon(next_test); |
michael@0 | 100 | do_test_pending(); |
michael@0 | 101 | } |