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 Ci = Components.interfaces; |
michael@0 | 2 | const Cc = Components.classes; |
michael@0 | 3 | |
michael@0 | 4 | var nameArray = [ |
michael@0 | 5 | "ascii", // ASCII |
michael@0 | 6 | "fran\u00E7ais", // Latin-1 |
michael@0 | 7 | "\u0420\u0443\u0441\u0441\u043A\u0438\u0439", // Cyrillic |
michael@0 | 8 | "\u65E5\u672C\u8A9E", // Japanese |
michael@0 | 9 | "\u4E2D\u6587", // Chinese |
michael@0 | 10 | "\uD55C\uAD6D\uC5B4", // Korean |
michael@0 | 11 | "\uD801\uDC0F\uD801\uDC2D\uD801\uDC3B\uD801\uDC2B" // Deseret |
michael@0 | 12 | ]; |
michael@0 | 13 | |
michael@0 | 14 | function getTempDir() |
michael@0 | 15 | { |
michael@0 | 16 | var dirService = Cc["@mozilla.org/file/directory_service;1"] |
michael@0 | 17 | .getService(Ci.nsIProperties); |
michael@0 | 18 | return dirService.get("TmpD", Ci.nsILocalFile); |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | function create_file(fileName) |
michael@0 | 22 | { |
michael@0 | 23 | var outFile = getTempDir(); |
michael@0 | 24 | outFile.append(fileName); |
michael@0 | 25 | outFile.createUnique(outFile.NORMAL_FILE_TYPE, 0600); |
michael@0 | 26 | |
michael@0 | 27 | var stream = Cc["@mozilla.org/network/file-output-stream;1"] |
michael@0 | 28 | .createInstance(Ci.nsIFileOutputStream); |
michael@0 | 29 | stream.init(outFile, 0x02 | 0x08 | 0x20, 0600, 0); |
michael@0 | 30 | stream.write("foo", 3); |
michael@0 | 31 | stream.close(); |
michael@0 | 32 | |
michael@0 | 33 | do_check_eq(outFile.leafName.substr(0, fileName.length), fileName); |
michael@0 | 34 | |
michael@0 | 35 | return outFile; |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | function test_create(fileName) |
michael@0 | 39 | { |
michael@0 | 40 | var file1 = create_file(fileName); |
michael@0 | 41 | var file2 = create_file(fileName); |
michael@0 | 42 | file1.remove(false); |
michael@0 | 43 | file2.remove(false); |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | function run_test() |
michael@0 | 47 | { |
michael@0 | 48 | for (var i = 0; i < nameArray.length; ++i) { |
michael@0 | 49 | test_create(nameArray[i]); |
michael@0 | 50 | } |
michael@0 | 51 | } |