Remove LocalStorage synchronization on storage events in Safari by dlarocque · Pull Request #8408 · firebase/firebase-js-sdk (original) (raw)
This PR removes a localStorage synchronization fix introduced in 2016 to address an issue in Safari 9 (Important: b/28330893). The fix, while necessary at the time, is now causing several Auth tests to fail in Safari. After removing this fix, all tests pass.
The Safari tests are failing because they assume that a storage event without a change to the underlying storage will not trigger callbacks that we attach. With this fix, if we dispatch a storage event without a change to the underlying storage, a manual synchronization will take place, which will then cause the callbacks to be called.
See: local_storage.test.ts.
Testing:
I tested localStorage behaviour in the latest Safari version with an app hosted at 127.0.0.1 that contains an iframe hosted at localhost. I opened the app in two tabs and triggered localStorage events by signing in with Google in a popup, and observed that changes to localStorage are synchronized correctly across the iframes in both tabs.
I created a repro with instructions to help others test this behaviour: https://github.com/dlarocque/safari-iframe-localstorage.