From e85fc6b467e79f7679ec8751d411889bf37bac76 Mon Sep 17 00:00:00 2001 From: Fedor Date: Sat, 1 Jun 2024 19:21:49 +0300 Subject: [PATCH] 68.14.2 - dom --- dom/animation/KeyframeUtils.cpp | 6 +- dom/base/AnonymousContent.cpp | 1 + dom/base/AnonymousContent.h | 15 +- dom/base/BodyConsumer.cpp | 3 + dom/base/BorrowedAttrInfo.cpp | 6 +- dom/base/CustomElementRegistry.cpp | 41 +- dom/base/CustomElementRegistry.h | 22 +- dom/base/DOMMatrix.cpp | 20 +- dom/base/DOMMatrix.h | 19 +- dom/base/Document.cpp | 119 ++-- dom/base/Document.h | 22 +- dom/base/Element.cpp | 3 +- dom/base/Element.h | 16 +- dom/base/EventSource.cpp | 1 - dom/base/IdentifierMapEntry.h | 11 +- dom/base/ImageEncoder.cpp | 7 +- dom/base/Link.cpp | 30 +- .../{nsStyleLinkElement.cpp => LinkStyle.cpp} | 150 ++--- dom/base/LinkStyle.h | 285 +++++++++ dom/base/ResizeObserver.cpp | 94 ++- dom/base/ResizeObserver.h | 31 +- dom/base/ResizeObserverController.cpp | 7 - dom/base/ResizeObserverController.h | 4 - dom/base/ResponsiveImageSelector.h | 1 - dom/base/ShadowRoot.cpp | 1 - dom/base/StructuredCloneHolder.h | 5 +- dom/base/ThirdPartyUtil.cpp | 4 +- dom/base/TimeoutManager.cpp | 2 +- dom/base/moz.build | 5 +- dom/base/nsAttrValue.cpp | 2 +- dom/base/nsContentPolicy.cpp | 4 +- dom/base/nsContentPolicyUtils.h | 59 +- dom/base/nsContentSink.cpp | 167 +++--- dom/base/nsContentSink.h | 32 +- dom/base/nsContentUtils.cpp | 92 +-- dom/base/nsContentUtils.h | 9 +- dom/base/nsDOMDataChannel.cpp | 33 +- dom/base/nsDOMMutationObserver.h | 29 +- dom/base/nsDocumentEncoder.cpp | 3 + dom/base/nsFrameMessageManager.cpp | 16 +- dom/base/nsFrameMessageManager.h | 4 +- dom/base/nsGlobalWindowInner.cpp | 7 - dom/base/nsGlobalWindowInner.h | 4 - dom/base/nsGlobalWindowOuter.cpp | 2 +- dom/base/nsGlobalWindowOuter.h | 1 - dom/base/nsIContentPolicy.idl | 24 + dom/base/nsINode.cpp | 6 +- dom/base/nsINode.h | 8 + dom/base/nsIStyleSheetLinkingElement.h | 204 ------- dom/base/nsImageLoadingContent.cpp | 4 +- dom/base/nsNodeInfoManager.cpp | 2 +- dom/base/nsObjectLoadingContent.cpp | 17 + dom/base/nsQueryContentEventResult.cpp | 8 +- dom/base/nsStyleLinkElement.h | 139 ----- dom/base/nsTreeSanitizer.cpp | 11 +- dom/bindings/Bindings.conf | 1 + dom/bindings/Codegen.py | 4 +- dom/bindings/Nullable.h | 8 +- dom/bindings/Record.h | 7 +- dom/bindings/ToJSValue.cpp | 27 + dom/bindings/ToJSValue.h | 34 +- dom/bindings/parser/WebIDL.py | 4 +- dom/cache/DBSchema.cpp | 6 +- dom/chrome-webidl/ChannelWrapper.webidl | 5 +- dom/events/Clipboard.cpp | 2 + dom/fetch/Fetch.h | 2 - dom/fetch/FetchDriver.cpp | 165 +++++- dom/fetch/FetchDriver.h | 20 +- dom/fetch/FetchUtil.cpp | 1 + dom/fetch/InternalRequest.cpp | 7 + dom/fetch/InternalRequest.h | 6 +- dom/fetch/Request.cpp | 40 +- dom/fetch/Request.h | 6 + dom/fetch/tests/crashtests/1664514.html | 6 + dom/fetch/tests/crashtests/crashtests.list | 3 +- dom/fetch/tests/crashtests/url.url | 5 + dom/file/ipc/FileCreatorParent.cpp | 7 +- dom/file/uri/BlobURLProtocolHandler.cpp | 10 +- dom/filehandle/ActorsParent.cpp | 26 +- dom/filehandle/ActorsParent.h | 4 +- dom/filesystem/Directory.cpp | 8 +- dom/filesystem/FileSystemBase.cpp | 9 +- dom/flex/Flex.h | 2 +- dom/html/HTMLDialogElement.cpp | 100 ++++ dom/html/HTMLDialogElement.h | 3 + dom/html/HTMLFormElement.cpp | 3 +- dom/html/HTMLFormSubmission.cpp | 1 + dom/html/HTMLImageElement.cpp | 18 +- dom/html/HTMLImageElement.h | 10 + dom/html/HTMLInputElement.cpp | 1 + dom/html/HTMLLegendElement.cpp | 1 + dom/html/HTMLLinkElement.cpp | 126 ++-- dom/html/HTMLLinkElement.h | 31 +- dom/html/HTMLMediaElement.cpp | 7 +- dom/html/HTMLMenuElement.cpp | 7 +- dom/html/HTMLStyleElement.cpp | 7 +- dom/html/HTMLStyleElement.h | 6 +- dom/html/HTMLTrackElement.cpp | 144 +++-- dom/html/HTMLTrackElement.h | 14 +- dom/html/TextTrackManager.cpp | 4 +- dom/html/moz.build | 1 + dom/html/nsHTMLContentSink.cpp | 2 - dom/html/test/dialog/mochitest.ini | 7 + .../dialog/test_cancelDialogByEscape.html | 63 ++ .../dialog/test_dialog_cancel_events.html | 56 ++ .../test_dialog_cancel_preventDefault.html | 56 ++ .../test_dialog_keydown_preventDefault.html | 56 ++ dom/html/test/file_cookiemanager.js | 2 +- dom/ipc/ContentParent.cpp | 2 + dom/ipc/WindowGlobalChild.cpp | 1 + .../en-US/chrome/security/csp.properties | 19 - dom/localstorage/ActorsParent.cpp | 4 +- dom/localstorage/LSSnapshot.cpp | 16 +- dom/manifest/test/mochitest.ini | 3 +- .../test_link_relList_supports_manifest.html | 47 ++ dom/media/TextTrack.cpp | 35 +- dom/media/TextTrack.h | 2 + dom/media/WebVTTListener.cpp | 61 +- dom/media/WebVTTListener.h | 9 + dom/media/gmp/GMPServiceParent.cpp | 2 +- dom/media/test/test_bug883173.html | 70 +-- dom/media/test/test_bug895091.html | 80 +-- dom/media/test/test_texttrack.html | 256 ++++---- dom/media/test/test_texttrack_moz.html | 104 ++-- dom/media/test/test_texttrackcue.html | 519 +++++++++-------- dom/media/test/test_texttrackregion.html | 89 ++- dom/media/test/test_trackelementevent.html | 108 ++-- dom/media/webaudio/AudioWorkletImpl.h | 4 + dom/media/webaudio/WebAudioUtils.cpp | 1 + dom/media/webvtt/WebVTTParserWrapper.jsm | 6 + dom/media/webvtt/nsIWebVTTParserWrapper.idl | 5 + dom/midi/MIDIUtils.cpp | 9 +- dom/network/TCPServerSocket.cpp | 1 + dom/notification/Notification.cpp | 6 +- dom/performance/PerformanceTiming.cpp | 2 +- .../base/nsPluginDirServiceProvider.cpp | 306 +++++++++- dom/plugins/base/nsPluginDirServiceProvider.h | 6 + dom/plugins/base/nsPluginHost.cpp | 81 ++- .../base/nsPluginStreamListenerPeer.cpp | 2 - .../PresentationDeviceManager.cpp | 1 + dom/presentation/PresentationRequest.cpp | 17 +- dom/presentation/PresentationSessionInfo.cpp | 21 +- .../PrototypeDocumentContentSink.cpp | 33 +- dom/prototype/PrototypeDocumentContentSink.h | 3 +- dom/push/PushManager.cpp | 1 + dom/push/test/xpcshell/head-http2.js | 12 - dom/quota/ActorsParent.cpp | 27 +- dom/script/ScriptKind.h | 16 + dom/script/ScriptLoadHandler.cpp | 18 +- dom/script/ScriptLoadHandler.h | 3 + dom/script/ScriptLoadRequest.cpp | 27 +- dom/script/ScriptLoadRequest.h | 24 +- dom/script/ScriptLoader.cpp | 53 +- dom/script/ScriptLoader.h | 2 + dom/script/moz.build | 1 + dom/security/CSPEvalChecker.cpp | 4 +- dom/security/nsCSPParser.cpp | 9 +- dom/security/nsCSPService.cpp | 2 +- dom/security/nsCSPUtils.cpp | 22 + dom/security/nsContentSecurityManager.cpp | 24 +- dom/security/nsMixedContentBlocker.cpp | 19 +- dom/security/test/csp/file_bug1505412.sjs | 36 ++ .../test/csp/file_bug1505412_frame.html | 14 + .../csp/file_bug1505412_frame.html^headers^ | 1 + .../test/csp/file_bug1505412_reporter.sjs | 18 + .../test/csp/file_link_rel_preload.html | 17 + .../test/csp/file_object_inherit.html | 21 + dom/security/test/csp/mochitest.ini | 12 + dom/security/test/csp/test_bug1505412.html | 50 ++ .../test/csp/test_link_rel_preload.html | 77 +++ .../test/csp/test_object_inherit.html | 30 + dom/smil/SMILAnimationFunction.cpp | 2 +- dom/smil/SMILCSSProperty.cpp | 4 +- dom/svg/SVGAnimatedNumberList.cpp | 2 +- dom/svg/SVGAnimatedPointList.cpp | 2 +- dom/svg/SVGElement.cpp | 1 + dom/svg/SVGStyleElement.cpp | 7 +- dom/svg/SVGStyleElement.h | 10 +- .../ajax/offline/browser_disableAppcache.js | 121 ---- dom/webbrowserpersist/nsWebBrowserPersist.cpp | 7 +- dom/webidl/CustomElementRegistry.webidl | 2 +- dom/webidl/ElementInternals.webidl | 3 +- dom/webidl/HTMLElement.webidl | 2 +- dom/webidl/HTMLImageElement.webidl | 2 + dom/webidl/HTMLLinkElement.webidl | 4 + dom/webidl/OfflineResourceList.webidl | 2 +- dom/webidl/ResizeObserver.webidl | 8 +- dom/webidl/Window.webidl | 2 +- dom/websocket/WebSocket.cpp | 6 +- dom/workers/RuntimeService.cpp | 33 +- dom/workers/ScriptLoader.cpp | 1 + dom/workers/WorkerLoadInfo.cpp | 15 +- dom/workers/WorkerLoadInfo.h | 7 +- dom/workers/WorkerPrivate.cpp | 51 +- dom/workers/WorkerPrivate.h | 5 +- .../remoteworkers/RemoteWorkerChild.cpp | 9 +- dom/worklet/Worklet.cpp | 33 +- dom/worklet/Worklet.h | 3 +- dom/worklet/WorkletImpl.h | 2 + dom/xhr/XMLHttpRequestMainThread.cpp | 130 ++++- dom/xhr/XMLHttpRequestMainThread.h | 17 +- dom/xml/CDATASection.cpp | 2 +- dom/xml/ProcessingInstruction.cpp | 22 +- dom/xml/ProcessingInstruction.h | 21 +- dom/xml/XMLDocument.cpp | 1 + .../XMLStylesheetProcessingInstruction.cpp | 17 +- dom/xml/XMLStylesheetProcessingInstruction.h | 23 +- dom/xml/nsXMLContentSink.cpp | 41 +- dom/xml/nsXMLContentSink.h | 4 +- dom/xml/nsXMLElement.h | 2 +- dom/xml/nsXMLFragmentContentSink.cpp | 10 +- dom/xslt/base/txExpandedNameMap.h | 4 +- dom/xslt/base/txList.cpp | 37 +- dom/xslt/base/txList.h | 10 +- dom/xslt/crashtests/1589930.xml | 10 + dom/xslt/crashtests/crashtests.list | 1 + dom/xslt/xpath/XPathEvaluator.cpp | 32 +- dom/xslt/xpath/XPathEvaluator.h | 1 - dom/xslt/xpath/XPathExpression.cpp | 20 +- dom/xslt/xpath/XPathExpression.h | 9 +- dom/xslt/xpath/XPathResult.cpp | 2 +- dom/xslt/xpath/XPathResult.h | 1 - dom/xslt/xpath/txCoreFunctionCall.cpp | 1 - dom/xslt/xpath/txExpr.h | 46 +- dom/xslt/xpath/txExprParser.cpp | 198 ++++--- dom/xslt/xpath/txExprParser.h | 6 +- dom/xslt/xpath/txExprResult.h | 1 - dom/xslt/xpath/txFilterExpr.cpp | 9 +- dom/xslt/xpath/txForwardContext.h | 1 - dom/xslt/xpath/txNodeSetContext.h | 1 - dom/xslt/xpath/txPathExpr.cpp | 13 +- dom/xslt/xpath/txResultRecycler.h | 1 - dom/xslt/xpath/txXPathNode.h | 1 - dom/xslt/xpath/txXPathOptimizer.cpp | 7 +- dom/xslt/xslt/txBufferingHandler.cpp | 4 +- dom/xslt/xslt/txBufferingHandler.h | 4 +- dom/xslt/xslt/txEXSLTFunctions.cpp | 9 +- dom/xslt/xslt/txExecutionState.cpp | 29 +- dom/xslt/xslt/txExecutionState.h | 8 +- dom/xslt/xslt/txFormatNumberFunctionCall.cpp | 23 +- dom/xslt/xslt/txInstructions.cpp | 86 +-- dom/xslt/xslt/txInstructions.h | 94 +-- dom/xslt/xslt/txKey.h | 7 +- dom/xslt/xslt/txKeyFunctionCall.cpp | 15 +- dom/xslt/xslt/txMozillaStylesheetCompiler.cpp | 13 +- dom/xslt/xslt/txMozillaXMLOutput.cpp | 31 +- dom/xslt/xslt/txMozillaXMLOutput.h | 1 - dom/xslt/xslt/txMozillaXSLTProcessor.cpp | 30 +- dom/xslt/xslt/txMozillaXSLTProcessor.h | 3 +- dom/xslt/xslt/txNodeSorter.cpp | 8 +- dom/xslt/xslt/txPatternParser.cpp | 14 +- dom/xslt/xslt/txRtfHandler.cpp | 6 +- dom/xslt/xslt/txRtfHandler.h | 10 +- dom/xslt/xslt/txStylesheet.cpp | 137 ++--- dom/xslt/xslt/txStylesheet.h | 26 +- dom/xslt/xslt/txStylesheetCompileHandlers.cpp | 549 ++++++++---------- dom/xslt/xslt/txStylesheetCompiler.cpp | 74 ++- dom/xslt/xslt/txStylesheetCompiler.h | 12 +- dom/xslt/xslt/txToplevelItems.cpp | 11 +- dom/xslt/xslt/txToplevelItems.h | 15 +- dom/xslt/xslt/txUnknownHandler.cpp | 18 +- dom/xslt/xslt/txXPathResultComparator.cpp | 75 ++- dom/xslt/xslt/txXPathResultComparator.h | 11 +- dom/xslt/xslt/txXSLTFunctions.h | 2 +- dom/xslt/xslt/txXSLTNumber.cpp | 26 +- dom/xslt/xslt/txXSLTPatterns.cpp | 12 +- dom/xslt/xslt/txXSLTPatterns.h | 10 +- dom/xul/XULDocument.cpp | 1 - 268 files changed, 4743 insertions(+), 3119 deletions(-) rename dom/base/{nsStyleLinkElement.cpp => LinkStyle.cpp} (66%) create mode 100644 dom/base/LinkStyle.h delete mode 100644 dom/base/nsIStyleSheetLinkingElement.h delete mode 100644 dom/base/nsStyleLinkElement.h create mode 100644 dom/fetch/tests/crashtests/1664514.html create mode 100644 dom/fetch/tests/crashtests/url.url create mode 100644 dom/html/test/dialog/mochitest.ini create mode 100644 dom/html/test/dialog/test_cancelDialogByEscape.html create mode 100644 dom/html/test/dialog/test_dialog_cancel_events.html create mode 100644 dom/html/test/dialog/test_dialog_cancel_preventDefault.html create mode 100644 dom/html/test/dialog/test_dialog_keydown_preventDefault.html create mode 100644 dom/manifest/test/test_link_relList_supports_manifest.html create mode 100644 dom/script/ScriptKind.h create mode 100644 dom/security/test/csp/file_bug1505412.sjs create mode 100644 dom/security/test/csp/file_bug1505412_frame.html create mode 100644 dom/security/test/csp/file_bug1505412_frame.html^headers^ create mode 100644 dom/security/test/csp/file_bug1505412_reporter.sjs create mode 100644 dom/security/test/csp/file_link_rel_preload.html create mode 100644 dom/security/test/csp/file_object_inherit.html create mode 100644 dom/security/test/csp/test_bug1505412.html create mode 100644 dom/security/test/csp/test_link_rel_preload.html create mode 100644 dom/security/test/csp/test_object_inherit.html create mode 100644 dom/xslt/crashtests/1589930.xml diff --git a/dom/animation/KeyframeUtils.cpp b/dom/animation/KeyframeUtils.cpp index 2fa823c171..4df501adb6 100644 --- a/dom/animation/KeyframeUtils.cpp +++ b/dom/animation/KeyframeUtils.cpp @@ -10,13 +10,13 @@ #include "jsapi.h" // For most JSAPI #include "mozilla/ComputedStyle.h" #include "mozilla/ErrorResult.h" -#include "mozilla/Move.h" +#include #include "mozilla/RangedArray.h" -#include "mozilla/ServoBindingTypes.h" #include "mozilla/ServoBindings.h" +#include "mozilla/ServoBindingTypes.h" #include "mozilla/ServoCSSParser.h" -#include "mozilla/StaticPrefs_dom.h" #include "mozilla/StyleAnimationValue.h" +#include "mozilla/StaticPrefs_dom.h" #include "mozilla/TimingParams.h" #include "mozilla/dom/BaseKeyframeTypesBinding.h" // For FastBaseKeyframe etc. #include "mozilla/dom/BindingCallContext.h" diff --git a/dom/base/AnonymousContent.cpp b/dom/base/AnonymousContent.cpp index 8d3dad26f7..36f2566f87 100644 --- a/dom/base/AnonymousContent.cpp +++ b/dom/base/AnonymousContent.cpp @@ -6,6 +6,7 @@ #include "mozilla/PresShell.h" #include "mozilla/dom/Document.h" #include "mozilla/dom/Element.h" +#include "mozilla/dom/Event.h" #include "mozilla/dom/AnonymousContentBinding.h" #include "nsComputedDOMStyle.h" #include "nsCycleCollectionParticipant.h" diff --git a/dom/base/AnonymousContent.h b/dom/base/AnonymousContent.h index c1d0bb95d9..db571328b4 100644 --- a/dom/base/AnonymousContent.h +++ b/dom/base/AnonymousContent.h @@ -5,17 +5,24 @@ #ifndef mozilla_dom_AnonymousContent_h #define mozilla_dom_AnonymousContent_h -#include "mozilla/dom/Element.h" -#include "mozilla/dom/Event.h" #include "nsCycleCollectionParticipant.h" -#include "nsICSSDeclaration.h" -#include "mozilla/dom/Document.h" + +class nsIPrincipal; namespace mozilla { +class ErrorResult; + namespace dom { +class Animation; +class DOMRect; +class DOMString; class Element; +class Event; +template +class Sequence; class UnrestrictedDoubleOrAnonymousKeyframeAnimationOptions; +class UnrestrictedDoubleOrKeyframeAnimationOptions; class AnonymousContent final { public: diff --git a/dom/base/BodyConsumer.cpp b/dom/base/BodyConsumer.cpp index 9d6739f08d..ae020242a4 100644 --- a/dom/base/BodyConsumer.cpp +++ b/dom/base/BodyConsumer.cpp @@ -5,6 +5,7 @@ #include "BodyConsumer.h" #include "mozilla/dom/BlobBinding.h" +#include "mozilla/dom/BlobImpl.h" #include "mozilla/dom/BlobURLProtocolHandler.h" #include "mozilla/dom/BodyUtil.h" #include "mozilla/dom/File.h" @@ -19,6 +20,8 @@ #include "mozilla/dom/WorkerRunnable.h" #include "mozilla/dom/WorkerScope.h" #include "mozilla/ipc/PBackgroundSharedTypes.h" +#include "nsComponentManagerUtils.h" +#include "nsIFile.h" #include "nsIThreadRetargetableRequest.h" #include "nsIStreamLoader.h" #include "nsNetUtil.h" diff --git a/dom/base/BorrowedAttrInfo.cpp b/dom/base/BorrowedAttrInfo.cpp index 029ca504f8..a4223d3dff 100644 --- a/dom/base/BorrowedAttrInfo.cpp +++ b/dom/base/BorrowedAttrInfo.cpp @@ -4,8 +4,7 @@ #include "mozilla/dom/BorrowedAttrInfo.h" -namespace mozilla { -namespace dom { +namespace mozilla::dom { BorrowedAttrInfo::BorrowedAttrInfo(const nsAttrName* aName, const nsAttrValue* aValue) @@ -18,5 +17,4 @@ BorrowedAttrInfo::BorrowedAttrInfo(const BorrowedAttrInfo& aOther) MOZ_ASSERT_IF(mName, mValue); } -} // namespace dom -} // namespace mozilla +} // namespace mozilla::dom diff --git a/dom/base/CustomElementRegistry.cpp b/dom/base/CustomElementRegistry.cpp index 33ba81f533..ebb645960a 100644 --- a/dom/base/CustomElementRegistry.cpp +++ b/dom/base/CustomElementRegistry.cpp @@ -7,7 +7,9 @@ #include "mozilla/AsyncEventDispatcher.h" #include "mozilla/CycleCollectedJSContext.h" #include "mozilla/dom/CustomElementRegistryBinding.h" +#include "mozilla/dom/ElementBinding.h" #include "mozilla/dom/HTMLElementBinding.h" +#include "mozilla/dom/PrimitiveConversions.h" #include "mozilla/dom/ShadowIncludingTreeIterator.h" #include "mozilla/dom/XULElementBinding.h" #include "mozilla/dom/Promise.h" @@ -15,6 +17,7 @@ #include "mozilla/dom/DocGroup.h" #include "mozilla/dom/CustomEvent.h" #include "mozilla/dom/ShadowRoot.h" +#include "mozilla/AutoRestore.h" #include "nsHTMLTags.h" #include "jsapi.h" #include "js/ForOfIterator.h" // JS::ForOfIterator @@ -843,13 +846,15 @@ void CustomElementRegistry::Define( auto callbacksHolder = MakeUnique(); nsTArray> observedAttributes; AutoTArray, 2> disabledFeatures; + bool formAssociated = false; bool disableInternals = false; bool disableShadow = false; { // Set mIsCustomDefinitionRunning. /** * 9. Set this CustomElementRegistry's element definition is running flag. */ - AutoSetRunningFlag as(this); + AutoRestore restoreRunning(mIsCustomDefinitionRunning); + mIsCustomDefinitionRunning = true; /** * 14.1. Let prototype be Get(constructor, "prototype"). Rethrow any @@ -918,7 +923,7 @@ void CustomElementRegistry::Define( * disabledFeaturesIterable to a sequence. * Rethrow any exceptions from the conversion. */ - if (StaticPrefs::dom_webcomponents_elementInternals_enabled()) { + if (StaticPrefs::dom_webcomponents_formAssociatedCustomElement_enabled()) { if (!JSObjectToAtomArray(aCx, constructor, NS_LITERAL_STRING("disabledFeatures"), disabledFeatures, aRv)) { @@ -934,6 +939,24 @@ void CustomElementRegistry::Define( // "shadow". disableShadow = disabledFeatures.Contains( static_cast(nsGkAtoms::shadow)); + + // 14.11. Let formAssociatedValue be Get(constructor, "formAssociated"). + // Rethrow any exceptions. + JS::Rooted formAssociatedValue(aCx); + if (!JS_GetProperty(aCx, constructor, "formAssociated", + &formAssociatedValue)) { + aRv.NoteJSContextException(aCx); + return; + } + + // 14.12. Set formAssociated to the result of converting + // formAssociatedValue to a boolean. Rethrow any exceptions from + // the conversion. + if (!ValueToPrimitive( + aCx, formAssociatedValue, "formAssociated", &formAssociated)) { + aRv.NoteJSContextException(aCx); + return; + } } } // Unset mIsCustomDefinitionRunning @@ -956,7 +979,7 @@ void CustomElementRegistry::Define( RefPtr definition = new CustomElementDefinition( nameAtom, localNameAtom, nameSpaceID, &aFunctionConstructor, - std::move(observedAttributes), std::move(callbacksHolder), + std::move(observedAttributes), std::move(callbacksHolder), formAssociated, disableInternals, disableShadow); CustomElementDefinition* def = definition.get(); @@ -981,7 +1004,7 @@ void CustomElementRegistry::Define( RefPtr promise; mWhenDefinedPromiseMap.Remove(nameAtom, getter_AddRefs(promise)); if (promise) { - promise->MaybeResolveWithUndefined(); + promise->MaybeResolve(def->mConstructor); } // Dispatch a "customelementdefined" event for DevTools. @@ -1075,8 +1098,9 @@ already_AddRefed CustomElementRegistry::WhenDefined( return promise.forget(); } - if (mCustomDefinitions.GetWeak(nameAtom)) { - promise->MaybeResolve(JS::UndefinedHandleValue); + if (CustomElementDefinition* definition = + mCustomDefinitions.GetWeak(nameAtom)) { + promise->MaybeResolve(definition->mConstructor); return promise.forget(); } @@ -1459,14 +1483,15 @@ CustomElementDefinition::CustomElementDefinition( nsAtom* aType, nsAtom* aLocalName, int32_t aNamespaceID, CustomElementConstructor* aConstructor, nsTArray>&& aObservedAttributes, - UniquePtr&& aCallbacks, bool aDisableInternals, - bool aDisableShadow) + UniquePtr&& aCallbacks, bool aFormAssociated, + bool aDisableInternals, bool aDisableShadow) : mType(aType), mLocalName(aLocalName), mNamespaceID(aNamespaceID), mConstructor(aConstructor), mObservedAttributes(std::move(aObservedAttributes)), mCallbacks(std::move(aCallbacks)), + mFormAssociated(aFormAssociated), mDisableInternals(aDisableInternals), mDisableShadow(aDisableShadow) {} diff --git a/dom/base/CustomElementRegistry.h b/dom/base/CustomElementRegistry.h index cb946825a9..63ff9ae62f 100644 --- a/dom/base/CustomElementRegistry.h +++ b/dom/base/CustomElementRegistry.h @@ -139,7 +139,8 @@ struct CustomElementDefinition { CustomElementConstructor* aConstructor, nsTArray>&& aObservedAttributes, UniquePtr&& aCallbacks, - bool aDisableInternals, bool aDisableShadow); + bool aFormAssociated, bool aDisableInternals, + bool aDisableShadow); // The type (name) for this custom element, for