tor-browser

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

test_chromeGetTestFile.xhtml (1947B)


      1 <?xml version="1.0"?>
      2 <!-- This Source Code Form is subject to the terms of the Mozilla Public
      3   - License, v. 2.0. If a copy of the MPL was not distributed with this
      4   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
      5 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
      6                 type="text/css"?>
      7 <window title="Test chrome harness functions"
      8        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
      9  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
     10  <script src="chrome://mochikit/content/chrome-harness.js"></script>
     11  <script type="application/javascript">
     12  <![CDATA[
     13    add_task(async function test() {
     14      SimpleTest.doesThrow(function () {
     15        getTestFilePath("/test_chromeGetTestFile.xhtml")
     16      }, "getTestFilePath rejects absolute paths");
     17 
     18      await Promise.all([
     19        IOUtils.exists(getTestFilePath("test_chromeGetTestFile.xhtml"))
     20          .then(function (exists) {
     21            ok(exists, "getTestFilePath consider the path as being relative");
     22          }),
     23 
     24        IOUtils.exists(getTestFilePath("./test_chromeGetTestFile.xhtml"))
     25          .then(function (exists) {
     26            ok(exists, "getTestFilePath also accepts explicit relative path");
     27          }),
     28 
     29        IOUtils.exists(getTestFilePath("./test_chromeGetTestFileTypo.xhtml"))
     30          .then(function (exists) {
     31            ok(!exists, "getTestFilePath do not throw if the file doesn't exists");
     32          }),
     33 
     34        IOUtils.readUTF8(getTestFilePath("test-dir/test-file"))
     35          .then(function (content) {
     36            is(content, "foo\n", "getTestFilePath can reach sub-folder files 1/2");
     37          }),
     38 
     39        IOUtils.readUTF8(getTestFilePath("./test-dir/test-file"))
     40          .then(function (content) {
     41            is(content, "foo\n", "getTestFilePath can reach sub-folder files 2/2");
     42          })
     43      ]);
     44    });
     45  ]]>
     46  </script>
     47 </window>