From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- dom/bindings/AtomList.h | 25 + dom/bindings/BindingCallContext.h | 66 + dom/bindings/BindingDeclarations.h | 547 + dom/bindings/BindingIPCUtils.h | 19 + dom/bindings/BindingUtils.cpp | 4375 ++++ dom/bindings/BindingUtils.h | 3267 +++ dom/bindings/Bindings.conf | 2131 ++ dom/bindings/CallbackFunction.h | 55 + dom/bindings/CallbackInterface.cpp | 35 + dom/bindings/CallbackInterface.h | 50 + dom/bindings/CallbackObject.cpp | 433 + dom/bindings/CallbackObject.h | 664 + dom/bindings/Codegen.py | 24278 +++++++++++++++++++ dom/bindings/Configuration.py | 1235 + dom/bindings/DOMExceptionNames.h | 53 + dom/bindings/DOMJSClass.h | 622 + dom/bindings/DOMJSProxyHandler.cpp | 331 + dom/bindings/DOMJSProxyHandler.h | 163 + dom/bindings/DOMString.h | 332 + dom/bindings/ErrorIPCUtils.h | 106 + dom/bindings/ErrorResult.h | 928 + dom/bindings/Errors.msg | 97 + dom/bindings/Exceptions.cpp | 759 + dom/bindings/Exceptions.h | 64 + dom/bindings/FakeString.h | 267 + dom/bindings/GenerateCSS2PropertiesWebIDL.py | 104 + dom/bindings/IterableIterator.cpp | 338 + dom/bindings/IterableIterator.h | 435 + dom/bindings/JSSlots.h | 41 + dom/bindings/Makefile.in | 53 + dom/bindings/NonRefcountedDOMObject.h | 37 + dom/bindings/Nullable.h | 108 + dom/bindings/ObservableArrayProxyHandler.cpp | 372 + dom/bindings/ObservableArrayProxyHandler.h | 114 + dom/bindings/PinnedStringId.h | 48 + dom/bindings/PrimitiveConversions.h | 330 + dom/bindings/ProxyHandlerUtils.h | 62 + dom/bindings/Record.h | 85 + dom/bindings/RemoteObjectProxy.cpp | 182 + dom/bindings/RemoteObjectProxy.h | 204 + dom/bindings/RootedDictionary.h | 41 + dom/bindings/RootedOwningNonNull.h | 58 + dom/bindings/RootedRecord.h | 28 + dom/bindings/RootedRefPtr.h | 48 + dom/bindings/RootedSequence.h | 28 + dom/bindings/SimpleGlobalObject.cpp | 177 + dom/bindings/SimpleGlobalObject.h | 96 + dom/bindings/SpiderMonkeyInterface.h | 114 + dom/bindings/ToJSValue.cpp | 123 + dom/bindings/ToJSValue.h | 486 + dom/bindings/TypedArray.h | 290 + dom/bindings/UnionMember.h | 45 + dom/bindings/WebIDLGlobalNameHash.cpp | 274 + dom/bindings/WebIDLGlobalNameHash.h | 92 + dom/bindings/XrayExpandoClass.h | 37 + dom/bindings/crashtests/1010658-1.html | 16 + dom/bindings/crashtests/1010658-2.html | 16 + dom/bindings/crashtests/769464.html | 11 + dom/bindings/crashtests/822340-1.html | 11 + dom/bindings/crashtests/822340-2.html | 8 + dom/bindings/crashtests/832899.html | 5 + dom/bindings/crashtests/860551.html | 4 + dom/bindings/crashtests/860591.html | 20 + dom/bindings/crashtests/862092.html | 19 + dom/bindings/crashtests/862610.html | 20 + dom/bindings/crashtests/869038.html | 22 + dom/bindings/crashtests/949940.html | 16 + dom/bindings/crashtests/crashtests.list | 13 + .../crashtests/stringbuffer-USVString.html | 11 + dom/bindings/docs/index.rst | 124 + dom/bindings/mach_commands.py | 62 + dom/bindings/moz.build | 204 + dom/bindings/mozwebidlcodegen/__init__.py | 681 + dom/bindings/mozwebidlcodegen/test/Child.webidl | 3 + .../mozwebidlcodegen/test/ExampleBinding.webidl | 3 + dom/bindings/mozwebidlcodegen/test/Parent.webidl | 3 + .../mozwebidlcodegen/test/TestEvent.webidl | 13 + dom/bindings/mozwebidlcodegen/test/python.ini | 4 + .../mozwebidlcodegen/test/test_mozwebidlcodegen.py | 297 + dom/bindings/nsIScriptError.idl | 296 + dom/bindings/nsScriptError.cpp | 531 + dom/bindings/nsScriptError.h | 143 + dom/bindings/nsScriptErrorWithStack.cpp | 188 + dom/bindings/parser/README | 1 + dom/bindings/parser/UPSTREAM | 1 + dom/bindings/parser/WebIDL.py | 9139 +++++++ dom/bindings/parser/runtests.py | 142 + dom/bindings/parser/tests/test_any_null.py | 16 + .../tests/test_argument_identifier_conflicts.py | 16 + .../parser/tests/test_argument_keywords.py | 22 + dom/bindings/parser/tests/test_argument_novoid.py | 16 + dom/bindings/parser/tests/test_arraybuffer.py | 95 + dom/bindings/parser/tests/test_attr.py | 199 + .../parser/tests/test_attr_sequence_type.py | 77 + .../parser/tests/test_attributes_on_types.py | 567 + dom/bindings/parser/tests/test_builtin_filename.py | 11 + dom/bindings/parser/tests/test_builtins.py | 59 + dom/bindings/parser/tests/test_bytestring.py | 125 + dom/bindings/parser/tests/test_callback.py | 42 + .../parser/tests/test_callback_constructor.py | 84 + .../parser/tests/test_callback_interface.py | 103 + dom/bindings/parser/tests/test_cereactions.py | 157 + .../tests/test_conditional_dictionary_member.py | 128 + dom/bindings/parser/tests/test_const.py | 96 + dom/bindings/parser/tests/test_constructor.py | 596 + .../parser/tests/test_constructor_global.py | 69 + .../tests/test_constructor_no_interface_object.py | 47 + dom/bindings/parser/tests/test_deduplicate.py | 17 + dom/bindings/parser/tests/test_dictionary.py | 875 + .../parser/tests/test_distinguishability.py | 421 + dom/bindings/parser/tests/test_double_null.py | 16 + .../parser/tests/test_duplicate_qualifiers.py | 64 + dom/bindings/parser/tests/test_empty_enum.py | 14 + .../tests/test_empty_sequence_default_value.py | 54 + dom/bindings/parser/tests/test_enum.py | 107 + .../parser/tests/test_enum_duplicate_values.py | 13 + dom/bindings/parser/tests/test_error_colno.py | 24 + dom/bindings/parser/tests/test_error_lineno.py | 38 + .../tests/test_exposed_extended_attribute.py | 383 + .../parser/tests/test_extended_attributes.py | 128 + dom/bindings/parser/tests/test_float_types.py | 145 + dom/bindings/parser/tests/test_forward_decl.py | 15 + .../parser/tests/test_global_extended_attr.py | 129 + .../parser/tests/test_identifier_conflict.py | 45 + .../parser/tests/test_incomplete_parent.py | 18 + dom/bindings/parser/tests/test_incomplete_types.py | 61 + dom/bindings/parser/tests/test_interface.py | 459 + .../test_interface_const_identifier_conflicts.py | 17 + ...nterface_identifier_conflicts_across_members.py | 168 + .../tests/test_interface_maplikesetlikeiterable.py | 935 + dom/bindings/parser/tests/test_interfacemixin.py | 534 + dom/bindings/parser/tests/test_lenientSetter.py | 84 + dom/bindings/parser/tests/test_method.py | 430 + dom/bindings/parser/tests/test_namespace.py | 232 + dom/bindings/parser/tests/test_newobject.py | 73 + .../parser/tests/test_nullable_equivalency.py | 138 + dom/bindings/parser/tests/test_nullable_void.py | 16 + dom/bindings/parser/tests/test_observableArray.py | 288 + .../parser/tests/test_optional_constraints.py | 35 + dom/bindings/parser/tests/test_overload.py | 74 + dom/bindings/parser/tests/test_promise.py | 177 + dom/bindings/parser/tests/test_prototype_ident.py | 107 + dom/bindings/parser/tests/test_putForwards.py | 119 + dom/bindings/parser/tests/test_record.py | 61 + dom/bindings/parser/tests/test_replaceable.py | 84 + dom/bindings/parser/tests/test_sanity.py | 7 + .../tests/test_securecontext_extended_attribute.py | 538 + .../test_special_method_signature_mismatch.py | 256 + dom/bindings/parser/tests/test_special_methods.py | 117 + .../tests/test_special_methods_uniqueness.py | 51 + dom/bindings/parser/tests/test_stringifier.py | 196 + dom/bindings/parser/tests/test_toJSON.py | 309 + .../parser/tests/test_treatNonCallableAsNull.py | 77 + dom/bindings/parser/tests/test_typedef.py | 94 + .../tests/test_typedef_identifier_conflict.py | 19 + dom/bindings/parser/tests/test_undefined.py | 243 + .../tests/test_unenumerable_own_properties.py | 71 + dom/bindings/parser/tests/test_unforgeable.py | 311 + dom/bindings/parser/tests/test_union.py | 196 + dom/bindings/parser/tests/test_union_any.py | 16 + dom/bindings/parser/tests/test_union_nullable.py | 60 + dom/bindings/parser/tests/test_usvstring.py | 40 + .../parser/tests/test_variadic_callback.py | 10 + .../parser/tests/test_variadic_constraints.py | 74 + dom/bindings/test/Makefile.in | 17 + dom/bindings/test/TestBindingHeader.h | 1772 ++ dom/bindings/test/TestCImplementedInterface.h | 37 + dom/bindings/test/TestCallback.webidl | 10 + dom/bindings/test/TestCodeGen.webidl | 1529 ++ dom/bindings/test/TestDictionary.webidl | 9 + dom/bindings/test/TestExampleGen.webidl | 911 + dom/bindings/test/TestFunctions.cpp | 315 + dom/bindings/test/TestFunctions.h | 138 + .../test/TestInterfaceAsyncIterableDouble.cpp | 98 + .../test/TestInterfaceAsyncIterableDouble.h | 64 + .../test/TestInterfaceAsyncIterableDoubleUnion.cpp | 107 + .../test/TestInterfaceAsyncIterableDoubleUnion.h | 64 + .../test/TestInterfaceAsyncIterableSingle.cpp | 130 + .../test/TestInterfaceAsyncIterableSingle.h | 81 + .../TestInterfaceAsyncIterableSingleWithArgs.cpp | 118 + .../TestInterfaceAsyncIterableSingleWithArgs.h | 60 + dom/bindings/test/TestInterfaceIterableDouble.cpp | 71 + dom/bindings/test/TestInterfaceIterableDouble.h | 53 + .../test/TestInterfaceIterableDoubleUnion.cpp | 76 + .../test/TestInterfaceIterableDoubleUnion.h | 52 + dom/bindings/test/TestInterfaceIterableSingle.cpp | 72 + dom/bindings/test/TestInterfaceIterableSingle.h | 51 + dom/bindings/test/TestInterfaceJS.sys.mjs | 220 + dom/bindings/test/TestInterfaceLength.cpp | 24 + dom/bindings/test/TestInterfaceLength.h | 39 + dom/bindings/test/TestInterfaceMaplike.cpp | 74 + dom/bindings/test/TestInterfaceMaplike.h | 52 + dom/bindings/test/TestInterfaceMaplikeJSObject.cpp | 85 + dom/bindings/test/TestInterfaceMaplikeJSObject.h | 55 + dom/bindings/test/TestInterfaceMaplikeObject.cpp | 81 + dom/bindings/test/TestInterfaceMaplikeObject.h | 55 + dom/bindings/test/TestInterfaceObservableArray.cpp | 225 + dom/bindings/test/TestInterfaceObservableArray.h | 115 + dom/bindings/test/TestInterfaceSetlike.cpp | 51 + dom/bindings/test/TestInterfaceSetlike.h | 44 + dom/bindings/test/TestInterfaceSetlikeNode.cpp | 53 + dom/bindings/test/TestInterfaceSetlikeNode.h | 46 + dom/bindings/test/TestJSImplGen.webidl | 884 + dom/bindings/test/TestJSImplInheritanceGen.webidl | 39 + dom/bindings/test/TestTrialInterface.cpp | 24 + dom/bindings/test/TestTrialInterface.h | 39 + dom/bindings/test/TestTypedef.webidl | 7 + .../WrapperCachedNonISupportsTestInterface.cpp | 28 + .../test/WrapperCachedNonISupportsTestInterface.h | 45 + dom/bindings/test/chrome.ini | 19 + dom/bindings/test/file_InstanceOf.html | 11 + .../test/file_barewordGetsWindow_frame1.html | 1 + .../test/file_barewordGetsWindow_frame2.html | 1 + dom/bindings/test/file_bug1808352_frame.html | 4 + dom/bindings/test/file_bug1808352b_frame.html | 3 + dom/bindings/test/file_bug775543.html | 5 + .../test/file_document_location_set_via_xray.html | 5 + dom/bindings/test/file_dom_xrays.html | 24 + dom/bindings/test/file_proxies_via_xray.html | 8 + dom/bindings/test/forOf_iframe.html | 13 + dom/bindings/test/mochitest.ini | 117 + dom/bindings/test/moz.build | 69 + dom/bindings/test/mozITestInterfaceJS.idl | 21 + dom/bindings/test/test_ByteString.html | 31 + dom/bindings/test/test_InstanceOf.html | 53 + dom/bindings/test/test_Object.prototype_props.html | 21 + dom/bindings/test/test_async_iterable.html | 300 + dom/bindings/test/test_async_stacks.html | 109 + dom/bindings/test/test_attributes_on_types.html | 246 + dom/bindings/test/test_barewordGetsWindow.html | 60 + dom/bindings/test/test_bug1036214.html | 141 + dom/bindings/test/test_bug1041646.html | 49 + .../test/test_bug1123516_maplikesetlike.html | 278 + .../test_bug1123516_maplikesetlikechrome.xhtml | 70 + dom/bindings/test/test_bug1123875.html | 15 + dom/bindings/test/test_bug1287912.html | 36 + dom/bindings/test/test_bug1457051.html | 34 + dom/bindings/test/test_bug1808352.html | 24 + dom/bindings/test/test_bug1808352b.html | 25 + dom/bindings/test/test_bug560072.html | 34 + dom/bindings/test/test_bug742191.html | 36 + dom/bindings/test/test_bug759621.html | 29 + dom/bindings/test/test_bug773326.html | 13 + dom/bindings/test/test_bug775543.html | 36 + dom/bindings/test/test_bug788369.html | 30 + dom/bindings/test/test_bug852846.html | 34 + dom/bindings/test/test_bug862092.html | 36 + .../test/test_callback_across_document_open.html | 22 + .../test/test_callback_default_thisval.html | 36 + dom/bindings/test/test_callback_exceptions.html | 19 + dom/bindings/test/test_cloneAndImportNode.html | 48 + .../test/test_crossOriginWindowSymbolAccess.html | 29 + dom/bindings/test/test_defineProperty.html | 157 + .../test/test_document_location_set_via_xray.html | 48 + .../test_document_location_via_xray_cached.html | 35 + .../test/test_domProxyArrayLengthGetter.html | 28 + dom/bindings/test/test_dom_xrays.html | 383 + dom/bindings/test/test_enums.html | 16 + dom/bindings/test/test_exceptionSanitization.html | 56 + dom/bindings/test/test_exceptionThrowing.html | 56 + dom/bindings/test/test_exception_messages.html | 83 + .../test_exception_options_from_jsimplemented.html | 166 + .../test/test_exceptions_from_jsimplemented.html | 56 + dom/bindings/test/test_forOf.html | 87 + dom/bindings/test/test_integers.html | 50 + dom/bindings/test/test_interfaceLength.html | 34 + dom/bindings/test/test_interfaceLength_chrome.html | 34 + dom/bindings/test/test_interfaceName.html | 28 + dom/bindings/test/test_interfaceToString.html | 45 + dom/bindings/test/test_iterable.html | 241 + .../test/test_jsimplemented_cross_realm_this.html | 44 + .../test/test_jsimplemented_eventhandler.html | 47 + .../test/test_jsimplemented_subclassing.html | 31 + dom/bindings/test/test_large_arraybuffers.html | 97 + dom/bindings/test/test_large_imageData.html | 68 + dom/bindings/test/test_lenientThis.html | 28 + dom/bindings/test/test_lookupGetter.html | 49 + dom/bindings/test/test_namedNoIndexed.html | 36 + .../test/test_named_getter_enumerability.html | 41 + dom/bindings/test/test_observablearray.html | 546 + dom/bindings/test/test_observablearray_helper.html | 376 + .../test/test_observablearray_proxyhandler.html | 859 + dom/bindings/test/test_oom_reporting.html | 42 + dom/bindings/test/test_prefOnConstructor.html | 57 + dom/bindings/test/test_primitive_this.html | 44 + ...test_promise_rejections_from_jsimplemented.html | 143 + dom/bindings/test/test_proxies_via_xray.html | 98 + dom/bindings/test/test_proxy_accessors.html | 78 + dom/bindings/test/test_proxy_expandos.html | 86 + dom/bindings/test/test_remoteProxyAsPrototype.html | 33 + dom/bindings/test/test_returnUnion.html | 59 + dom/bindings/test/test_sequence_detection.html | 53 + dom/bindings/test/test_sequence_wrapping.html | 59 + .../test/test_setWithNamedGetterNoNamedSetter.html | 40 + dom/bindings/test/test_stringBindings.html | 109 + dom/bindings/test/test_throwing_method_noDCE.html | 30 + dom/bindings/test/test_toJSON.html | 59 + dom/bindings/test/test_traceProtos.html | 37 + .../test/test_treat_non_object_as_null.html | 39 + dom/bindings/test/test_unforgeablesonexpando.html | 19 + dom/bindings/test/test_usvstring.html | 43 + dom/bindings/test/test_worker_UnwrapArg.html | 58 + 302 files changed, 84513 insertions(+) create mode 100644 dom/bindings/AtomList.h create mode 100644 dom/bindings/BindingCallContext.h create mode 100644 dom/bindings/BindingDeclarations.h create mode 100644 dom/bindings/BindingIPCUtils.h create mode 100644 dom/bindings/BindingUtils.cpp create mode 100644 dom/bindings/BindingUtils.h create mode 100644 dom/bindings/Bindings.conf create mode 100644 dom/bindings/CallbackFunction.h create mode 100644 dom/bindings/CallbackInterface.cpp create mode 100644 dom/bindings/CallbackInterface.h create mode 100644 dom/bindings/CallbackObject.cpp create mode 100644 dom/bindings/CallbackObject.h create mode 100644 dom/bindings/Codegen.py create mode 100644 dom/bindings/Configuration.py create mode 100644 dom/bindings/DOMExceptionNames.h create mode 100644 dom/bindings/DOMJSClass.h create mode 100644 dom/bindings/DOMJSProxyHandler.cpp create mode 100644 dom/bindings/DOMJSProxyHandler.h create mode 100644 dom/bindings/DOMString.h create mode 100644 dom/bindings/ErrorIPCUtils.h create mode 100644 dom/bindings/ErrorResult.h create mode 100644 dom/bindings/Errors.msg create mode 100644 dom/bindings/Exceptions.cpp create mode 100644 dom/bindings/Exceptions.h create mode 100644 dom/bindings/FakeString.h create mode 100644 dom/bindings/GenerateCSS2PropertiesWebIDL.py create mode 100644 dom/bindings/IterableIterator.cpp create mode 100644 dom/bindings/IterableIterator.h create mode 100644 dom/bindings/JSSlots.h create mode 100644 dom/bindings/Makefile.in create mode 100644 dom/bindings/NonRefcountedDOMObject.h create mode 100644 dom/bindings/Nullable.h create mode 100644 dom/bindings/ObservableArrayProxyHandler.cpp create mode 100644 dom/bindings/ObservableArrayProxyHandler.h create mode 100644 dom/bindings/PinnedStringId.h create mode 100644 dom/bindings/PrimitiveConversions.h create mode 100644 dom/bindings/ProxyHandlerUtils.h create mode 100644 dom/bindings/Record.h create mode 100644 dom/bindings/RemoteObjectProxy.cpp create mode 100644 dom/bindings/RemoteObjectProxy.h create mode 100644 dom/bindings/RootedDictionary.h create mode 100644 dom/bindings/RootedOwningNonNull.h create mode 100644 dom/bindings/RootedRecord.h create mode 100644 dom/bindings/RootedRefPtr.h create mode 100644 dom/bindings/RootedSequence.h create mode 100644 dom/bindings/SimpleGlobalObject.cpp create mode 100644 dom/bindings/SimpleGlobalObject.h create mode 100644 dom/bindings/SpiderMonkeyInterface.h create mode 100644 dom/bindings/ToJSValue.cpp create mode 100644 dom/bindings/ToJSValue.h create mode 100644 dom/bindings/TypedArray.h create mode 100644 dom/bindings/UnionMember.h create mode 100644 dom/bindings/WebIDLGlobalNameHash.cpp create mode 100644 dom/bindings/WebIDLGlobalNameHash.h create mode 100644 dom/bindings/XrayExpandoClass.h create mode 100644 dom/bindings/crashtests/1010658-1.html create mode 100644 dom/bindings/crashtests/1010658-2.html create mode 100644 dom/bindings/crashtests/769464.html create mode 100644 dom/bindings/crashtests/822340-1.html create mode 100644 dom/bindings/crashtests/822340-2.html create mode 100644 dom/bindings/crashtests/832899.html create mode 100644 dom/bindings/crashtests/860551.html create mode 100644 dom/bindings/crashtests/860591.html create mode 100644 dom/bindings/crashtests/862092.html create mode 100644 dom/bindings/crashtests/862610.html create mode 100644 dom/bindings/crashtests/869038.html create mode 100644 dom/bindings/crashtests/949940.html create mode 100644 dom/bindings/crashtests/crashtests.list create mode 100644 dom/bindings/crashtests/stringbuffer-USVString.html create mode 100644 dom/bindings/docs/index.rst create mode 100644 dom/bindings/mach_commands.py create mode 100644 dom/bindings/moz.build create mode 100644 dom/bindings/mozwebidlcodegen/__init__.py create mode 100644 dom/bindings/mozwebidlcodegen/test/Child.webidl create mode 100644 dom/bindings/mozwebidlcodegen/test/ExampleBinding.webidl create mode 100644 dom/bindings/mozwebidlcodegen/test/Parent.webidl create mode 100644 dom/bindings/mozwebidlcodegen/test/TestEvent.webidl create mode 100644 dom/bindings/mozwebidlcodegen/test/python.ini create mode 100644 dom/bindings/mozwebidlcodegen/test/test_mozwebidlcodegen.py create mode 100644 dom/bindings/nsIScriptError.idl create mode 100644 dom/bindings/nsScriptError.cpp create mode 100644 dom/bindings/nsScriptError.h create mode 100644 dom/bindings/nsScriptErrorWithStack.cpp create mode 100644 dom/bindings/parser/README create mode 100644 dom/bindings/parser/UPSTREAM create mode 100644 dom/bindings/parser/WebIDL.py create mode 100644 dom/bindings/parser/runtests.py create mode 100644 dom/bindings/parser/tests/test_any_null.py create mode 100644 dom/bindings/parser/tests/test_argument_identifier_conflicts.py create mode 100644 dom/bindings/parser/tests/test_argument_keywords.py create mode 100644 dom/bindings/parser/tests/test_argument_novoid.py create mode 100644 dom/bindings/parser/tests/test_arraybuffer.py create mode 100644 dom/bindings/parser/tests/test_attr.py create mode 100644 dom/bindings/parser/tests/test_attr_sequence_type.py create mode 100644 dom/bindings/parser/tests/test_attributes_on_types.py create mode 100644 dom/bindings/parser/tests/test_builtin_filename.py create mode 100644 dom/bindings/parser/tests/test_builtins.py create mode 100644 dom/bindings/parser/tests/test_bytestring.py create mode 100644 dom/bindings/parser/tests/test_callback.py create mode 100644 dom/bindings/parser/tests/test_callback_constructor.py create mode 100644 dom/bindings/parser/tests/test_callback_interface.py create mode 100644 dom/bindings/parser/tests/test_cereactions.py create mode 100644 dom/bindings/parser/tests/test_conditional_dictionary_member.py create mode 100644 dom/bindings/parser/tests/test_const.py create mode 100644 dom/bindings/parser/tests/test_constructor.py create mode 100644 dom/bindings/parser/tests/test_constructor_global.py create mode 100644 dom/bindings/parser/tests/test_constructor_no_interface_object.py create mode 100644 dom/bindings/parser/tests/test_deduplicate.py create mode 100644 dom/bindings/parser/tests/test_dictionary.py create mode 100644 dom/bindings/parser/tests/test_distinguishability.py create mode 100644 dom/bindings/parser/tests/test_double_null.py create mode 100644 dom/bindings/parser/tests/test_duplicate_qualifiers.py create mode 100644 dom/bindings/parser/tests/test_empty_enum.py create mode 100644 dom/bindings/parser/tests/test_empty_sequence_default_value.py create mode 100644 dom/bindings/parser/tests/test_enum.py create mode 100644 dom/bindings/parser/tests/test_enum_duplicate_values.py create mode 100644 dom/bindings/parser/tests/test_error_colno.py create mode 100644 dom/bindings/parser/tests/test_error_lineno.py create mode 100644 dom/bindings/parser/tests/test_exposed_extended_attribute.py create mode 100644 dom/bindings/parser/tests/test_extended_attributes.py create mode 100644 dom/bindings/parser/tests/test_float_types.py create mode 100644 dom/bindings/parser/tests/test_forward_decl.py create mode 100644 dom/bindings/parser/tests/test_global_extended_attr.py create mode 100644 dom/bindings/parser/tests/test_identifier_conflict.py create mode 100644 dom/bindings/parser/tests/test_incomplete_parent.py create mode 100644 dom/bindings/parser/tests/test_incomplete_types.py create mode 100644 dom/bindings/parser/tests/test_interface.py create mode 100644 dom/bindings/parser/tests/test_interface_const_identifier_conflicts.py create mode 100644 dom/bindings/parser/tests/test_interface_identifier_conflicts_across_members.py create mode 100644 dom/bindings/parser/tests/test_interface_maplikesetlikeiterable.py create mode 100644 dom/bindings/parser/tests/test_interfacemixin.py create mode 100644 dom/bindings/parser/tests/test_lenientSetter.py create mode 100644 dom/bindings/parser/tests/test_method.py create mode 100644 dom/bindings/parser/tests/test_namespace.py create mode 100644 dom/bindings/parser/tests/test_newobject.py create mode 100644 dom/bindings/parser/tests/test_nullable_equivalency.py create mode 100644 dom/bindings/parser/tests/test_nullable_void.py create mode 100644 dom/bindings/parser/tests/test_observableArray.py create mode 100644 dom/bindings/parser/tests/test_optional_constraints.py create mode 100644 dom/bindings/parser/tests/test_overload.py create mode 100644 dom/bindings/parser/tests/test_promise.py create mode 100644 dom/bindings/parser/tests/test_prototype_ident.py create mode 100644 dom/bindings/parser/tests/test_putForwards.py create mode 100644 dom/bindings/parser/tests/test_record.py create mode 100644 dom/bindings/parser/tests/test_replaceable.py create mode 100644 dom/bindings/parser/tests/test_sanity.py create mode 100644 dom/bindings/parser/tests/test_securecontext_extended_attribute.py create mode 100644 dom/bindings/parser/tests/test_special_method_signature_mismatch.py create mode 100644 dom/bindings/parser/tests/test_special_methods.py create mode 100644 dom/bindings/parser/tests/test_special_methods_uniqueness.py create mode 100644 dom/bindings/parser/tests/test_stringifier.py create mode 100644 dom/bindings/parser/tests/test_toJSON.py create mode 100644 dom/bindings/parser/tests/test_treatNonCallableAsNull.py create mode 100644 dom/bindings/parser/tests/test_typedef.py create mode 100644 dom/bindings/parser/tests/test_typedef_identifier_conflict.py create mode 100644 dom/bindings/parser/tests/test_undefined.py create mode 100644 dom/bindings/parser/tests/test_unenumerable_own_properties.py create mode 100644 dom/bindings/parser/tests/test_unforgeable.py create mode 100644 dom/bindings/parser/tests/test_union.py create mode 100644 dom/bindings/parser/tests/test_union_any.py create mode 100644 dom/bindings/parser/tests/test_union_nullable.py create mode 100644 dom/bindings/parser/tests/test_usvstring.py create mode 100644 dom/bindings/parser/tests/test_variadic_callback.py create mode 100644 dom/bindings/parser/tests/test_variadic_constraints.py create mode 100644 dom/bindings/test/Makefile.in create mode 100644 dom/bindings/test/TestBindingHeader.h create mode 100644 dom/bindings/test/TestCImplementedInterface.h create mode 100644 dom/bindings/test/TestCallback.webidl create mode 100644 dom/bindings/test/TestCodeGen.webidl create mode 100644 dom/bindings/test/TestDictionary.webidl create mode 100644 dom/bindings/test/TestExampleGen.webidl create mode 100644 dom/bindings/test/TestFunctions.cpp create mode 100644 dom/bindings/test/TestFunctions.h create mode 100644 dom/bindings/test/TestInterfaceAsyncIterableDouble.cpp create mode 100644 dom/bindings/test/TestInterfaceAsyncIterableDouble.h create mode 100644 dom/bindings/test/TestInterfaceAsyncIterableDoubleUnion.cpp create mode 100644 dom/bindings/test/TestInterfaceAsyncIterableDoubleUnion.h create mode 100644 dom/bindings/test/TestInterfaceAsyncIterableSingle.cpp create mode 100644 dom/bindings/test/TestInterfaceAsyncIterableSingle.h create mode 100644 dom/bindings/test/TestInterfaceAsyncIterableSingleWithArgs.cpp create mode 100644 dom/bindings/test/TestInterfaceAsyncIterableSingleWithArgs.h create mode 100644 dom/bindings/test/TestInterfaceIterableDouble.cpp create mode 100644 dom/bindings/test/TestInterfaceIterableDouble.h create mode 100644 dom/bindings/test/TestInterfaceIterableDoubleUnion.cpp create mode 100644 dom/bindings/test/TestInterfaceIterableDoubleUnion.h create mode 100644 dom/bindings/test/TestInterfaceIterableSingle.cpp create mode 100644 dom/bindings/test/TestInterfaceIterableSingle.h create mode 100644 dom/bindings/test/TestInterfaceJS.sys.mjs create mode 100644 dom/bindings/test/TestInterfaceLength.cpp create mode 100644 dom/bindings/test/TestInterfaceLength.h create mode 100644 dom/bindings/test/TestInterfaceMaplike.cpp create mode 100644 dom/bindings/test/TestInterfaceMaplike.h create mode 100644 dom/bindings/test/TestInterfaceMaplikeJSObject.cpp create mode 100644 dom/bindings/test/TestInterfaceMaplikeJSObject.h create mode 100644 dom/bindings/test/TestInterfaceMaplikeObject.cpp create mode 100644 dom/bindings/test/TestInterfaceMaplikeObject.h create mode 100644 dom/bindings/test/TestInterfaceObservableArray.cpp create mode 100644 dom/bindings/test/TestInterfaceObservableArray.h create mode 100644 dom/bindings/test/TestInterfaceSetlike.cpp create mode 100644 dom/bindings/test/TestInterfaceSetlike.h create mode 100644 dom/bindings/test/TestInterfaceSetlikeNode.cpp create mode 100644 dom/bindings/test/TestInterfaceSetlikeNode.h create mode 100644 dom/bindings/test/TestJSImplGen.webidl create mode 100644 dom/bindings/test/TestJSImplInheritanceGen.webidl create mode 100644 dom/bindings/test/TestTrialInterface.cpp create mode 100644 dom/bindings/test/TestTrialInterface.h create mode 100644 dom/bindings/test/TestTypedef.webidl create mode 100644 dom/bindings/test/WrapperCachedNonISupportsTestInterface.cpp create mode 100644 dom/bindings/test/WrapperCachedNonISupportsTestInterface.h create mode 100644 dom/bindings/test/chrome.ini create mode 100644 dom/bindings/test/file_InstanceOf.html create mode 100644 dom/bindings/test/file_barewordGetsWindow_frame1.html create mode 100644 dom/bindings/test/file_barewordGetsWindow_frame2.html create mode 100644 dom/bindings/test/file_bug1808352_frame.html create mode 100644 dom/bindings/test/file_bug1808352b_frame.html create mode 100644 dom/bindings/test/file_bug775543.html create mode 100644 dom/bindings/test/file_document_location_set_via_xray.html create mode 100644 dom/bindings/test/file_dom_xrays.html create mode 100644 dom/bindings/test/file_proxies_via_xray.html create mode 100644 dom/bindings/test/forOf_iframe.html create mode 100644 dom/bindings/test/mochitest.ini create mode 100644 dom/bindings/test/moz.build create mode 100644 dom/bindings/test/mozITestInterfaceJS.idl create mode 100644 dom/bindings/test/test_ByteString.html create mode 100644 dom/bindings/test/test_InstanceOf.html create mode 100644 dom/bindings/test/test_Object.prototype_props.html create mode 100644 dom/bindings/test/test_async_iterable.html create mode 100644 dom/bindings/test/test_async_stacks.html create mode 100644 dom/bindings/test/test_attributes_on_types.html create mode 100644 dom/bindings/test/test_barewordGetsWindow.html create mode 100644 dom/bindings/test/test_bug1036214.html create mode 100644 dom/bindings/test/test_bug1041646.html create mode 100644 dom/bindings/test/test_bug1123516_maplikesetlike.html create mode 100644 dom/bindings/test/test_bug1123516_maplikesetlikechrome.xhtml create mode 100644 dom/bindings/test/test_bug1123875.html create mode 100644 dom/bindings/test/test_bug1287912.html create mode 100644 dom/bindings/test/test_bug1457051.html create mode 100644 dom/bindings/test/test_bug1808352.html create mode 100644 dom/bindings/test/test_bug1808352b.html create mode 100644 dom/bindings/test/test_bug560072.html create mode 100644 dom/bindings/test/test_bug742191.html create mode 100644 dom/bindings/test/test_bug759621.html create mode 100644 dom/bindings/test/test_bug773326.html create mode 100644 dom/bindings/test/test_bug775543.html create mode 100644 dom/bindings/test/test_bug788369.html create mode 100644 dom/bindings/test/test_bug852846.html create mode 100644 dom/bindings/test/test_bug862092.html create mode 100644 dom/bindings/test/test_callback_across_document_open.html create mode 100644 dom/bindings/test/test_callback_default_thisval.html create mode 100644 dom/bindings/test/test_callback_exceptions.html create mode 100644 dom/bindings/test/test_cloneAndImportNode.html create mode 100644 dom/bindings/test/test_crossOriginWindowSymbolAccess.html create mode 100644 dom/bindings/test/test_defineProperty.html create mode 100644 dom/bindings/test/test_document_location_set_via_xray.html create mode 100644 dom/bindings/test/test_document_location_via_xray_cached.html create mode 100644 dom/bindings/test/test_domProxyArrayLengthGetter.html create mode 100644 dom/bindings/test/test_dom_xrays.html create mode 100644 dom/bindings/test/test_enums.html create mode 100644 dom/bindings/test/test_exceptionSanitization.html create mode 100644 dom/bindings/test/test_exceptionThrowing.html create mode 100644 dom/bindings/test/test_exception_messages.html create mode 100644 dom/bindings/test/test_exception_options_from_jsimplemented.html create mode 100644 dom/bindings/test/test_exceptions_from_jsimplemented.html create mode 100644 dom/bindings/test/test_forOf.html create mode 100644 dom/bindings/test/test_integers.html create mode 100644 dom/bindings/test/test_interfaceLength.html create mode 100644 dom/bindings/test/test_interfaceLength_chrome.html create mode 100644 dom/bindings/test/test_interfaceName.html create mode 100644 dom/bindings/test/test_interfaceToString.html create mode 100644 dom/bindings/test/test_iterable.html create mode 100644 dom/bindings/test/test_jsimplemented_cross_realm_this.html create mode 100644 dom/bindings/test/test_jsimplemented_eventhandler.html create mode 100644 dom/bindings/test/test_jsimplemented_subclassing.html create mode 100644 dom/bindings/test/test_large_arraybuffers.html create mode 100644 dom/bindings/test/test_large_imageData.html create mode 100644 dom/bindings/test/test_lenientThis.html create mode 100644 dom/bindings/test/test_lookupGetter.html create mode 100644 dom/bindings/test/test_namedNoIndexed.html create mode 100644 dom/bindings/test/test_named_getter_enumerability.html create mode 100644 dom/bindings/test/test_observablearray.html create mode 100644 dom/bindings/test/test_observablearray_helper.html create mode 100644 dom/bindings/test/test_observablearray_proxyhandler.html create mode 100644 dom/bindings/test/test_oom_reporting.html create mode 100644 dom/bindings/test/test_prefOnConstructor.html create mode 100644 dom/bindings/test/test_primitive_this.html create mode 100644 dom/bindings/test/test_promise_rejections_from_jsimplemented.html create mode 100644 dom/bindings/test/test_proxies_via_xray.html create mode 100644 dom/bindings/test/test_proxy_accessors.html create mode 100644 dom/bindings/test/test_proxy_expandos.html create mode 100644 dom/bindings/test/test_remoteProxyAsPrototype.html create mode 100644 dom/bindings/test/test_returnUnion.html create mode 100644 dom/bindings/test/test_sequence_detection.html create mode 100644 dom/bindings/test/test_sequence_wrapping.html create mode 100644 dom/bindings/test/test_setWithNamedGetterNoNamedSetter.html create mode 100644 dom/bindings/test/test_stringBindings.html create mode 100644 dom/bindings/test/test_throwing_method_noDCE.html create mode 100644 dom/bindings/test/test_toJSON.html create mode 100644 dom/bindings/test/test_traceProtos.html create mode 100644 dom/bindings/test/test_treat_non_object_as_null.html create mode 100644 dom/bindings/test/test_unforgeablesonexpando.html create mode 100644 dom/bindings/test/test_usvstring.html create mode 100644 dom/bindings/test/test_worker_UnwrapArg.html (limited to 'dom/bindings') diff --git a/dom/bindings/AtomList.h b/dom/bindings/AtomList.h new file mode 100644 index 0000000000..844e481fc4 --- /dev/null +++ b/dom/bindings/AtomList.h @@ -0,0 +1,25 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_AtomList_h +#define mozilla_dom_AtomList_h + +#include "jsapi.h" +#include "js/Context.h" +#include "mozilla/dom/GeneratedAtomList.h" + +namespace mozilla::dom { + +template +T* GetAtomCache(JSContext* aCx) { + auto atomCache = static_cast(JS_GetContextPrivate(aCx)); + + return static_cast(atomCache); +} + +} // namespace mozilla::dom + +#endif // mozilla_dom_AtomList_h diff --git a/dom/bindings/BindingCallContext.h b/dom/bindings/BindingCallContext.h new file mode 100644 index 0000000000..41978eb167 --- /dev/null +++ b/dom/bindings/BindingCallContext.h @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/** + * A struct that encapsulates a JSContex and information about + * which binding method was called. The idea is to automatically annotate + * exceptions thrown via the BindingCallContext with the method name. + */ + +#ifndef mozilla_dom_BindingCallContext_h +#define mozilla_dom_BindingCallContext_h + +#include + +#include "js/TypeDecls.h" +#include "mozilla/Assertions.h" +#include "mozilla/Attributes.h" +#include "mozilla/ErrorResult.h" + +namespace mozilla::dom { + +class MOZ_NON_TEMPORARY_CLASS MOZ_STACK_CLASS BindingCallContext { + public: + // aCx is allowed to be null. If it is, the BindingCallContext should + // generally act like a null JSContext*: test false when tested as a boolean + // and produce nullptr when used as a JSContext*. + // + // aMethodDescription should be something with longer lifetime than this + // BindingCallContext. Most simply, a string literal. nullptr or "" is + // allowed if we want to not have any particular message description. This + // argument corresponds to the "context" string used for DOM error codes that + // support one. See Errors.msg and the documentation for + // ErrorResult::MaybeSetPendingException for details on he context arg. + BindingCallContext(JSContext* aCx, const char* aMethodDescription) + : mCx(aCx), mDescription(aMethodDescription) {} + + ~BindingCallContext() = default; + + // Allow passing a BindingCallContext as a JSContext*, as needed. + operator JSContext*() const { return mCx; } + + // Allow testing a BindingCallContext for falsiness, just like a + // JSContext* could be tested. + explicit operator bool() const { return !!mCx; } + + // Allow throwing an error message, if it has a context. + template + bool ThrowErrorMessage(Ts&&... aMessageArgs) const { + static_assert(ErrorFormatHasContext[errorNumber], + "We plan to add a context; it better be expected!"); + MOZ_ASSERT(mCx); + return dom::ThrowErrorMessage( + mCx, mDescription, std::forward(aMessageArgs)...); + } + + private: + JSContext* const mCx; + const char* const mDescription; +}; + +} // namespace mozilla::dom + +#endif // mozilla_dom_BindingCallContext_h diff --git a/dom/bindings/BindingDeclarations.h b/dom/bindings/BindingDeclarations.h new file mode 100644 index 0000000000..8209f6323d --- /dev/null +++ b/dom/bindings/BindingDeclarations.h @@ -0,0 +1,547 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/** + * A header for declaring various things that binding implementation headers + * might need. The idea is to make binding implementation headers safe to + * include anywhere without running into include hell like we do with + * BindingUtils.h + */ +#ifndef mozilla_dom_BindingDeclarations_h__ +#define mozilla_dom_BindingDeclarations_h__ + +#include "js/RootingAPI.h" +#include "js/TypeDecls.h" + +#include "mozilla/Maybe.h" + +#include "mozilla/dom/DOMString.h" + +#include "nsCOMPtr.h" +#include "nsString.h" +#include "nsTArray.h" + +#include + +#include "js/Value.h" +#include "mozilla/RootedOwningNonNull.h" +#include "mozilla/RootedRefPtr.h" + +class nsIPrincipal; +class nsWrapperCache; + +namespace mozilla { + +class ErrorResult; +class OOMReporter; +class CopyableErrorResult; + +namespace dom { + +class BindingCallContext; + +// Struct that serves as a base class for all dictionaries. Particularly useful +// so we can use std::is_base_of to detect dictionary template arguments. +struct DictionaryBase { + protected: + bool ParseJSON(JSContext* aCx, const nsAString& aJSON, + JS::MutableHandle aVal); + + bool StringifyToJSON(JSContext* aCx, JS::Handle aObj, + nsAString& aJSON) const; + + // Struct used as a way to force a dictionary constructor to not init the + // dictionary (via constructing from a pointer to this class). We're putting + // it here so that all the dictionaries will have access to it, but outside + // code will not. + struct FastDictionaryInitializer {}; + + bool mIsAnyMemberPresent = false; + + private: + // aString is expected to actually be an nsAString*. Should only be + // called from StringifyToJSON. + static bool AppendJSONToString(const char16_t* aJSONData, + uint32_t aDataLength, void* aString); + + public: + bool IsAnyMemberPresent() const { return mIsAnyMemberPresent; } +}; + +template +inline std::enable_if_t::value, void> +ImplCycleCollectionUnlink(T& aDictionary) { + aDictionary.UnlinkForCC(); +} + +template +inline std::enable_if_t::value, void> +ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, + T& aDictionary, const char* aName, + uint32_t aFlags = 0) { + aDictionary.TraverseForCC(aCallback, aFlags); +} + +template +inline std::enable_if_t::value, void> +ImplCycleCollectionUnlink(UniquePtr& aDictionary) { + aDictionary.reset(); +} + +template +inline std::enable_if_t::value, void> +ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, + UniquePtr& aDictionary, const char* aName, + uint32_t aFlags = 0) { + if (aDictionary) { + ImplCycleCollectionTraverse(aCallback, *aDictionary, aName, aFlags); + } +} +// Struct that serves as a base class for all typed arrays and array buffers and +// array buffer views. Particularly useful so we can use std::is_base_of to +// detect typed array/buffer/view template arguments. +struct AllTypedArraysBase {}; + +// Struct that serves as a base class for all owning unions. +// Particularly useful so we can use std::is_base_of to detect owning union +// template arguments. +struct AllOwningUnionBase {}; + +struct EnumEntry { + const char* value; + size_t length; +}; + +enum class CallerType : uint32_t; + +class MOZ_STACK_CLASS GlobalObject { + public: + GlobalObject(JSContext* aCx, JSObject* aObject); + + JSObject* Get() const { return mGlobalJSObject; } + + nsISupports* GetAsSupports() const; + + // The context that this returns is not guaranteed to be in the compartment of + // the object returned from Get(), in fact it's generally in the caller's + // compartment. + JSContext* Context() const { return mCx; } + + bool Failed() const { return !Get(); } + + // It returns the subjectPrincipal if called on the main-thread, otherwise + // a nullptr is returned. + nsIPrincipal* GetSubjectPrincipal() const; + + // Get the caller type. Note that this needs to be called before anyone has + // had a chance to mess with the JSContext. + dom::CallerType CallerType() const; + + protected: + JS::Rooted mGlobalJSObject; + JSContext* mCx; + mutable nsISupports* MOZ_UNSAFE_REF( + "Valid because GlobalObject is a stack " + "class, and mGlobalObject points to the " + "global, so it won't be destroyed as long " + "as GlobalObject lives on the stack") mGlobalObject; +}; + +// Class for representing optional arguments. +template +class Optional_base { + public: + Optional_base() = default; + + Optional_base(Optional_base&&) = default; + Optional_base& operator=(Optional_base&&) = default; + + explicit Optional_base(const T& aValue) { mImpl.emplace(aValue); } + explicit Optional_base(T&& aValue) { mImpl.emplace(std::move(aValue)); } + + bool operator==(const Optional_base& aOther) const { + return mImpl == aOther.mImpl; + } + + bool operator!=(const Optional_base& aOther) const { + return mImpl != aOther.mImpl; + } + + template + explicit Optional_base(const T1& aValue1, const T2& aValue2) { + mImpl.emplace(aValue1, aValue2); + } + + bool WasPassed() const { return mImpl.isSome(); } + + // Return InternalType here so we can work with it usefully. + template + InternalType& Construct(Args&&... aArgs) { + mImpl.emplace(std::forward(aArgs)...); + return *mImpl; + } + + void Reset() { mImpl.reset(); } + + const T& Value() const { return *mImpl; } + + // Return InternalType here so we can work with it usefully. + InternalType& Value() { return *mImpl; } + + // And an explicit way to get the InternalType even if we're const. + const InternalType& InternalValue() const { return *mImpl; } + + // If we ever decide to add conversion operators for optional arrays + // like the ones Nullable has, we'll need to ensure that Maybe<> has + // the boolean before the actual data. + + private: + // Forbid copy-construction and assignment + Optional_base(const Optional_base& other) = delete; + const Optional_base& operator=(const Optional_base& other) = delete; + + protected: + Maybe mImpl; +}; + +template +class Optional : public Optional_base { + public: + MOZ_ALLOW_TEMPORARY Optional() : Optional_base() {} + + explicit Optional(const T& aValue) : Optional_base(aValue) {} + Optional(Optional&&) = default; +}; + +template +class Optional> + : public Optional_base, JS::Rooted> { + public: + MOZ_ALLOW_TEMPORARY Optional() + : Optional_base, JS::Rooted>() {} + + explicit Optional(JSContext* cx) + : Optional_base, JS::Rooted>() { + this->Construct(cx); + } + + Optional(JSContext* cx, const T& aValue) + : Optional_base, JS::Rooted>(cx, aValue) {} + + // Override the const Value() to return the right thing so we're not + // returning references to temporaries. + JS::Handle Value() const { return *this->mImpl; } + + // And we have to override the non-const one too, since we're + // shadowing the one on the superclass. + JS::Rooted& Value() { return *this->mImpl; } +}; + +// A specialization of Optional for JSObject* to make sure that when someone +// calls Construct() on it we will pre-initialized the JSObject* to nullptr so +// it can be traced safely. +template <> +class Optional : public Optional_base { + public: + Optional() = default; + + explicit Optional(JSObject* aValue) + : Optional_base(aValue) {} + + // Don't allow us to have an uninitialized JSObject* + JSObject*& Construct() { + // The Android compiler sucks and thinks we're trying to construct + // a JSObject* from an int if we don't cast here. :( + return Optional_base::Construct( + static_cast(nullptr)); + } + + template + JSObject*& Construct(const T1& t1) { + return Optional_base::Construct(t1); + } +}; + +// A specialization of Optional for JS::Value to make sure no one ever uses it. +template <> +class Optional { + private: + Optional() = delete; + + explicit Optional(const JS::Value& aValue) = delete; +}; + +// A specialization of Optional for NonNull that lets us get a T& from Value() +template +class NonNull; +template +class Optional> : public Optional_base> { + public: + // We want our Value to actually return a non-const reference, even + // if we're const. At least for things that are normally pointer + // types... + T& Value() const { return *this->mImpl->get(); } + + // And we have to override the non-const one too, since we're + // shadowing the one on the superclass. + NonNull& Value() { return *this->mImpl; } +}; + +// A specialization of Optional for OwningNonNull that lets us get a +// T& from Value() +template +class Optional> : public Optional_base> { + public: + // We want our Value to actually return a non-const reference, even + // if we're const. At least for things that are normally pointer + // types... + T& Value() const { return *this->mImpl->get(); } + + // And we have to override the non-const one too, since we're + // shadowing the one on the superclass. + OwningNonNull& Value() { return *this->mImpl; } +}; + +// Specialization for strings. +// XXXbz we can't pull in FakeString here, because it depends on internal +// strings. So we just have to forward-declare it and reimplement its +// ToAStringPtr. + +namespace binding_detail { +template +struct FakeString; +} // namespace binding_detail + +template +class Optional> { + using AString = nsTSubstring; + + public: + Optional() : mStr(nullptr) {} + + bool WasPassed() const { return !!mStr; } + + void operator=(const AString* str) { + MOZ_ASSERT(str); + mStr = str; + } + + // If this code ever goes away, remove the comment pointing to it in the + // FakeString class in BindingUtils.h. + void operator=(const binding_detail::FakeString* str) { + MOZ_ASSERT(str); + mStr = reinterpret_cast*>(str); + } + + const AString& Value() const { + MOZ_ASSERT(WasPassed()); + return *mStr; + } + + private: + // Forbid copy-construction and assignment + Optional(const Optional& other) = delete; + const Optional& operator=(const Optional& other) = delete; + + const AString* mStr; +}; + +template +inline void ImplCycleCollectionUnlink(Optional& aField) { + if (aField.WasPassed()) { + ImplCycleCollectionUnlink(aField.Value()); + } +} + +template +inline void ImplCycleCollectionTraverse( + nsCycleCollectionTraversalCallback& aCallback, Optional& aField, + const char* aName, uint32_t aFlags = 0) { + if (aField.WasPassed()) { + ImplCycleCollectionTraverse(aCallback, aField.Value(), aName, aFlags); + } +} + +template +class NonNull { + public: + NonNull() +#ifdef DEBUG + : inited(false) +#endif + { + } + + // This is no worse than get() in terms of const handling. + operator T&() const { + MOZ_ASSERT(inited); + MOZ_ASSERT(ptr, "NonNull was set to null"); + return *ptr; + } + + operator T*() const { + MOZ_ASSERT(inited); + MOZ_ASSERT(ptr, "NonNull was set to null"); + return ptr; + } + + void operator=(T* t) { + ptr = t; + MOZ_ASSERT(ptr); +#ifdef DEBUG + inited = true; +#endif + } + + template + void operator=(U* t) { + ptr = t->ToAStringPtr(); + MOZ_ASSERT(ptr); +#ifdef DEBUG + inited = true; +#endif + } + + T** Slot() { +#ifdef DEBUG + inited = true; +#endif + return &ptr; + } + + T* Ptr() { + MOZ_ASSERT(inited); + MOZ_ASSERT(ptr, "NonNull was set to null"); + return ptr; + } + + // Make us work with smart-ptr helpers that expect a get() + T* get() const { + MOZ_ASSERT(inited); + MOZ_ASSERT(ptr); + return ptr; + } + + protected: + // ptr is left uninitialized for optimization purposes. + MOZ_INIT_OUTSIDE_CTOR T* ptr; +#ifdef DEBUG + bool inited; +#endif +}; + +// Class for representing sequences in arguments. We use a non-auto array +// because that allows us to use sequences of sequences and the like. This +// needs to be fallible because web content controls the length of the array, +// and can easily try to create very large lengths. +template +class Sequence : public FallibleTArray { + public: + Sequence() : FallibleTArray() {} + MOZ_IMPLICIT Sequence(FallibleTArray&& aArray) + : FallibleTArray(std::move(aArray)) {} + MOZ_IMPLICIT Sequence(nsTArray&& aArray) + : FallibleTArray(std::move(aArray)) {} + + Sequence(Sequence&&) = default; + Sequence& operator=(Sequence&&) = default; + + // XXX(Bug 1631461) Codegen.py must be adapted to allow making Sequence + // uncopyable. + Sequence(const Sequence& aOther) { + if (!this->AppendElements(aOther, fallible)) { + MOZ_CRASH("Out of memory"); + } + } + Sequence& operator=(const Sequence& aOther) { + if (this != &aOther) { + this->Clear(); + if (!this->AppendElements(aOther, fallible)) { + MOZ_CRASH("Out of memory"); + } + } + return *this; + } +}; + +inline nsWrapperCache* GetWrapperCache(nsWrapperCache* cache) { return cache; } + +inline nsWrapperCache* GetWrapperCache(void* p) { return nullptr; } + +// Helper template for smart pointers to resolve ambiguity between +// GetWrappeCache(void*) and GetWrapperCache(const ParentObject&). +template