Skip to content

Commit

Permalink
Destroy popover close watchers on hidepopover
Browse files Browse the repository at this point in the history
Differential Revision: https://phabricator.services.mozilla.com/D223880

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1921363
gecko-commit: 49ce9d42094458fa66352c121d2f59eca257cda2
gecko-reviewers: smaug
  • Loading branch information
Keith Cirkel authored and moz-wptsync-bot committed Oct 15, 2024
1 parent 6f30ec0 commit fff1849
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
43 changes: 43 additions & 0 deletions close-watcher/user-activation/y-dialog-disconnected.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<link rel=author href="mailto:[email protected]">
<link rel=author href="mailto:[email protected]">
<link rel=help href="https://github.com/whatwg/html/pull/9462">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="../resources/helpers.js"></script>

<button id=b0>b0</button>

<dialog id=d1>
<button id=b1>b1</button>

<dialog id=d2>d2</dialog>
</dialog>

<script>
promise_test(async () => {
const d1 = document.getElementById('d1');
const d2 = document.getElementById('d2');
await test_driver.click(b0);
d1.showModal();
await test_driver.click(b1);
d2.showModal();

assert_true(d1.matches(':modal'), 'd1 should be open.');
assert_true(d2.matches(':modal'), 'd2 should be open.');

d2.remove()

assert_false(d2.matches(':modal'), 'd2 should now be closed.');
await sendCloseRequest();
assert_false(d2.matches(':modal'), 'd2 still now be closed.');
assert_false(d1.matches(':modal'), 'd1 should now be closed.');

await sendCloseRequest();
assert_false(d2.matches(':modal'), 'd2 still now be closed.');
assert_false(d1.matches(':modal'), 'd1 still now be closed.');
}, 'Disconnect dialog with close request');
</script>
43 changes: 43 additions & 0 deletions close-watcher/user-activation/y-popover-disconnected.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<link rel=author href="mailto:[email protected]">
<link rel=author href="mailto:[email protected]">
<link rel=help href="https://github.com/whatwg/html/pull/9462">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="../resources/helpers.js"></script>

<button id=b0>b0</button>

<div id=p1 popover=auto>
<button id=b1>b1</button>

<div id=p2 popover=auto>p2</div>
</div>

<script>
promise_test(async () => {
const p1 = document.getElementById('p1');
const p2 = document.getElementById('p2');
await test_driver.click(b0);
p1.showPopover();
await test_driver.click(b1);
p2.showPopover();

assert_true(p1.matches(':popover-open'), 'p1 should be open.');
assert_true(p2.matches(':popover-open'), 'p2 should be open.');

p2.remove()

assert_false(p2.matches(':popover-open'), 'p2 should now be closed.');
await sendCloseRequest();
assert_false(p2.matches(':popover-open'), 'p2 still now be closed.');
assert_false(p1.matches(':popover-open'), 'p1 should now be closed.');

await sendCloseRequest();
assert_false(p2.matches(':popover-open'), 'p2 still now be closed.');
assert_false(p1.matches(':popover-open'), 'p1 still now be closed.');
}, 'Disconnect popover with close request');
</script>

0 comments on commit fff1849

Please sign in to comment.