Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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 type="application/javascript"
10 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
11 <script type="application/javascript" src="chrome://mochikit/content/chrome-harness.js"></script>
12 <script type="application/javascript">
13 <![CDATA[
14 let {Promise} = Components.utils.import("resource://gre/modules/Promise.jsm");
15 Components.utils.import("resource://gre/modules/osfile.jsm");
16 let decoder = new TextDecoder();
18 SimpleTest.waitForExplicitFinish();
20 SimpleTest.doesThrow(function () {
21 getTestFilePath("/test_chromeGetTestFile.xul")
22 }, "getTestFilePath rejects absolute paths");
24 Promise.all([
25 OS.File.exists(getTestFilePath("test_chromeGetTestFile.xul"))
26 .then(function (exists) {
27 ok(exists, "getTestFilePath consider the path as being relative");
28 }),
30 OS.File.exists(getTestFilePath("./test_chromeGetTestFile.xul"))
31 .then(function (exists) {
32 ok(exists, "getTestFilePath also accepts explicit relative path");
33 }),
35 OS.File.exists(getTestFilePath("./test_chromeGetTestFileTypo.xul"))
36 .then(function (exists) {
37 ok(!exists, "getTestFilePath do not throw if the file doesn't exists");
38 }),
40 OS.File.read(getTestFilePath("test-dir/test-file"))
41 .then(function (array) {
42 is(decoder.decode(array), "foo\n", "getTestFilePath can reach sub-folder files 1/2");
43 }),
45 OS.File.read(getTestFilePath("./test-dir/test-file"))
46 .then(function (array) {
47 is(decoder.decode(array), "foo\n", "getTestFilePath can reach sub-folder files 2/2");
48 })
50 ]).then(function () {
51 SimpleTest.finish();
52 }, console.error);
53 ]]>
54 </script>
55 </window>