From 9f3526b08030492cfdcce1c86abc857b09b39aa0 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Wed, 21 May 2025 12:26:31 -0400 Subject: [PATCH] LibWeb: Handle non-OK network responses in elements We were previously only testing for network errors, which includes e.g. DNS resolution and connection errors. It does not include e.g. HTTP 404 responses, which is exercised by Acid 2. --- Libraries/LibWeb/HTML/HTMLObjectElement.cpp | 2 +- Tests/LibWeb/Layout/expected/object-fallback.txt | 14 ++++++++++++++ Tests/LibWeb/Layout/input/object-fallback.html | 5 +++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Layout/expected/object-fallback.txt create mode 100644 Tests/LibWeb/Layout/input/object-fallback.html diff --git a/Libraries/LibWeb/HTML/HTMLObjectElement.cpp b/Libraries/LibWeb/HTML/HTMLObjectElement.cpp index 85a82cc0d1b..0e4db3b9b6c 100644 --- a/Libraries/LibWeb/HTML/HTMLObjectElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLObjectElement.cpp @@ -297,7 +297,7 @@ void HTMLObjectElement::queue_element_task_to_run_object_representation_steps() auto& realm = this->realm(); auto& global = document().realm().global_object(); - if (response->is_network_error()) { + if (response->is_network_error() || !Fetch::Infrastructure::is_ok_status(response->status())) { resource_did_fail(); return; } diff --git a/Tests/LibWeb/Layout/expected/object-fallback.txt b/Tests/LibWeb/Layout/expected/object-fallback.txt new file mode 100644 index 00000000000..5a40a9f2c57 --- /dev/null +++ b/Tests/LibWeb/Layout/expected/object-fallback.txt @@ -0,0 +1,14 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x34 [BFC] children: not-inline + BlockContainer at (8,8) content-size 784x18 children: inline + InlineNode + frag 0 from TextNode start: 1, length: 23, rect: [8,8 181.5x18] baseline: 13.796875 + "This should be visible!" + TextNode <#text> + TextNode <#text> + +ViewportPaintable (Viewport<#document>) [0,0 800x600] + PaintableWithLines (BlockContainer) [0,0 800x34] + PaintableWithLines (BlockContainer) [8,8 784x18] + PaintableWithLines (InlineNode) + TextPaintable (TextNode<#text>) diff --git a/Tests/LibWeb/Layout/input/object-fallback.html b/Tests/LibWeb/Layout/input/object-fallback.html new file mode 100644 index 00000000000..91c024f764c --- /dev/null +++ b/Tests/LibWeb/Layout/input/object-fallback.html @@ -0,0 +1,5 @@ + + + + This should be visible! +