LibWeb: Skip creating a navigable for <object> not connected to document

Navigation should not run for <object> element until it is inserted into
a document. Spec deoes not seem to explicitely say that, but that
matches other browsers behavior.

Fixes hanging after reloading in Acid3 test.
This commit is contained in:
Aliaksandr Kalenik 2024-04-17 12:26:25 +02:00 committed by Alexander Kalenik
commit d876f32e5d
Notes: sideshowbarker 2024-07-17 11:30:54 +09:00
3 changed files with 21 additions and 1 deletions

View file

@ -0,0 +1,19 @@
<!DOCTYPE html>
<script src="../include.js"></script>
<object id="obj" type="text/html" data="about:blank"></object>
<script>
asyncTest(done => {
const objectElement = document.getElementById("obj");
objectElement.onload = () => {
// Should not be reached.
println("load event fired");
};
objectElement.remove();
objectElement.data = "data:text/html;charset=utf-8,%3Chtml%3E%3Cbody%3E%3Ch1%3EHello%2C%20World%21%3C%2Fh1%3E%3Cp%3EThis%20is%20a%20simple%20embedded%20HTML%20using%20data%20URI.%3C%2Fp%3E%3C%2Fbody%3E%3C%2Fhtml%3E";
setTimeout(() => {
println("PASS");
done();
}, 100);
});
</script>

View file

@ -258,7 +258,7 @@ void HTMLObjectElement::run_object_representation_handler_steps(Optional<ByteStr
// * If the resource type is an XML MIME type, or if the resource type does not start with "image/" // * If the resource type is an XML MIME type, or if the resource type does not start with "image/"
if (mime_type.has_value() && can_load_document_with_type(*mime_type) && (mime_type->is_xml() || !mime_type->is_image())) { if (mime_type.has_value() && can_load_document_with_type(*mime_type) && (mime_type->is_xml() || !mime_type->is_image())) {
// If the object element's content navigable is null, then create a new child navigable for the element. // If the object element's content navigable is null, then create a new child navigable for the element.
if (!m_content_navigable) { if (!m_content_navigable && in_a_document_tree()) {
MUST(create_new_child_navigable()); MUST(create_new_child_navigable());
set_content_navigable_initialized(); set_content_navigable_initialized();
} }