diff options
author | Gaming4JC <g4jc@hyperbola.info> | 2020-01-05 18:38:55 -0500 |
---|---|---|
committer | Gaming4JC <g4jc@hyperbola.info> | 2020-01-26 15:50:31 -0500 |
commit | 4dda3f6039c4432a3545986ebc698a725c6c057c (patch) | |
tree | 491c34302e208c1cf52604949fa85eaf828d8bc6 /dom/html/nsHTMLContentSink.cpp | |
parent | 6ec385fbdb2523fb2876055a054ba1cdf6916784 (diff) | |
download | UXP-4dda3f6039c4432a3545986ebc698a725c6c057c.tar UXP-4dda3f6039c4432a3545986ebc698a725c6c057c.tar.gz UXP-4dda3f6039c4432a3545986ebc698a725c6c057c.tar.lz UXP-4dda3f6039c4432a3545986ebc698a725c6c057c.tar.xz UXP-4dda3f6039c4432a3545986ebc698a725c6c057c.zip |
Bug 1406297 - Fix Document.createElement must report an exception.
Tag UXP Issue #1344
Diffstat (limited to 'dom/html/nsHTMLContentSink.cpp')
-rw-r--r-- | dom/html/nsHTMLContentSink.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/dom/html/nsHTMLContentSink.cpp b/dom/html/nsHTMLContentSink.cpp index ef160cf21..87ae2a4ac 100644 --- a/dom/html/nsHTMLContentSink.cpp +++ b/dom/html/nsHTMLContentSink.cpp @@ -233,18 +233,23 @@ public: }; static void -DoCustomElementCreate(Element** aElement, nsIDocument* aDoc, +DoCustomElementCreate(Element** aElement, nsIDocument* aDoc, nsIAtom* aLocalName, CustomElementConstructor* aConstructor, ErrorResult& aRv) { RefPtr<Element> element = aConstructor->Construct("Custom Element Create", aRv); - if (aRv.Failed() || !element->IsHTMLElement()) { + if (aRv.Failed()) { + return; + } + + if (!element || !element->IsHTMLElement()) { aRv.ThrowTypeError<MSG_THIS_DOES_NOT_IMPLEMENT_INTERFACE>(NS_LITERAL_STRING("HTMLElement")); return; } if (aDoc != element->OwnerDoc() || element->GetParentNode() || - element->HasChildren() || element->GetAttrCount()) { + element->HasChildren() || element->GetAttrCount() || + element->NodeInfo()->NameAtom() != aLocalName) { aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR); return; } @@ -320,19 +325,20 @@ NS_NewHTMLElement(Element** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& (*aResult)->SetCustomElementData(new CustomElementData(typeAtom)); if (synchronousCustomElements) { CustomElementRegistry::Upgrade(*aResult, definition, rv); + if (rv.MaybeSetPendingException(cx)) { + aes.ReportException(); + } } else { nsContentUtils::EnqueueUpgradeReaction(*aResult, definition); } - if (rv.MaybeSetPendingException(cx)) { - aes.ReportException(); - } return NS_OK; } // Step 6.1. if (synchronousCustomElements) { DoCustomElementCreate(aResult, nodeInfo->GetDocument(), + nodeInfo->NameAtom(), definition->mConstructor, rv); if (rv.MaybeSetPendingException(cx)) { NS_IF_ADDREF(*aResult = NS_NewHTMLUnknownElement(nodeInfo.forget(), aFromParser)); |