summaryrefslogtreecommitdiffstats
path: root/testing/mochitest/tests/browser/browser_getTestFile.js
blob: 23524b9f233b1d2f8cde1c1969a9fe6853450bd5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
add_task(async function test() {
  SimpleTest.doesThrow(function() {
    getTestFilePath("/browser_getTestFile.js");
  }, "getTestFilePath rejects absolute paths");

  await Promise.all([
    IOUtils.exists(getTestFilePath("browser_getTestFile.js")).then(function(
      exists
    ) {
      ok(exists, "getTestFilePath consider the path as being relative");
    }),

    IOUtils.exists(getTestFilePath("./browser_getTestFile.js")).then(function(
      exists
    ) {
      ok(exists, "getTestFilePath also accepts explicit relative path");
    }),

    IOUtils.exists(getTestFilePath("./browser_getTestFileTypo.xul")).then(
      function(exists) {
        ok(!exists, "getTestFilePath do not throw if the file doesn't exists");
      }
    ),

    IOUtils.readUTF8(getTestFilePath("test-dir/test-file")).then(function(
      content
    ) {
      is(content, "foo\n", "getTestFilePath can reach sub-folder files 1/2");
    }),

    IOUtils.readUTF8(getTestFilePath("./test-dir/test-file")).then(function(
      content
    ) {
      is(content, "foo\n", "getTestFilePath can reach sub-folder files 2/2");
    }),
  ]);
});