Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | const URL = "ftp://localhost/bug515583/"; |
michael@0 | 2 | |
michael@0 | 3 | const tests = [ |
michael@0 | 4 | ["[RWCEM1 4 1-MAR-1993 18:09:01.12\r\n" + |
michael@0 | 5 | "[RWCEM1] 4 2-MAR-1993 18:09:01.12\r\n" + |
michael@0 | 6 | "[RWCEM1]A 4 3-MAR-1993 18:09:01.12\r\n" + |
michael@0 | 7 | "[RWCEM1]B; 4 4-MAR-1993 18:09:01.12\r\n" + |
michael@0 | 8 | "[RWCEM1];1 4 5-MAR-1993 18:09:01.12\r\n" + |
michael@0 | 9 | "[RWCEM1]; 4 6-MAR-1993 18:09:01.12\r\n" + |
michael@0 | 10 | "[RWCEM1]C;1D 4 7-MAR-1993 18:09:01.12\r\n" + |
michael@0 | 11 | "[RWCEM1]E;1 4 8-MAR-1993 18:09:01.12\r\n" |
michael@0 | 12 | , |
michael@0 | 13 | "300: " + URL + "\n" + |
michael@0 | 14 | "200: filename content-length last-modified file-type\n" + |
michael@0 | 15 | "201: \"A\" 2048 Sun%2C%2003%20Mar%201993%2018%3A09%3A01 FILE \n" + |
michael@0 | 16 | "201: \"E\" 2048 Sun%2C%2008%20Mar%201993%2018%3A09%3A01 FILE \n"] |
michael@0 | 17 | , |
michael@0 | 18 | ["\r\r\r\n" |
michael@0 | 19 | , |
michael@0 | 20 | "300: " + URL + "\n" + |
michael@0 | 21 | "200: filename content-length last-modified file-type\n"] |
michael@0 | 22 | ] |
michael@0 | 23 | |
michael@0 | 24 | function checkData(request, data, ctx) { |
michael@0 | 25 | do_check_eq(tests[0][1], data); |
michael@0 | 26 | tests.shift(); |
michael@0 | 27 | next_test(); |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | function storeData(status, entry) { |
michael@0 | 31 | do_check_eq(status, Components.results.NS_OK); |
michael@0 | 32 | entry.setMetaDataElement("servertype", "0"); |
michael@0 | 33 | var os = entry.openOutputStream(0); |
michael@0 | 34 | |
michael@0 | 35 | var written = os.write(tests[0][0], tests[0][0].length); |
michael@0 | 36 | if (written != tests[0][0].length) { |
michael@0 | 37 | do_throw("os.write has not written all data!\n" + |
michael@0 | 38 | " Expected: " + written + "\n" + |
michael@0 | 39 | " Actual: " + tests[0][0].length + "\n"); |
michael@0 | 40 | } |
michael@0 | 41 | os.close(); |
michael@0 | 42 | entry.close(); |
michael@0 | 43 | |
michael@0 | 44 | var ios = Components.classes["@mozilla.org/network/io-service;1"]. |
michael@0 | 45 | getService(Components.interfaces.nsIIOService); |
michael@0 | 46 | var channel = ios.newChannel(URL, "", null); |
michael@0 | 47 | channel.asyncOpen(new ChannelListener(checkData, null, CL_ALLOW_UNKNOWN_CL), null); |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | function next_test() { |
michael@0 | 51 | if (tests.length == 0) |
michael@0 | 52 | do_test_finished(); |
michael@0 | 53 | else { |
michael@0 | 54 | asyncOpenCacheEntry(URL, |
michael@0 | 55 | "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, |
michael@0 | 56 | storeData); |
michael@0 | 57 | } |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | function run_test() { |
michael@0 | 61 | do_execute_soon(next_test); |
michael@0 | 62 | do_test_pending(); |
michael@0 | 63 | } |