Bug 1640336 - Use descriptive error messages for dialog.showModal() r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D77126
This commit is contained in:
sefeng 2020-05-27 20:35:47 +00:00
parent f3489ed171
commit 7c966cd62c

View File

@ -83,8 +83,13 @@ void HTMLDialogElement::UnbindFromTree(bool aNullParent) {
}
void HTMLDialogElement::ShowModal(ErrorResult& aError) {
if (!IsInComposedDoc() || Open()) {
aError.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
if (!IsInComposedDoc()) {
aError.ThrowInvalidStateError("Dialog element is not connected");
return;
}
if (Open()) {
aError.ThrowInvalidStateError("Dialog element already has an 'open' attribute");
return;
}