Skip to content

Commit

Permalink
Bug 1828556 [wpt PR 39589] - Reset the popover invoker in `showPopove…
Browse files Browse the repository at this point in the history
…r()`, a=testonly

Automatic update from web-platform-tests
Reset the popover invoker in `showPopover()`

As was pointed out in [1], if we don't reset invoker, it is possible
to get into a state where a closed popover still has an invoker. The
new test case in this CL shows that problem.

[1] whatwg/html#9152

Bug: 1307772
Change-Id: I1511ec8f0e9e0193f0c8b5ce834d20de9d8b46e9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4435697
Reviewed-by: Joey Arhar <jarhar@chromium.org>
Commit-Queue: Tommy Steimel <steimel@chromium.org>
Code-Coverage: Findit <findit-for-me@appspot.gserviceaccount.com>
Auto-Submit: Mason Freed <masonf@chromium.org>
Reviewed-by: Tommy Steimel <steimel@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1133290}

--

wpt-commits: cc0704e3a1741d28d2bef73c6e84796b7c928849
wpt-pr: 39589
  • Loading branch information
mfreed7 authored and moz-wptsync-bot committed Apr 22, 2023
1 parent ae7afdd commit 0a8bcf6
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="author" href="mailto:masonf@chromium.org">
<link rel=help href="https://open-ui.org/components/popup.research.explainer">
<link rel=help href="https://github.com/whatwg/html/issues/9152">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="resources/popover-utils.js"></script>

<div id=p1 popover>Popover 1
<button popovertarget=p2>Button</button>
</div>
<div id=p2 popover>Popover 2</div>

<script>
test((t) => {
p1.showPopover();
assert_true(p1.matches(':popover-open'));
const invoker = p1.querySelector('button');
p2.addEventListener('beforetoggle',(e) => {
assert_equals(e.newState,'open');
e.preventDefault();
},{once:true});
invoker.click(); // Will be cancelled
assert_false(p2.matches(':popover-open'));
assert_true(p1.matches(':popover-open'));
p2.showPopover();
assert_true(p2.matches(':popover-open'));
assert_false(p1.matches(':popover-open'),'invoker was not used to show p2, so p1 should close');
},'Invoker gets reset appropriately');
</script>

0 comments on commit 0a8bcf6

Please sign in to comment.