tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_getTestFile.js (1147B)


      1 add_task(async function test() {
      2  SimpleTest.doesThrow(function () {
      3    getTestFilePath("/browser_getTestFile.js");
      4  }, "getTestFilePath rejects absolute paths");
      5 
      6  await Promise.all([
      7    IOUtils.exists(getTestFilePath("browser_getTestFile.js")).then(
      8      function (exists) {
      9        ok(exists, "getTestFilePath consider the path as being relative");
     10      }
     11    ),
     12 
     13    IOUtils.exists(getTestFilePath("./browser_getTestFile.js")).then(
     14      function (exists) {
     15        ok(exists, "getTestFilePath also accepts explicit relative path");
     16      }
     17    ),
     18 
     19    IOUtils.exists(getTestFilePath("./browser_getTestFileTypo.xul")).then(
     20      function (exists) {
     21        ok(!exists, "getTestFilePath do not throw if the file doesn't exists");
     22      }
     23    ),
     24 
     25    IOUtils.readUTF8(getTestFilePath("test-dir/test-file")).then(
     26      function (content) {
     27        is(content, "foo\n", "getTestFilePath can reach sub-folder files 1/2");
     28      }
     29    ),
     30 
     31    IOUtils.readUTF8(getTestFilePath("./test-dir/test-file")).then(
     32      function (content) {
     33        is(content, "foo\n", "getTestFilePath can reach sub-folder files 2/2");
     34      }
     35    ),
     36  ]);
     37 });