Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,12 @@ describe('LongTasks API', () => {
it('does NOT report short tasks (under 50ms)', () => {
const callback = jest.fn();

observer = new PerformanceObserver(callback);
observer.observe({entryTypes: ['longtask']});
Fantom.runTask(() => {
observer = new PerformanceObserver(callback);
observer.observe({entryTypes: ['longtask']});
});

expect(callback).not.toHaveBeenCalled();

Fantom.runTask(() => {
// Short task.
Expand All @@ -75,8 +79,12 @@ describe('LongTasks API', () => {
it('reports long tasks (over 50ms)', () => {
const callback = jest.fn();

observer = new PerformanceObserver(callback);
observer.observe({entryTypes: ['longtask']});
Fantom.runTask(() => {
observer = new PerformanceObserver(callback);
observer.observe({entryTypes: ['longtask']});
});

expect(callback).not.toHaveBeenCalled();

const beforeTaskStartTime = performance.now();
let afterTaskStartTime;
Expand Down Expand Up @@ -122,8 +130,12 @@ describe('LongTasks API', () => {
it('should NOT be reported if they are longer than 50ms but had yielding opportunities in intervals shorter than 50ms', () => {
const callback = jest.fn();

observer = new PerformanceObserver(callback);
observer.observe({entryTypes: ['longtask']});
Fantom.runTask(() => {
observer = new PerformanceObserver(callback);
observer.observe({entryTypes: ['longtask']});
});

expect(callback).not.toHaveBeenCalled();

const shouldYield = global.nativeRuntimeScheduler.unstable_shouldYield;

Expand All @@ -141,8 +153,12 @@ describe('LongTasks API', () => {
it('should be reported if running for longer than 50ms between yielding opportunities', () => {
const callback = jest.fn();

observer = new PerformanceObserver(callback);
observer.observe({entryTypes: ['longtask']});
Fantom.runTask(() => {
observer = new PerformanceObserver(callback);
observer.observe({entryTypes: ['longtask']});
});

expect(callback).not.toHaveBeenCalled();

const shouldYield = global.nativeRuntimeScheduler.unstable_shouldYield;

Expand Down
Loading