From b06dacfcae57f7eb2e7a74204ef53005a2755535 Mon Sep 17 00:00:00 2001 From: Ziran Sun Date: Thu, 25 May 2023 08:35:29 +0000 Subject: [PATCH] Bug 1834519 - Don't throw when popovers/dialogs are in requested state. r=emilio Update to be in line with spec discussions at https://github.com/whatwg/html/pull/9142 Differential Revision: https://phabricator.services.mozilla.com/D178782 --- dom/html/HTMLDialogElement.cpp | 19 +++++++++++++------ .../dialog-no-throw-requested-state.html.ini | 3 --- 2 files changed, 13 insertions(+), 9 deletions(-) delete mode 100644 testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/dialog-no-throw-requested-state.html.ini diff --git a/dom/html/HTMLDialogElement.cpp b/dom/html/HTMLDialogElement.cpp index 5af7d6cf75387..c80d4e6298010 100644 --- a/dom/html/HTMLDialogElement.cpp +++ b/dom/html/HTMLDialogElement.cpp @@ -71,7 +71,11 @@ void HTMLDialogElement::Close( void HTMLDialogElement::Show(ErrorResult& aError) { if (Open()) { - return; + if (!IsInTopLayer()) { + return; + } + return aError.ThrowInvalidStateError( + "Cannot call show() on an open modal dialog."); } if (IsPopoverOpen()) { @@ -121,13 +125,16 @@ void HTMLDialogElement::UnbindFromTree(bool aNullParent) { } void HTMLDialogElement::ShowModal(ErrorResult& aError) { - if (!IsInComposedDoc()) { - return aError.ThrowInvalidStateError("Dialog element is not connected"); - } - if (Open()) { + if (IsInTopLayer()) { + return; + } return aError.ThrowInvalidStateError( - "Dialog element already has an 'open' attribute"); + "Cannot call showModal() on an open non-modal dialog."); + } + + if (!IsInComposedDoc()) { + return aError.ThrowInvalidStateError("Dialog element is not connected"); } if (IsPopoverOpen()) { diff --git a/testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/dialog-no-throw-requested-state.html.ini b/testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/dialog-no-throw-requested-state.html.ini deleted file mode 100644 index d1af0a488be0f..0000000000000 --- a/testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/dialog-no-throw-requested-state.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[dialog-no-throw-requested-state.html] - [dialog-no-throw-requested-state] - expected: FAIL