mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 06:48:49 +00:00
LibWeb: Initialize the Storage byte count upon creation
A Storage object may be created with an existing storage bottle. For example, if you navigate from site.com/page1 to site.com/page2, they will have different localStorage objects, but will use the same bottle for actual storage. Previously, if page1 set some key/value item, we would initialize the byte count to 0 on page2 despite having a non-empty bottle. Thus, if page2 set a smaller value with the same key, we would overflow the computed byte count, and all subsequent writes would be rejected. This was seen navigating from the chess.com home page to the daily puzzle page.
This commit is contained in:
parent
31da70bbfc
commit
4dfc29356d
Notes:
github-actions[bot]
2025-03-18 19:35:13 +00:00
Author: https://github.com/trflynn89
Commit: 4dfc29356d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3990
Reviewed-by: https://github.com/gmta ✅
4 changed files with 26 additions and 0 deletions
|
@ -46,6 +46,9 @@ Storage::Storage(JS::Realm& realm, Type type, NonnullRefPtr<StorageAPI::StorageB
|
|||
.named_property_deleter_has_identifier = true,
|
||||
};
|
||||
|
||||
for (auto const& item : map())
|
||||
m_stored_bytes += item.key.byte_count() + item.value.byte_count();
|
||||
|
||||
all_storages().set(*this);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue