1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_TestFunctions_h
8 #define mozilla_dom_TestFunctions_h
10 #include "mozilla/ErrorResult.h"
11 #include "mozilla/dom/BindingDeclarations.h"
12 #include "mozilla/dom/NonRefcountedDOMObject.h"
13 #include "mozilla/dom/TestFunctionsBinding.h"
20 class PromiseReturner
;
21 class WrapperCachedNonISupportsTestInterface
;
23 class TestFunctions
: public NonRefcountedDOMObject
{
25 static UniquePtr
<TestFunctions
> Constructor(GlobalObject
& aGlobal
);
27 static void ThrowUncatchableException(GlobalObject
& aGlobal
,
30 static Promise
* PassThroughPromise(GlobalObject
& aGlobal
, Promise
& aPromise
);
33 static already_AddRefed
<Promise
> PassThroughCallbackPromise(
34 GlobalObject
& aGlobal
, PromiseReturner
& aCallback
, ErrorResult
& aRv
);
36 void SetStringData(const nsAString
& aString
);
38 void GetStringDataAsAString(nsAString
& aString
);
39 void GetStringDataAsAString(uint32_t aLength
, nsAString
& aString
);
40 void GetStringDataAsDOMString(const Optional
<uint32_t>& aLength
,
43 void GetShortLiteralString(nsAString
& aString
);
44 void GetMediumLiteralString(nsAString
& aString
);
45 void GetLongLiteralString(nsAString
& aString
);
47 void GetStringbufferString(const nsAString
& aInput
, nsAString
& aRetval
);
49 StringType
GetStringType(const nsAString
& aString
);
51 bool StringbufferMatchesStored(const nsAString
& aString
);
53 void TestThrowNsresult(ErrorResult
& aError
);
54 void TestThrowNsresultFromNative(ErrorResult
& aError
);
55 static already_AddRefed
<Promise
> ThrowToRejectPromise(GlobalObject
& aGlobal
,
61 void SetClampedNullableOctet(const Nullable
<uint8_t>& aOctet
);
62 Nullable
<uint8_t> GetClampedNullableOctet() const;
63 void SetEnforcedNullableOctet(const Nullable
<uint8_t>& aOctet
);
64 Nullable
<uint8_t> GetEnforcedNullableOctet() const;
66 void SetArrayBufferView(const ArrayBufferView
& aBuffer
);
67 void GetArrayBufferView(JSContext
* aCx
, JS::Handle
<JSObject
*> aObj
,
68 JS::MutableHandle
<JSObject
*> aRetval
,
70 void SetAllowSharedArrayBufferView(const ArrayBufferView
& aBuffer
);
71 void GetAllowSharedArrayBufferView(JSContext
* aCx
, JS::Handle
<JSObject
*> aObj
,
72 JS::MutableHandle
<JSObject
*> aRetval
,
74 void SetSequenceOfArrayBufferView(const Sequence
<ArrayBufferView
>& aBuffers
);
75 void GetSequenceOfArrayBufferView(JSContext
* aCx
, JS::Handle
<JSObject
*> aObj
,
76 nsTArray
<JSObject
*>& aRetval
,
78 void SetSequenceOfAllowSharedArrayBufferView(
79 const Sequence
<ArrayBufferView
>& aBuffers
);
80 void GetSequenceOfAllowSharedArrayBufferView(JSContext
* aCx
,
81 JS::Handle
<JSObject
*> aObj
,
82 nsTArray
<JSObject
*>& aRetval
,
84 void SetArrayBuffer(const ArrayBuffer
& aBuffer
);
85 void GetArrayBuffer(JSContext
* aCx
, JS::Handle
<JSObject
*> aObj
,
86 JS::MutableHandle
<JSObject
*> aRetval
,
88 void SetAllowSharedArrayBuffer(const ArrayBuffer
& aBuffer
);
89 void GetAllowSharedArrayBuffer(JSContext
* aCx
, JS::Handle
<JSObject
*> aObj
,
90 JS::MutableHandle
<JSObject
*> aRetval
,
92 void SetSequenceOfArrayBuffer(const Sequence
<ArrayBuffer
>& aBuffers
);
93 void GetSequenceOfArrayBuffer(JSContext
* aCx
, JS::Handle
<JSObject
*> aObj
,
94 nsTArray
<JSObject
*>& aRetval
,
96 void SetSequenceOfAllowSharedArrayBuffer(
97 const Sequence
<ArrayBuffer
>& aBuffers
);
98 void GetSequenceOfAllowSharedArrayBuffer(JSContext
* aCx
,
99 JS::Handle
<JSObject
*> aObj
,
100 nsTArray
<JSObject
*>& aRetval
,
101 ErrorResult
& aError
);
102 void TestNotAllowShared(const ArrayBufferView
& aBuffer
);
103 void TestNotAllowShared(const ArrayBuffer
& aBuffer
);
104 void TestNotAllowShared(const nsAString
& aBuffer
);
105 void TestAllowShared(const ArrayBufferView
& aBuffer
);
106 void TestAllowShared(const ArrayBuffer
& aBuffer
);
107 void TestDictWithAllowShared(const DictWithAllowSharedBufferSource
& aDict
);
108 void TestUnionOfBuffferSource(
109 const ArrayBufferOrArrayBufferViewOrString
& aUnion
);
110 void TestUnionOfAllowSharedBuffferSource(
111 const MaybeSharedArrayBufferOrMaybeSharedArrayBufferView
& aUnion
);
113 bool StaticAndNonStaticOverload() { return false; }
114 static bool StaticAndNonStaticOverload(GlobalObject
& aGlobal
,
115 const Optional
<uint32_t>& aLength
) {
119 static bool ObjectFromAboutBlank(JSContext
* aCx
, JSObject
* aObj
);
121 WrapperCachedNonISupportsTestInterface
* WrapperCachedNonISupportsObject();
123 bool WrapObject(JSContext
* aCx
, JS::Handle
<JSObject
*> aGivenProto
,
124 JS::MutableHandle
<JSObject
*> aWrapper
);
127 nsString mStringData
;
128 RefPtr
<WrapperCachedNonISupportsTestInterface
>
129 mWrapperCachedNonISupportsTestInterface
;
131 Nullable
<uint8_t> mClampedNullableOctet
;
132 Nullable
<uint8_t> mEnforcedNullableOctet
;
136 } // namespace mozilla
138 #endif // mozilla_dom_TestFunctions_h