Bug 823872 - Add test for OS.Constants.{libc, Win}. r=Yoric
authorSankha Narayan Guria <sankha93@gmail.com>
Sat, 19 Jan 2013 18:49:42 -0500
changeset 119376 68f8f4b74f63d074b042af1ff4052e4fb1513dda
parent 119375 587ac3f2bd30880393aa13546ae8d6c59ff8200f
child 119377 077caacae057202aced93f84cfd423a0ecb71e37
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersYoric
bugs823872
milestone21.0a1
Bug 823872 - Add test for OS.Constants.{libc, Win}. r=Yoric
dom/system/tests/test_constants.xul
--- a/dom/system/tests/test_constants.xul
+++ b/dom/system/tests/test_constants.xul
@@ -27,25 +27,54 @@ function test_xul() {
     ok(false, "Could not open libxul " + x);
   }
   if (lib) {
     lib.close();
   }
   ok(true, "test_xul: opened libxul successfully");
 }
 
+// Test that OS.Constants.libc is defined
+function test_libc() {
+  isnot(null, OS.Constants.libc, "OS.Constants.libc is defined");
+  is(0001, OS.Constants.libc.S_IXOTH, "OS.Constants.libc.S_IXOTH is defined");
+  is(0002, OS.Constants.libc.S_IWOTH, "OS.Constants.libc.S_IWOTH is defined");
+  is(0007, OS.Constants.libc.S_IRWXO, "OS.Constants.libc.S_IRWXO is defined");
+  is(0010, OS.Constants.libc.S_IXGRP, "OS.Constants.libc.S_IXGRP is defined");
+  is(0020, OS.Constants.libc.S_IWGRP, "OS.Constants.libc.S_IWGRP is defined");
+  is(0040, OS.Constants.libc.S_IRGRP, "OS.Constants.libc.S_IRGRP is defined");
+  is(0070, OS.Constants.libc.S_IRWXG, "OS.Constants.libc.S_IRWXG is defined");
+  is(0100, OS.Constants.libc.S_IXUSR, "OS.Constants.libc.S_IXUSR is defined");
+  is(0200, OS.Constants.libc.S_IWUSR, "OS.Constants.libc.S_IWUSR is defined");
+  is(0400, OS.Constants.libc.S_IRUSR, "OS.Constants.libc.S_IRUSR is defined");
+  is(0700, OS.Constants.libc.S_IRWXU, "OS.Constants.libc.S_IRWXU is defined");
+}
+
+// Test that OS.Constants.Win is defined
+function test_Win() {
+  var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
+                           .getService(Components.interfaces.nsIXULRuntime);
+  if(xulRuntime.OS == "Windows") {
+    ok("Win" in OS.Constants, "OS.Constants.Win is defined");
+    is(OS.Constants.Win.INVALID_HANDLE_VALUE, -1,
+      "OS.Constants.Win.INVALID_HANDLE_VALUE is defined and correct");
+  }
+}
+
 function test() {
   ok(true, "test_constants.xul: Starting test");
 
   // Test 1: Load libxul from main thread
   Components.classes["@mozilla.org/net/osfileconstantsservice;1"].
     getService(Components.interfaces.nsIOSFileConstantsService).
     init();
   Components.utils.import("resource://gre/modules/ctypes.jsm");
   test_xul();
+  test_libc();
+  test_Win();
 
   // Test 2: Load libxul from chrome thread
   worker = new ChromeWorker("worker_constants.js");
   SimpleTest.waitForExplicitFinish();
   ok(true, "test_constants.xul: Chrome worker created");
   worker.onerror = function onerror(error) {
     error.preventDefault();
     ok(false, "error " + error);