Backed out changeset d6ec40f470fc (bug 1319854)
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Mon, 28 Nov 2016 15:56:37 +0100
changeset 324445 f62ce5db4ee2eecb3c69b8bb1405cb0adc2bc3eb
parent 324444 ecd2e5b74e52d190cec7f887806adacd245d04d7
child 324446 d2a6721fbbde1f38a29fde87f13bbb49fed49706
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
bugs1319854
milestone53.0a1
backs outd6ec40f470fced56227e005c08ee40a0f5a47b5b
Backed out changeset d6ec40f470fc (bug 1319854)
toolkit/components/osfile/tests/xpcshell/test_path.js
--- a/toolkit/components/osfile/tests/xpcshell/test_path.js
+++ b/toolkit/components/osfile/tests/xpcshell/test_path.js
@@ -1,34 +1,41 @@
 /* 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 test_windows()
+function run_test()
 {
   do_print("Testing Windows paths");
 
-  let Win = {};
-  Components.utils.import("resource://gre/modules/osfile/ospath_win.jsm", Win);
-
   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"), ".");
@@ -116,25 +123,18 @@ function test_windows()
   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");
-}
 
-function test_unix()
-{
   do_print("Testing unix paths");
-
-  let Unix = {};
-  Components.utils.import("resource://gre/modules/osfile/ospath_unix.jsm", Unix);
-
   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");
@@ -142,26 +142,16 @@ function test_unix()
   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");
-}
-
-function run_test()
-{
-  let isWindows = ("@mozilla.org/windows-registry-key;1" in Components.classes);
-  if (isWindows) {
-    test_windows();
-  } else {
-    test_unix();
-  }
 
   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
   }