From b90ad31e15f0419dacbf8df1832e4af5899bbb24 Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Mon, 16 Jan 2023 14:13:29 +0000 Subject: [PATCH] Bug 1809223 [wpt PR 37814] - Do not fire `beforetoggle` asynchronously, a=testonly Automatic update from web-platform-tests Do not fire `beforetoggle` asynchronously Per the discussion at [1], we have decided not to fire async beforetoggle events at all. This means that no event will be fired in this case: ```javascript myPopover.showPopover(); myPopover.remove(); ``` [1] https://github.com/whatwg/html/pull/8221#discussion_r1049368041 Bug: 1307772 Change-Id: Ie6d0f24f1181131fd6e15732020c0575cd3ba865 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4146026 Commit-Queue: Joey Arhar Reviewed-by: Joey Arhar Auto-Submit: Mason Freed Cr-Commit-Position: refs/heads/main@{#1090506} -- wpt-commits: 7c3aacf158efb050bdb81a1dd97ac324eaee799a wpt-pr: 37814 --- .../popovers/popover-events.tentative.html | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/testing/web-platform/tests/html/semantics/popovers/popover-events.tentative.html b/testing/web-platform/tests/html/semantics/popovers/popover-events.tentative.html index 7d63ce74b7f68..c88dc21dfa23f 100644 --- a/testing/web-platform/tests/html/semantics/popovers/popover-events.tentative.html +++ b/testing/web-platform/tests/html/semantics/popovers/popover-events.tentative.html @@ -63,7 +63,7 @@ assert_false(popover.matches(':open')); assert_equals(1,showCount); assert_equals(1,hideCount); - }, `Toggle event (${method}) get properly dispatched for popovers`); + }, `Beforetoggle event (${method}) get properly dispatched for popovers`); } promise_test(async t => { @@ -86,6 +86,24 @@ assert_true(popover.matches(':open')); popover.hidePopover(); assert_false(popover.matches(':open')); - }, 'Toggle event is cancelable for the "opening" transition'); + }, 'Beforetoggle event is cancelable for the "opening" transition'); + + promise_test(async t => { + const popover = document.querySelector('[popover]'); + const controller = new AbortController(); + const signal = controller.signal; + t.add_cleanup(() => {controller.abort();}); + popover.addEventListener('beforetoggle',(e) => { + assert_not_equals(e.newState,"closed",'The "beforetoggle" event was fired for the closing transition'); + }, {signal}); + assert_false(popover.matches(':open')); + popover.showPopover(); + assert_true(popover.matches(':open')); + t.add_cleanup(() => {document.body.appendChild(popover);}); + popover.remove(); + await waitForRender(); // Check for async events also + await waitForRender(); // Check for async events also + assert_false(popover.matches(':open')); + }, 'Beforetoggle event is not fired for element removal'); };