mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 06:27:35 +00:00
LibWeb: Don't treat erroring subresource loads as success
If a subresource fails to load, we don't care that we got some custom 404 page. The subresource should still be considered failed. This is an ad-hoc solution that unbreaks Acid2. This code will eventually be replaced by fetch mechanisms.
This commit is contained in:
parent
954d660094
commit
20132da88d
3 changed files with 9 additions and 1 deletions
|
@ -212,6 +212,8 @@ bool FrameLoader::load(LoadRequest& request, Type type)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
request.set_main_resource(true);
|
||||||
|
|
||||||
auto& url = request.url();
|
auto& url = request.url();
|
||||||
|
|
||||||
if (type == Type::Navigation || type == Type::Reload || type == Type::Redirect) {
|
if (type == Type::Navigation || type == Type::Reload || type == Type::Redirect) {
|
||||||
|
|
|
@ -24,6 +24,11 @@ public:
|
||||||
|
|
||||||
static LoadRequest create_for_url_on_page(const AK::URL& url, Page* page);
|
static LoadRequest create_for_url_on_page(const AK::URL& url, Page* page);
|
||||||
|
|
||||||
|
// The main resource is the file being displayed in a frame (unlike subresources like images, scripts, etc.)
|
||||||
|
// If a main resource fails with an HTTP error, we may still display its content if non-empty, e.g a custom 404 page.
|
||||||
|
bool is_main_resource() const { return m_main_resource; }
|
||||||
|
void set_main_resource(bool b) { m_main_resource = b; }
|
||||||
|
|
||||||
bool is_valid() const { return m_url.is_valid(); }
|
bool is_valid() const { return m_url.is_valid(); }
|
||||||
|
|
||||||
const AK::URL& url() const { return m_url; }
|
const AK::URL& url() const { return m_url; }
|
||||||
|
@ -75,6 +80,7 @@ private:
|
||||||
ByteBuffer m_body;
|
ByteBuffer m_body;
|
||||||
Core::ElapsedTimer m_load_timer;
|
Core::ElapsedTimer m_load_timer;
|
||||||
Optional<Page&> m_page;
|
Optional<Page&> m_page;
|
||||||
|
bool m_main_resource { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -322,7 +322,7 @@ void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, Has
|
||||||
store_response_cookies(request.page().value(), request.url(), *set_cookie);
|
store_response_cookies(request.page().value(), request.url(), *set_cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success || (status_code.has_value() && *status_code >= 400 && *status_code <= 599 && payload.is_empty())) {
|
if (!success || (status_code.has_value() && *status_code >= 400 && *status_code <= 599 && (payload.is_empty() || !request.is_main_resource()))) {
|
||||||
StringBuilder error_builder;
|
StringBuilder error_builder;
|
||||||
if (status_code.has_value())
|
if (status_code.has_value())
|
||||||
error_builder.appendff("Load failed: {}", *status_code);
|
error_builder.appendff("Load failed: {}", *status_code);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue