mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-29 20:07:30 +09:00
Bug 1406297 - Fix Document.createElement must report an exception.
Tag UXP Issue #1344
This commit is contained in:
parent
f077bd93a4
commit
e925977c0f
2 changed files with 13 additions and 9 deletions
|
|
@ -111,13 +111,11 @@ CustomElementConstructor::Construct(const char* aExecutionReason,
|
||||||
JS::Rooted<JSObject*> result(cx);
|
JS::Rooted<JSObject*> result(cx);
|
||||||
JS::Rooted<JS::Value> constructor(cx, JS::ObjectValue(*mCallback));
|
JS::Rooted<JS::Value> constructor(cx, JS::ObjectValue(*mCallback));
|
||||||
if (!JS::Construct(cx, constructor, JS::HandleValueArray::empty(), &result)) {
|
if (!JS::Construct(cx, constructor, JS::HandleValueArray::empty(), &result)) {
|
||||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<Element> element;
|
RefPtr<Element> element;
|
||||||
if (NS_FAILED(UNWRAP_OBJECT(Element, &result, element))) {
|
if (NS_FAILED(UNWRAP_OBJECT(Element, &result, element))) {
|
||||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -894,7 +892,7 @@ DoUpgrade(Element* aElement,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (constructResult.get() != aElement) {
|
if (!constructResult || constructResult.get() != aElement) {
|
||||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -233,18 +233,23 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
DoCustomElementCreate(Element** aElement, nsIDocument* aDoc,
|
DoCustomElementCreate(Element** aElement, nsIDocument* aDoc, nsIAtom* aLocalName,
|
||||||
CustomElementConstructor* aConstructor, ErrorResult& aRv)
|
CustomElementConstructor* aConstructor, ErrorResult& aRv)
|
||||||
{
|
{
|
||||||
RefPtr<Element> element =
|
RefPtr<Element> element =
|
||||||
aConstructor->Construct("Custom Element Create", aRv);
|
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"));
|
aRv.ThrowTypeError<MSG_THIS_DOES_NOT_IMPLEMENT_INTERFACE>(NS_LITERAL_STRING("HTMLElement"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aDoc != element->OwnerDoc() || element->GetParentNode() ||
|
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);
|
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -320,19 +325,20 @@ NS_NewHTMLElement(Element** aResult, already_AddRefed<mozilla::dom::NodeInfo>&&
|
||||||
(*aResult)->SetCustomElementData(new CustomElementData(typeAtom));
|
(*aResult)->SetCustomElementData(new CustomElementData(typeAtom));
|
||||||
if (synchronousCustomElements) {
|
if (synchronousCustomElements) {
|
||||||
CustomElementRegistry::Upgrade(*aResult, definition, rv);
|
CustomElementRegistry::Upgrade(*aResult, definition, rv);
|
||||||
|
if (rv.MaybeSetPendingException(cx)) {
|
||||||
|
aes.ReportException();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
nsContentUtils::EnqueueUpgradeReaction(*aResult, definition);
|
nsContentUtils::EnqueueUpgradeReaction(*aResult, definition);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rv.MaybeSetPendingException(cx)) {
|
|
||||||
aes.ReportException();
|
|
||||||
}
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 6.1.
|
// Step 6.1.
|
||||||
if (synchronousCustomElements) {
|
if (synchronousCustomElements) {
|
||||||
DoCustomElementCreate(aResult, nodeInfo->GetDocument(),
|
DoCustomElementCreate(aResult, nodeInfo->GetDocument(),
|
||||||
|
nodeInfo->NameAtom(),
|
||||||
definition->mConstructor, rv);
|
definition->mConstructor, rv);
|
||||||
if (rv.MaybeSetPendingException(cx)) {
|
if (rv.MaybeSetPendingException(cx)) {
|
||||||
NS_IF_ADDREF(*aResult = NS_NewHTMLUnknownElement(nodeInfo.forget(), aFromParser));
|
NS_IF_ADDREF(*aResult = NS_NewHTMLUnknownElement(nodeInfo.forget(), aFromParser));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue