From 8b2499b11211556cc5998aa4e08501cf580e4c93 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 21 Feb 2022 21:54:21 +0100 Subject: LibWeb: Make document.write() work while document is parsing This necessitated making HTMLParser ref-counted, and having it register itself with Document when created. That makes it possible for scripts to add new input at the current parser insertion point. There is now a reference cycle between Document and HTMLParser. This cycle is explicitly broken by calling Document::detach_parser() at the end of HTMLParser::run(). This is a huge progression on ACID3, from 31% to 49%! :^) --- Tests/LibWeb/test-web.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Tests/LibWeb') diff --git a/Tests/LibWeb/test-web.cpp b/Tests/LibWeb/test-web.cpp index 14819e41c1..a7d9913d3d 100644 --- a/Tests/LibWeb/test-web.cpp +++ b/Tests/LibWeb/test-web.cpp @@ -150,10 +150,10 @@ JS_DEFINE_NATIVE_FUNCTION(TestWebGlobalObject::wait_for_page_to_load) loader.load_sync( request, [&](auto data, auto&, auto) { - Web::HTML::HTMLParser parser(document, data, "utf-8"); + auto parser = Web::HTML::HTMLParser::create(document, data, "utf-8"); // Now parse the HTML page. - parser.run(next_page_to_load.value()); - g_page_view->set_document(&parser.document()); + parser->run(next_page_to_load.value()); + g_page_view->set_document(&parser->document()); // Note: Unhandled exceptions are just dropped here. // Run the "after" hooks -- cgit v1.2.3