testing/mochitest/chrome/test_chromeGetTestFile.xul

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial