Skip to content

Commit

Permalink
[popover] Handle showPopover changing popover attribute during before…
Browse files Browse the repository at this point in the history
…toggle

https://bugs.webkit.org/show_bug.cgi?id=254268

Reviewed by Tim Nguyen.

Handle showPopover changing popover attribute during beforetoggle by throwing an exception:
whatwg/html#9058

* LayoutTests/imported/w3c/web-platform-tests/html/semantics/popovers/popover-attribute-basic-expected.txt:
* LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/popovers/popover-attribute-basic-expected.txt:
* Source/WebCore/html/HTMLElement.cpp:
(WebCore::HTMLElement::showPopover):

Canonical link: https://commits.webkit.org/262026@main
  • Loading branch information
rwlbuis authored and nt1m committed Mar 23, 2023
1 parent c655abc commit 8cbe612
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ PASS Removing a visible popover=auto element from the document should close the
PASS A showing popover=auto does not match :modal
PASS Removing a visible popover=manual element from the document should close the popover
PASS A showing popover=manual does not match :modal
FAIL Changing the popover type in a "beforetoggle" event handler should throw an exception (during showPopover()) assert_throws_dom: function "() => popover.showPopover()" did not throw
PASS Changing the popover type in a "beforetoggle" event handler should throw an exception (during showPopover())
PASS Changing the popover type in a "beforetoggle" event handler should throw an exception (during hidePopover())
PASS Changing a popover from auto to auto (via attr), and then auto during 'beforetoggle' works
PASS Changing a popover from auto to auto (via attr), and then manual during 'beforetoggle' works
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ PASS Removing a visible popover=auto element from the document should close the
PASS A showing popover=auto does not match :modal
PASS Removing a visible popover=manual element from the document should close the popover
PASS A showing popover=manual does not match :modal
FAIL Changing the popover type in a "beforetoggle" event handler should throw an exception (during showPopover()) assert_throws_dom: function "() => popover.showPopover()" did not throw
PASS Changing the popover type in a "beforetoggle" event handler should throw an exception (during showPopover())
PASS Changing the popover type in a "beforetoggle" event handler should throw an exception (during hidePopover())
PASS Changing a popover from auto to auto (via attr), and then auto during 'beforetoggle' works
PASS Changing a popover from auto to auto (via attr), and then manual during 'beforetoggle' works
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/html/HTMLElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,7 @@ ExceptionOr<void> HTMLElement::showPopover()
document().hideAllPopoversUntil(ancestor.get(), FocusPreviousElement::No, FireEvents::Yes);

if (popoverState() != originalState)
return { };
return Exception { InvalidStateError, "The value of the popover attribute was changed while hiding the popover."_s };

if (auto check = checkPopoverValidity(*this, PopoverVisibilityState::Hidden); check.hasException())
return check.releaseException();
Expand Down

0 comments on commit 8cbe612

Please sign in to comment.