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
commit 8ebb4e8047
Notes: sideshowbarker 2024-07-18 00:54:03 +09:00
4 changed files with 24 additions and 12 deletions

View file

@ -30,6 +30,7 @@
#include <LibWeb/HTML/Origin.h>
#include <LibWeb/HTML/SandboxingFlagSet.h>
#include <LibWeb/HTML/Scripting/Environments.h>
#include <LibWeb/HTML/SharedImageRequest.h>
#include <LibWeb/HTML/VisibilityState.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
@ -531,6 +532,8 @@ public:
void update_for_history_step_application(JS::NonnullGCPtr<HTML::SessionHistoryEntry>, bool do_not_reactive, size_t script_history_length, size_t script_history_index);
HashMap<AK::URL, HTML::SharedImageRequest*>& shared_image_requests();
protected:
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
@ -735,6 +738,8 @@ private:
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#latest-entry
JS::GCPtr<HTML::SessionHistoryEntry> m_latest_entry;
HashMap<AK::URL, HTML::SharedImageRequest*> m_shared_image_requests;
};
template<>