From c45e33d2cc480aa273effab90af3cc5517370860 Mon Sep 17 00:00:00 2001 From: spicemix Date: Tue, 4 May 2021 00:42:25 -0700 Subject: [PATCH 1/2] Check for window.performance.mark For compatibility with test environments that replace window.performance --- src/performance/performance.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/performance/performance.service.ts b/src/performance/performance.service.ts index 94c532884..edc1861d2 100644 --- a/src/performance/performance.service.ts +++ b/src/performance/performance.service.ts @@ -6,7 +6,7 @@ const IS_STABLE_START_MARK = '_isStableStart'; const IS_STABLE_END_MARK = '_isStableEnd'; function markStarts() { - if (typeof(window) !== 'undefined' && window.performance) { + if (typeof(window) !== 'undefined' && window.performance && window.performance.mark) { window.performance.mark(IS_STABLE_START_MARK); return true; } else { @@ -22,7 +22,7 @@ export class PerformanceMonitoringService implements OnDestroy { private disposable: Subscription|undefined; constructor(appRef: ApplicationRef) { - if (started) { + if (started && window.performance.mark) { this.disposable = appRef.isStable.pipe( first(it => it), tap(() => { From 68609880aff704c114ae1ae79a817196bb7922cc Mon Sep 17 00:00:00 2001 From: spicemix Date: Tue, 4 May 2021 00:43:32 -0700 Subject: [PATCH 2/2] Check for window.performance.mark For compatibility with test environments that replace window.performance --- src/performance/performance.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/performance/performance.ts b/src/performance/performance.ts index 6bc4dd958..7f173e36f 100644 --- a/src/performance/performance.ts +++ b/src/performance/performance.ts @@ -53,7 +53,7 @@ export class AngularFirePerformance { } const trace$ = (traceId: string) => { - if (typeof window !== 'undefined' && window.performance) { + if (typeof window !== 'undefined' && window.performance && window.performance.mark) { const entries = window.performance.getEntriesByName(traceId, 'measure') || []; const startMarkName = `_${traceId}Start[${entries.length}]`; const endMarkName = `_${traceId}End[${entries.length}]`;