1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:28:12 +00:00

LibWeb: Forbid sharing image requests across documents

This change addresses the bug where images unable to load when the
reload button in the UI is clicked repeatedly. Before this fix, it was
possible to use SharedImageRequests across multiple documents. However,
when the document that initiated the request is gone, tasks scheduled
on the event loop remain in the fetching state because the originating
document is no longer active. Furthermore, another reason to prohibit
the sharing of image requests across documents is that the "Origin"
header in an image request is dependent on the document.
This commit is contained in:
Aliaksandr Kalenik 2023-10-17 16:52:16 +02:00 committed by Andreas Kling
parent c2eaa0eb1c
commit 8ebb4e8047
4 changed files with 24 additions and 12 deletions

View file

@ -42,7 +42,7 @@ public:
virtual void visit_edges(JS::Cell::Visitor&) override;
private:
explicit SharedImageRequest(Page&, AK::URL);
explicit SharedImageRequest(Page&, AK::URL, JS::NonnullGCPtr<DOM::Document>);
void handle_successful_fetch(AK::URL const&, StringView mime_type, ByteBuffer data);
void handle_failed_fetch();
@ -67,6 +67,8 @@ private:
AK::URL m_url;
RefPtr<DecodedImageData const> m_image_data;
JS::GCPtr<Fetch::Infrastructure::FetchController> m_fetch_controller;
JS::GCPtr<DOM::Document> m_document;
};
}