mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 23:09:08 +00:00
LibWeb: Wait until new document becomes active before running scripts
Fixes https://github.com/SerenityOS/serenity/issues/22485 With this change WebContent does not crash when `location.reload()` is invoked but `Navigable::reload()` still not working because of spec issue (https://github.com/whatwg/html/issues/9869) so we can't add a test yet.
This commit is contained in:
parent
7e8d3e370f
commit
07928129dd
Notes:
sideshowbarker
2024-07-17 06:54:15 +09:00
Author: https://github.com/kalenikaliaksandr
Commit: 07928129dd
Pull-request: https://github.com/SerenityOS/serenity/pull/22503
Issue: https://github.com/SerenityOS/serenity/issues/22485
3 changed files with 13 additions and 1 deletions
|
@ -2729,6 +2729,12 @@ void HTMLParser::handle_text(HTMLToken& token)
|
|||
|
||||
// -> An end tag whose tag name is "script"
|
||||
if (token.is_end_tag() && token.tag_name() == HTML::TagNames::script) {
|
||||
// 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()) {
|
||||
main_thread_event_loop().spin_until([&] { return m_document->ready_to_run_scripts(); });
|
||||
}
|
||||
|
||||
// FIXME: If the active speculative HTML parser is null and the JavaScript execution context stack is empty, then perform a microtask checkpoint.
|
||||
|
||||
// Non-standard: Make sure the <script> element has up-to-date text content before preparing the script.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue