Skip to content

Commit

Permalink
fix(perf): AFP should not error in Jest #2813 (#2920)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesdaniels authored Sep 2, 2021
1 parent 6a652df commit b0e147e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/compat/performance/performance.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/compat/performance/performance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,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}]`;
Expand Down

0 comments on commit b0e147e

Please sign in to comment.