mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 03:07:43 +00:00
LibWeb: Wait until new document is active before running SVG scripts
This is the same fix as 07928129dd
also applied to the SVG script element case. Fixes a crash for the
following HTML:
```html
<svg>
<script>
location.reload();
</script>
</svg>
```
As with the linked commit:
> With this change WebContent does not crash when `location.reload()` is
> invoked but `Navigable::reload()` still not working because of spec
> issue (whatwg/html#9869) so we can't add a
> test yet.
This commit is contained in:
parent
4135c3885c
commit
9d4278ad9a
1 changed files with 7 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2023, Shannon Booth <shannon@serenityos.org>
|
* Copyright (c) 2023-2024, Shannon Booth <shannon@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -55,6 +55,12 @@ void SVGScriptElement::process_the_script_element()
|
||||||
// 4. If the script content is inline, or if it is external and was fetched successfully, then the
|
// 4. If the script content is inline, or if it is external and was fetched successfully, then the
|
||||||
// script is executed. Note that at this point, these steps may be re-entrant if the execution
|
// script is executed. Note that at this point, these steps may be re-entrant if the execution
|
||||||
// of the script results in further 'script' elements being inserted into the document.
|
// of the script results in further 'script' elements being inserted into the document.
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/document-lifecycle.html#read-html
|
||||||
|
// Before any script execution occurs, the user agent must wait for scripts may run for the newly-created document to be true for document.
|
||||||
|
if (!m_document->ready_to_run_scripts())
|
||||||
|
HTML::main_thread_event_loop().spin_until([&] { return m_document->ready_to_run_scripts(); });
|
||||||
|
|
||||||
// FIXME: Support non-inline scripts.
|
// FIXME: Support non-inline scripts.
|
||||||
auto& settings_object = document().relevant_settings_object();
|
auto& settings_object = document().relevant_settings_object();
|
||||||
auto base_url = document().base_url();
|
auto base_url = document().base_url();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue