mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-15 23:01:52 +00:00
LibWeb/HTML: Enforce quota limit for local and session storage
Fixes a timeout/crash for the two commited WPT tests.
This commit is contained in:
parent
e767029e24
commit
f3ecd23a21
Notes:
github-actions[bot]
2025-01-02 10:39:50 +00:00
Author: https://github.com/shannonbooth
Commit: f3ecd23a21
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3070
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/konradekk
7 changed files with 74 additions and 8 deletions
|
@ -447,10 +447,13 @@ void Window::fire_a_page_transition_event(FlyString const& event_name, bool pers
|
|||
// https://html.spec.whatwg.org/multipage/webstorage.html#dom-localstorage
|
||||
WebIDL::ExceptionOr<GC::Ref<Storage>> Window::local_storage()
|
||||
{
|
||||
// See table in: https://storage.spec.whatwg.org/#registered-storage-endpoints
|
||||
constexpr u64 quota_bytes = 5 * MiB;
|
||||
|
||||
// FIXME: Implement according to spec.
|
||||
static HashMap<URL::Origin, GC::Root<Storage>> local_storage_per_origin;
|
||||
auto storage = local_storage_per_origin.ensure(associated_document().origin(), [this]() -> GC::Root<Storage> {
|
||||
return Storage::create(realm());
|
||||
return Storage::create(realm(), quota_bytes);
|
||||
});
|
||||
return GC::Ref { *storage };
|
||||
}
|
||||
|
@ -458,10 +461,13 @@ WebIDL::ExceptionOr<GC::Ref<Storage>> Window::local_storage()
|
|||
// https://html.spec.whatwg.org/multipage/webstorage.html#dom-sessionstorage
|
||||
WebIDL::ExceptionOr<GC::Ref<Storage>> Window::session_storage()
|
||||
{
|
||||
// See table in: https://storage.spec.whatwg.org/#registered-storage-endpoints
|
||||
constexpr u64 quota_bytes = 5 * MiB;
|
||||
|
||||
// FIXME: Implement according to spec.
|
||||
static HashMap<URL::Origin, GC::Root<Storage>> session_storage_per_origin;
|
||||
auto storage = session_storage_per_origin.ensure(associated_document().origin(), [this]() -> GC::Root<Storage> {
|
||||
return Storage::create(realm());
|
||||
return Storage::create(realm(), quota_bytes);
|
||||
});
|
||||
return GC::Ref { *storage };
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue