mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
Storage objects are created lazily when window.localStorage or window.sessionStorage is first accessed. Previously, broadcast() iterated over already-created Storage objects, so windows that had never accessed these properties would not receive storage events. Fix this by iterating over all active windows and initializing Storage objects as part of the broadcast loop so all eligible windows receive the event regardless of whether they had previously accessed their storage property.
18 lines
505 B
HTML
18 lines
505 B
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<script>
|
|
function handleStorageEvent(e) {
|
|
if (window.sessionStorage === e.storageArea)
|
|
e.storageAreaString = "sessionStorage";
|
|
window.parent.onStorageEventReceived(e);
|
|
}
|
|
</script>
|
|
</head>
|
|
<!-- Intentionally do NOT access sessionStorage before the event fires.
|
|
The storage event should still be received even though the Storage
|
|
object has not yet been lazily created for this window. -->
|
|
<body onstorage="handleStorageEvent(event);">
|
|
</body>
|
|
</html>
|