Bug 1840342 - Throw exception when popover attribute changes during beforetoggle in showpopover. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D182871
This commit is contained in:
Ziran Sun
2023-07-07 13:30:21 +00:00
parent 03fd4812ae
commit 9fa33c2381
2 changed files with 7 additions and 3 deletions

View File

@@ -3362,12 +3362,19 @@ void nsGenericHTMLElement::ShowPopoverInternal(
bool shouldRestoreFocus = false;
nsWeakPtr originallyFocusedElement;
if (IsAutoPopover()) {
auto originalState = GetPopoverAttributeState();
RefPtr<nsINode> ancestor = GetTopmostPopoverAncestor();
if (!ancestor) {
ancestor = document;
}
document->HideAllPopoversUntil(*ancestor, false,
/* aFireEvents = */ !wasShowingOrHiding);
if (GetPopoverAttributeState() != originalState) {
aRv.ThrowInvalidStateError(
"The value of the popover attribute was changed while hiding the "
"popover.");
return;
}
// TODO: Handle if document changes, see
// https://github.com/whatwg/html/issues/9177