Skip to content

Commit fcd0448

Browse files
authored
Merge 7d069bc into b4c5ef3
2 parents b4c5ef3 + 7d069bc commit fcd0448

File tree

2 files changed

+6
-36
lines changed

2 files changed

+6
-36
lines changed

.changeset/mighty-shirts-pump.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@firebase/auth': patch
3+
---
4+
5+
Remove localStorage synchronization on storage events in Safari iframes. See [GitHub PR #8408](https://github.com/firebase/firebase-js-sdk/pull/8408).

packages/auth/src/platform_browser/persistence/local_storage.ts

+1-36
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,7 @@
1717

1818
import { Persistence } from '../../model/public_types';
1919

20-
import { getUA } from '@firebase/util';
21-
import {
22-
_isSafari,
23-
_isIOS,
24-
_isIframe,
25-
_isMobileBrowser,
26-
_isIE10
27-
} from '../../core/util/browser';
20+
import { _isMobileBrowser, _isIE10 } from '../../core/util/browser';
2821
import {
2922
PersistenceInternal as InternalPersistence,
3023
PersistenceType,
@@ -33,11 +26,6 @@ import {
3326
} from '../../core/persistence';
3427
import { BrowserPersistenceClass } from './browser';
3528

36-
function _iframeCannotSyncWebStorage(): boolean {
37-
const ua = getUA();
38-
return _isSafari(ua) || _isIOS(ua);
39-
}
40-
4129
// The polling period in case events are not supported
4230
export const _POLLING_INTERVAL_MS = 1000;
4331

@@ -64,9 +52,6 @@ class BrowserLocalPersistence
6452
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6553
private pollTimer: any | null = null;
6654

67-
// Safari or iOS browser and embedded in an iframe.
68-
private readonly safariLocalStorageNotSynced =
69-
_iframeCannotSyncWebStorage() && _isIframe();
7055
// Whether to use polling instead of depending on window events
7156
private readonly fallbackToPolling = _isMobileBrowser();
7257
readonly _shouldAllowMigration = true;
@@ -112,26 +97,6 @@ class BrowserLocalPersistence
11297
this.stopPolling();
11398
}
11499

115-
// Safari embedded iframe. Storage event will trigger with the delta
116-
// changes but no changes will be applied to the iframe localStorage.
117-
if (this.safariLocalStorageNotSynced) {
118-
// Get current iframe page value.
119-
const storedValue = this.storage.getItem(key);
120-
// Value not synchronized, synchronize manually.
121-
if (event.newValue !== storedValue) {
122-
if (event.newValue !== null) {
123-
// Value changed from current value.
124-
this.storage.setItem(key, event.newValue);
125-
} else {
126-
// Current value deleted.
127-
this.storage.removeItem(key);
128-
}
129-
} else if (this.localCache[key] === event.newValue && !poll) {
130-
// Already detected and processed, do not trigger listeners again.
131-
return;
132-
}
133-
}
134-
135100
const triggerListeners = (): void => {
136101
// Keep local map up to date in case storage event is triggered before
137102
// poll.

0 commit comments

Comments
 (0)