LibWeb: Handle failed browsing context creation in HTMLObjectElement

If the document is not attached to a browsing context we can't create
a new nested browsing context.

This can happen when the resource load for the <object> finishes after
the user navigated away from the current document, for example by
reloading ACID 3 while it's running.
This commit is contained in:
Simon Wanner 2022-04-03 22:26:34 +02:00 committed by Andreas Kling
parent 450c0df938
commit d28f3e0735
Notes: sideshowbarker 2024-07-17 14:31:01 +09:00

View file

@ -217,6 +217,10 @@ void HTMLObjectElement::run_object_representation_handler_steps(Optional<String>
if (!m_nested_browsing_context)
create_new_nested_browsing_context();
// NOTE: Creating a new nested browsing context can fail if the document is not attached to a browsing context
if (!m_nested_browsing_context)
return;
// If the URL of the given resource does not match about:blank, then navigate the element's nested browsing context to that resource, with historyHandling set to "replace" and the source browsing context set to the object element's node document's browsing context. (The data attribute of the object element doesn't get updated if the browsing context gets further navigated to other locations.)
if (auto const& url = resource()->url(); url != "about:blank"sv)
m_nested_browsing_context->loader().load(url, FrameLoader::Type::IFrame);