Bug 1885602 - Part 5: Implement navigating to the SUMO help topic from the menu heade...
[gecko.git] / dom / webidl / TestFunctions.webidl
blobfcc52016a1543372352c1fc2ea73690fbf6ba0f4
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/.
5  */
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",
13  Exposed=Window]
14 interface WrapperCachedNonISupportsTestInterface {
15   [Pref="dom.webidl.test1"] constructor();
18 [Trial="TestTrial", Exposed=*]
19 interface TestTrialInterface {
20   constructor();
23 [Pref="dom.expose_test_interfaces",
24  Exposed=Window]
25 interface TestInterfaceLength {
26   [ChromeOnly]
27   constructor(boolean arg);
30 // The type of string C++ sees.
31 enum StringType {
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",
39  Exposed=Window]
40 interface TestFunctions {
41   constructor();
43   [Throws]
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.
51   [Throws]
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
63   // C++ side.
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
92   [Throws]
93   undefined testThrowNsresult();
94   [Throws]
95   undefined testThrowNsresultFromNative();
97   // Throws an InvalidStateError to auto-create a rejected promise.
98   [Throws]
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.
113   // See bug 1351501.
114   readonly attribute WrapperCachedNonISupportsTestInterface wrapperCachedNonISupportsObject;
116   attribute [Clamp] octet? clampedNullableOctet;
117   attribute [EnforceRange] octet? enforcedNullableOctet;
119   // Testing for [AllowShared]
120   [GetterThrows]
121   attribute ArrayBufferView arrayBufferView;
122   [GetterThrows]
123   attribute [AllowShared] ArrayBufferView allowSharedArrayBufferView;
124   [Cached, Pure, GetterThrows]
125   attribute sequence<ArrayBufferView> sequenceOfArrayBufferView;
126   [Cached, Pure, GetterThrows]
127   attribute sequence<[AllowShared] ArrayBufferView> sequenceOfAllowSharedArrayBufferView;
128   [GetterThrows]
129   attribute ArrayBuffer arrayBuffer;
130   [GetterThrows]
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;