Skip to content

Commit 45924b2

Browse files
committed
isSupported fixes
1 parent 29e0be2 commit 45924b2

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

packages/messaging/src/api/isSupported.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ export async function isWindowSupported(): Promise<boolean> {
2828
// might be prohibited to run. In these contexts, an error would be thrown during the messaging
2929
// instantiating phase, informing the developers to import/call isSupported for special handling.
3030
return (
31+
typeof window !== 'undefined' &&
32+
typeof indexedDB !== 'undefined' &&
3133
(await validateIndexedDBOpenable()) &&
32-
'indexedDB' in window &&
33-
indexedDB !== null &&
3434
navigator.cookieEnabled &&
3535
'serviceWorker' in navigator &&
3636
'PushManager' in window &&

packages/performance/src/services/api_service.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
import { ERROR_FACTORY, ErrorCode } from '../utils/errors';
19-
import { isIndexedDBAvailable } from '@firebase/util';
19+
import { isIndexedDBAvailable, areCookiesEnabled } from '@firebase/util';
2020
import { consoleLogger } from '../utils/console_logger';
2121

2222
declare global {
@@ -112,12 +112,7 @@ export class Api {
112112
}
113113

114114
requiredApisAvailable(): boolean {
115-
if (
116-
!fetch ||
117-
!Promise ||
118-
!this.navigator ||
119-
!this.navigator.cookieEnabled
120-
) {
115+
if (!fetch || !Promise || !areCookiesEnabled()) {
121116
consoleLogger.info(
122117
'Firebase Performance cannot start if browser does not support fetch and Promise or cookie is disabled.'
123118
);

packages/util/src/environment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export function validateIndexedDBOpenable(): Promise<boolean> {
184184
* @return true if cookie is enabled within current browser
185185
*/
186186
export function areCookiesEnabled(): boolean {
187-
if (!navigator || !navigator.cookieEnabled) {
187+
if (typeof navigator === 'undefined' || !navigator.cookieEnabled) {
188188
return false;
189189
}
190190
return true;

0 commit comments

Comments
 (0)