Skip to content

Commit

Permalink
Bug 1809223 [wpt PR 37814] - Do not fire beforetoggle asynchronousl…
Browse files Browse the repository at this point in the history
…y, 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] whatwg/html#8221 (comment)

Bug: 1307772
Change-Id: Ie6d0f24f1181131fd6e15732020c0575cd3ba865
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4146026
Commit-Queue: Joey Arhar <[email protected]>
Reviewed-by: Joey Arhar <[email protected]>
Auto-Submit: Mason Freed <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1090506}

--

wpt-commits: 7c3aacf158efb050bdb81a1dd97ac324eaee799a
wpt-pr: 37814
  • Loading branch information
mfreed7 authored and moz-wptsync-bot committed Jan 18, 2023
1 parent 874ae22 commit b90ad31
Showing 1 changed file with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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');
};
</script>

0 comments on commit b90ad31

Please sign in to comment.