TestBindingHeader.h (79512B)
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/. 6 */ 7 8 #ifndef TestBindingHeader_h 9 #define TestBindingHeader_h 10 11 #include "js/Object.h" // JS::GetClass 12 #include "mozilla/ErrorResult.h" 13 #include "mozilla/dom/BindingUtils.h" 14 #include "mozilla/dom/Record.h" 15 #include "mozilla/dom/TypedArray.h" 16 #include "nsCOMPtr.h" 17 #include "nsGenericHTMLElement.h" 18 #include "nsWrapperCache.h" 19 20 // Forward declare this before we include TestCodeGenBinding.h, because that 21 // header relies on including this one for it, for ParentDict. Hopefully it 22 // won't begin to rely on it in more fundamental ways. 23 namespace mozilla { 24 namespace dom { 25 class DocGroup; 26 class TestExternalInterface; 27 class TestUnionArguments; 28 class Promise; 29 } // namespace dom 30 } // namespace mozilla 31 32 // We don't export TestCodeGenBinding.h, but it's right in our parent dir. 33 #include "../TestCodeGenBinding.h" 34 35 extern bool TestFuncControlledMember(JSContext*, JSObject*); 36 37 namespace mozilla { 38 namespace dom { 39 40 // IID for nsRenamedInterface 41 #define NS_RENAMED_INTERFACE_IID \ 42 {0xd4b19ef3, 0xe68b, 0x4e3f, {0x94, 0xbc, 0xc9, 0xde, 0x3a, 0x69, 0xb0, 0xe8}} 43 44 class nsRenamedInterface : public nsISupports, public nsWrapperCache { 45 public: 46 NS_INLINE_DECL_STATIC_IID(NS_RENAMED_INTERFACE_IID) 47 NS_DECL_ISUPPORTS 48 49 // We need a GetParentObject to make binding codegen happy 50 virtual nsISupports* GetParentObject(); 51 }; 52 53 // IID for the TestExternalInterface 54 #define NS_TEST_EXTERNAL_INTERFACE_IID \ 55 {0xd5ba0c99, 0x9b1d, 0x4e71, {0x8a, 0x94, 0x56, 0x38, 0x6c, 0xa3, 0xda, 0x3d}} 56 class TestExternalInterface : public nsISupports { 57 public: 58 NS_INLINE_DECL_STATIC_IID(NS_TEST_EXTERNAL_INTERFACE_IID) 59 NS_DECL_ISUPPORTS 60 }; 61 62 class TestNonWrapperCacheInterface : public nsISupports { 63 public: 64 NS_DECL_ISUPPORTS 65 66 bool WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto, 67 JS::MutableHandle<JSObject*> aReflector); 68 }; 69 70 class OnlyForUseInConstructor : public nsISupports, public nsWrapperCache { 71 public: 72 NS_DECL_ISUPPORTS 73 // We need a GetParentObject to make binding codegen happy 74 virtual nsISupports* GetParentObject(); 75 }; 76 77 class TestInterface : public nsISupports, public nsWrapperCache { 78 public: 79 NS_DECL_ISUPPORTS 80 81 // We need a GetParentObject and GetDocGroup to make binding codegen happy 82 virtual nsISupports* GetParentObject(); 83 DocGroup* GetDocGroup() const; 84 85 // And now our actual WebIDL API 86 // Constructors 87 static already_AddRefed<TestInterface> Constructor(const GlobalObject&); 88 static already_AddRefed<TestInterface> Constructor(const GlobalObject&, 89 const nsAString&); 90 static already_AddRefed<TestInterface> Constructor(const GlobalObject&, 91 uint32_t, 92 const Nullable<bool>&); 93 static already_AddRefed<TestInterface> Constructor(const GlobalObject&, 94 TestInterface*); 95 static already_AddRefed<TestInterface> Constructor(const GlobalObject&, 96 uint32_t, TestInterface&); 97 98 static already_AddRefed<TestInterface> Constructor(const GlobalObject&, 99 const ArrayBuffer&); 100 static already_AddRefed<TestInterface> Constructor(const GlobalObject&, 101 const Uint8Array&); 102 /* static 103 already_AddRefed<TestInterface> 104 Constructor(const GlobalObject&, uint32_t, uint32_t, 105 const TestInterfaceOrOnlyForUseInConstructor&); 106 */ 107 108 static already_AddRefed<TestInterface> Test(const GlobalObject&, 109 ErrorResult&); 110 static already_AddRefed<TestInterface> Test(const GlobalObject&, 111 const nsAString&, ErrorResult&); 112 static already_AddRefed<TestInterface> Test(const GlobalObject&, 113 const nsACString&, ErrorResult&); 114 115 static already_AddRefed<TestInterface> Test2( 116 const GlobalObject&, const DictForConstructor&, JS::Handle<JS::Value>, 117 JS::Handle<JSObject*>, JS::Handle<JSObject*>, const Sequence<Dict>&, 118 JS::Handle<JS::Value>, const Optional<JS::Handle<JSObject*>>&, 119 const Optional<JS::Handle<JSObject*>>&, ErrorResult&); 120 121 // Integer types 122 int8_t ReadonlyByte(); 123 int8_t WritableByte(); 124 void SetWritableByte(int8_t); 125 void PassByte(int8_t); 126 int8_t ReceiveByte(); 127 void PassOptionalByte(const Optional<int8_t>&); 128 void PassOptionalByteBeforeRequired(const Optional<int8_t>&, int8_t); 129 void PassOptionalByteWithDefault(int8_t); 130 void PassOptionalByteWithDefaultBeforeRequired(int8_t, int8_t); 131 void PassNullableByte(const Nullable<int8_t>&); 132 void PassOptionalNullableByte(const Optional<Nullable<int8_t>>&); 133 void PassVariadicByte(const Sequence<int8_t>&); 134 int8_t CachedByte(); 135 int8_t CachedConstantByte(); 136 int8_t CachedWritableByte(); 137 void SetCachedWritableByte(int8_t); 138 int8_t SideEffectFreeByte(); 139 void SetSideEffectFreeByte(int8_t); 140 int8_t DomDependentByte(); 141 void SetDomDependentByte(int8_t); 142 int8_t ConstantByte(); 143 int8_t DeviceStateDependentByte(); 144 int8_t ReturnByteSideEffectFree(); 145 int8_t ReturnDOMDependentByte(); 146 int8_t ReturnConstantByte(); 147 int8_t ReturnDeviceStateDependentByte(); 148 149 void UnsafePrerenderMethod(); 150 int32_t UnsafePrerenderWritable(); 151 void SetUnsafePrerenderWritable(int32_t); 152 int32_t UnsafePrerenderReadonly(); 153 int16_t ReadonlyShort(); 154 int16_t WritableShort(); 155 void SetWritableShort(int16_t); 156 void PassShort(int16_t); 157 int16_t ReceiveShort(); 158 void PassOptionalShort(const Optional<int16_t>&); 159 void PassOptionalShortWithDefault(int16_t); 160 161 int32_t ReadonlyLong(); 162 int32_t WritableLong(); 163 void SetWritableLong(int32_t); 164 void PassLong(int32_t); 165 int16_t ReceiveLong(); 166 void PassOptionalLong(const Optional<int32_t>&); 167 void PassOptionalLongWithDefault(int32_t); 168 169 int64_t ReadonlyLongLong(); 170 int64_t WritableLongLong(); 171 void SetWritableLongLong(int64_t); 172 void PassLongLong(int64_t); 173 int64_t ReceiveLongLong(); 174 void PassOptionalLongLong(const Optional<int64_t>&); 175 void PassOptionalLongLongWithDefault(int64_t); 176 177 uint8_t ReadonlyOctet(); 178 uint8_t WritableOctet(); 179 void SetWritableOctet(uint8_t); 180 void PassOctet(uint8_t); 181 uint8_t ReceiveOctet(); 182 void PassOptionalOctet(const Optional<uint8_t>&); 183 void PassOptionalOctetWithDefault(uint8_t); 184 185 uint16_t ReadonlyUnsignedShort(); 186 uint16_t WritableUnsignedShort(); 187 void SetWritableUnsignedShort(uint16_t); 188 void PassUnsignedShort(uint16_t); 189 uint16_t ReceiveUnsignedShort(); 190 void PassOptionalUnsignedShort(const Optional<uint16_t>&); 191 void PassOptionalUnsignedShortWithDefault(uint16_t); 192 193 uint32_t ReadonlyUnsignedLong(); 194 uint32_t WritableUnsignedLong(); 195 void SetWritableUnsignedLong(uint32_t); 196 void PassUnsignedLong(uint32_t); 197 uint32_t ReceiveUnsignedLong(); 198 void PassOptionalUnsignedLong(const Optional<uint32_t>&); 199 void PassOptionalUnsignedLongWithDefault(uint32_t); 200 201 uint64_t ReadonlyUnsignedLongLong(); 202 uint64_t WritableUnsignedLongLong(); 203 void SetWritableUnsignedLongLong(uint64_t); 204 void PassUnsignedLongLong(uint64_t); 205 uint64_t ReceiveUnsignedLongLong(); 206 void PassOptionalUnsignedLongLong(const Optional<uint64_t>&); 207 void PassOptionalUnsignedLongLongWithDefault(uint64_t); 208 209 float WritableFloat() const; 210 void SetWritableFloat(float); 211 float WritableUnrestrictedFloat() const; 212 void SetWritableUnrestrictedFloat(float); 213 Nullable<float> GetWritableNullableFloat() const; 214 void SetWritableNullableFloat(const Nullable<float>&); 215 Nullable<float> GetWritableNullableUnrestrictedFloat() const; 216 void SetWritableNullableUnrestrictedFloat(const Nullable<float>&); 217 double WritableDouble() const; 218 void SetWritableDouble(double); 219 double WritableUnrestrictedDouble() const; 220 void SetWritableUnrestrictedDouble(double); 221 Nullable<double> GetWritableNullableDouble() const; 222 void SetWritableNullableDouble(const Nullable<double>&); 223 Nullable<double> GetWritableNullableUnrestrictedDouble() const; 224 void SetWritableNullableUnrestrictedDouble(const Nullable<double>&); 225 void PassFloat(float, float, const Nullable<float>&, const Nullable<float>&, 226 double, double, const Nullable<double>&, 227 const Nullable<double>&, const Sequence<float>&, 228 const Sequence<float>&, const Sequence<Nullable<float>>&, 229 const Sequence<Nullable<float>>&, const Sequence<double>&, 230 const Sequence<double>&, const Sequence<Nullable<double>>&, 231 const Sequence<Nullable<double>>&); 232 void PassLenientFloat(float, float, const Nullable<float>&, 233 const Nullable<float>&, double, double, 234 const Nullable<double>&, const Nullable<double>&, 235 const Sequence<float>&, const Sequence<float>&, 236 const Sequence<Nullable<float>>&, 237 const Sequence<Nullable<float>>&, 238 const Sequence<double>&, const Sequence<double>&, 239 const Sequence<Nullable<double>>&, 240 const Sequence<Nullable<double>>&); 241 float LenientFloatAttr() const; 242 void SetLenientFloatAttr(float); 243 double LenientDoubleAttr() const; 244 void SetLenientDoubleAttr(double); 245 246 void PassUnrestricted(float arg1, float arg2, float arg3, float arg4, 247 double arg5, double arg6, double arg7, double arg8); 248 249 // Interface types 250 already_AddRefed<TestInterface> ReceiveSelf(); 251 already_AddRefed<TestInterface> ReceiveNullableSelf(); 252 TestInterface* ReceiveWeakSelf(); 253 TestInterface* ReceiveWeakNullableSelf(); 254 void PassSelf(TestInterface&); 255 void PassNullableSelf(TestInterface*); 256 already_AddRefed<TestInterface> NonNullSelf(); 257 void SetNonNullSelf(TestInterface&); 258 already_AddRefed<TestInterface> GetNullableSelf(); 259 already_AddRefed<TestInterface> CachedSelf(); 260 void SetNullableSelf(TestInterface*); 261 void PassOptionalSelf(const Optional<TestInterface*>&); 262 void PassOptionalNonNullSelf(const Optional<NonNull<TestInterface>>&); 263 void PassOptionalSelfWithDefault(TestInterface*); 264 265 already_AddRefed<TestNonWrapperCacheInterface> 266 ReceiveNonWrapperCacheInterface(); 267 already_AddRefed<TestNonWrapperCacheInterface> 268 ReceiveNullableNonWrapperCacheInterface(); 269 void ReceiveNonWrapperCacheInterfaceSequence( 270 nsTArray<RefPtr<TestNonWrapperCacheInterface>>&); 271 void ReceiveNullableNonWrapperCacheInterfaceSequence( 272 nsTArray<RefPtr<TestNonWrapperCacheInterface>>&); 273 void ReceiveNonWrapperCacheInterfaceNullableSequence( 274 Nullable<nsTArray<RefPtr<TestNonWrapperCacheInterface>>>&); 275 void ReceiveNullableNonWrapperCacheInterfaceNullableSequence( 276 Nullable<nsTArray<RefPtr<TestNonWrapperCacheInterface>>>&); 277 278 already_AddRefed<TestExternalInterface> ReceiveExternal(); 279 already_AddRefed<TestExternalInterface> ReceiveNullableExternal(); 280 TestExternalInterface* ReceiveWeakExternal(); 281 TestExternalInterface* ReceiveWeakNullableExternal(); 282 void PassExternal(TestExternalInterface*); 283 void PassNullableExternal(TestExternalInterface*); 284 already_AddRefed<TestExternalInterface> NonNullExternal(); 285 void SetNonNullExternal(TestExternalInterface*); 286 already_AddRefed<TestExternalInterface> GetNullableExternal(); 287 void SetNullableExternal(TestExternalInterface*); 288 void PassOptionalExternal(const Optional<TestExternalInterface*>&); 289 void PassOptionalNonNullExternal(const Optional<TestExternalInterface*>&); 290 void PassOptionalExternalWithDefault(TestExternalInterface*); 291 292 already_AddRefed<TestCallbackInterface> ReceiveCallbackInterface(); 293 already_AddRefed<TestCallbackInterface> ReceiveNullableCallbackInterface(); 294 TestCallbackInterface* ReceiveWeakCallbackInterface(); 295 TestCallbackInterface* ReceiveWeakNullableCallbackInterface(); 296 void PassCallbackInterface(TestCallbackInterface&); 297 void PassNullableCallbackInterface(TestCallbackInterface*); 298 already_AddRefed<TestCallbackInterface> NonNullCallbackInterface(); 299 void SetNonNullCallbackInterface(TestCallbackInterface&); 300 already_AddRefed<TestCallbackInterface> GetNullableCallbackInterface(); 301 void SetNullableCallbackInterface(TestCallbackInterface*); 302 void PassOptionalCallbackInterface( 303 const Optional<RefPtr<TestCallbackInterface>>&); 304 void PassOptionalNonNullCallbackInterface( 305 const Optional<OwningNonNull<TestCallbackInterface>>&); 306 void PassOptionalCallbackInterfaceWithDefault(TestCallbackInterface*); 307 308 // Sequence types 309 void GetReadonlySequence(nsTArray<int32_t>&); 310 void GetReadonlySequenceOfDictionaries(JSContext*, nsTArray<Dict>&); 311 void GetReadonlyNullableSequenceOfDictionaries(JSContext*, 312 Nullable<nsTArray<Dict>>&); 313 void GetReadonlyFrozenSequence(JSContext*, nsTArray<Dict>&); 314 void GetReadonlyFrozenNullableSequence(JSContext*, Nullable<nsTArray<Dict>>&); 315 void ReceiveSequence(nsTArray<int32_t>&); 316 void ReceiveNullableSequence(Nullable<nsTArray<int32_t>>&); 317 void ReceiveSequenceOfNullableInts(nsTArray<Nullable<int32_t>>&); 318 void ReceiveNullableSequenceOfNullableInts( 319 Nullable<nsTArray<Nullable<int32_t>>>&); 320 void PassSequence(const Sequence<int32_t>&); 321 void PassNullableSequence(const Nullable<Sequence<int32_t>>&); 322 void PassSequenceOfNullableInts(const Sequence<Nullable<int32_t>>&); 323 void PassOptionalSequenceOfNullableInts( 324 const Optional<Sequence<Nullable<int32_t>>>&); 325 void PassOptionalNullableSequenceOfNullableInts( 326 const Optional<Nullable<Sequence<Nullable<int32_t>>>>&); 327 void ReceiveCastableObjectSequence(nsTArray<RefPtr<TestInterface>>&); 328 void ReceiveCallbackObjectSequence(nsTArray<RefPtr<TestCallbackInterface>>&); 329 void ReceiveNullableCastableObjectSequence(nsTArray<RefPtr<TestInterface>>&); 330 void ReceiveNullableCallbackObjectSequence( 331 nsTArray<RefPtr<TestCallbackInterface>>&); 332 void ReceiveCastableObjectNullableSequence( 333 Nullable<nsTArray<RefPtr<TestInterface>>>&); 334 void ReceiveNullableCastableObjectNullableSequence( 335 Nullable<nsTArray<RefPtr<TestInterface>>>&); 336 void ReceiveWeakCastableObjectSequence(nsTArray<RefPtr<TestInterface>>&); 337 void ReceiveWeakNullableCastableObjectSequence( 338 nsTArray<RefPtr<TestInterface>>&); 339 void ReceiveWeakCastableObjectNullableSequence( 340 Nullable<nsTArray<RefPtr<TestInterface>>>&); 341 void ReceiveWeakNullableCastableObjectNullableSequence( 342 Nullable<nsTArray<RefPtr<TestInterface>>>&); 343 void PassCastableObjectSequence( 344 const Sequence<OwningNonNull<TestInterface>>&); 345 void PassNullableCastableObjectSequence( 346 const Sequence<RefPtr<TestInterface>>&); 347 void PassCastableObjectNullableSequence( 348 const Nullable<Sequence<OwningNonNull<TestInterface>>>&); 349 void PassNullableCastableObjectNullableSequence( 350 const Nullable<Sequence<RefPtr<TestInterface>>>&); 351 void PassOptionalSequence(const Optional<Sequence<int32_t>>&); 352 void PassOptionalSequenceWithDefaultValue(const Sequence<int32_t>&); 353 void PassOptionalNullableSequence( 354 const Optional<Nullable<Sequence<int32_t>>>&); 355 void PassOptionalNullableSequenceWithDefaultValue( 356 const Nullable<Sequence<int32_t>>&); 357 void PassOptionalNullableSequenceWithDefaultValue2( 358 const Nullable<Sequence<int32_t>>&); 359 void PassOptionalObjectSequence( 360 const Optional<Sequence<OwningNonNull<TestInterface>>>&); 361 void PassExternalInterfaceSequence( 362 const Sequence<RefPtr<TestExternalInterface>>&); 363 void PassNullableExternalInterfaceSequence( 364 const Sequence<RefPtr<TestExternalInterface>>&); 365 366 void ReceiveStringSequence(nsTArray<nsString>&); 367 void PassStringSequence(const Sequence<nsString>&); 368 369 void ReceiveByteStringSequence(nsTArray<nsCString>&); 370 void PassByteStringSequence(const Sequence<nsCString>&); 371 372 void ReceiveUTF8StringSequence(nsTArray<nsCString>&); 373 void PassUTF8StringSequence(const Sequence<nsCString>&); 374 375 void ReceiveAnySequence(JSContext*, nsTArray<JS::Value>&); 376 void ReceiveNullableAnySequence(JSContext*, Nullable<nsTArray<JS::Value>>&); 377 void ReceiveAnySequenceSequence(JSContext*, nsTArray<nsTArray<JS::Value>>&); 378 379 void ReceiveObjectSequence(JSContext*, nsTArray<JSObject*>&); 380 void ReceiveNullableObjectSequence(JSContext*, nsTArray<JSObject*>&); 381 382 void PassSequenceOfSequences(const Sequence<Sequence<int32_t>>&); 383 void PassSequenceOfSequencesOfSequences( 384 const Sequence<Sequence<Sequence<int32_t>>>&); 385 void ReceiveSequenceOfSequences(nsTArray<nsTArray<int32_t>>&); 386 void ReceiveSequenceOfSequencesOfSequences( 387 nsTArray<nsTArray<nsTArray<int32_t>>>&); 388 389 // Record types 390 void PassRecord(const Record<nsString, int32_t>&); 391 void PassNullableRecord(const Nullable<Record<nsString, int32_t>>&); 392 void PassRecordOfNullableInts(const Record<nsString, Nullable<int32_t>>&); 393 void PassOptionalRecordOfNullableInts( 394 const Optional<Record<nsString, Nullable<int32_t>>>&); 395 void PassOptionalNullableRecordOfNullableInts( 396 const Optional<Nullable<Record<nsString, Nullable<int32_t>>>>&); 397 void PassCastableObjectRecord( 398 const Record<nsString, OwningNonNull<TestInterface>>&); 399 void PassNullableCastableObjectRecord( 400 const Record<nsString, RefPtr<TestInterface>>&); 401 void PassCastableObjectNullableRecord( 402 const Nullable<Record<nsString, OwningNonNull<TestInterface>>>&); 403 void PassNullableCastableObjectNullableRecord( 404 const Nullable<Record<nsString, RefPtr<TestInterface>>>&); 405 void PassOptionalRecord(const Optional<Record<nsString, int32_t>>&); 406 void PassOptionalNullableRecord( 407 const Optional<Nullable<Record<nsString, int32_t>>>&); 408 void PassOptionalNullableRecordWithDefaultValue( 409 const Nullable<Record<nsString, int32_t>>&); 410 void PassOptionalObjectRecord( 411 const Optional<Record<nsString, OwningNonNull<TestInterface>>>&); 412 void PassExternalInterfaceRecord( 413 const Record<nsString, RefPtr<TestExternalInterface>>&); 414 void PassNullableExternalInterfaceRecord( 415 const Record<nsString, RefPtr<TestExternalInterface>>&); 416 void PassStringRecord(const Record<nsString, nsString>&); 417 void PassByteStringRecord(const Record<nsString, nsCString>&); 418 void PassUTF8StringRecord(const Record<nsString, nsCString>&); 419 void PassRecordOfRecords(const Record<nsString, Record<nsString, int32_t>>&); 420 void ReceiveRecord(Record<nsString, int32_t>&); 421 void ReceiveNullableRecord(Nullable<Record<nsString, int32_t>>&); 422 void ReceiveRecordOfNullableInts(Record<nsString, Nullable<int32_t>>&); 423 void ReceiveNullableRecordOfNullableInts( 424 Nullable<Record<nsString, Nullable<int32_t>>>&); 425 void ReceiveRecordOfRecords(Record<nsString, Record<nsString, int32_t>>&); 426 void ReceiveAnyRecord(JSContext*, Record<nsString, JS::Value>&); 427 428 // Typed array types 429 void PassArrayBuffer(const ArrayBuffer&); 430 void PassNullableArrayBuffer(const Nullable<ArrayBuffer>&); 431 void PassOptionalArrayBuffer(const Optional<ArrayBuffer>&); 432 void PassOptionalNullableArrayBuffer(const Optional<Nullable<ArrayBuffer>>&); 433 void PassOptionalNullableArrayBufferWithDefaultValue( 434 const Nullable<ArrayBuffer>&); 435 void PassArrayBufferView(const ArrayBufferView&); 436 void PassInt8Array(const Int8Array&); 437 void PassInt16Array(const Int16Array&); 438 void PassInt32Array(const Int32Array&); 439 void PassUint8Array(const Uint8Array&); 440 void PassUint16Array(const Uint16Array&); 441 void PassUint32Array(const Uint32Array&); 442 void PassUint8ClampedArray(const Uint8ClampedArray&); 443 void PassFloat32Array(const Float32Array&); 444 void PassFloat64Array(const Float64Array&); 445 void PassSequenceOfArrayBuffers(const Sequence<ArrayBuffer>&); 446 void PassSequenceOfNullableArrayBuffers( 447 const Sequence<Nullable<ArrayBuffer>>&); 448 void PassRecordOfArrayBuffers(const Record<nsString, ArrayBuffer>&); 449 void PassRecordOfNullableArrayBuffers( 450 const Record<nsString, Nullable<ArrayBuffer>>&); 451 void PassVariadicTypedArray(const Sequence<Float32Array>&); 452 void PassVariadicNullableTypedArray(const Sequence<Nullable<Float32Array>>&); 453 void ReceiveUint8Array(JSContext*, JS::MutableHandle<JSObject*>); 454 void SetUint8ArrayAttr(const Uint8Array&); 455 void GetUint8ArrayAttr(JSContext*, JS::MutableHandle<JSObject*>); 456 457 // DOMString types 458 void PassString(const nsAString&); 459 void PassNullableString(const nsAString&); 460 void PassOptionalString(const Optional<nsAString>&); 461 void PassOptionalStringWithDefaultValue(const nsAString&); 462 void PassOptionalNullableString(const Optional<nsAString>&); 463 void PassOptionalNullableStringWithDefaultValue(const nsAString&); 464 void PassVariadicString(const Sequence<nsString>&); 465 void ReceiveString(DOMString&); 466 467 // ByteString types 468 void PassByteString(const nsCString&); 469 void PassNullableByteString(const nsCString&); 470 void PassOptionalByteString(const Optional<nsCString>&); 471 void PassOptionalByteStringWithDefaultValue(const nsCString&); 472 void PassOptionalNullableByteString(const Optional<nsCString>&); 473 void PassOptionalNullableByteStringWithDefaultValue(const nsCString&); 474 void PassVariadicByteString(const Sequence<nsCString>&); 475 void PassOptionalUnionByteString(const Optional<ByteStringOrLong>&); 476 void PassOptionalUnionByteStringWithDefaultValue(const ByteStringOrLong&); 477 478 // UTF8String types 479 void PassUTF8String(const nsACString&); 480 void PassNullableUTF8String(const nsACString&); 481 void PassOptionalUTF8String(const Optional<nsACString>&); 482 void PassOptionalUTF8StringWithDefaultValue(const nsACString&); 483 void PassOptionalNullableUTF8String(const Optional<nsACString>&); 484 void PassOptionalNullableUTF8StringWithDefaultValue(const nsACString&); 485 void PassVariadicUTF8String(const Sequence<nsCString>&); 486 void PassOptionalUnionUTF8String(const Optional<UTF8StringOrLong>&); 487 void PassOptionalUnionUTF8StringWithDefaultValue(const UTF8StringOrLong&); 488 489 // USVString types 490 void PassUSVS(const nsAString&); 491 void PassNullableUSVS(const nsAString&); 492 void PassOptionalUSVS(const Optional<nsAString>&); 493 void PassOptionalUSVSWithDefaultValue(const nsAString&); 494 void PassOptionalNullableUSVS(const Optional<nsAString>&); 495 void PassOptionalNullableUSVSWithDefaultValue(const nsAString&); 496 void PassVariadicUSVS(const Sequence<nsString>&); 497 void ReceiveUSVS(DOMString&); 498 499 // JSString types 500 void PassJSString(JSContext*, JS::Handle<JSString*>); 501 void PassOptionalJSStringWithDefaultValue(JSContext*, JS::Handle<JSString*>); 502 void ReceiveJSString(JSContext*, JS::MutableHandle<JSString*>); 503 void GetReadonlyJSStringAttr(JSContext*, JS::MutableHandle<JSString*>); 504 void GetJsStringAttr(JSContext*, JS::MutableHandle<JSString*>); 505 void SetJsStringAttr(JSContext*, JS::Handle<JSString*>); 506 507 // Enumerated types 508 void PassEnum(TestEnum); 509 void PassNullableEnum(const Nullable<TestEnum>&); 510 void PassOptionalEnum(const Optional<TestEnum>&); 511 void PassEnumWithDefault(TestEnum); 512 void PassOptionalNullableEnum(const Optional<Nullable<TestEnum>>&); 513 void PassOptionalNullableEnumWithDefaultValue(const Nullable<TestEnum>&); 514 void PassOptionalNullableEnumWithDefaultValue2(const Nullable<TestEnum>&); 515 TestEnum ReceiveEnum(); 516 Nullable<TestEnum> ReceiveNullableEnum(); 517 TestEnum EnumAttribute(); 518 TestEnum ReadonlyEnumAttribute(); 519 void SetEnumAttribute(TestEnum); 520 521 // Callback types 522 void PassCallback(TestCallback&); 523 void PassNullableCallback(TestCallback*); 524 void PassOptionalCallback(const Optional<OwningNonNull<TestCallback>>&); 525 void PassOptionalNullableCallback(const Optional<RefPtr<TestCallback>>&); 526 void PassOptionalNullableCallbackWithDefaultValue(TestCallback*); 527 already_AddRefed<TestCallback> ReceiveCallback(); 528 already_AddRefed<TestCallback> ReceiveNullableCallback(); 529 void PassNullableTreatAsNullCallback(TestTreatAsNullCallback*); 530 void PassOptionalNullableTreatAsNullCallback( 531 const Optional<RefPtr<TestTreatAsNullCallback>>&); 532 void PassOptionalNullableTreatAsNullCallbackWithDefaultValue( 533 TestTreatAsNullCallback*); 534 void SetTreatAsNullCallback(TestTreatAsNullCallback&); 535 already_AddRefed<TestTreatAsNullCallback> TreatAsNullCallback(); 536 void SetNullableTreatAsNullCallback(TestTreatAsNullCallback*); 537 already_AddRefed<TestTreatAsNullCallback> GetNullableTreatAsNullCallback(); 538 539 void ForceCallbackGeneration( 540 TestIntegerReturn&, TestNullableIntegerReturn&, TestBooleanReturn&, 541 TestFloatReturn&, TestStringReturn&, TestEnumReturn&, 542 TestInterfaceReturn&, TestNullableInterfaceReturn&, 543 TestExternalInterfaceReturn&, TestNullableExternalInterfaceReturn&, 544 TestCallbackInterfaceReturn&, TestNullableCallbackInterfaceReturn&, 545 TestCallbackReturn&, TestNullableCallbackReturn&, TestObjectReturn&, 546 TestNullableObjectReturn&, TestTypedArrayReturn&, 547 TestNullableTypedArrayReturn&, TestSequenceReturn&, 548 TestNullableSequenceReturn&, TestIntegerArguments&, 549 TestInterfaceArguments&, TestStringEnumArguments&, TestObjectArguments&, 550 TestOptionalArguments&, TestUnionArguments&, TestUndefinedConstruction&, 551 TestIntegerConstruction&, TestBooleanConstruction&, 552 TestFloatConstruction&, TestStringConstruction&, TestEnumConstruction&, 553 TestInterfaceConstruction&, TestExternalInterfaceConstruction&, 554 TestCallbackInterfaceConstruction&, TestCallbackConstruction&, 555 TestObjectConstruction&, TestTypedArrayConstruction&, 556 TestSequenceConstruction&); 557 558 // Any types 559 void PassAny(JSContext*, JS::Handle<JS::Value>); 560 void PassVariadicAny(JSContext*, const Sequence<JS::Value>&); 561 void PassOptionalAny(JSContext*, JS::Handle<JS::Value>); 562 void PassAnyDefaultNull(JSContext*, JS::Handle<JS::Value>); 563 void PassSequenceOfAny(JSContext*, const Sequence<JS::Value>&); 564 void PassNullableSequenceOfAny(JSContext*, 565 const Nullable<Sequence<JS::Value>>&); 566 void PassOptionalSequenceOfAny(JSContext*, 567 const Optional<Sequence<JS::Value>>&); 568 void PassOptionalNullableSequenceOfAny( 569 JSContext*, const Optional<Nullable<Sequence<JS::Value>>>&); 570 void PassOptionalSequenceOfAnyWithDefaultValue( 571 JSContext*, const Nullable<Sequence<JS::Value>>&); 572 void PassSequenceOfSequenceOfAny(JSContext*, 573 const Sequence<Sequence<JS::Value>>&); 574 void PassSequenceOfNullableSequenceOfAny( 575 JSContext*, const Sequence<Nullable<Sequence<JS::Value>>>&); 576 void PassNullableSequenceOfNullableSequenceOfAny( 577 JSContext*, const Nullable<Sequence<Nullable<Sequence<JS::Value>>>>&); 578 void PassOptionalNullableSequenceOfNullableSequenceOfAny( 579 JSContext*, 580 const Optional<Nullable<Sequence<Nullable<Sequence<JS::Value>>>>>&); 581 void PassRecordOfAny(JSContext*, const Record<nsString, JS::Value>&); 582 void PassNullableRecordOfAny(JSContext*, 583 const Nullable<Record<nsString, JS::Value>>&); 584 void PassOptionalRecordOfAny(JSContext*, 585 const Optional<Record<nsString, JS::Value>>&); 586 void PassOptionalNullableRecordOfAny( 587 JSContext*, const Optional<Nullable<Record<nsString, JS::Value>>>&); 588 void PassOptionalRecordOfAnyWithDefaultValue( 589 JSContext*, const Nullable<Record<nsString, JS::Value>>&); 590 void PassRecordOfRecordOfAny( 591 JSContext*, const Record<nsString, Record<nsString, JS::Value>>&); 592 void PassRecordOfNullableRecordOfAny( 593 JSContext*, 594 const Record<nsString, Nullable<Record<nsString, JS::Value>>>&); 595 void PassNullableRecordOfNullableRecordOfAny( 596 JSContext*, 597 const Nullable<Record<nsString, Nullable<Record<nsString, JS::Value>>>>&); 598 void PassOptionalNullableRecordOfNullableRecordOfAny( 599 JSContext*, 600 const Optional< 601 Nullable<Record<nsString, Nullable<Record<nsString, JS::Value>>>>>&); 602 void PassOptionalNullableRecordOfNullableSequenceOfAny( 603 JSContext*, 604 const Optional< 605 Nullable<Record<nsString, Nullable<Sequence<JS::Value>>>>>&); 606 void PassOptionalNullableSequenceOfNullableRecordOfAny( 607 JSContext*, 608 const Optional< 609 Nullable<Sequence<Nullable<Record<nsString, JS::Value>>>>>&); 610 void ReceiveAny(JSContext*, JS::MutableHandle<JS::Value>); 611 612 // object types 613 void PassObject(JSContext*, JS::Handle<JSObject*>); 614 void PassVariadicObject(JSContext*, const Sequence<JSObject*>&); 615 void PassNullableObject(JSContext*, JS::Handle<JSObject*>); 616 void PassVariadicNullableObject(JSContext*, const Sequence<JSObject*>&); 617 void PassOptionalObject(JSContext*, const Optional<JS::Handle<JSObject*>>&); 618 void PassOptionalNullableObject(JSContext*, 619 const Optional<JS::Handle<JSObject*>>&); 620 void PassOptionalNullableObjectWithDefaultValue(JSContext*, 621 JS::Handle<JSObject*>); 622 void PassSequenceOfObject(JSContext*, const Sequence<JSObject*>&); 623 void PassSequenceOfNullableObject(JSContext*, const Sequence<JSObject*>&); 624 void PassNullableSequenceOfObject(JSContext*, 625 const Nullable<Sequence<JSObject*>>&); 626 void PassOptionalNullableSequenceOfNullableSequenceOfObject( 627 JSContext*, 628 const Optional<Nullable<Sequence<Nullable<Sequence<JSObject*>>>>>&); 629 void PassOptionalNullableSequenceOfNullableSequenceOfNullableObject( 630 JSContext*, 631 const Optional<Nullable<Sequence<Nullable<Sequence<JSObject*>>>>>&); 632 void PassRecordOfObject(JSContext*, const Record<nsString, JSObject*>&); 633 void ReceiveObject(JSContext*, JS::MutableHandle<JSObject*>); 634 void ReceiveNullableObject(JSContext*, JS::MutableHandle<JSObject*>); 635 636 // Union types 637 void PassUnion(JSContext*, const ObjectOrLong& arg); 638 void PassUnionWithNullable(JSContext* cx, const ObjectOrNullOrLong& arg) { 639 OwningObjectOrLong returnValue; 640 if (arg.IsNull()) { 641 } else if (arg.IsObject()) { 642 JS::Rooted<JSObject*> obj(cx, arg.GetAsObject()); 643 JS::GetClass(obj); 644 returnValue.SetAsObject() = obj; 645 } else { 646 int32_t i = arg.GetAsLong(); 647 i += 1; 648 returnValue.SetAsLong() = i; 649 } 650 } 651 #ifdef DEBUG 652 void PassUnion2(const LongOrBoolean& arg); 653 void PassUnion3(JSContext*, const ObjectOrLongOrBoolean& arg); 654 void PassUnion4(const NodeOrLongOrBoolean& arg); 655 void PassUnion5(JSContext*, const ObjectOrBoolean& arg); 656 void PassUnion6(JSContext*, const ObjectOrString& arg); 657 void PassUnion7(JSContext*, const ObjectOrStringOrLong& arg); 658 void PassUnion8(JSContext*, const ObjectOrStringOrBoolean& arg); 659 void PassUnion9(JSContext*, const ObjectOrStringOrLongOrBoolean& arg); 660 void PassUnion10(const EventInitOrLong& arg); 661 void PassUnion11(JSContext*, const CustomEventInitOrLong& arg); 662 void PassUnion12(const EventInitOrLong& arg); 663 void PassUnion13(JSContext*, const ObjectOrLongOrNull& arg); 664 void PassUnion14(JSContext*, const ObjectOrLongOrNull& arg); 665 void PassUnion15(const LongSequenceOrLong&); 666 void PassUnion16(const Optional<LongSequenceOrLong>&); 667 void PassUnion17(const LongSequenceOrNullOrLong&); 668 void PassUnion18(JSContext*, const ObjectSequenceOrLong&); 669 void PassUnion19(JSContext*, const Optional<ObjectSequenceOrLong>&); 670 void PassUnion20(JSContext*, const ObjectSequenceOrLong&); 671 void PassUnion21(const StringLongRecordOrLong&); 672 void PassUnion22(JSContext*, const StringObjectRecordOrLong&); 673 void PassUnion23(const ImageDataSequenceOrLong&); 674 void PassUnion24(const ImageDataOrNullSequenceOrLong&); 675 void PassUnion25(const ImageDataSequenceSequenceOrLong&); 676 void PassUnion26(const ImageDataOrNullSequenceSequenceOrLong&); 677 void PassUnion27(const StringSequenceOrEventInit&); 678 void PassUnion28(const EventInitOrStringSequence&); 679 void PassUnionWithCallback(const EventHandlerNonNullOrNullOrLong& arg); 680 void PassUnionWithByteString(const ByteStringOrLong&); 681 void PassUnionWithUTF8String(const UTF8StringOrLong&); 682 void PassUnionWithRecord(const StringStringRecordOrString&); 683 void PassUnionWithRecordAndSequence( 684 const StringStringRecordOrStringSequence&); 685 void PassUnionWithSequenceAndRecord( 686 const StringSequenceOrStringStringRecord&); 687 void PassUnionWithUSVS(const USVStringOrLong&); 688 #endif 689 void PassNullableUnion(JSContext*, const Nullable<ObjectOrLong>&); 690 void PassOptionalUnion(JSContext*, const Optional<ObjectOrLong>&); 691 void PassOptionalNullableUnion(JSContext*, 692 const Optional<Nullable<ObjectOrLong>>&); 693 void PassOptionalNullableUnionWithDefaultValue(JSContext*, 694 const Nullable<ObjectOrLong>&); 695 // void PassUnionWithInterfaces(const TestInterfaceOrTestExternalInterface& 696 // arg); void PassUnionWithInterfacesAndNullable(const 697 // TestInterfaceOrNullOrTestExternalInterface& arg); 698 void PassUnionWithArrayBuffer(const UTF8StringOrArrayBuffer& aArg) { 699 auto processor = [](const Span<uint8_t>& aData) -> int { return -1; }; 700 static_assert( 701 std::is_same_v<decltype(ProcessTypedArraysFixed(aArg, processor)), 702 Maybe<int>>, 703 "If the union can contain non-typedarray members we need to signal " 704 "that with a Maybe<…> rv."); 705 } 706 void PassUnionWithArrayBufferOrNull( 707 const UTF8StringOrArrayBufferOrNull& aArg) { 708 auto processor = [](const Span<uint8_t>& aData) -> int { return -1; }; 709 static_assert( 710 std::is_same_v<decltype(ProcessTypedArraysFixed(aArg, processor)), 711 Maybe<int>>, 712 "If the union can contain non-typedarray members or null we need to " 713 "signal that with a Maybe<…> rv."); 714 } 715 void PassUnionWithTypedArrays(const ArrayBufferViewOrArrayBuffer& aArg) { 716 auto processor = [](const Span<uint8_t>& aData) -> int { return -1; }; 717 static_assert( 718 std::is_same_v<decltype(ProcessTypedArraysFixed(aArg, processor)), int>, 719 "If the union can't contain non-typedarray members or null we can just " 720 "return the result of calling the lambda."); 721 } 722 void PassUnionWithTypedArraysOrNull( 723 const ArrayBufferViewOrArrayBufferOrNull& aArg) { 724 auto processor = [](const Span<uint8_t>& aData) -> int { return -1; }; 725 static_assert( 726 std::is_same_v<decltype(ProcessTypedArraysFixed(aArg, processor)), 727 Maybe<int>>, 728 "If the union can contain non-typedarray members or null we need to " 729 "signal that with a Maybe<…> rv."); 730 } 731 void PassUnionWithString(JSContext*, const StringOrObject&); 732 void PassUnionWithEnum(JSContext*, const SupportedTypeOrObject&); 733 // void PassUnionWithCallback(JSContext*, const TestCallbackOrLong&); 734 void PassUnionWithObject(JSContext*, const ObjectOrLong&); 735 736 void PassUnionWithDefaultValue1(const DoubleOrString& arg); 737 void PassUnionWithDefaultValue2(const DoubleOrString& arg); 738 void PassUnionWithDefaultValue3(const DoubleOrString& arg); 739 void PassUnionWithDefaultValue4(const FloatOrString& arg); 740 void PassUnionWithDefaultValue5(const FloatOrString& arg); 741 void PassUnionWithDefaultValue6(const FloatOrString& arg); 742 void PassUnionWithDefaultValue7(const UnrestrictedDoubleOrString& arg); 743 void PassUnionWithDefaultValue8(const UnrestrictedDoubleOrString& arg); 744 void PassUnionWithDefaultValue9(const UnrestrictedDoubleOrString& arg); 745 void PassUnionWithDefaultValue10(const UnrestrictedDoubleOrString& arg); 746 void PassUnionWithDefaultValue11(const UnrestrictedFloatOrString& arg); 747 void PassUnionWithDefaultValue12(const UnrestrictedFloatOrString& arg); 748 void PassUnionWithDefaultValue13(const UnrestrictedFloatOrString& arg); 749 void PassUnionWithDefaultValue14(const DoubleOrByteString& arg); 750 void PassUnionWithDefaultValue15(const DoubleOrByteString& arg); 751 void PassUnionWithDefaultValue16(const DoubleOrByteString& arg); 752 void PassUnionWithDefaultValue17(const DoubleOrSupportedType& arg); 753 void PassUnionWithDefaultValue18(const DoubleOrSupportedType& arg); 754 void PassUnionWithDefaultValue19(const DoubleOrSupportedType& arg); 755 void PassUnionWithDefaultValue20(const DoubleOrUSVString& arg); 756 void PassUnionWithDefaultValue21(const DoubleOrUSVString& arg); 757 void PassUnionWithDefaultValue22(const DoubleOrUSVString& arg); 758 void PassUnionWithDefaultValue23(const DoubleOrUTF8String& arg); 759 void PassUnionWithDefaultValue24(const DoubleOrUTF8String& arg); 760 void PassUnionWithDefaultValue25(const DoubleOrUTF8String& arg); 761 762 void PassNullableUnionWithDefaultValue1(const Nullable<DoubleOrString>& arg); 763 void PassNullableUnionWithDefaultValue2(const Nullable<DoubleOrString>& arg); 764 void PassNullableUnionWithDefaultValue3(const Nullable<DoubleOrString>& arg); 765 void PassNullableUnionWithDefaultValue4(const Nullable<FloatOrString>& arg); 766 void PassNullableUnionWithDefaultValue5(const Nullable<FloatOrString>& arg); 767 void PassNullableUnionWithDefaultValue6(const Nullable<FloatOrString>& arg); 768 void PassNullableUnionWithDefaultValue7( 769 const Nullable<UnrestrictedDoubleOrString>& arg); 770 void PassNullableUnionWithDefaultValue8( 771 const Nullable<UnrestrictedDoubleOrString>& arg); 772 void PassNullableUnionWithDefaultValue9( 773 const Nullable<UnrestrictedDoubleOrString>& arg); 774 void PassNullableUnionWithDefaultValue10( 775 const Nullable<UnrestrictedFloatOrString>& arg); 776 void PassNullableUnionWithDefaultValue11( 777 const Nullable<UnrestrictedFloatOrString>& arg); 778 void PassNullableUnionWithDefaultValue12( 779 const Nullable<UnrestrictedFloatOrString>& arg); 780 void PassNullableUnionWithDefaultValue13( 781 const Nullable<DoubleOrByteString>& arg); 782 void PassNullableUnionWithDefaultValue14( 783 const Nullable<DoubleOrByteString>& arg); 784 void PassNullableUnionWithDefaultValue15( 785 const Nullable<DoubleOrByteString>& arg); 786 void PassNullableUnionWithDefaultValue16( 787 const Nullable<DoubleOrByteString>& arg); 788 void PassNullableUnionWithDefaultValue17( 789 const Nullable<DoubleOrSupportedType>& arg); 790 void PassNullableUnionWithDefaultValue18( 791 const Nullable<DoubleOrSupportedType>& arg); 792 void PassNullableUnionWithDefaultValue19( 793 const Nullable<DoubleOrSupportedType>& arg); 794 void PassNullableUnionWithDefaultValue20( 795 const Nullable<DoubleOrSupportedType>& arg); 796 void PassNullableUnionWithDefaultValue21( 797 const Nullable<DoubleOrUSVString>& arg); 798 void PassNullableUnionWithDefaultValue22( 799 const Nullable<DoubleOrUSVString>& arg); 800 void PassNullableUnionWithDefaultValue23( 801 const Nullable<DoubleOrUSVString>& arg); 802 void PassNullableUnionWithDefaultValue24( 803 const Nullable<DoubleOrUSVString>& arg); 804 void PassNullableUnionWithDefaultValue25( 805 const Nullable<DoubleOrUTF8String>& arg); 806 void PassNullableUnionWithDefaultValue26( 807 const Nullable<DoubleOrUTF8String>& arg); 808 void PassNullableUnionWithDefaultValue27( 809 const Nullable<DoubleOrUTF8String>& arg); 810 void PassNullableUnionWithDefaultValue28( 811 const Nullable<DoubleOrUTF8String>& arg); 812 813 void PassSequenceOfUnions( 814 const Sequence<OwningCanvasPatternOrCanvasGradient>&); 815 void PassSequenceOfUnions2(JSContext*, const Sequence<OwningObjectOrLong>&); 816 void PassVariadicUnion(const Sequence<OwningCanvasPatternOrCanvasGradient>&); 817 818 void PassSequenceOfNullableUnions( 819 const Sequence<Nullable<OwningCanvasPatternOrCanvasGradient>>&); 820 void PassVariadicNullableUnion( 821 const Sequence<Nullable<OwningCanvasPatternOrCanvasGradient>>&); 822 void PassRecordOfUnions( 823 const Record<nsString, OwningCanvasPatternOrCanvasGradient>&); 824 void PassRecordOfUnions2(JSContext*, 825 const Record<nsString, OwningObjectOrLong>&); 826 827 void PassUnionWithSequenceOfUnions( 828 const StringOrOnlyForUseInInnerUnionOrCanvasPatternSequence& arg); 829 void PassUnionWithRecordOfUnions( 830 const LongSequenceOrStringOnlyForUseInInnerUnionOrLongSequenceRecord& 831 arg); 832 833 void ReceiveUnion(OwningCanvasPatternOrCanvasGradient&); 834 void ReceiveUnion2(JSContext*, OwningObjectOrLong&); 835 void ReceiveUnionContainingNull(OwningCanvasPatternOrNullOrCanvasGradient&); 836 void ReceiveNullableUnion(Nullable<OwningCanvasPatternOrCanvasGradient>&); 837 void ReceiveNullableUnion2(JSContext*, Nullable<OwningObjectOrLong>&); 838 void ReceiveUnionWithUndefined(OwningUndefinedOrCanvasPattern&); 839 void ReceiveUnionWithNullableUndefined(OwningUndefinedOrNullOrCanvasPattern&); 840 void ReceiveUnionWithUndefinedAndNullable( 841 OwningUndefinedOrCanvasPatternOrNull&); 842 void ReceiveNullableUnionWithUndefined( 843 Nullable<OwningUndefinedOrCanvasPattern>&); 844 845 void GetWritableUnion(OwningCanvasPatternOrCanvasGradient&); 846 void SetWritableUnion(const CanvasPatternOrCanvasGradient&); 847 void GetWritableUnionContainingNull( 848 OwningCanvasPatternOrNullOrCanvasGradient&); 849 void SetWritableUnionContainingNull( 850 const CanvasPatternOrNullOrCanvasGradient&); 851 void GetWritableNullableUnion(Nullable<OwningCanvasPatternOrCanvasGradient>&); 852 void SetWritableNullableUnion(const Nullable<CanvasPatternOrCanvasGradient>&); 853 void GetWritableUnionWithUndefined(OwningUndefinedOrCanvasPattern&); 854 void SetWritableUnionWithUndefined(const UndefinedOrCanvasPattern&); 855 void GetWritableUnionWithNullableUndefined( 856 OwningUndefinedOrNullOrCanvasPattern&); 857 void SetWritableUnionWithNullableUndefined( 858 const UndefinedOrNullOrCanvasPattern&); 859 void GetWritableUnionWithUndefinedAndNullable( 860 OwningUndefinedOrCanvasPatternOrNull&); 861 void SetWritableUnionWithUndefinedAndNullable( 862 const UndefinedOrCanvasPatternOrNull&); 863 void GetWritableNullableUnionWithUndefined( 864 Nullable<OwningUndefinedOrCanvasPattern>&); 865 void SetWritableNullableUnionWithUndefined( 866 const Nullable<UndefinedOrCanvasPattern>&); 867 868 // Promise types 869 void PassPromise(Promise&); 870 void PassOptionalPromise(const Optional<OwningNonNull<Promise>>&); 871 void PassPromiseSequence(const Sequence<OwningNonNull<Promise>>&); 872 void PassPromiseRecord(const Record<nsString, RefPtr<Promise>>&); 873 Promise* ReceivePromise(); 874 already_AddRefed<Promise> ReceiveAddrefedPromise(); 875 876 // ObservableArray types 877 void OnDeleteBooleanObservableArray(bool, uint32_t, ErrorResult&); 878 void OnSetBooleanObservableArray(bool, uint32_t, ErrorResult&); 879 void OnDeleteObjectObservableArray(JSContext*, JS::Handle<JSObject*>, 880 uint32_t, ErrorResult&); 881 void OnSetObjectObservableArray(JSContext*, JS::Handle<JSObject*>, uint32_t, 882 ErrorResult&); 883 void OnDeleteAnyObservableArray(JSContext*, JS::Handle<JS::Value>, uint32_t, 884 ErrorResult&); 885 void OnSetAnyObservableArray(JSContext*, JS::Handle<JS::Value>, uint32_t, 886 ErrorResult&); 887 void OnDeleteInterfaceObservableArray(TestInterface*, uint32_t, ErrorResult&); 888 void OnSetInterfaceObservableArray(TestInterface*, uint32_t, ErrorResult&); 889 void OnDeleteNullableObservableArray(const Nullable<int>&, uint32_t, 890 ErrorResult&); 891 void OnSetNullableObservableArray(const Nullable<int>&, uint32_t, 892 ErrorResult&); 893 894 // binaryNames tests 895 void MethodRenamedTo(); 896 void MethodRenamedTo(int8_t); 897 int8_t AttributeGetterRenamedTo(); 898 int8_t AttributeRenamedTo(); 899 void SetAttributeRenamedTo(int8_t); 900 901 // Dictionary tests 902 void PassDictionary(JSContext*, const Dict&); 903 void PassDictionary2(JSContext*, const Dict&); 904 void GetReadonlyDictionary(JSContext*, Dict&); 905 void GetReadonlyNullableDictionary(JSContext*, Nullable<Dict>&); 906 void GetWritableDictionary(JSContext*, Dict&); 907 void SetWritableDictionary(JSContext*, const Dict&); 908 void GetReadonlyFrozenDictionary(JSContext*, Dict&); 909 void GetReadonlyFrozenNullableDictionary(JSContext*, Nullable<Dict>&); 910 void GetWritableFrozenDictionary(JSContext*, Dict&); 911 void SetWritableFrozenDictionary(JSContext*, const Dict&); 912 void ReceiveDictionary(JSContext*, Dict&); 913 void ReceiveNullableDictionary(JSContext*, Nullable<Dict>&); 914 void PassOtherDictionary(const GrandparentDict&); 915 void PassSequenceOfDictionaries(JSContext*, const Sequence<Dict>&); 916 void PassRecordOfDictionaries(const Record<nsString, GrandparentDict>&); 917 void PassDictionaryOrLong(JSContext*, const Dict&); 918 void PassDictionaryOrLong(int32_t); 919 void PassDictContainingDict(JSContext*, const DictContainingDict&); 920 void PassDictContainingSequence(JSContext*, const DictContainingSequence&); 921 void ReceiveDictContainingSequence(JSContext*, DictContainingSequence&); 922 void PassVariadicDictionary(JSContext*, const Sequence<Dict>&); 923 924 // Typedefs 925 void ExerciseTypedefInterfaces1(TestInterface&); 926 already_AddRefed<TestInterface> ExerciseTypedefInterfaces2(TestInterface*); 927 void ExerciseTypedefInterfaces3(TestInterface&); 928 929 // Deprecated methods and attributes 930 int8_t DeprecatedAttribute(); 931 void SetDeprecatedAttribute(int8_t); 932 int8_t DeprecatedMethod(); 933 int8_t DeprecatedMethodWithContext(JSContext*, const JS::Value&); 934 935 // Static methods and attributes 936 static void StaticMethod(const GlobalObject&, bool); 937 static void StaticMethodWithContext(const GlobalObject&, const JS::Value&); 938 static bool StaticAttribute(const GlobalObject&); 939 static void SetStaticAttribute(const GlobalObject&, bool); 940 static void Assert(const GlobalObject&, bool); 941 942 // Deprecated static methods and attributes 943 static int8_t StaticDeprecatedAttribute(const GlobalObject&); 944 static void SetStaticDeprecatedAttribute(const GlobalObject&, int8_t); 945 static void StaticDeprecatedMethod(const GlobalObject&); 946 static void StaticDeprecatedMethodWithContext(const GlobalObject&, 947 const JS::Value&); 948 949 // Overload resolution tests 950 bool Overload1(TestInterface&); 951 TestInterface* Overload1(const nsAString&, TestInterface&); 952 void Overload2(TestInterface&); 953 void Overload2(JSContext*, const Dict&); 954 void Overload2(bool); 955 void Overload2(const nsAString&); 956 void Overload3(TestInterface&); 957 void Overload3(const TestCallback&); 958 void Overload3(bool); 959 void Overload4(TestInterface&); 960 void Overload4(TestCallbackInterface&); 961 void Overload4(const nsAString&); 962 void Overload5(int32_t); 963 void Overload5(TestEnum); 964 void Overload6(int32_t); 965 void Overload6(bool); 966 void Overload7(int32_t); 967 void Overload7(bool); 968 void Overload7(const nsCString&); 969 void Overload8(int32_t); 970 void Overload8(TestInterface&); 971 void Overload9(const Nullable<int32_t>&); 972 void Overload9(const nsAString&); 973 void Overload10(const Nullable<int32_t>&); 974 void Overload10(JSContext*, JS::Handle<JSObject*>); 975 void Overload11(int32_t); 976 void Overload11(const nsAString&); 977 void Overload12(int32_t); 978 void Overload12(const Nullable<bool>&); 979 void Overload13(const Nullable<int32_t>&); 980 void Overload13(bool); 981 void Overload14(const Optional<int32_t>&); 982 void Overload14(TestInterface&); 983 void Overload15(int32_t); 984 void Overload15(const Optional<NonNull<TestInterface>>&); 985 void Overload16(int32_t); 986 void Overload16(const Optional<TestInterface*>&); 987 void Overload17(const Sequence<int32_t>&); 988 void Overload17(const Record<nsString, int32_t>&); 989 void Overload18(const Record<nsString, nsString>&); 990 void Overload18(const Sequence<nsString>&); 991 void Overload19(const Sequence<int32_t>&); 992 void Overload19(JSContext*, const Dict&); 993 void Overload20(JSContext*, const Dict&); 994 void Overload20(const Sequence<int32_t>&); 995 996 // Variadic handling 997 void PassVariadicThirdArg(const nsAString&, int32_t, 998 const Sequence<OwningNonNull<TestInterface>>&); 999 1000 // Conditionally exposed methods/attributes 1001 bool Prefable1(); 1002 bool Prefable2(); 1003 bool Prefable3(); 1004 bool Prefable4(); 1005 bool Prefable5(); 1006 bool Prefable6(); 1007 bool Prefable7(); 1008 bool Prefable8(); 1009 bool Prefable9(); 1010 void Prefable10(); 1011 void Prefable11(); 1012 bool Prefable12(); 1013 void Prefable13(); 1014 bool Prefable14(); 1015 bool Prefable15(); 1016 bool Prefable16(); 1017 void Prefable17(); 1018 void Prefable18(); 1019 void Prefable19(); 1020 void Prefable20(); 1021 void Prefable21(); 1022 void Prefable22(); 1023 void Prefable23(); 1024 void Prefable24(); 1025 1026 // Conditionally exposed methods/attributes involving [SecureContext] 1027 bool ConditionalOnSecureContext1(); 1028 bool ConditionalOnSecureContext2(); 1029 bool ConditionalOnSecureContext3(); 1030 bool ConditionalOnSecureContext4(); 1031 void ConditionalOnSecureContext5(); 1032 void ConditionalOnSecureContext6(); 1033 void ConditionalOnSecureContext7(); 1034 void ConditionalOnSecureContext8(); 1035 1036 bool ConditionalOnSecureContext9(); 1037 void ConditionalOnSecureContext10(); 1038 1039 // Miscellania 1040 int32_t AttrWithLenientThis(); 1041 void SetAttrWithLenientThis(int32_t); 1042 uint32_t UnforgeableAttr(); 1043 uint32_t UnforgeableAttr2(); 1044 uint32_t UnforgeableMethod(); 1045 uint32_t UnforgeableMethod2(); 1046 void Stringify(nsString&); 1047 void PassRenamedInterface(nsRenamedInterface&); 1048 TestInterface* PutForwardsAttr(); 1049 TestInterface* PutForwardsAttr2(); 1050 TestInterface* PutForwardsAttr3(); 1051 void GetToJSONShouldSkipThis(JSContext*, JS::MutableHandle<JS::Value>); 1052 void SetToJSONShouldSkipThis(JSContext*, JS::Rooted<JS::Value>&); 1053 TestParentInterface* ToJSONShouldSkipThis2(); 1054 void SetToJSONShouldSkipThis2(TestParentInterface&); 1055 TestCallbackInterface* ToJSONShouldSkipThis3(); 1056 void SetToJSONShouldSkipThis3(TestCallbackInterface&); 1057 void ThrowingMethod(ErrorResult& aRv); 1058 bool GetThrowingAttr(ErrorResult& aRv) const; 1059 void SetThrowingAttr(bool arg, ErrorResult& aRv); 1060 bool GetThrowingGetterAttr(ErrorResult& aRv) const; 1061 void SetThrowingGetterAttr(bool arg); 1062 bool ThrowingSetterAttr() const; 1063 void SetThrowingSetterAttr(bool arg, ErrorResult& aRv); 1064 void CanOOMMethod(OOMReporter& aRv); 1065 bool GetCanOOMAttr(OOMReporter& aRv) const; 1066 void SetCanOOMAttr(bool arg, OOMReporter& aRv); 1067 bool GetCanOOMGetterAttr(OOMReporter& aRv) const; 1068 void SetCanOOMGetterAttr(bool arg); 1069 bool CanOOMSetterAttr() const; 1070 void SetCanOOMSetterAttr(bool arg, OOMReporter& aRv); 1071 void NeedsSubjectPrincipalMethod(nsIPrincipal&); 1072 bool NeedsSubjectPrincipalAttr(nsIPrincipal&); 1073 void SetNeedsSubjectPrincipalAttr(bool, nsIPrincipal&); 1074 void NeedsCallerTypeMethod(CallerType); 1075 bool NeedsCallerTypeAttr(CallerType); 1076 void SetNeedsCallerTypeAttr(bool, CallerType); 1077 void NeedsNonSystemSubjectPrincipalMethod(nsIPrincipal*); 1078 bool NeedsNonSystemSubjectPrincipalAttr(nsIPrincipal*); 1079 void SetNeedsNonSystemSubjectPrincipalAttr(bool, nsIPrincipal*); 1080 void CeReactionsMethod(); 1081 void CeReactionsMethodOverload(); 1082 void CeReactionsMethodOverload(const nsAString&); 1083 bool CeReactionsAttr() const; 1084 void SetCeReactionsAttr(bool); 1085 int16_t LegacyCall(const JS::Value&, uint32_t, TestInterface&); 1086 void PassArgsWithDefaults(JSContext*, const Optional<int32_t>&, 1087 TestInterface*, const Dict&, double, 1088 const Optional<float>&); 1089 1090 void SetDashed_attribute(int8_t); 1091 int8_t Dashed_attribute(); 1092 void Dashed_method(); 1093 1094 bool NonEnumerableAttr() const; 1095 void SetNonEnumerableAttr(bool); 1096 void NonEnumerableMethod(); 1097 1098 // Methods and properties imported via "includes" 1099 bool MixedInProperty(); 1100 void SetMixedInProperty(bool); 1101 void MixedInMethod(); 1102 1103 // Test EnforceRange/Clamp 1104 void DontEnforceRangeOrClamp(int8_t); 1105 void DoEnforceRange(int8_t); 1106 void DoEnforceRangeNullable(const Nullable<int8_t>&); 1107 void DoClamp(int8_t); 1108 void DoClampNullable(const Nullable<int8_t>&); 1109 void SetEnforcedByte(int8_t); 1110 int8_t EnforcedByte(); 1111 void SetEnforcedNullableByte(const Nullable<int8_t>&); 1112 Nullable<int8_t> GetEnforcedNullableByte() const; 1113 void SetClampedNullableByte(const Nullable<int8_t>&); 1114 Nullable<int8_t> GetClampedNullableByte() const; 1115 void SetClampedByte(int8_t); 1116 int8_t ClampedByte(); 1117 1118 // Test AllowShared 1119 void SetAllowSharedArrayBufferViewTypedef(const ArrayBufferView&); 1120 void GetAllowSharedArrayBufferViewTypedef(JSContext*, 1121 JS::MutableHandle<JSObject*>); 1122 void SetAllowSharedArrayBufferView(const ArrayBufferView&); 1123 void GetAllowSharedArrayBufferView(JSContext*, JS::MutableHandle<JSObject*>); 1124 void SetAllowSharedNullableArrayBufferView(const Nullable<ArrayBufferView>&); 1125 void GetAllowSharedNullableArrayBufferView(JSContext*, 1126 JS::MutableHandle<JSObject*>); 1127 void SetAllowSharedArrayBuffer(const ArrayBuffer&); 1128 void GetAllowSharedArrayBuffer(JSContext*, JS::MutableHandle<JSObject*>); 1129 void SetAllowSharedNullableArrayBuffer(const Nullable<ArrayBuffer>&); 1130 void GetAllowSharedNullableArrayBuffer(JSContext*, 1131 JS::MutableHandle<JSObject*>); 1132 1133 void PassAllowSharedArrayBufferViewTypedef(const ArrayBufferView&); 1134 void PassAllowSharedArrayBufferView(const ArrayBufferView&); 1135 void PassAllowSharedNullableArrayBufferView(const Nullable<ArrayBufferView>&); 1136 void PassAllowSharedArrayBuffer(const ArrayBuffer&); 1137 void PassAllowSharedNullableArrayBuffer(const Nullable<ArrayBuffer>&); 1138 void PassUnionArrayBuffer(const StringOrArrayBuffer& foo); 1139 void PassUnionAllowSharedArrayBuffer( 1140 const StringOrMaybeSharedArrayBuffer& foo); 1141 void passAllowSharedInt8ArrayOrInt16Array( 1142 const MaybeSharedInt8ArrayOrMaybeSharedInt16Array&); 1143 1144 void GetReflectedHTMLAttributeReturningFrozenArray( 1145 bool*, Nullable<nsTArray<RefPtr<Element>>>&) const; 1146 void SetReflectedHTMLAttributeReturningFrozenArray( 1147 const Nullable<Sequence<OwningNonNull<Element>>>&); 1148 1149 private: 1150 // We add signatures here that _could_ start matching if the codegen 1151 // got data types wrong. That way if it ever does we'll have a call 1152 // to these private deleted methods and compilation will fail. 1153 void SetReadonlyByte(int8_t) = delete; 1154 template <typename T> 1155 void SetWritableByte(T) = delete; 1156 template <typename T> 1157 void PassByte(T) = delete; 1158 void PassNullableByte(Nullable<int8_t>&) = delete; 1159 template <typename T> 1160 void PassOptionalByte(const Optional<T>&) = delete; 1161 template <typename T> 1162 void PassOptionalByteWithDefault(T) = delete; 1163 void PassVariadicByte(Sequence<int8_t>&) = delete; 1164 1165 void SetReadonlyShort(int16_t) = delete; 1166 template <typename T> 1167 void SetWritableShort(T) = delete; 1168 template <typename T> 1169 void PassShort(T) = delete; 1170 template <typename T> 1171 void PassOptionalShort(const Optional<T>&) = delete; 1172 template <typename T> 1173 void PassOptionalShortWithDefault(T) = delete; 1174 1175 void SetReadonlyLong(int32_t) = delete; 1176 template <typename T> 1177 void SetWritableLong(T) = delete; 1178 template <typename T> 1179 void PassLong(T) = delete; 1180 template <typename T> 1181 void PassOptionalLong(const Optional<T>&) = delete; 1182 template <typename T> 1183 void PassOptionalLongWithDefault(T) = delete; 1184 1185 void SetReadonlyLongLong(int64_t) = delete; 1186 template <typename T> 1187 void SetWritableLongLong(T) = delete; 1188 template <typename T> 1189 void PassLongLong(T) = delete; 1190 template <typename T> 1191 void PassOptionalLongLong(const Optional<T>&) = delete; 1192 template <typename T> 1193 void PassOptionalLongLongWithDefault(T) = delete; 1194 1195 void SetReadonlyOctet(uint8_t) = delete; 1196 template <typename T> 1197 void SetWritableOctet(T) = delete; 1198 template <typename T> 1199 void PassOctet(T) = delete; 1200 template <typename T> 1201 void PassOptionalOctet(const Optional<T>&) = delete; 1202 template <typename T> 1203 void PassOptionalOctetWithDefault(T) = delete; 1204 1205 void SetReadonlyUnsignedShort(uint16_t) = delete; 1206 template <typename T> 1207 void SetWritableUnsignedShort(T) = delete; 1208 template <typename T> 1209 void PassUnsignedShort(T) = delete; 1210 template <typename T> 1211 void PassOptionalUnsignedShort(const Optional<T>&) = delete; 1212 template <typename T> 1213 void PassOptionalUnsignedShortWithDefault(T) = delete; 1214 1215 void SetReadonlyUnsignedLong(uint32_t) = delete; 1216 template <typename T> 1217 void SetWritableUnsignedLong(T) = delete; 1218 template <typename T> 1219 void PassUnsignedLong(T) = delete; 1220 template <typename T> 1221 void PassOptionalUnsignedLong(const Optional<T>&) = delete; 1222 template <typename T> 1223 void PassOptionalUnsignedLongWithDefault(T) = delete; 1224 1225 void SetReadonlyUnsignedLongLong(uint64_t) = delete; 1226 template <typename T> 1227 void SetWritableUnsignedLongLong(T) = delete; 1228 template <typename T> 1229 void PassUnsignedLongLong(T) = delete; 1230 template <typename T> 1231 void PassOptionalUnsignedLongLong(const Optional<T>&) = delete; 1232 template <typename T> 1233 void PassOptionalUnsignedLongLongWithDefault(T) = delete; 1234 1235 // Enforce that only const things are passed for sequences 1236 void PassSequence(Sequence<int32_t>&) = delete; 1237 void PassNullableSequence(Nullable<Sequence<int32_t>>&) = delete; 1238 void PassOptionalNullableSequenceWithDefaultValue( 1239 Nullable<Sequence<int32_t>>&) = delete; 1240 void PassSequenceOfAny(JSContext*, Sequence<JS::Value>&) = delete; 1241 void PassNullableSequenceOfAny(JSContext*, 1242 Nullable<Sequence<JS::Value>>&) = delete; 1243 void PassOptionalSequenceOfAny(JSContext*, 1244 Optional<Sequence<JS::Value>>&) = delete; 1245 void PassOptionalNullableSequenceOfAny( 1246 JSContext*, Optional<Nullable<Sequence<JS::Value>>>&) = delete; 1247 void PassOptionalSequenceOfAnyWithDefaultValue( 1248 JSContext*, Nullable<Sequence<JS::Value>>&) = delete; 1249 void PassSequenceOfSequenceOfAny(JSContext*, 1250 Sequence<Sequence<JS::Value>>&) = delete; 1251 void PassSequenceOfNullableSequenceOfAny( 1252 JSContext*, Sequence<Nullable<Sequence<JS::Value>>>&) = delete; 1253 void PassNullableSequenceOfNullableSequenceOfAny( 1254 JSContext*, Nullable<Sequence<Nullable<Sequence<JS::Value>>>>&) = delete; 1255 void PassOptionalNullableSequenceOfNullableSequenceOfAny( 1256 JSContext*, 1257 Optional<Nullable<Sequence<Nullable<Sequence<JS::Value>>>>>&) = delete; 1258 void PassSequenceOfObject(JSContext*, Sequence<JSObject*>&) = delete; 1259 void PassSequenceOfNullableObject(JSContext*, Sequence<JSObject*>&) = delete; 1260 void PassOptionalNullableSequenceOfNullableSequenceOfObject( 1261 JSContext*, 1262 Optional<Nullable<Sequence<Nullable<Sequence<JSObject*>>>>>&) = delete; 1263 void PassOptionalNullableSequenceOfNullableSequenceOfNullableObject( 1264 JSContext*, 1265 Optional<Nullable<Sequence<Nullable<Sequence<JSObject*>>>>>&) = delete; 1266 1267 // Enforce that only const things are passed for optional 1268 void PassOptionalByte(Optional<int8_t>&) = delete; 1269 void PassOptionalNullableByte(Optional<Nullable<int8_t>>&) = delete; 1270 void PassOptionalShort(Optional<int16_t>&) = delete; 1271 void PassOptionalLong(Optional<int32_t>&) = delete; 1272 void PassOptionalLongLong(Optional<int64_t>&) = delete; 1273 void PassOptionalOctet(Optional<uint8_t>&) = delete; 1274 void PassOptionalUnsignedShort(Optional<uint16_t>&) = delete; 1275 void PassOptionalUnsignedLong(Optional<uint32_t>&) = delete; 1276 void PassOptionalUnsignedLongLong(Optional<uint64_t>&) = delete; 1277 void PassOptionalSelf(Optional<TestInterface*>&) = delete; 1278 void PassOptionalNonNullSelf(Optional<NonNull<TestInterface>>&) = delete; 1279 void PassOptionalExternal(Optional<TestExternalInterface*>&) = delete; 1280 void PassOptionalNonNullExternal(Optional<TestExternalInterface*>&) = delete; 1281 void PassOptionalSequence(Optional<Sequence<int32_t>>&) = delete; 1282 void PassOptionalNullableSequence(Optional<Nullable<Sequence<int32_t>>>&) = 1283 delete; 1284 void PassOptionalObjectSequence( 1285 Optional<Sequence<OwningNonNull<TestInterface>>>&) = delete; 1286 void PassOptionalArrayBuffer(Optional<ArrayBuffer>&) = delete; 1287 void PassOptionalNullableArrayBuffer(Optional<ArrayBuffer*>&) = delete; 1288 void PassOptionalEnum(Optional<TestEnum>&) = delete; 1289 void PassOptionalCallback(JSContext*, 1290 Optional<OwningNonNull<TestCallback>>&) = delete; 1291 void PassOptionalNullableCallback(JSContext*, 1292 Optional<RefPtr<TestCallback>>&) = delete; 1293 void PassOptionalAny(Optional<JS::Handle<JS::Value>>&) = delete; 1294 1295 // And test that string stuff is always const 1296 void PassString(nsAString&) = delete; 1297 void PassNullableString(nsAString&) = delete; 1298 void PassOptionalString(Optional<nsAString>&) = delete; 1299 void PassOptionalStringWithDefaultValue(nsAString&) = delete; 1300 void PassOptionalNullableString(Optional<nsAString>&) = delete; 1301 void PassOptionalNullableStringWithDefaultValue(nsAString&) = delete; 1302 void PassVariadicString(Sequence<nsString>&) = delete; 1303 1304 // cstrings should be const as well 1305 void PassByteString(nsCString&) = delete; 1306 void PassNullableByteString(nsCString&) = delete; 1307 void PassOptionalByteString(Optional<nsCString>&) = delete; 1308 void PassOptionalByteStringWithDefaultValue(nsCString&) = delete; 1309 void PassOptionalNullableByteString(Optional<nsCString>&) = delete; 1310 void PassOptionalNullableByteStringWithDefaultValue(nsCString&) = delete; 1311 void PassVariadicByteString(Sequence<nsCString>&) = delete; 1312 1313 // cstrings should be const as well 1314 void PassUTF8String(nsACString&) = delete; 1315 void PassNullableUTF8String(nsACString&) = delete; 1316 void PassOptionalUTF8String(Optional<nsACString>&) = delete; 1317 void PassOptionalUTF8StringWithDefaultValue(nsACString&) = delete; 1318 void PassOptionalNullableUTF8String(Optional<nsACString>&) = delete; 1319 void PassOptionalNullableUTF8StringWithDefaultValue(nsACString&) = delete; 1320 void PassVariadicUTF8String(Sequence<nsCString>&) = delete; 1321 1322 // Make sure dictionary arguments are always const 1323 void PassDictionary(JSContext*, Dict&) = delete; 1324 void PassOtherDictionary(GrandparentDict&) = delete; 1325 void PassSequenceOfDictionaries(JSContext*, Sequence<Dict>&) = delete; 1326 void PassDictionaryOrLong(JSContext*, Dict&) = delete; 1327 void PassDictContainingDict(JSContext*, DictContainingDict&) = delete; 1328 void PassDictContainingSequence(DictContainingSequence&) = delete; 1329 1330 // Make sure various nullable things are always const 1331 void PassNullableEnum(Nullable<TestEnum>&) = delete; 1332 1333 // Make sure unions are always const 1334 void PassUnion(JSContext*, ObjectOrLong& arg) = delete; 1335 void PassUnionWithNullable(JSContext*, ObjectOrNullOrLong& arg) = delete; 1336 void PassNullableUnion(JSContext*, Nullable<ObjectOrLong>&) = delete; 1337 void PassOptionalUnion(JSContext*, Optional<ObjectOrLong>&) = delete; 1338 void PassOptionalNullableUnion(JSContext*, 1339 Optional<Nullable<ObjectOrLong>>&) = delete; 1340 void PassOptionalNullableUnionWithDefaultValue( 1341 JSContext*, Nullable<ObjectOrLong>&) = delete; 1342 1343 // Make sure variadics are const as needed 1344 void PassVariadicAny(JSContext*, Sequence<JS::Value>&) = delete; 1345 void PassVariadicObject(JSContext*, Sequence<JSObject*>&) = delete; 1346 void PassVariadicNullableObject(JSContext*, Sequence<JSObject*>&) = delete; 1347 1348 // Ensure NonNull does not leak in 1349 void PassSelf(NonNull<TestInterface>&) = delete; 1350 void PassSelf(OwningNonNull<TestInterface>&) = delete; 1351 void PassSelf(const NonNull<TestInterface>&) = delete; 1352 void PassSelf(const OwningNonNull<TestInterface>&) = delete; 1353 void PassCallbackInterface(OwningNonNull<TestCallbackInterface>&) = delete; 1354 void PassCallbackInterface(const OwningNonNull<TestCallbackInterface>&) = 1355 delete; 1356 void PassCallbackInterface(NonNull<TestCallbackInterface>&) = delete; 1357 void PassCallbackInterface(const NonNull<TestCallbackInterface>&) = delete; 1358 void PassCallback(OwningNonNull<TestCallback>&) = delete; 1359 void PassCallback(const OwningNonNull<TestCallback>&) = delete; 1360 void PassCallback(NonNull<TestCallback>&) = delete; 1361 void PassCallback(const NonNull<TestCallback>&) = delete; 1362 void PassString(const NonNull<nsAString>&) = delete; 1363 void PassString(NonNull<nsAString>&) = delete; 1364 void PassString(const OwningNonNull<nsAString>&) = delete; 1365 void PassString(OwningNonNull<nsAString>&) = delete; 1366 }; 1367 1368 class TestLegacyFactoryFunctionInterface : public nsISupports, 1369 public nsWrapperCache { 1370 public: 1371 NS_DECL_ISUPPORTS 1372 1373 // We need a GetParentObject to make binding codegen happy 1374 virtual nsISupports* GetParentObject(); 1375 1376 // And now our actual WebIDL API 1377 static already_AddRefed<TestLegacyFactoryFunctionInterface> Test3( 1378 const GlobalObject&, const LongOrStringAnyRecord&, ErrorResult&); 1379 1380 static already_AddRefed<TestLegacyFactoryFunctionInterface> Test4( 1381 const GlobalObject&, const Record<nsString, Record<nsString, JS::Value>>&, 1382 ErrorResult&); 1383 }; 1384 1385 class TestLegacyFactoryFunctionInterface2 : public nsISupports, 1386 public nsWrapperCache { 1387 public: 1388 NS_DECL_ISUPPORTS 1389 1390 // We need a GetParentObject to make binding codegen happy 1391 virtual nsISupports* GetParentObject(); 1392 1393 // And now our actual WebIDL API 1394 static already_AddRefed<TestLegacyFactoryFunctionInterface2> Test5( 1395 const GlobalObject&, 1396 const Record< 1397 nsString, 1398 Sequence<Record<nsString, 1399 Record<nsString, Sequence<Sequence<JS::Value>>>>>>&, 1400 ErrorResult&); 1401 1402 static already_AddRefed<TestLegacyFactoryFunctionInterface2> Test6( 1403 const GlobalObject&, 1404 const Sequence<Record< 1405 nsCString, 1406 Sequence<Sequence<Record<nsCString, Record<nsString, JS::Value>>>>>>&, 1407 ErrorResult&); 1408 }; 1409 1410 class TestIndexedGetterInterface : public nsISupports, public nsWrapperCache { 1411 public: 1412 NS_DECL_ISUPPORTS 1413 1414 // We need a GetParentObject to make binding codegen happy 1415 virtual nsISupports* GetParentObject(); 1416 1417 uint32_t IndexedGetter(uint32_t, bool&); 1418 uint32_t IndexedGetter(uint32_t&) = delete; 1419 uint32_t Item(uint32_t&); 1420 uint32_t Item(uint32_t, bool&) = delete; 1421 uint32_t Length(); 1422 void LegacyCall(JS::Handle<JS::Value>); 1423 int32_t CachedAttr(); 1424 int32_t StoreInSlotAttr(); 1425 }; 1426 1427 class TestNamedGetterInterface : public nsISupports, public nsWrapperCache { 1428 public: 1429 NS_DECL_ISUPPORTS 1430 1431 // We need a GetParentObject to make binding codegen happy 1432 virtual nsISupports* GetParentObject(); 1433 1434 void NamedGetter(const nsAString&, bool&, nsAString&); 1435 void GetSupportedNames(nsTArray<nsString>&); 1436 }; 1437 1438 class TestIndexedGetterAndSetterAndNamedGetterInterface 1439 : public nsISupports, 1440 public nsWrapperCache { 1441 public: 1442 NS_DECL_ISUPPORTS 1443 1444 // We need a GetParentObject to make binding codegen happy 1445 virtual nsISupports* GetParentObject(); 1446 1447 void NamedGetter(const nsAString&, bool&, nsAString&); 1448 void GetSupportedNames(nsTArray<nsString>&); 1449 int32_t IndexedGetter(uint32_t, bool&); 1450 void IndexedSetter(uint32_t, int32_t); 1451 uint32_t Length(); 1452 }; 1453 1454 class TestIndexedAndNamedGetterInterface : public nsISupports, 1455 public nsWrapperCache { 1456 public: 1457 NS_DECL_ISUPPORTS 1458 1459 // We need a GetParentObject to make binding codegen happy 1460 virtual nsISupports* GetParentObject(); 1461 1462 uint32_t IndexedGetter(uint32_t, bool&); 1463 void NamedGetter(const nsAString&, bool&, nsAString&); 1464 void NamedItem(const nsAString&, nsAString&); 1465 uint32_t Length(); 1466 void GetSupportedNames(nsTArray<nsString>&); 1467 }; 1468 1469 class TestIndexedSetterInterface : public nsISupports, public nsWrapperCache { 1470 public: 1471 NS_DECL_ISUPPORTS 1472 1473 // We need a GetParentObject to make binding codegen happy 1474 virtual nsISupports* GetParentObject(); 1475 1476 void IndexedSetter(uint32_t, const nsAString&); 1477 void IndexedGetter(uint32_t, bool&, nsString&); 1478 uint32_t Length(); 1479 void SetItem(uint32_t, const nsAString&); 1480 }; 1481 1482 class TestNamedSetterInterface : public nsISupports, public nsWrapperCache { 1483 public: 1484 NS_DECL_ISUPPORTS 1485 1486 // We need a GetParentObject to make binding codegen happy 1487 virtual nsISupports* GetParentObject(); 1488 1489 void NamedSetter(const nsAString&, TestIndexedSetterInterface&); 1490 TestIndexedSetterInterface* NamedGetter(const nsAString&, bool&); 1491 void GetSupportedNames(nsTArray<nsString>&); 1492 }; 1493 1494 class TestIndexedAndNamedSetterInterface : public nsISupports, 1495 public nsWrapperCache { 1496 public: 1497 NS_DECL_ISUPPORTS 1498 1499 // We need a GetParentObject to make binding codegen happy 1500 virtual nsISupports* GetParentObject(); 1501 1502 void IndexedSetter(uint32_t, TestIndexedSetterInterface&); 1503 TestIndexedSetterInterface* IndexedGetter(uint32_t, bool&); 1504 uint32_t Length(); 1505 void NamedSetter(const nsAString&, TestIndexedSetterInterface&); 1506 TestIndexedSetterInterface* NamedGetter(const nsAString&, bool&); 1507 void SetNamedItem(const nsAString&, TestIndexedSetterInterface&); 1508 void GetSupportedNames(nsTArray<nsString>&); 1509 }; 1510 1511 class TestIndexedAndNamedGetterAndSetterInterface 1512 : public TestIndexedSetterInterface { 1513 public: 1514 uint32_t IndexedGetter(uint32_t, bool&); 1515 uint32_t Item(uint32_t); 1516 void NamedGetter(const nsAString&, bool&, nsAString&); 1517 void NamedItem(const nsAString&, nsAString&); 1518 void IndexedSetter(uint32_t, int32_t&); 1519 void IndexedSetter(uint32_t, const nsAString&) = delete; 1520 void NamedSetter(const nsAString&, const nsAString&); 1521 void Stringify(nsAString&); 1522 uint32_t Length(); 1523 void GetSupportedNames(nsTArray<nsString>&); 1524 }; 1525 1526 class TestCppKeywordNamedMethodsInterface : public nsISupports, 1527 public nsWrapperCache { 1528 public: 1529 NS_DECL_ISUPPORTS 1530 1531 // We need a GetParentObject to make binding codegen happy 1532 virtual nsISupports* GetParentObject(); 1533 1534 bool Continue(); 1535 bool Delete(); 1536 int32_t Volatile(); 1537 }; 1538 1539 class TestNamedDeleterInterface : public nsISupports, public nsWrapperCache { 1540 public: 1541 NS_DECL_ISUPPORTS 1542 1543 // We need a GetParentObject to make binding codegen happy 1544 virtual nsISupports* GetParentObject(); 1545 1546 void NamedDeleter(const nsAString&, bool&); 1547 long NamedGetter(const nsAString&, bool&); 1548 void GetSupportedNames(nsTArray<nsString>&); 1549 }; 1550 1551 class TestNamedDeleterWithRetvalInterface : public nsISupports, 1552 public nsWrapperCache { 1553 public: 1554 NS_DECL_ISUPPORTS 1555 1556 // We need a GetParentObject to make binding codegen happy 1557 virtual nsISupports* GetParentObject(); 1558 1559 void NamedDeleter(const nsAString&, bool&); 1560 void NamedDeleter(const nsAString&) = delete; 1561 long NamedGetter(const nsAString&, bool&); 1562 void DelNamedItem(const nsAString&); 1563 void DelNamedItem(const nsAString&, bool&) = delete; 1564 void GetSupportedNames(nsTArray<nsString>&); 1565 }; 1566 1567 class TestParentInterface : public nsISupports, public nsWrapperCache { 1568 public: 1569 NS_DECL_ISUPPORTS 1570 1571 // We need a GetParentObject to make binding codegen happy 1572 virtual nsISupports* GetParentObject(); 1573 }; 1574 1575 class TestChildInterface : public TestParentInterface {}; 1576 1577 class TestDeprecatedInterface : public nsISupports, public nsWrapperCache { 1578 public: 1579 NS_DECL_ISUPPORTS 1580 1581 static already_AddRefed<TestDeprecatedInterface> Constructor( 1582 const GlobalObject&); 1583 1584 static void AlsoDeprecated(const GlobalObject&); 1585 1586 virtual nsISupports* GetParentObject(); 1587 }; 1588 1589 class TestInterfaceWithPromiseConstructorArg : public nsISupports, 1590 public nsWrapperCache { 1591 public: 1592 NS_DECL_ISUPPORTS 1593 1594 static already_AddRefed<TestInterfaceWithPromiseConstructorArg> Constructor( 1595 const GlobalObject&, Promise&); 1596 1597 virtual nsISupports* GetParentObject(); 1598 }; 1599 1600 class TestSecureContextInterface : public nsISupports, public nsWrapperCache { 1601 public: 1602 NS_DECL_ISUPPORTS 1603 1604 static already_AddRefed<TestSecureContextInterface> Constructor( 1605 const GlobalObject&, ErrorResult&); 1606 1607 static void AlsoSecureContext(const GlobalObject&); 1608 1609 virtual nsISupports* GetParentObject(); 1610 }; 1611 1612 class TestNamespace { 1613 public: 1614 static bool Foo(const GlobalObject&); 1615 static int32_t Bar(const GlobalObject&); 1616 static void Baz(const GlobalObject&); 1617 }; 1618 1619 class TestRenamedNamespace {}; 1620 1621 class TestProtoObjectHackedNamespace {}; 1622 1623 class TestWorkerExposedInterface : public nsISupports, public nsWrapperCache { 1624 public: 1625 NS_DECL_ISUPPORTS 1626 1627 // We need a GetParentObject to make binding codegen happy 1628 nsISupports* GetParentObject(); 1629 1630 void NeedsSubjectPrincipalMethod(nsIPrincipal&); 1631 bool NeedsSubjectPrincipalAttr(nsIPrincipal&); 1632 void SetNeedsSubjectPrincipalAttr(bool, nsIPrincipal&); 1633 void NeedsCallerTypeMethod(CallerType); 1634 bool NeedsCallerTypeAttr(CallerType); 1635 void SetNeedsCallerTypeAttr(bool, CallerType); 1636 void NeedsNonSystemSubjectPrincipalMethod(nsIPrincipal*); 1637 bool NeedsNonSystemSubjectPrincipalAttr(nsIPrincipal*); 1638 void SetNeedsNonSystemSubjectPrincipalAttr(bool, nsIPrincipal*); 1639 }; 1640 1641 class TestHTMLConstructorInterface : public nsGenericHTMLElement { 1642 public: 1643 virtual nsISupports* GetParentObject(); 1644 }; 1645 1646 class TestThrowingConstructorInterface : public nsISupports, 1647 public nsWrapperCache { 1648 public: 1649 static already_AddRefed<TestThrowingConstructorInterface> Constructor( 1650 const GlobalObject&, ErrorResult&); 1651 static already_AddRefed<TestThrowingConstructorInterface> Constructor( 1652 const GlobalObject&, const nsAString&, ErrorResult&); 1653 static already_AddRefed<TestThrowingConstructorInterface> Constructor( 1654 const GlobalObject&, uint32_t, const Nullable<bool>&, ErrorResult&); 1655 static already_AddRefed<TestThrowingConstructorInterface> Constructor( 1656 const GlobalObject&, TestInterface*, ErrorResult&); 1657 static already_AddRefed<TestThrowingConstructorInterface> Constructor( 1658 const GlobalObject&, uint32_t, TestInterface&, ErrorResult&); 1659 1660 static already_AddRefed<TestThrowingConstructorInterface> Constructor( 1661 const GlobalObject&, const ArrayBuffer&, ErrorResult&); 1662 static already_AddRefed<TestThrowingConstructorInterface> Constructor( 1663 const GlobalObject&, const Uint8Array&, ErrorResult&); 1664 /* static 1665 already_AddRefed<TestThrowingConstructorInterface> 1666 Constructor(const GlobalObject&, uint32_t, uint32_t, 1667 const TestInterfaceOrOnlyForUseInConstructor&, ErrorResult&); 1668 */ 1669 1670 virtual nsISupports* GetParentObject(); 1671 }; 1672 1673 class TestCEReactionsInterface : public nsISupports, public nsWrapperCache { 1674 public: 1675 NS_DECL_ISUPPORTS 1676 1677 // We need a GetParentObject and GetDocGroup to make binding codegen happy 1678 virtual nsISupports* GetParentObject(); 1679 DocGroup* GetDocGroup() const; 1680 1681 int32_t Item(uint32_t); 1682 uint32_t Length() const; 1683 int32_t IndexedGetter(uint32_t, bool&); 1684 void IndexedSetter(uint32_t, int32_t); 1685 void NamedDeleter(const nsAString&, bool&); 1686 void NamedGetter(const nsAString&, bool&, nsString&); 1687 void NamedSetter(const nsAString&, const nsAString&); 1688 void GetSupportedNames(nsTArray<nsString>&); 1689 }; 1690 1691 class TestAttributesOnTypes : public nsISupports, public nsWrapperCache { 1692 public: 1693 NS_DECL_ISUPPORTS 1694 1695 // We need a GetParentObject and GetDocGroup to make binding codegen happy 1696 virtual nsISupports* GetParentObject(); 1697 1698 void Foo(uint8_t arg); 1699 void Bar(uint8_t arg); 1700 void Baz(const nsAString& arg); 1701 uint8_t SomeAttr(); 1702 void SetSomeAttr(uint8_t); 1703 void ArgWithAttr(uint8_t arg1, const Optional<uint8_t>& arg2); 1704 }; 1705 1706 class TestPrefConstructorForInterface : public nsISupports, 1707 public nsWrapperCache { 1708 public: 1709 NS_DECL_ISUPPORTS 1710 virtual nsISupports* GetParentObject(); 1711 1712 // Since only the constructor is under a pref, 1713 // the generated constructor should check for the pref. 1714 static already_AddRefed<TestPrefConstructorForInterface> Constructor( 1715 const GlobalObject&); 1716 }; 1717 1718 class TestConstructorForPrefInterface : public nsISupports, 1719 public nsWrapperCache { 1720 public: 1721 NS_DECL_ISUPPORTS 1722 virtual nsISupports* GetParentObject(); 1723 1724 // Since the interface itself is under a Pref, there should be no 1725 // check for the pref in the generated constructor. 1726 static already_AddRefed<TestConstructorForPrefInterface> Constructor( 1727 const GlobalObject&); 1728 }; 1729 1730 class TestPrefConstructorForDifferentPrefInterface : public nsISupports, 1731 public nsWrapperCache { 1732 public: 1733 NS_DECL_ISUPPORTS 1734 virtual nsISupports* GetParentObject(); 1735 1736 // Since the constructor's pref is different than the interface pref 1737 // there should still be a check for the pref in the generated constructor. 1738 static already_AddRefed<TestPrefConstructorForDifferentPrefInterface> 1739 Constructor(const GlobalObject&); 1740 }; 1741 1742 class TestConstructorForSCInterface : public nsISupports, 1743 public nsWrapperCache { 1744 public: 1745 NS_DECL_ISUPPORTS 1746 virtual nsISupports* GetParentObject(); 1747 1748 // Since the interface itself is SecureContext, there should be no 1749 // check for SecureContext in the constructor. 1750 static already_AddRefed<TestConstructorForSCInterface> Constructor( 1751 const GlobalObject&); 1752 }; 1753 1754 class TestSCConstructorForInterface : public nsISupports, 1755 public nsWrapperCache { 1756 public: 1757 NS_DECL_ISUPPORTS 1758 virtual nsISupports* GetParentObject(); 1759 1760 // Since the interface context is unspecified but the constructor is 1761 // SecureContext, the generated constructor should check for SecureContext. 1762 static already_AddRefed<TestSCConstructorForInterface> Constructor( 1763 const GlobalObject&); 1764 }; 1765 1766 class TestConstructorForFuncInterface : public nsISupports, 1767 public nsWrapperCache { 1768 public: 1769 NS_DECL_ISUPPORTS 1770 virtual nsISupports* GetParentObject(); 1771 1772 // Since the interface has a Func attribute, but the constructor does not, 1773 // the generated constructor should not check for the Func. 1774 static already_AddRefed<TestConstructorForFuncInterface> Constructor( 1775 const GlobalObject&); 1776 }; 1777 1778 class TestFuncConstructorForInterface : public nsISupports, 1779 public nsWrapperCache { 1780 public: 1781 NS_DECL_ISUPPORTS 1782 virtual nsISupports* GetParentObject(); 1783 1784 // Since the constructor has a Func attribute, but the interface does not, 1785 // the generated constructor should check for the Func. 1786 static already_AddRefed<TestFuncConstructorForInterface> Constructor( 1787 const GlobalObject&); 1788 }; 1789 1790 class TestFuncConstructorForDifferentFuncInterface : public nsISupports, 1791 public nsWrapperCache { 1792 public: 1793 NS_DECL_ISUPPORTS 1794 virtual nsISupports* GetParentObject(); 1795 1796 // Since the constructor has a different Func attribute from the interface, 1797 // the generated constructor should still check for its conditional func. 1798 static already_AddRefed<TestFuncConstructorForDifferentFuncInterface> 1799 Constructor(const GlobalObject&); 1800 }; 1801 1802 class TestPrefChromeOnlySCFuncConstructorForInterface : public nsISupports, 1803 public nsWrapperCache { 1804 public: 1805 NS_DECL_ISUPPORTS 1806 virtual nsISupports* GetParentObject(); 1807 1808 // There should be checks for all Pref/ChromeOnly/SecureContext/Func 1809 // in the generated constructor. 1810 static already_AddRefed<TestPrefChromeOnlySCFuncConstructorForInterface> 1811 Constructor(const GlobalObject&); 1812 }; 1813 1814 class TestCallbackDictUnionOverload : public nsISupports, 1815 public nsWrapperCache { 1816 public: 1817 NS_DECL_ISUPPORTS 1818 virtual nsISupports* GetParentObject(); 1819 1820 void Overload1(bool); 1821 void Overload1(TestCallback&); 1822 void Overload1(const GrandparentDict&); 1823 void Overload2(bool); 1824 void Overload2(const GrandparentDict&); 1825 void Overload2(TestCallback&); 1826 }; 1827 1828 } // namespace dom 1829 } // namespace mozilla 1830 1831 #endif /* TestBindingHeader_h */