Bug 952335 - Provide the full path for OS.Constants.Path.libxul on OSX. r=mossop, a=sledru
authorDavid Rajchenbach-Teller <dteller@mozilla.com>
Wed, 05 Feb 2014 13:29:51 -0500
changeset 182749 4afffeb6c0560a8ec2ecfb4e1bff614d1a406230
parent 182748 f9028e3008d5e18011f05fa1ec700f2225843286
child 182750 01a65675640a32ed1f52b0a9cc7a289488498d52
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop, sledru
bugs952335
milestone29.0a2
Bug 952335 - Provide the full path for OS.Constants.Path.libxul on OSX. r=mossop, a=sledru
addon-sdk/source/test/test-libxul.js
dom/system/OSFileConstants.cpp
new file mode 100644
--- /dev/null
+++ b/addon-sdk/source/test/test-libxul.js
@@ -0,0 +1,18 @@
+/* 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/. */
+
+// Test that we can link with libxul using js-ctypes
+
+const {Cu} = require("chrome");
+const {ctypes} = Cu.import("resource://gre/modules/ctypes.jsm", {});
+const {OS} = Cu.import("resource://gre/modules/osfile.jsm", {});
+
+exports.test = function(assert) {
+  let path = OS.Constants.Path.libxul;
+  assert.pass("libxul is at " + path);
+  let lib = ctypes.open(path);
+  assert.ok(lib != null, "linked to libxul successfully");
+};
+
+require('test').run(exports);
--- a/dom/system/OSFileConstants.cpp
+++ b/dom/system/OSFileConstants.cpp
@@ -832,21 +832,24 @@ bool DefineOSFileConstants(JSContext *cx
     return false;
   }
 
   // Locate libxul
   // Note that we don't actually provide the full path, only the name of the
   // library, which is sufficient to link to the library using js-ctypes.
 
 #if defined(XP_MACOSX)
-  // Under MacOS X, for some reason, libxul is called simply "XUL"
-  nsAutoString libxul(NS_LITERAL_STRING("XUL"));
+  // Under MacOS X, for some reason, libxul is called simply "XUL",
+  // and we need to provide the full path.
+  nsAutoString libxul;
+  libxul.Append(gPaths->libDir);
+  libxul.Append(NS_LITERAL_STRING("/XUL"));
 #else
   // On other platforms, libxul is a library "xul" with regular
-  // library prefix/suffix
+  // library prefix/suffix.
   nsAutoString libxul;
   libxul.Append(NS_LITERAL_STRING(DLL_PREFIX));
   libxul.Append(NS_LITERAL_STRING("xul"));
   libxul.Append(NS_LITERAL_STRING(DLL_SUFFIX));
 #endif // defined(XP_MACOSX)
 
   if (!SetStringProperty(cx, objPath, "libxul", libxul)) {
     return false;