summaryrefslogtreecommitdiffstats
path: root/toolkit/components/osfile/tests/xpcshell/test_path.js
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-02-25 15:07:00 -0500
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-04-14 12:55:19 +0200
commiteb70e6e3d0bff11c25f14b1196025791bf2308fb (patch)
tree5ef4ce17db83c74d7b05ec12c8f59e095a6dd5bd /toolkit/components/osfile/tests/xpcshell/test_path.js
parent32ead795290b3399d56b4708fc75b77d296f6a1a (diff)
downloadUXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.gz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.lz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.xz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.zip
Issue #439 - Remove tests from toolkit/
Diffstat (limited to 'toolkit/components/osfile/tests/xpcshell/test_path.js')
-rw-r--r--toolkit/components/osfile/tests/xpcshell/test_path.js159
1 files changed, 0 insertions, 159 deletions
diff --git a/toolkit/components/osfile/tests/xpcshell/test_path.js b/toolkit/components/osfile/tests/xpcshell/test_path.js
deleted file mode 100644
index 76a507ee3..000000000
--- a/toolkit/components/osfile/tests/xpcshell/test_path.js
+++ /dev/null
@@ -1,159 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-Components.utils.import("resource://gre/modules/Services.jsm", this);
-Services.prefs.setBoolPref("toolkit.osfile.test.syslib_necessary", false);
- // We don't need libc/kernel32.dll for this test
-
-var ImportWin = {};
-var ImportUnix = {};
-Components.utils.import("resource://gre/modules/osfile/ospath_win.jsm", ImportWin);
-Components.utils.import("resource://gre/modules/osfile/ospath_unix.jsm", ImportUnix);
-
-var Win = ImportWin;
-var Unix = ImportUnix;
-
-function do_check_fail(f)
-{
- try {
- let result = f();
- do_print("Failed do_check_fail: " + result);
- do_check_true(false);
- } catch (ex) {
- do_check_true(true);
- }
-};
-
-function run_test()
-{
- do_print("Testing Windows paths");
-
- do_print("Backslash-separated, no drive");
- do_check_eq(Win.basename("a\\b"), "b");
- do_check_eq(Win.basename("a\\b\\"), "");
- do_check_eq(Win.basename("abc"), "abc");
- do_check_eq(Win.dirname("a\\b"), "a");
- do_check_eq(Win.dirname("a\\b\\"), "a\\b");
- do_check_eq(Win.dirname("a\\\\\\\\b"), "a");
- do_check_eq(Win.dirname("abc"), ".");
- do_check_eq(Win.normalize("\\a\\b\\c"), "\\a\\b\\c");
- do_check_eq(Win.normalize("\\a\\b\\\\\\\\c"), "\\a\\b\\c");
- do_check_eq(Win.normalize("\\a\\b\\c\\\\\\"), "\\a\\b\\c");
- do_check_eq(Win.normalize("\\a\\b\\c\\..\\..\\..\\d\\e\\f"), "\\d\\e\\f");
- do_check_eq(Win.normalize("a\\b\\c\\..\\..\\..\\d\\e\\f"), "d\\e\\f");
- do_check_fail(() => Win.normalize("\\a\\b\\c\\..\\..\\..\\..\\d\\e\\f"));
-
- do_check_eq(Win.join("\\tmp", "foo", "bar"), "\\tmp\\foo\\bar", "join \\tmp,foo,bar");
- do_check_eq(Win.join("\\tmp", "\\foo", "bar"), "\\foo\\bar", "join \\tmp,\\foo,bar");
- do_check_eq(Win.winGetDrive("\\tmp"), null);
- do_check_eq(Win.winGetDrive("\\tmp\\a\\b\\c\\d\\e"), null);
- do_check_eq(Win.winGetDrive("\\"), null);
-
-
- do_print("Backslash-separated, with a drive");
- do_check_eq(Win.basename("c:a\\b"), "b");
- do_check_eq(Win.basename("c:a\\b\\"), "");
- do_check_eq(Win.basename("c:abc"), "abc");
- do_check_eq(Win.dirname("c:a\\b"), "c:a");
- do_check_eq(Win.dirname("c:a\\b\\"), "c:a\\b");
- do_check_eq(Win.dirname("c:a\\\\\\\\b"), "c:a");
- do_check_eq(Win.dirname("c:abc"), "c:");
- let options = {
- winNoDrive: true
- };
- do_check_eq(Win.dirname("c:a\\b", options), "a");
- do_check_eq(Win.dirname("c:a\\b\\", options), "a\\b");
- do_check_eq(Win.dirname("c:a\\\\\\\\b", options), "a");
- do_check_eq(Win.dirname("c:abc", options), ".");
- do_check_eq(Win.join("c:", "abc"), "c:\\abc", "join c:,abc");
-
- do_check_eq(Win.normalize("c:"), "c:\\");
- do_check_eq(Win.normalize("c:\\"), "c:\\");
- do_check_eq(Win.normalize("c:\\a\\b\\c"), "c:\\a\\b\\c");
- do_check_eq(Win.normalize("c:\\a\\b\\\\\\\\c"), "c:\\a\\b\\c");
- do_check_eq(Win.normalize("c:\\\\\\\\a\\b\\c"), "c:\\a\\b\\c");
- do_check_eq(Win.normalize("c:\\a\\b\\c\\\\\\"), "c:\\a\\b\\c");
- do_check_eq(Win.normalize("c:\\a\\b\\c\\..\\..\\..\\d\\e\\f"), "c:\\d\\e\\f");
- do_check_eq(Win.normalize("c:a\\b\\c\\..\\..\\..\\d\\e\\f"), "c:\\d\\e\\f");
- do_check_fail(() => Win.normalize("c:\\a\\b\\c\\..\\..\\..\\..\\d\\e\\f"));
-
- do_check_eq(Win.join("c:\\", "foo"), "c:\\foo", "join c:\,foo");
- do_check_eq(Win.join("c:\\tmp", "foo", "bar"), "c:\\tmp\\foo\\bar", "join c:\\tmp,foo,bar");
- do_check_eq(Win.join("c:\\tmp", "\\foo", "bar"), "c:\\foo\\bar", "join c:\\tmp,\\foo,bar");
- do_check_eq(Win.join("c:\\tmp", "c:\\foo", "bar"), "c:\\foo\\bar", "join c:\\tmp,c:\\foo,bar");
- do_check_eq(Win.join("c:\\tmp", "c:foo", "bar"), "c:\\foo\\bar", "join c:\\tmp,c:foo,bar");
- do_check_eq(Win.winGetDrive("c:"), "c:");
- do_check_eq(Win.winGetDrive("c:\\"), "c:");
- do_check_eq(Win.winGetDrive("c:abc"), "c:");
- do_check_eq(Win.winGetDrive("c:abc\\d\\e\\f\\g"), "c:");
- do_check_eq(Win.winGetDrive("c:\\abc"), "c:");
- do_check_eq(Win.winGetDrive("c:\\abc\\d\\e\\f\\g"), "c:");
-
- do_print("Forwardslash-separated, no drive");
- do_check_eq(Win.normalize("/a/b/c"), "\\a\\b\\c");
- do_check_eq(Win.normalize("/a/b////c"), "\\a\\b\\c");
- do_check_eq(Win.normalize("/a/b/c///"), "\\a\\b\\c");
- do_check_eq(Win.normalize("/a/b/c/../../../d/e/f"), "\\d\\e\\f");
- do_check_eq(Win.normalize("a/b/c/../../../d/e/f"), "d\\e\\f");
-
- do_print("Forwardslash-separated, with a drive");
- do_check_eq(Win.normalize("c:/"), "c:\\");
- do_check_eq(Win.normalize("c:/a/b/c"), "c:\\a\\b\\c");
- do_check_eq(Win.normalize("c:/a/b////c"), "c:\\a\\b\\c");
- do_check_eq(Win.normalize("c:////a/b/c"), "c:\\a\\b\\c");
- do_check_eq(Win.normalize("c:/a/b/c///"), "c:\\a\\b\\c");
- do_check_eq(Win.normalize("c:/a/b/c/../../../d/e/f"), "c:\\d\\e\\f");
- do_check_eq(Win.normalize("c:a/b/c/../../../d/e/f"), "c:\\d\\e\\f");
-
- do_print("Backslash-separated, UNC-style");
- do_check_eq(Win.basename("\\\\a\\b"), "b");
- do_check_eq(Win.basename("\\\\a\\b\\"), "");
- do_check_eq(Win.basename("\\\\abc"), "");
- do_check_eq(Win.dirname("\\\\a\\b"), "\\\\a");
- do_check_eq(Win.dirname("\\\\a\\b\\"), "\\\\a\\b");
- do_check_eq(Win.dirname("\\\\a\\\\\\\\b"), "\\\\a");
- do_check_eq(Win.dirname("\\\\abc"), "\\\\abc");
- do_check_eq(Win.normalize("\\\\a\\b\\c"), "\\\\a\\b\\c");
- do_check_eq(Win.normalize("\\\\a\\b\\\\\\\\c"), "\\\\a\\b\\c");
- do_check_eq(Win.normalize("\\\\a\\b\\c\\\\\\"), "\\\\a\\b\\c");
- do_check_eq(Win.normalize("\\\\a\\b\\c\\..\\..\\d\\e\\f"), "\\\\a\\d\\e\\f");
- do_check_fail(() => Win.normalize("\\\\a\\b\\c\\..\\..\\..\\d\\e\\f"));
-
- do_check_eq(Win.join("\\\\a\\tmp", "foo", "bar"), "\\\\a\\tmp\\foo\\bar");
- do_check_eq(Win.join("\\\\a\\tmp", "\\foo", "bar"), "\\\\a\\foo\\bar");
- do_check_eq(Win.join("\\\\a\\tmp", "\\\\foo\\", "bar"), "\\\\foo\\bar");
- do_check_eq(Win.winGetDrive("\\\\"), null);
- do_check_eq(Win.winGetDrive("\\\\c"), "\\\\c");
- do_check_eq(Win.winGetDrive("\\\\c\\abc"), "\\\\c");
-
- do_print("Testing unix paths");
- do_check_eq(Unix.basename("a/b"), "b");
- do_check_eq(Unix.basename("a/b/"), "");
- do_check_eq(Unix.basename("abc"), "abc");
- do_check_eq(Unix.dirname("a/b"), "a");
- do_check_eq(Unix.dirname("a/b/"), "a/b");
- do_check_eq(Unix.dirname("a////b"), "a");
- do_check_eq(Unix.dirname("abc"), ".");
- do_check_eq(Unix.normalize("/a/b/c"), "/a/b/c");
- do_check_eq(Unix.normalize("/a/b////c"), "/a/b/c");
- do_check_eq(Unix.normalize("////a/b/c"), "/a/b/c");
- do_check_eq(Unix.normalize("/a/b/c///"), "/a/b/c");
- do_check_eq(Unix.normalize("/a/b/c/../../../d/e/f"), "/d/e/f");
- do_check_eq(Unix.normalize("a/b/c/../../../d/e/f"), "d/e/f");
- do_check_fail(() => Unix.normalize("/a/b/c/../../../../d/e/f"));
-
- do_check_eq(Unix.join("/tmp", "foo", "bar"), "/tmp/foo/bar", "join /tmp,foo,bar");
- do_check_eq(Unix.join("/tmp", "/foo", "bar"), "/foo/bar", "join /tmp,/foo,bar");
-
- do_print("Testing the presence of ospath.jsm");
- let Scope = {};
- try {
- Components.utils.import("resource://gre/modules/osfile/ospath.jsm", Scope);
- } catch (ex) {
- // Can't load ospath
- }
- do_check_true(!!Scope.basename);
-}