From f88e42793cd43c89995d5f912d83866deeff3b11 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Wed, 31 May 2023 11:43:41 +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 UltraBlame original commit: 39007d3d4f3eee8382115fb59e595de006ceca70 --- 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 bf368ab2819a1..7621e31bb9973 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