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 | function test() { |
michael@0 | 2 | let {Promise} = Components.utils.import("resource://gre/modules/Promise.jsm"); |
michael@0 | 3 | Components.utils.import("resource://gre/modules/osfile.jsm"); |
michael@0 | 4 | let decoder = new TextDecoder(); |
michael@0 | 5 | |
michael@0 | 6 | waitForExplicitFinish(); |
michael@0 | 7 | |
michael@0 | 8 | SimpleTest.doesThrow(function () { |
michael@0 | 9 | getTestFilePath("/browser_getTestFile.js") |
michael@0 | 10 | }, "getTestFilePath rejects absolute paths"); |
michael@0 | 11 | |
michael@0 | 12 | Promise.all([ |
michael@0 | 13 | OS.File.exists(getTestFilePath("browser_getTestFile.js")) |
michael@0 | 14 | .then(function (exists) { |
michael@0 | 15 | ok(exists, "getTestFilePath consider the path as being relative"); |
michael@0 | 16 | }), |
michael@0 | 17 | |
michael@0 | 18 | OS.File.exists(getTestFilePath("./browser_getTestFile.js")) |
michael@0 | 19 | .then(function (exists) { |
michael@0 | 20 | ok(exists, "getTestFilePath also accepts explicit relative path"); |
michael@0 | 21 | }), |
michael@0 | 22 | |
michael@0 | 23 | OS.File.exists(getTestFilePath("./browser_getTestFileTypo.xul")) |
michael@0 | 24 | .then(function (exists) { |
michael@0 | 25 | ok(!exists, "getTestFilePath do not throw if the file doesn't exists"); |
michael@0 | 26 | }), |
michael@0 | 27 | |
michael@0 | 28 | OS.File.read(getTestFilePath("test-dir/test-file")) |
michael@0 | 29 | .then(function (array) { |
michael@0 | 30 | is(decoder.decode(array), "foo\n", "getTestFilePath can reach sub-folder files 1/2"); |
michael@0 | 31 | }), |
michael@0 | 32 | |
michael@0 | 33 | OS.File.read(getTestFilePath("./test-dir/test-file")) |
michael@0 | 34 | .then(function (array) { |
michael@0 | 35 | is(decoder.decode(array), "foo\n", "getTestFilePath can reach sub-folder files 2/2"); |
michael@0 | 36 | }) |
michael@0 | 37 | |
michael@0 | 38 | ]).then(function () { |
michael@0 | 39 | finish(); |
michael@0 | 40 | }, function (error) { |
michael@0 | 41 | ok(false, error); |
michael@0 | 42 | finish(); |
michael@0 | 43 | }); |
michael@0 | 44 | } |