Bug 684327 - Test parameter passing. r=khuey
authorBobby Holley <bobbyholley@gmail.com>
Sun, 25 Sep 2011 15:38:00 +0100
changeset 77524 3d4cbdd72c036e2492adf32013a1332cac2212d8
parent 77523 ca6bb27d3527ef30ec3277c684e1176d0aed268f
child 77525 2fe54a83eb507eb412d9ff8920b68a0e8000bfdf
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewerskhuey
bugs684327
milestone9.0a1
Bug 684327 - Test parameter passing. r=khuey
js/src/xpconnect/tests/components/js/Makefile.in
js/src/xpconnect/tests/components/js/xpctest.manifest
js/src/xpconnect/tests/components/js/xpctest_params.js
js/src/xpconnect/tests/components/native/Makefile.in
js/src/xpconnect/tests/components/native/xpctest_module.cpp
js/src/xpconnect/tests/components/native/xpctest_params.cpp
js/src/xpconnect/tests/components/native/xpctest_private.h
js/src/xpconnect/tests/idl/Makefile.in
js/src/xpconnect/tests/idl/xpctest_params.idl
js/src/xpconnect/tests/unit/test_params.js
js/src/xpconnect/tests/unit/xpcshell.ini
--- a/js/src/xpconnect/tests/components/js/Makefile.in
+++ b/js/src/xpconnect/tests/components/js/Makefile.in
@@ -45,16 +45,17 @@ include $(DEPTH)/config/autoconf.mk
 MODULE = xpctest
 LIBRARY_NAME = xpctest
 IS_COMPONENT = 1
 MODULE_NAME = xpconnect_test
 NO_DIST_INSTALL = 1
 
 JS_FILES = \
   xpctest_attributes.js \
+  xpctest_params.js \
   $(NULL)
 
 include $(topsrcdir)/config/config.mk
 
 MANIFEST_FILE = xpctest.manifest
 
 include $(topsrcdir)/config/rules.mk
 
--- a/js/src/xpconnect/tests/components/js/xpctest.manifest
+++ b/js/src/xpconnect/tests/components/js/xpctest.manifest
@@ -1,5 +1,8 @@
 component {8ff41d9c-66e9-4453-924a-7d8de0a5e966} xpctest_attributes.js
 contract @mozilla.org/js/xpc/test/js/ObjectReadWrite;1 {8ff41d9c-66e9-4453-924a-7d8de0a5e966}
 
 component {916c4247-253d-4ed0-a425-adfedf53ecc8} xpctest_attributes.js
 contract @mozilla.org/js/xpc/test/js/ObjectReadOnly;1 {916c4247-253d-4ed0-a425-adfedf53ecc8}
+
+component {e3b86f4e-49c0-487c-a2b0-3a986720a044} xpctest_params.js
+contract @mozilla.org/js/xpc/test/js/Params;1 {e3b86f4e-49c0-487c-a2b0-3a986720a044}
new file mode 100644
--- /dev/null
+++ b/js/src/xpconnect/tests/components/js/xpctest_params.js
@@ -0,0 +1,77 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is XPConnect Test Code.
+ *
+ * The Initial Developer of the Original Code is The Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2011
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Bobby Holley <bobbyholley@gmail.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+Components.utils.import("resource:///modules/XPCOMUtils.jsm");
+
+function TestParams() {
+}
+
+/* For once I'm happy that JS is weakly typed. */
+function f(a, b) {
+    var rv = b.value;
+    b.value = a;
+    return rv;
+};
+
+TestParams.prototype = {
+
+  /* Boilerplate */
+  QueryInterface: XPCOMUtils.generateQI([Components.interfaces["nsIXPCTestParams"]]),
+  contractID: "@mozilla.org/js/xpc/test/js/Params;1",
+  classID: Components.ID("{e3b86f4e-49c0-487c-a2b0-3a986720a044}"),
+
+  /* nsIXPCTestParams */
+  testBoolean: f,
+  testOctet: f,
+  testShort: f,
+  testLong: f,
+  testLongLong: f,
+  testUnsignedShort: f,
+  testUnsignedLong: f,
+  testUnsignedLongLong: f,
+  testFloat: f,
+  testDouble: f,
+  testChar: f,
+  testString: f,
+  testWchar: f,
+  testWstring: f,
+  testDOMString: f,
+  testAString: f,
+  testAUTF8String: f,
+  testACString: f,
+  testJsval: f
+};
+
+var NSGetFactory = XPCOMUtils.generateNSGetFactory([TestParams]);
--- a/js/src/xpconnect/tests/components/native/Makefile.in
+++ b/js/src/xpconnect/tests/components/native/Makefile.in
@@ -46,19 +46,20 @@ include $(DEPTH)/config/autoconf.mk
 
 MODULE = xpctest
 LIBRARY_NAME = xpctest
 IS_COMPONENT = 1
 MODULE_NAME = xpconnect_test
 NO_DIST_INSTALL = 1
 FORCE_SHARED_LIB = 1
 
-CPPSRCS		= \
+CPPSRCS = \
   xpctest_module.cpp \
   xpctest_attributes.cpp \
+  xpctest_params.cpp \
   $(NULL)
 
 include $(topsrcdir)/config/config.mk
 
 MANIFEST_FILE = xpctest.manifest
 
 EXTRA_DSO_LDOPTS += \
   $(XPCOM_GLUE_LDOPTS) \
--- a/js/src/xpconnect/tests/components/native/xpctest_module.cpp
+++ b/js/src/xpconnect/tests/components/native/xpctest_module.cpp
@@ -50,30 +50,38 @@
 #define NS_XPCTESTOBJECTREADONLY_CID \
 { 0x492609a7, 0x2582, 0x436b, \
    { 0xb0, 0xef, 0x92, 0xe2, 0x9b, 0xb9, 0xe1, 0x43 } }
 
 #define NS_XPCTESTOBJECTREADWRITE_CID \
 { 0x8f37f760, 0x3686, 0x4dbb, \
    { 0xb1, 0x21, 0x96, 0x93, 0xba, 0x81, 0x3f, 0x8f } }
 
+#define NS_XPCTESTPARAMS_CID \
+{ 0x1f11076a, 0x0fa2, 0x4f07, \
+    { 0xb4, 0x7a, 0xa1, 0x54, 0x31, 0xf2, 0xce, 0xf7 } }
+
 NS_GENERIC_FACTORY_CONSTRUCTOR(xpcTestObjectReadOnly)
 NS_GENERIC_FACTORY_CONSTRUCTOR(xpcTestObjectReadWrite)
+NS_GENERIC_FACTORY_CONSTRUCTOR(nsXPCTestParams)
 NS_DEFINE_NAMED_CID(NS_XPCTESTOBJECTREADONLY_CID);
 NS_DEFINE_NAMED_CID(NS_XPCTESTOBJECTREADWRITE_CID);
+NS_DEFINE_NAMED_CID(NS_XPCTESTPARAMS_CID);
 
 static const mozilla::Module::CIDEntry kXPCTestCIDs[] = {
     { &kNS_XPCTESTOBJECTREADONLY_CID, false, NULL, xpcTestObjectReadOnlyConstructor },
     { &kNS_XPCTESTOBJECTREADWRITE_CID, false, NULL, xpcTestObjectReadWriteConstructor },
+    { &kNS_XPCTESTPARAMS_CID, false, NULL, nsXPCTestParamsConstructor },
     { NULL }
 };
 
 static const mozilla::Module::ContractIDEntry kXPCTestContracts[] = {
     { "@mozilla.org/js/xpc/test/native/ObjectReadOnly;1", &kNS_XPCTESTOBJECTREADONLY_CID },
     { "@mozilla.org/js/xpc/test/native/ObjectReadWrite;1", &kNS_XPCTESTOBJECTREADWRITE_CID },
+    { "@mozilla.org/js/xpc/test/native/Params;1", &kNS_XPCTESTPARAMS_CID },
     { NULL }
 };
 
 static const mozilla::Module kXPCTestModule = {
     mozilla::Module::kVersion,
     kXPCTestCIDs,
     kXPCTestContracts
 };
new file mode 100644
--- /dev/null
+++ b/js/src/xpconnect/tests/components/native/xpctest_params.cpp
@@ -0,0 +1,184 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is XPConnect Test Code.
+ *
+ * The Initial Developer of the Original Code is The Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2011
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Bobby Holley <bobbyholley@gmail.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "xpctest_private.h"
+
+NS_IMPL_ISUPPORTS1(nsXPCTestParams, nsIXPCTestParams)
+
+nsXPCTestParams::nsXPCTestParams()
+{
+}
+
+nsXPCTestParams::~nsXPCTestParams()
+{
+}
+
+#define GENERIC_METHOD_IMPL { \
+    *_retval = *b; \
+    *b = a; \
+    return NS_OK; \
+}
+
+#define STRING_METHOD_IMPL { \
+    _retval.Assign(b); \
+    b.Assign(a); \
+    return NS_OK; \
+}
+
+/* boolean testBoolean (in boolean a, inout boolean b); */
+NS_IMETHODIMP nsXPCTestParams::TestBoolean(PRBool a, PRBool *b NS_INOUTPARAM, PRBool *_retval NS_OUTPARAM)
+{
+    GENERIC_METHOD_IMPL;
+}
+
+/* octet testOctet (in octet a, inout octet b); */
+NS_IMETHODIMP nsXPCTestParams::TestOctet(PRUint8 a, PRUint8 *b NS_INOUTPARAM, PRUint8 *_retval NS_OUTPARAM)
+{
+    GENERIC_METHOD_IMPL;
+}
+
+/* short testShort (in short a, inout short b); */
+NS_IMETHODIMP nsXPCTestParams::TestShort(PRInt16 a, PRInt16 *b NS_INOUTPARAM, PRInt16 *_retval NS_OUTPARAM)
+{
+    GENERIC_METHOD_IMPL;
+}
+
+/* long testLong (in long a, inout long b); */
+NS_IMETHODIMP nsXPCTestParams::TestLong(PRInt32 a, PRInt32 *b NS_INOUTPARAM, PRInt32 *_retval NS_OUTPARAM)
+{
+    GENERIC_METHOD_IMPL;
+}
+
+/* long long testLongLong (in long long a, inout long long b); */
+NS_IMETHODIMP nsXPCTestParams::TestLongLong(PRInt64 a, PRInt64 *b NS_INOUTPARAM, PRInt64 *_retval NS_OUTPARAM)
+{
+    GENERIC_METHOD_IMPL;
+}
+
+/* unsigned short testUnsignedShort (in unsigned short a, inout unsigned short b); */
+NS_IMETHODIMP nsXPCTestParams::TestUnsignedShort(PRUint16 a, PRUint16 *b NS_INOUTPARAM, PRUint16 *_retval NS_OUTPARAM)
+{
+    GENERIC_METHOD_IMPL;
+}
+
+/* unsigned long testUnsignedLong (in unsigned long a, inout unsigned long b); */
+NS_IMETHODIMP nsXPCTestParams::TestUnsignedLong(PRUint32 a, PRUint32 *b NS_INOUTPARAM, PRUint32 *_retval NS_OUTPARAM)
+{
+    GENERIC_METHOD_IMPL;
+}
+
+/* unsigned long long testUnsignedLongLong (in unsigned long long a, inout unsigned long long b); */
+NS_IMETHODIMP nsXPCTestParams::TestUnsignedLongLong(PRUint64 a, PRUint64 *b NS_INOUTPARAM, PRUint64 *_retval NS_OUTPARAM)
+{
+    GENERIC_METHOD_IMPL;
+}
+
+/* float testFloat (in float a, inout float b); */
+NS_IMETHODIMP nsXPCTestParams::TestFloat(float a, float *b NS_INOUTPARAM, float *_retval NS_OUTPARAM)
+{
+    GENERIC_METHOD_IMPL;
+}
+
+/* double testDouble (in double a, inout float b); */
+NS_IMETHODIMP nsXPCTestParams::TestDouble(double a, float *b NS_INOUTPARAM, double *_retval NS_OUTPARAM)
+{
+    GENERIC_METHOD_IMPL;
+}
+
+/* char testChar (in char a, inout char b); */
+NS_IMETHODIMP nsXPCTestParams::TestChar(char a, char *b NS_INOUTPARAM, char *_retval NS_OUTPARAM)
+{
+    GENERIC_METHOD_IMPL;
+}
+
+/* string testString (in string a, inout string b); */
+NS_IMETHODIMP nsXPCTestParams::TestString(const char * a, char * *b NS_INOUTPARAM, char * *_retval NS_OUTPARAM)
+{
+    nsDependentCString aprime(a);
+    nsDependentCString bprime(*b);
+    *_retval = ToNewCString(bprime);
+    *b = ToNewCString(aprime);
+    return NS_OK;
+}
+
+/* wchar testWchar (in wchar a, inout wchar b); */
+NS_IMETHODIMP nsXPCTestParams::TestWchar(PRUnichar a, PRUnichar *b NS_INOUTPARAM, PRUnichar *_retval NS_OUTPARAM)
+{
+    GENERIC_METHOD_IMPL;
+}
+
+/* wstring testWstring (in wstring a, inout wstring b); */
+NS_IMETHODIMP nsXPCTestParams::TestWstring(const PRUnichar * a, PRUnichar * *b NS_INOUTPARAM, PRUnichar * *_retval NS_OUTPARAM)
+{
+    nsDependentString aprime(a);
+    nsDependentString bprime(*b);
+    *_retval = ToNewUnicode(bprime);
+    *b = ToNewUnicode(aprime);
+    return NS_OK;
+}
+
+/* DOMString testDOMString (in DOMString a, inout DOMString b); */
+NS_IMETHODIMP nsXPCTestParams::TestDOMString(const nsAString & a, nsAString & b NS_INOUTPARAM, nsAString & _retval NS_OUTPARAM)
+{
+    STRING_METHOD_IMPL;
+}
+
+
+/* AString testAString (in AString a, inout AString b); */
+NS_IMETHODIMP nsXPCTestParams::TestAString(const nsAString & a, nsAString & b NS_INOUTPARAM, nsAString & _retval NS_OUTPARAM)
+{
+    STRING_METHOD_IMPL;
+}
+
+/* AUTF8String testAUTF8String (in AUTF8String a, inout AUTF8String b); */
+NS_IMETHODIMP nsXPCTestParams::TestAUTF8String(const nsACString & a, nsACString & b NS_INOUTPARAM, nsACString & _retval NS_OUTPARAM)
+{
+    STRING_METHOD_IMPL;
+}
+
+/* ACString testACString (in ACString a, inout ACString b); */
+NS_IMETHODIMP nsXPCTestParams::TestACString(const nsACString & a, nsACString & b NS_INOUTPARAM, nsACString & _retval NS_OUTPARAM)
+{
+    STRING_METHOD_IMPL;
+}
+
+/* jsval testJsval (in jsval a, inout jsval b); */
+NS_IMETHODIMP nsXPCTestParams::TestJsval(const jsval & a, jsval & b NS_INOUTPARAM, jsval *_retval NS_OUTPARAM)
+{
+    *_retval = b;
+    b = a;
+    return NS_OK;
+}
--- a/js/src/xpconnect/tests/components/native/xpctest_private.h
+++ b/js/src/xpconnect/tests/components/native/xpctest_private.h
@@ -41,17 +41,19 @@
 /* local header for xpconnect tests components */
 
 #ifndef xpctest_private_h___
 #define xpctest_private_h___
 
 #include "nsISupports.h"
 #include "nsMemory.h"
 #include "jsapi.h"
+#include "nsStringGlue.h"
 #include "xpctest_attributes.h"
+#include "xpctest_params.h"
 
 class xpcTestObjectReadOnly : public nsIXPCTestObjectReadOnly {
  public: 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIXPCTESTOBJECTREADONLY
   xpcTestObjectReadOnly();
    
  private:
@@ -74,9 +76,21 @@ class xpcTestObjectReadWrite : public ns
      PRBool boolProperty;
      PRInt16 shortProperty;
      PRInt32 longProperty;
      float floatProperty;
      char charProperty;
      char *stringProperty;
 };
 
+class nsXPCTestParams : public nsIXPCTestParams
+{
+public:
+    NS_DECL_ISUPPORTS
+    NS_DECL_NSIXPCTESTPARAMS
+
+    nsXPCTestParams();
+
+private:
+    ~nsXPCTestParams();
+};
+
 #endif /* xpctest_private_h___ */
--- a/js/src/xpconnect/tests/idl/Makefile.in
+++ b/js/src/xpconnect/tests/idl/Makefile.in
@@ -40,13 +40,14 @@ DEPTH = ../../../../..
 topsrcdir = @top_srcdir@
 srcdir = @srcdir@
 VPATH = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE = xpctest
 
-XPIDLSRCS	= \
+XPIDLSRCS = \
   xpctest_attributes.idl \
+  xpctest_params.idl \
   $(NULL)
 
 include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/js/src/xpconnect/tests/idl/xpctest_params.idl
@@ -0,0 +1,70 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is XPConnect Test Code.
+ *
+ * The Initial Developer of the Original Code is The Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2011
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Bobby Holley <bobbyholley@gmail.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**
+ * Test pararameter passing and argument conversion.
+ *
+ * Each test method returns the value in 'b', and copies 'a' into 'b'. This lets
+ * us test return values, in params, and inout params (out params should be
+ * covered by the intersection of return values and inout).
+ */
+
+#include "nsISupports.idl"
+
+[scriptable, uuid(b94cd289-d0df-4d25-8995-facf687d921d)]
+interface nsIXPCTestParams : nsISupports {
+
+  // These types correspond to the ones in typelib.py
+  boolean               testBoolean(in boolean a, inout boolean b);
+  octet                 testOctet(in octet a, inout octet b);
+  short                 testShort(in short a, inout short b);
+  long                  testLong(in long a, inout long b);
+  long long             testLongLong(in long long a, inout long long b);
+  unsigned short        testUnsignedShort(in unsigned short a, inout unsigned short b);
+  unsigned long         testUnsignedLong(in unsigned long a, inout unsigned long b);
+  unsigned long long    testUnsignedLongLong(in unsigned long long a, inout unsigned long long b);
+  float                 testFloat(in float a, inout float b);
+  double                testDouble(in double a, inout float b);
+  char                  testChar(in char a, inout char b);
+  string                testString(in string a, inout string b);
+  wchar                 testWchar(in wchar a, inout wchar b);
+  wstring               testWstring(in wstring a, inout wstring b);
+  DOMString             testDOMString(in DOMString a, inout DOMString b);
+  AString               testAString(in AString a, inout AString b);
+  AUTF8String           testAUTF8String(in AUTF8String a, inout AUTF8String b);
+  ACString              testACString(in ACString a, inout ACString b);
+  jsval                 testJsval(in jsval a, inout jsval b);
+};
new file mode 100644
--- /dev/null
+++ b/js/src/xpconnect/tests/unit/test_params.js
@@ -0,0 +1,108 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is XPConnect Test Code.
+ *
+ * The Initial Developer of the Original Code is The Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2011
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Bobby Holley <bobbyholley@gmail.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+
+function run_test() {
+
+  // Load the component manifests.
+  Components.manager.autoRegister(do_get_file('../components/native/xpctest.manifest'));
+  Components.manager.autoRegister(do_get_file('../components/js/xpctest.manifest'));
+
+  // Test for each component.
+  test_component("@mozilla.org/js/xpc/test/native/Params;1");
+  test_component("@mozilla.org/js/xpc/test/js/Params;1");
+}
+
+function test_component(contractid) {
+
+  // Instantiate the object.
+  var o = Cc[contractid].createInstance(Ci["nsIXPCTestParams"]);
+
+  // Helper test function - takes the name of test method and two values of
+  // the given type.
+  //
+  // The optional comparator argument can be used for alternative notions of
+  // equality. The comparator should return true on equality.
+  function doTest(name, val1, val2, comparator) {
+    var a = val1;
+    var b = {value: val2};
+    var rv = o[name].call(o, a, b);
+    if (comparator) {
+      do_check_true(comparator(rv, val2));
+      do_check_true(comparator(val1, b.value));
+    }
+    else {
+      do_check_eq(rv, val2);
+      do_check_eq(val1, b.value);
+    }
+  };
+  var fuzzComparator = function(a,b) {return Math.abs(a - b) < 0.1;};
+
+  // Workaround for bug 687612 (inout parameters broken for dipper types).
+  // We do a simple test of copying a into b, and ignore the rv.
+  function doTestWorkaround(name, val1) {
+    var a = val1;
+    var b = {value: ""};
+    o[name].call(o, a, b);
+    do_check_eq(val1, b.value);
+  }
+
+  // Test all the different types
+  doTest("testBoolean", true, false);
+  doTest("testOctet", 4, 156);
+  doTest("testShort", -456, 1299);
+  doTest("testLong", 50060, -12121212);
+  doTest("testLongLong", 12345, -10000000000);
+  doTest("testUnsignedShort", 1532, 65000);
+  doTest("testUnsignedLong", 0, 4000000000);
+  doTest("testUnsignedLongLong", 215435, 3453492580348535809);
+  doTest("testFloat", 4.9, -11.2, fuzzComparator);
+  doTest("testDouble", -80.5, 15000.2, fuzzComparator);
+  doTest("testChar", "a", "2");
+  doTest("testString", "someString", "another string");
+  // TODO: Fix bug 687679 and use the second argument listed below
+  doTest("testWchar", "z", "q");// "ア");
+  // TODO - Test nsIID in bug 687662
+  doTestWorkaround("testDOMString", "Beware: ☠ s");
+  doTestWorkaround("testAString", "Frosty the ☃ ;-)");
+  doTestWorkaround("testAUTF8String", "We deliver 〠!");
+  doTestWorkaround("testACString", "Just a regular C string.");
+
+  // TODO: Uncomment when bug 604196 is fixed.
+  // doTest("testJsval", {aprop: 12, bprop: "str"}, 4.22);
+}
--- a/js/src/xpconnect/tests/unit/xpcshell.ini
+++ b/js/src/xpconnect/tests/unit/xpcshell.ini
@@ -17,8 +17,9 @@ tail =
 [test_reflect_parse.js]
 [test_localeCompare.js]
 # Bug 676965: test fails consistently on Android
 fail-if = os == "android"
 [test_recursive_import.js]
 [test_xpcomutils.js]
 [test_unload.js]
 [test_attributes.js]
+[test_params.js]