Files
ladybird/Tests/LibWeb/Text/data/session-storage-event-iframe.html
Shannon Booth cc711a6060 LibWeb/HTML: Fire storage events to windows without a Storage
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.
2026-03-16 13:55:07 +01:00

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>