Skip to content

Commit

Permalink
馃悰鉁匜ix tickevent tests for Safari (ampproject#21096)
Browse files Browse the repository at this point in the history
* Fix tickevent tests for Safari

Fixes ampproject#21062

* Add comment to allow legit usage of console.warn

* ESLint fix

* Use dev() log instead of console

* Add import statement

* Fix lint
  • Loading branch information
ericandrewlewis authored and bramanudom committed Mar 22, 2019
1 parent fe73241 commit 9b36738
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
11 changes: 10 additions & 1 deletion src/service/performance-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import {Services} from '../services';
import {dev} from '../log';
import {dict, map} from '../utils/object';
import {getMode} from '../mode';
import {getService, registerServiceBuilder} from '../service';
Expand Down Expand Up @@ -281,7 +282,15 @@ export class Performance {
list.getEntries().forEach(processEntry);
this.flush();
});
observer.observe({entryTypes: entryTypesToObserve});

// Wrap observer.observe() in a try statement for testing, because
// Webkit throws an error if the entry types to observe are not natively
// supported.
try {
observer.observe({entryTypes: entryTypesToObserve});
} catch (err) {
dev()/*OK*/.warn(err);
}
}

/**
Expand Down
8 changes: 2 additions & 6 deletions test/unit/test-performance.js
Original file line number Diff line number Diff line change
Expand Up @@ -718,9 +718,7 @@ describes.realWin('PeformanceObserver metrics', {amp: true}, env => {
}

describe('should forward paint metrics for performance entries', () => {
// TODO(ericandrewlewis, 20721): Fails on Safari.
it.configure().skipSafari('created before performance service ' +
'registered', () => {
it('created before performance service registered', () => {
// Pretend that the PaintTiming API exists.
env.win.PerformancePaintTiming = true;

Expand Down Expand Up @@ -813,9 +811,7 @@ describes.realWin('PeformanceObserver metrics', {amp: true}, env => {
});

describe('should forward first input metrics for performance entries', () => {
// TODO(ericandrewlewis, 20721): Fails on Safari.
it.configure().skipSafari('created before performance service ' +
'registered', () => {
it('created before performance service registered', () => {
// Pretend that the EventTiming API exists.
env.win.PerformanceEventTiming = true;

Expand Down

0 comments on commit 9b36738

Please sign in to comment.