Skip to content

Commit a288e8c

Browse files
committed
Move isSafari()
1 parent 6513829 commit a288e8c

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

packages/firestore/test/unit/util/async_queue.test.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,10 @@ import { getLogLevel, setLogLevel, LogLevel } from '../../../src/util/log';
2424
import { Deferred, Rejecter, Resolver } from '../../../src/util/promise';
2525
import { fail } from '../../../src/util/assert';
2626
import { IndexedDbTransactionError } from '../../../src/local/simple_db';
27+
import { isSafari } from '../../util/test_platform';
2728

2829
use(chaiAsPromised);
2930

30-
function isSafari(): boolean {
31-
return (
32-
navigator.userAgent.includes('Safari') &&
33-
!navigator.userAgent.includes('Chrome')
34-
);
35-
}
36-
3731
describe('AsyncQueue', () => {
3832
// We reuse these TimerIds for generic testing.
3933
const timerId1 = TimerId.ListenStreamConnectionBackoff;
@@ -147,12 +141,6 @@ describe('AsyncQueue', () => {
147141
// Flaky on Safari.
148142
// eslint-disable-next-line no-restricted-properties
149143
(isSafari() ? it.skip : it)('can schedule ops in the future', async () => {
150-
if (
151-
navigator.userAgent.includes('Safari') &&
152-
!navigator.userAgent.includes('Chrome')
153-
) {
154-
return;
155-
}
156144
const queue = new AsyncQueue();
157145
const completedSteps: number[] = [];
158146
const doStep = (n: number): Promise<number> =>

packages/firestore/test/util/test_platform.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { JsonProtoSerializer } from '../../src/remote/serializer';
2222
import { debugAssert, fail } from '../../src/util/assert';
2323
import { ConnectivityMonitor } from './../../src/remote/connectivity_monitor';
2424
import { NoopConnectivityMonitor } from './../../src/remote/connectivity_monitor_noop';
25+
import { isNode } from '@firebase/util';
2526

2627
/* eslint-disable no-restricted-globals */
2728

@@ -272,11 +273,11 @@ export class TestPlatform implements Platform {
272273
}
273274
}
274275

275-
/** Returns true if we are running under Node. */
276-
export function isNode(): boolean {
276+
/** Returns true if we are running in Safari. */
277+
export function isSafari(): boolean {
277278
return (
278-
typeof process !== 'undefined' &&
279-
process.title !== undefined &&
280-
process.title.indexOf('node') !== -1
279+
!isNode() &&
280+
navigator.userAgent.includes('Safari') &&
281+
!navigator.userAgent.includes('Chrome')
281282
);
282283
}

0 commit comments

Comments
 (0)