summaryrefslogtreecommitdiffstats
path: root/js/xpconnect/tests/idl
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/xpconnect/tests/idl
parentInitial commit. (diff)
downloadfirefox-upstream/124.0.1.tar.xz
firefox-upstream/124.0.1.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--js/xpconnect/tests/idl/moz.build17
-rw-r--r--js/xpconnect/tests/idl/xpctest_attributes.idl33
-rw-r--r--js/xpconnect/tests/idl/xpctest_bug809674.idl47
-rw-r--r--js/xpconnect/tests/idl/xpctest_cenums.idl39
-rw-r--r--js/xpconnect/tests/idl/xpctest_esmreturncode.idl45
-rw-r--r--js/xpconnect/tests/idl/xpctest_interfaces.idl27
-rw-r--r--js/xpconnect/tests/idl/xpctest_params.idl120
-rw-r--r--js/xpconnect/tests/idl/xpctest_returncode.idl45
-rw-r--r--js/xpconnect/tests/idl/xpctest_utils.idl19
9 files changed, 392 insertions, 0 deletions
diff --git a/js/xpconnect/tests/idl/moz.build b/js/xpconnect/tests/idl/moz.build
new file mode 100644
index 0000000000..8b56f40c21
--- /dev/null
+++ b/js/xpconnect/tests/idl/moz.build
@@ -0,0 +1,17 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# 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/.
+
+XPIDL_SOURCES += [
+ "xpctest_attributes.idl",
+ "xpctest_bug809674.idl",
+ "xpctest_cenums.idl",
+ "xpctest_interfaces.idl",
+ "xpctest_params.idl",
+ "xpctest_returncode.idl",
+ "xpctest_utils.idl",
+]
+
+XPIDL_MODULE = "xpctest"
diff --git a/js/xpconnect/tests/idl/xpctest_attributes.idl b/js/xpconnect/tests/idl/xpctest_attributes.idl
new file mode 100644
index 0000000000..9822b24dfb
--- /dev/null
+++ b/js/xpconnect/tests/idl/xpctest_attributes.idl
@@ -0,0 +1,33 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * 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/. */
+
+#include "nsISupports.idl"
+/*
+ * This defines the interface for a test object.
+ *
+ */
+
+[scriptable, uuid(42fbd9f6-b12d-47ef-b7a1-02d73c11fe53)]
+interface nsIXPCTestObjectReadOnly : nsISupports {
+ readonly attribute string strReadOnly;
+ readonly attribute boolean boolReadOnly;
+ readonly attribute short shortReadOnly;
+ readonly attribute long longReadOnly;
+ readonly attribute float floatReadOnly;
+ readonly attribute char charReadOnly;
+ readonly attribute PRTime timeReadOnly;
+};
+
+[scriptable, uuid(f07529b0-a479-4954-aba5-ab3142c6b1cb)]
+interface nsIXPCTestObjectReadWrite : nsISupports {
+ attribute string stringProperty;
+ attribute boolean booleanProperty;
+ attribute short shortProperty;
+ attribute long longProperty;
+ attribute float floatProperty;
+ attribute char charProperty;
+ attribute PRTime timeProperty;
+};
diff --git a/js/xpconnect/tests/idl/xpctest_bug809674.idl b/js/xpconnect/tests/idl/xpctest_bug809674.idl
new file mode 100644
index 0000000000..1e83e244ec
--- /dev/null
+++ b/js/xpconnect/tests/idl/xpctest_bug809674.idl
@@ -0,0 +1,47 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * 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/. */
+
+#include "nsISupports.idl"
+/*
+ * Test interface for https://bugzilla.mozilla.org/show_bug.cgi?id=809674 .
+ *
+ * This test makes sure that accessing JS-implemented attributes or methods
+ * marked with [implicit_jscontext] works as expected.
+ *
+ * It also makes sure [optional_argc] is not supported on JS-implemented
+ * methods.
+ */
+
+[scriptable, uuid(2df46559-da21-49bf-b863-0d7b7bbcbc73)]
+interface nsIXPCTestBug809674 : nsISupports {
+ // Various interesting [implicit_jscontext] cases.
+ [implicit_jscontext] unsigned long addArgs(in unsigned long x, in unsigned long y);
+ [implicit_jscontext] unsigned long addSubMulArgs(in unsigned long x, in unsigned long y,
+ out unsigned long subOut,
+ out unsigned long mulOut);
+ [implicit_jscontext] jsval addVals(in jsval x, in jsval y);
+
+ [implicit_jscontext] unsigned long methodNoArgs();
+ [implicit_jscontext] void methodNoArgsNoRetVal();
+
+ // When there are many arguments, the context is passed on the stack on
+ // most platforms.
+ [implicit_jscontext] unsigned long addMany(in unsigned long x1,
+ in unsigned long x2,
+ in unsigned long x3,
+ in unsigned long x4,
+ in unsigned long x5,
+ in unsigned long x6,
+ in unsigned long x7,
+ in unsigned long x8);
+
+ // Attributes can use [implicit_jscontext], too.
+ [implicit_jscontext] attribute jsval valProperty;
+ [implicit_jscontext] attribute unsigned long uintProperty;
+
+ // [optional_argc] is not supported.
+ [optional_argc] void methodWithOptionalArgc();
+};
diff --git a/js/xpconnect/tests/idl/xpctest_cenums.idl b/js/xpconnect/tests/idl/xpctest_cenums.idl
new file mode 100644
index 0000000000..70b7f8fae7
--- /dev/null
+++ b/js/xpconnect/tests/idl/xpctest_cenums.idl
@@ -0,0 +1,39 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * 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/. */
+
+#include "nsISupports.idl"
+/*
+ * This defines the interface for a test object.
+ *
+ */
+
+[scriptable, uuid(6a2f918e-cda2-11e8-bc9a-a34c716d1f2a)]
+interface nsIXPCTestCEnums : nsISupports {
+ const long testConst = 1;
+
+ cenum testFlagsExplicit: 8 {
+ shouldBe1Explicit = 1,
+ shouldBe2Explicit = 2,
+ shouldBe4Explicit = 4,
+ shouldBe8Explicit = 8,
+ shouldBe12Explicit = shouldBe4Explicit | shouldBe8Explicit,
+ };
+
+ cenum testFlagsImplicit: 8 {
+ shouldBe0Implicit,
+ shouldBe1Implicit,
+ shouldBe2Implicit,
+ shouldBe3Implicit,
+ shouldBe5Implicit = 5,
+ shouldBe6Implicit,
+ shouldBe2AgainImplicit = 2,
+ shouldBe3AgainImplicit,
+ };
+
+ void testCEnumInput(in nsIXPCTestCEnums_testFlagsExplicit abc);
+
+ nsIXPCTestCEnums_testFlagsExplicit testCEnumOutput();
+};
diff --git a/js/xpconnect/tests/idl/xpctest_esmreturncode.idl b/js/xpconnect/tests/idl/xpctest_esmreturncode.idl
new file mode 100644
index 0000000000..ac17feda3f
--- /dev/null
+++ b/js/xpconnect/tests/idl/xpctest_esmreturncode.idl
@@ -0,0 +1,45 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * 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 the use of Components.returnCode with system ESM
+ *
+ * This ("parent") interface defines a method that in-turn calls another
+ * ("child") interface implemented in JS, and returns the nsresult from that
+ * child interface. The child interface manages the return code by way of
+ * Components.returnCode.
+ */
+
+#include "nsISupports.idl"
+
+
+[scriptable, uuid(494f9336-ad06-46ad-bbb4-b0010e27e12d)]
+interface nsIXPCTestESMReturnCodeParent : nsISupports {
+ // Calls the "child" interface with the specified behavior flag. Returns
+ // the NSRESULT from the child interface.
+ nsresult callChild(in long childBehavior);
+};
+
+[scriptable, uuid(dee07408-75d8-4968-a37c-fe0d48ccd1ac)]
+interface nsIXPCTestESMReturnCodeChild : nsISupports {
+ void doIt(in long behavior);
+
+ // Flags to control that the child does.
+ // child will throw a JS exception
+ const long CHILD_SHOULD_THROW = 0;
+
+ // child will just return normally
+ const long CHILD_SHOULD_RETURN_SUCCESS = 1;
+
+ // child will return after setting Components.returnCode to NS_ERROR_FAILURE
+ const long CHILD_SHOULD_RETURN_RESULTCODE = 2;
+
+ // child will set Components.returnCode to NS_ERROR_UNEXPECTED, then create
+ // a new component that sets Components.returnCode to NS_ERROR_FAILURE.
+ // Our caller should see the NS_ERROR_UNEXPECTED we set rather than the
+ // value set later by the "inner" child.
+ const long CHILD_SHOULD_NEST_RESULTCODES = 3;
+};
diff --git a/js/xpconnect/tests/idl/xpctest_interfaces.idl b/js/xpconnect/tests/idl/xpctest_interfaces.idl
new file mode 100644
index 0000000000..2abc149623
--- /dev/null
+++ b/js/xpconnect/tests/idl/xpctest_interfaces.idl
@@ -0,0 +1,27 @@
+/* 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/. */
+
+/**
+ * Very simple test interfaces.
+ *
+ * This is used by the other test functionality when it needs to play around with
+ * interface pointers.
+ */
+
+#include "nsISupports.idl"
+
+[scriptable, uuid(3c8fd2f5-970c-42c6-b5dd-cda1c16dcfd8)]
+interface nsIXPCTestInterfaceA : nsISupports {
+ attribute string name;
+};
+
+[scriptable, uuid(ff528c3a-2410-46de-acaa-449aa6403a33)]
+interface nsIXPCTestInterfaceB : nsISupports {
+ attribute string name;
+};
+
+[scriptable, uuid(401cf1b4-355b-4cee-b7b3-c7973aee49bd)]
+interface nsIXPCTestInterfaceC : nsISupports {
+ attribute long someInteger;
+};
diff --git a/js/xpconnect/tests/idl/xpctest_params.idl b/js/xpconnect/tests/idl/xpctest_params.idl
new file mode 100644
index 0000000000..8bf224507c
--- /dev/null
+++ b/js/xpconnect/tests/idl/xpctest_params.idl
@@ -0,0 +1,120 @@
+/* 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 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"
+
+interface nsIURI;
+interface nsIXPCTestInterfaceA;
+interface nsIXPCTestInterfaceB;
+
+[scriptable, uuid(812145c7-9fcc-425e-a878-36ad1b7730b7)]
+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);
+ 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);
+
+ // Test various forms of the Array<T> type.
+ Array<short> testShortSequence(in Array<short> a, inout Array<short> b);
+ Array<double> testDoubleSequence(in Array<double> a, inout Array<double> b);
+ Array<nsIXPCTestInterfaceA> testInterfaceSequence(in Array<nsIXPCTestInterfaceA> a, inout Array<nsIXPCTestInterfaceA> b);
+ Array<AString> testAStringSequence(in Array<AString> a, inout Array<AString> b);
+ Array<ACString> testACStringSequence(in Array<ACString> a, inout Array<ACString> b);
+ Array<jsval> testJsvalSequence(in Array<jsval> a, inout Array<jsval> b);
+ Array<Array<short> > testSequenceSequence(in Array<Array<short> > a, inout Array<Array<short> > b);
+
+ void testInterfaceIsSequence(in nsIIDPtr aIID, [iid_is(aIID)] in Array<nsQIResult> a,
+ inout nsIIDPtr bIID, [iid_is(bIID)] inout Array<nsQIResult> b,
+ out nsIIDPtr rvIID, [retval, iid_is(rvIID)] out Array<nsQIResult> rv);
+
+ // Returns whatever was passed in.
+ Array<uint8_t> testOptionalSequence([optional] in Array<uint8_t> arr);
+
+ //
+ // Dependent parameters use the same types as above, but are handled much differently.
+ //
+
+ // Test arrays.
+ void testShortArray(in unsigned long aLength, [array, size_is(aLength)] in short a,
+ inout unsigned long bLength, [array, size_is(bLength)] inout short b,
+ out unsigned long rvLength, [retval, array, size_is(rvLength)] out short rv);
+ void testDoubleArray(in unsigned long aLength, [array, size_is(aLength)] in double a,
+ inout unsigned long bLength, [array, size_is(bLength)] inout double b,
+ out unsigned long rvLength, [retval, array, size_is(rvLength)] out double rv);
+ void testStringArray(in unsigned long aLength, [array, size_is(aLength)] in string a,
+ inout unsigned long bLength, [array, size_is(bLength)] inout string b,
+ out unsigned long rvLength, [retval, array, size_is(rvLength)] out string rv);
+ void testWstringArray(in unsigned long aLength, [array, size_is(aLength)] in wstring a,
+ inout unsigned long bLength, [array, size_is(bLength)] inout wstring b,
+ out unsigned long rvLength, [retval, array, size_is(rvLength)] out wstring rv);
+ void testInterfaceArray(in unsigned long aLength, [array, size_is(aLength)] in nsIXPCTestInterfaceA a,
+ inout unsigned long bLength, [array, size_is(bLength)] inout nsIXPCTestInterfaceA b,
+ out unsigned long rvLength, [retval, array, size_is(rvLength)] out nsIXPCTestInterfaceA rv);
+
+ // uint8 array with optional length. Returns array length.
+ unsigned long testByteArrayOptionalLength([array, size_is(aLength)] in uint8_t a, [optional] in unsigned long aLength);
+
+ // Test sized strings.
+ void testSizedString(in unsigned long aLength, [size_is(aLength)] in string a,
+ inout unsigned long bLength, [size_is(bLength)] inout string b,
+ out unsigned long rvLength, [retval, size_is(rvLength)] out string rv);
+ void testSizedWstring(in unsigned long aLength, [size_is(aLength)] in wstring a,
+ inout unsigned long bLength, [size_is(bLength)] inout wstring b,
+ out unsigned long rvLength, [retval, size_is(rvLength)] out wstring rv);
+
+ // Test iid_is.
+ void testInterfaceIs(in nsIIDPtr aIID, [iid_is(aIID)] in nsQIResult a,
+ inout nsIIDPtr bIID, [iid_is(bIID)] inout nsQIResult b,
+ out nsIIDPtr rvIID, [retval, iid_is(rvIID)] out nsQIResult rv);
+
+ // Test arrays of iid_is. According to khuey we don't use it for anything
+ // in mozilla-central, but calendar stuff depends on it.
+ void testInterfaceIsArray(in unsigned long aLength, in nsIIDPtr aIID,
+ [array, size_is(aLength), iid_is(aIID)] in nsQIResult a,
+ inout unsigned long bLength, inout nsIIDPtr bIID,
+ [array, size_is(bLength), iid_is(bIID)] inout nsQIResult b,
+ out unsigned long rvLength, out nsIIDPtr rvIID,
+ [retval, array, size_is(rvLength), iid_is(rvIID)] out nsQIResult rv);
+
+ // Test arrays of jsvals
+ void testJsvalArray(in unsigned long aLength, [array, size_is(aLength)] in jsval a,
+ inout unsigned long bLength, [array, size_is(bLength)] inout jsval b,
+ out unsigned long rvLength, [retval, array, size_is(rvLength)] out jsval rv);
+
+
+ // Test for out dipper parameters
+ void testOutAString(out AString o);
+
+ // Test for optional array size_is.
+ ACString testStringArrayOptionalSize([array, size_is(aLength)] in string a, [optional] in unsigned long aLength);
+
+ // Test for omitted optional out parameter.
+ void testOmittedOptionalOut(in nsIXPCTestParams aJSObj, [optional] out nsIURI aOut);
+
+ readonly attribute double testNaN;
+};
diff --git a/js/xpconnect/tests/idl/xpctest_returncode.idl b/js/xpconnect/tests/idl/xpctest_returncode.idl
new file mode 100644
index 0000000000..5ee6c55479
--- /dev/null
+++ b/js/xpconnect/tests/idl/xpctest_returncode.idl
@@ -0,0 +1,45 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * 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 the use of Components.returnCode
+ *
+ * This ("parent") interface defines a method that in-turn calls another
+ * ("child") interface implemented in JS, and returns the nsresult from that
+ * child interface. The child interface manages the return code by way of
+ * Components.returnCode.
+ */
+
+#include "nsISupports.idl"
+
+
+[scriptable, uuid(479e4532-95cf-48b8-a99b-8a5881e47138)]
+interface nsIXPCTestReturnCodeParent : nsISupports {
+ // Calls the "child" interface with the specified behavior flag. Returns
+ // the NSRESULT from the child interface.
+ nsresult callChild(in long childBehavior);
+};
+
+[scriptable, uuid(672cfd34-1fd1-455d-9901-d879fa6fdb95)]
+interface nsIXPCTestReturnCodeChild : nsISupports {
+ void doIt(in long behavior);
+
+ // Flags to control that the child does.
+ // child will throw a JS exception
+ const long CHILD_SHOULD_THROW = 0;
+
+ // child will just return normally
+ const long CHILD_SHOULD_RETURN_SUCCESS = 1;
+
+ // child will return after setting Components.returnCode to NS_ERROR_FAILURE
+ const long CHILD_SHOULD_RETURN_RESULTCODE = 2;
+
+ // child will set Components.returnCode to NS_ERROR_UNEXPECTED, then create
+ // a new component that sets Components.returnCode to NS_ERROR_FAILURE.
+ // Our caller should see the NS_ERROR_UNEXPECTED we set rather than the
+ // value set later by the "inner" child.
+ const long CHILD_SHOULD_NEST_RESULTCODES = 3;
+};
diff --git a/js/xpconnect/tests/idl/xpctest_utils.idl b/js/xpconnect/tests/idl/xpctest_utils.idl
new file mode 100644
index 0000000000..e59814272b
--- /dev/null
+++ b/js/xpconnect/tests/idl/xpctest_utils.idl
@@ -0,0 +1,19 @@
+/* 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/. */
+
+/**
+ * Utility interfaces for testing.
+ */
+
+#include "nsISupports.idl"
+
+[scriptable, function, uuid(d58a82ab-d8f7-4ca9-9273-b3290d42a0cf)]
+interface nsIXPCTestFunctionInterface : nsISupports {
+ string echo(in string arg);
+};
+
+[scriptable, uuid(1e9cddeb-510d-449a-b152-3c1b5b31d41d)]
+interface nsIXPCTestUtils : nsISupports {
+ nsIXPCTestFunctionInterface doubleWrapFunction(in nsIXPCTestFunctionInterface f);
+};