mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 02:27:19 +02:00
HTMLScriptElement::execute_script() and SVGScriptElement had spin_until calls waiting for ready_to_run_scripts to become true. The race exists because load_html_document() resolves the session history signal and starts the parser in the same deferred_invoke — so the parser can hit a <script> before update_for_history_step_application() sets the flag. Instead of spinning, defer parser->run() until the document is ready. Document gains a m_deferred_parser_start callback that is invoked when set_ready_to_run_scripts() is called. The callback is cleared before invocation to avoid reentrancy issues (parser->run() can synchronously execute scripts). All three document loading paths (HTML, XML, text) now check ready_to_run_scripts before starting the parser and defer if needed. create_document_for_inline_content() (used for error pages) now calls set_ready_to_run_scripts() before mutating the document, ensuring the invariant holds for all parser paths. The spin_until calls are replaced with VERIFY assertions.
40 KiB
40 KiB