michael@0: function test() { michael@0: let {Promise} = Components.utils.import("resource://gre/modules/Promise.jsm"); michael@0: Components.utils.import("resource://gre/modules/osfile.jsm"); michael@0: let decoder = new TextDecoder(); michael@0: michael@0: waitForExplicitFinish(); michael@0: michael@0: SimpleTest.doesThrow(function () { michael@0: getTestFilePath("/browser_getTestFile.js") michael@0: }, "getTestFilePath rejects absolute paths"); michael@0: michael@0: Promise.all([ michael@0: OS.File.exists(getTestFilePath("browser_getTestFile.js")) michael@0: .then(function (exists) { michael@0: ok(exists, "getTestFilePath consider the path as being relative"); michael@0: }), michael@0: michael@0: OS.File.exists(getTestFilePath("./browser_getTestFile.js")) michael@0: .then(function (exists) { michael@0: ok(exists, "getTestFilePath also accepts explicit relative path"); michael@0: }), michael@0: michael@0: OS.File.exists(getTestFilePath("./browser_getTestFileTypo.xul")) michael@0: .then(function (exists) { michael@0: ok(!exists, "getTestFilePath do not throw if the file doesn't exists"); michael@0: }), michael@0: michael@0: OS.File.read(getTestFilePath("test-dir/test-file")) michael@0: .then(function (array) { michael@0: is(decoder.decode(array), "foo\n", "getTestFilePath can reach sub-folder files 1/2"); michael@0: }), michael@0: michael@0: OS.File.read(getTestFilePath("./test-dir/test-file")) michael@0: .then(function (array) { michael@0: is(decoder.decode(array), "foo\n", "getTestFilePath can reach sub-folder files 2/2"); michael@0: }) michael@0: michael@0: ]).then(function () { michael@0: finish(); michael@0: }, function (error) { michael@0: ok(false, error); michael@0: finish(); michael@0: }); michael@0: }