mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
LibWeb: Fix dialog.requestClose() crash
The spec previously asserted that close watcher was not null. This could lead to a crash in some situations, so instead we skip to close the dialog.
This commit is contained in:
parent
6147557999
commit
62f4cebbee
Notes:
github-actions[bot]
2025-02-04 11:23:18 +00:00
Author: https://github.com/lukewarlow Commit: https://github.com/LadybirdBrowser/ladybird/commit/62f4cebbee3 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3433
2 changed files with 16 additions and 2 deletions
|
@ -242,8 +242,11 @@ void HTMLDialogElement::request_close(Optional<String> return_value)
|
|||
// 1. If this does not have an open attribute, then return.
|
||||
if (!has_attribute(AttributeNames::open))
|
||||
return;
|
||||
// 2. Assert: this's close watcher is not null.
|
||||
VERIFY(m_close_watcher);
|
||||
// ADHOC: 2. If this's close watcher is null, then close the dialog this with returnValue, and return. See https://github.com/whatwg/html/pull/10983
|
||||
if (!m_close_watcher) {
|
||||
close_the_dialog(move(return_value));
|
||||
return;
|
||||
}
|
||||
// 3. Set dialog's enable close watcher for requestClose() to true.
|
||||
// ADHOC: Implemented slightly differently to the spec, as the spec is unnecessarily complex.
|
||||
m_close_watcher->set_enabled(true);
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
|
||||
<!-- This test passes if it does not crash. -->
|
||||
|
||||
<dialog id="dialog" open>Dialog</dialog>
|
||||
|
||||
<script>
|
||||
window.onload = () => {
|
||||
dialog.requestClose();
|
||||
}
|
||||
</script>
|
Loading…
Add table
Reference in a new issue