1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/.
7 // A dumping ground for random testing functions
9 callback PromiseReturner = Promise<any>();
10 callback PromiseReturner2 = Promise<any>(any arg, DOMString arg2);
12 [Pref="dom.expose_test_interfaces",
14 interface WrapperCachedNonISupportsTestInterface {
15 [Pref="dom.webidl.test1"] constructor();
18 [Trial="TestTrial", Exposed=*]
19 interface TestTrialInterface {
23 [Pref="dom.expose_test_interfaces",
25 interface TestInterfaceLength {
27 constructor(boolean arg);
30 // The type of string C++ sees.
32 "literal", // A string with the LITERAL flag.
33 "stringbuffer", // A string with the REFCOUNTED flag.
34 "inline", // A string with the INLINE flag.
35 "other", // Anything else.
38 [Pref="dom.expose_test_interfaces",
40 interface TestFunctions {
44 static undefined throwUncatchableException();
46 // Simply returns its argument. Can be used to test Promise
47 // argument processing behavior.
48 static Promise<any> passThroughPromise(Promise<any> arg);
50 // Returns whatever Promise the given PromiseReturner returned.
52 static Promise<any> passThroughCallbackPromise(PromiseReturner callback);
54 // Some basic tests for string binding round-tripping behavior.
55 undefined setStringData(DOMString arg);
57 // Get the string data, using an nsAString argument on the C++ side.
58 // This will just use Assign/operator=, whatever that does.
59 DOMString getStringDataAsAString();
61 // Get the string data, but only "length" chars of it, using an
62 // nsAString argument on the C++ side. This will always copy on the
64 DOMString getStringDataAsAString(unsigned long length);
66 // Get the string data, but only "length" chars of it, using a
67 // DOMString argument on the C++ side and trying to hand it
68 // stringbuffers. If length not passed, use our full length.
69 DOMString getStringDataAsDOMString(optional unsigned long length);
71 // Get a short (short enough to fit in a JS inline string) literal string.
72 DOMString getShortLiteralString();
74 // Get a medium (long enough to not be a JS inline, but short enough
75 // to fit in a FakeString inline buffer) literal string.
76 DOMString getMediumLiteralString();
78 // Get a long (long enough to not fit in any inline buffers) literal string.
79 DOMString getLongLiteralString();
81 // Get a stringbuffer string for whatever string is passed in.
82 DOMString getStringbufferString(DOMString input);
84 // Get the type of string that the C++ sees after going through bindings.
85 StringType getStringType(DOMString str);
87 // Returns true if both the incoming string and the stored (via setStringData())
88 // string have stringbuffers and they're the same stringbuffer.
89 boolean stringbufferMatchesStored(DOMString str);
91 // Functions that just punch through to mozITestInterfaceJS.idl
93 undefined testThrowNsresult();
95 undefined testThrowNsresultFromNative();
97 // Throws an InvalidStateError to auto-create a rejected promise.
99 static Promise<any> throwToRejectPromise();
101 // Some attributes for the toJSON to work with.
102 readonly attribute long one;
103 [Func="mozilla::dom::TestFunctions::ObjectFromAboutBlank"]
104 readonly attribute long two;
106 // Testing for how default toJSON behaves.
107 [Default] object toJSON();
109 // This returns a wrappercached non-ISupports object. While this will always
110 // return the same object, no optimization attributes like [Pure] should be
111 // used here because the object should not be held alive from JS by the
112 // bindings. This is needed to test wrapper preservation for weak map keys.
114 readonly attribute WrapperCachedNonISupportsTestInterface wrapperCachedNonISupportsObject;
116 attribute [Clamp] octet? clampedNullableOctet;
117 attribute [EnforceRange] octet? enforcedNullableOctet;
119 // Testing for [AllowShared]
121 attribute ArrayBufferView arrayBufferView;
123 attribute [AllowShared] ArrayBufferView allowSharedArrayBufferView;
124 [Cached, Pure, GetterThrows]
125 attribute sequence<ArrayBufferView> sequenceOfArrayBufferView;
126 [Cached, Pure, GetterThrows]
127 attribute sequence<[AllowShared] ArrayBufferView> sequenceOfAllowSharedArrayBufferView;
129 attribute ArrayBuffer arrayBuffer;
131 attribute [AllowShared] ArrayBuffer allowSharedArrayBuffer;
132 [Cached, Pure, GetterThrows]
133 attribute sequence<ArrayBuffer> sequenceOfArrayBuffer;
134 [Cached, Pure, GetterThrows]
135 attribute sequence<[AllowShared] ArrayBuffer> sequenceOfAllowSharedArrayBuffer;
136 undefined testNotAllowShared(ArrayBufferView buffer);
137 undefined testNotAllowShared(ArrayBuffer buffer);
138 undefined testNotAllowShared(DOMString buffer);
139 undefined testAllowShared([AllowShared] ArrayBufferView buffer);
140 undefined testAllowShared([AllowShared] ArrayBuffer buffer);
141 undefined testDictWithAllowShared(optional DictWithAllowSharedBufferSource buffer = {});
142 undefined testUnionOfBuffferSource((ArrayBuffer or ArrayBufferView or DOMString) foo);
143 undefined testUnionOfAllowSharedBuffferSource(([AllowShared] ArrayBuffer or [AllowShared] ArrayBufferView) foo);
145 boolean staticAndNonStaticOverload();
146 static boolean staticAndNonStaticOverload(optional unsigned long foo);
149 dictionary DictWithAllowSharedBufferSource {
150 ArrayBuffer arrayBuffer;
151 ArrayBufferView arrayBufferView;
152 [AllowShared] ArrayBuffer allowSharedArrayBuffer;
153 [AllowShared] ArrayBufferView allowSharedArrayBufferView;