From 2b22402c6a430e7bde51c6cdaa77f9f12a09d4ca Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Thu, 18 Jan 2024 16:34:16 -0500 Subject: [PATCH] LibWeb: Correctly categorize Fetch responses as network errors The condition here is flipped. From the spec: A network error is a response whose ... body is null ... --- .../Text/expected/video-failed-load.txt | 3 ++ .../LibWeb/Text/input/video-failed-load.html | 35 +++++++++++++++++++ .../Fetch/Infrastructure/HTTP/Responses.cpp | 2 +- 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Text/expected/video-failed-load.txt create mode 100644 Tests/LibWeb/Text/input/video-failed-load.html diff --git a/Tests/LibWeb/Text/expected/video-failed-load.txt b/Tests/LibWeb/Text/expected/video-failed-load.txt new file mode 100644 index 0000000000..18af3d39d2 --- /dev/null +++ b/Tests/LibWeb/Text/expected/video-failed-load.txt @@ -0,0 +1,3 @@ +failed to load: "data:" +failed to load: "file:///i-do-no-exist-i-swear" +failed to load: "https://i-do-no-exist-i-swear.net.uk" diff --git a/Tests/LibWeb/Text/input/video-failed-load.html b/Tests/LibWeb/Text/input/video-failed-load.html new file mode 100644 index 0000000000..34c07971e6 --- /dev/null +++ b/Tests/LibWeb/Text/input/video-failed-load.html @@ -0,0 +1,35 @@ + + diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp index f59c151827..9f576a0cff 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp @@ -96,7 +96,7 @@ bool Response::is_network_error() const return false; if (!header_list()->is_empty()) return false; - if (!body()) + if (body()) return false; if (body_info() != BodyInfo {}) return false;