Skip to content

Commit de0bbd3

Browse files
authored
chore: remove page pause support (#2431)
1 parent e587531 commit de0bbd3

File tree

6 files changed

+47
-129
lines changed

6 files changed

+47
-129
lines changed

src/chromium/crPage.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,6 @@ export class CRPage implements PageDelegate {
273273
return this._sessionForHandle(handle)._scrollRectIntoViewIfNeeded(handle, rect);
274274
}
275275

276-
async setActivityPaused(paused: boolean): Promise<void> {
277-
await this._forAllFrameSessions(frame => frame._setActivityPaused(paused));
278-
}
279-
280276
rafCountForStablePosition(): number {
281277
return 1;
282278
}
@@ -834,9 +830,6 @@ class FrameSession {
834830
});
835831
}
836832

837-
async _setActivityPaused(paused: boolean): Promise<void> {
838-
}
839-
840833
async _getContentQuads(handle: dom.ElementHandle): Promise<types.Quad[] | null> {
841834
const result = await this._client.send('DOM.getContentQuads', {
842835
objectId: handle._objectId

src/dom.ts

Lines changed: 47 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -255,70 +255,57 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
255255
if (!force)
256256
await this._waitForDisplayedAtStablePositionAndEnabled(deadline);
257257

258-
let paused = false;
259-
try {
260-
await this._page._delegate.setActivityPaused(true);
261-
paused = true;
262-
263-
this._page._log(inputLog, 'scrolling into view if needed...');
264-
const scrolled = await this._scrollRectIntoViewIfNeeded(position ? { x: position.x, y: position.y, width: 0, height: 0 } : undefined);
265-
if (scrolled === 'invisible') {
266-
if (force)
267-
throw new Error('Element is not visible');
268-
this._page._log(inputLog, '...element is not visible, retrying input action');
258+
this._page._log(inputLog, 'scrolling into view if needed...');
259+
const scrolled = await this._scrollRectIntoViewIfNeeded(position ? { x: position.x, y: position.y, width: 0, height: 0 } : undefined);
260+
if (scrolled === 'invisible') {
261+
if (force)
262+
throw new Error('Element is not visible');
263+
this._page._log(inputLog, '...element is not visible, retrying input action');
264+
return 'retry';
265+
}
266+
this._page._log(inputLog, '...done scrolling');
267+
268+
const maybePoint = position ? await this._offsetPoint(position) : await this._clickablePoint();
269+
if (maybePoint === 'invisible') {
270+
if (force)
271+
throw new Error('Element is not visible');
272+
this._page._log(inputLog, 'element is not visibile, retrying input action');
273+
return 'retry';
274+
}
275+
if (maybePoint === 'outsideviewport') {
276+
if (force)
277+
throw new Error('Element is outside of the viewport');
278+
this._page._log(inputLog, 'element is outside of the viewport, retrying input action');
279+
return 'retry';
280+
}
281+
const point = roundPoint(maybePoint);
282+
283+
if (!force) {
284+
if ((options as any).__testHookBeforeHitTarget)
285+
await (options as any).__testHookBeforeHitTarget();
286+
this._page._log(inputLog, `checking that element receives pointer events at (${point.x},${point.y})...`);
287+
const matchesHitTarget = await this._checkHitTargetAt(point);
288+
if (!matchesHitTarget) {
289+
this._page._log(inputLog, '...element does not receive pointer events, retrying input action');
269290
return 'retry';
270291
}
271-
this._page._log(inputLog, '...done scrolling');
292+
this._page._log(inputLog, `...element does receive pointer events, continuing input action`);
293+
}
272294

273-
const maybePoint = position ? await this._offsetPoint(position) : await this._clickablePoint();
274-
if (maybePoint === 'invisible') {
275-
if (force)
276-
throw new Error('Element is not visible');
277-
this._page._log(inputLog, 'element is not visibile, retrying input action');
278-
return 'retry';
279-
}
280-
if (maybePoint === 'outsideviewport') {
281-
if (force)
282-
throw new Error('Element is outside of the viewport');
283-
this._page._log(inputLog, 'element is outside of the viewport, retrying input action');
284-
return 'retry';
285-
}
286-
const point = roundPoint(maybePoint);
287-
288-
if (!force) {
289-
if ((options as any).__testHookBeforeHitTarget)
290-
await (options as any).__testHookBeforeHitTarget();
291-
this._page._log(inputLog, `checking that element receives pointer events at (${point.x},${point.y})...`);
292-
const matchesHitTarget = await this._checkHitTargetAt(point);
293-
if (!matchesHitTarget) {
294-
this._page._log(inputLog, '...element does not receive pointer events, retrying input action');
295-
await this._page._delegate.setActivityPaused(false);
296-
paused = false;
297-
return 'retry';
298-
}
299-
this._page._log(inputLog, `...element does receive pointer events, continuing input action`);
300-
}
295+
await this._page._frameManager.waitForSignalsCreatedBy(async () => {
296+
let restoreModifiers: input.Modifier[] | undefined;
297+
if (options && options.modifiers)
298+
restoreModifiers = await this._page.keyboard._ensureModifiers(options.modifiers);
299+
this._page._log(inputLog, `performing "${actionName}" action...`);
300+
await action(point);
301+
this._page._log(inputLog, `... "${actionName}" action done`);
302+
this._page._log(inputLog, 'waiting for scheduled navigations to finish...');
303+
if (restoreModifiers)
304+
await this._page.keyboard._ensureModifiers(restoreModifiers);
305+
}, deadline, options, true);
306+
this._page._log(inputLog, '...navigations have finished');
301307

302-
await this._page._frameManager.waitForSignalsCreatedBy(async () => {
303-
let restoreModifiers: input.Modifier[] | undefined;
304-
if (options && options.modifiers)
305-
restoreModifiers = await this._page.keyboard._ensureModifiers(options.modifiers);
306-
this._page._log(inputLog, `performing "${actionName}" action...`);
307-
await action(point);
308-
this._page._log(inputLog, `... "${actionName}" action done`);
309-
this._page._log(inputLog, 'waiting for scheduled navigations to finish...');
310-
await this._page._delegate.setActivityPaused(false);
311-
paused = false;
312-
if (restoreModifiers)
313-
await this._page.keyboard._ensureModifiers(restoreModifiers);
314-
}, deadline, options, true);
315-
this._page._log(inputLog, '...navigations have finished');
316-
317-
return 'done';
318-
} finally {
319-
if (paused)
320-
await this._page._delegate.setActivityPaused(false);
321-
}
308+
return 'done';
322309
}
323310

324311
hover(options?: PointerActionOptions & types.PointerActionWaitOptions): Promise<void> {

src/firefox/ffPage.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,6 @@ export class FFPage implements PageDelegate {
424424
});
425425
}
426426

427-
async setActivityPaused(paused: boolean): Promise<void> {
428-
}
429-
430427
rafCountForStablePosition(): number {
431428
return 1;
432429
}

src/page.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ export interface PageDelegate {
6969
getBoundingBox(handle: dom.ElementHandle): Promise<types.Rect | null>;
7070
getFrameElement(frame: frames.Frame): Promise<dom.ElementHandle>;
7171
scrollRectIntoViewIfNeeded(handle: dom.ElementHandle, rect?: types.Rect): Promise<'success' | 'invisible'>;
72-
setActivityPaused(paused: boolean): Promise<void>;
7372
rafCountForStablePosition(): number;
7473

7574
getAccessibilityTree(needle?: dom.ElementHandle): Promise<{tree: accessibility.AXNode, needle: accessibility.AXNode | null}>;

src/webkit/wkPage.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -762,9 +762,6 @@ export class WKPage implements PageDelegate {
762762
});
763763
}
764764

765-
async setActivityPaused(paused: boolean): Promise<void> {
766-
}
767-
768765
rafCountForStablePosition(): number {
769766
return process.platform === 'win32' ? 5 : 1;
770767
}

test/click.spec.js

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -706,61 +706,6 @@ describe('Page.click', function() {
706706
expect(error.message).toContain('timeout exceeded');
707707
expect(error.message).toContain('DEBUG=pw:input');
708708
});
709-
it.skip(true)('should pause animations', async({page}) => {
710-
// This test requires pausing the page.
711-
await page.setContent(`<style>
712-
@keyframes spinner {
713-
from { transform: rotate(0deg); }
714-
to { transform: rotate(360deg); }
715-
}
716-
.spinner {
717-
animation: spinner 2s linear infinite;
718-
animation-delay: 500ms;
719-
}
720-
</style>
721-
<div class="spinner" style="width: 500px; height: 500px; display: flex; justify-content: center;" >
722-
<button id="target"
723-
style="width: 30px; height: 30px; background-color: green"
724-
onclick="window.clicked=true"></button>
725-
</div>
726-
`);
727-
await page.click('#target', { __testHookBeforeHitTarget: () => new Promise(f => setTimeout(f, 1000)) });
728-
expect(await page.evaluate(() => window.clicked)).toBe(true);
729-
});
730-
it.skip(true)('should defer timers', async({page}) => {
731-
// This test requires pausing the page.
732-
await page.setContent(`<button id=button onclick="window.clicked=true">Click me</button>`);
733-
await page.click('button', { __testHookBeforeHitTarget: async () => {
734-
// Schedule a timer that hides the element
735-
await page.evaluate(() => setTimeout(() => button.style.display = 'none', 0));
736-
// Allow enough time for timer to fire
737-
await page.waitForTimeout(500);
738-
}});
739-
expect(await page.evaluate(() => window.clicked)).toBe(true);
740-
});
741-
it.skip(true)('should defer rafs', async({page}) => {
742-
// This test requires pausing the page.
743-
await page.setContent(`<button id=button onclick="window.clicked=true">Click me</button>`);
744-
await page.click('button', { __testHookBeforeHitTarget: async () => {
745-
// Schedule a timer that hides the element
746-
await page.evaluate(() => requestAnimationFrame(() => button.style.display = 'none'));
747-
// Allow enough time for raf to fire
748-
await page.waitForTimeout(500);
749-
}});
750-
expect(await page.evaluate(() => window.clicked)).toBe(true);
751-
});
752-
it.skip(true)('should defer fetch', async({page, server}) => {
753-
// This test requires pausing the page.
754-
await page.goto(server.EMPTY_PAGE);
755-
await page.setContent(`<button id=button onclick="window.clicked=true">Click me</button>`);
756-
await page.click('button', { __testHookBeforeHitTarget: async () => {
757-
// Fetch that would immediately delete button.
758-
page.evaluate(() => fetch(window.location.href).then(() => button.style.display = 'none'));
759-
// Allow enough time for raf to fire
760-
await page.waitForTimeout(500);
761-
}});
762-
expect(await page.evaluate(() => window.clicked)).toBe(true);
763-
});
764709
it('should dispatch microtasks in order', async({page, server}) => {
765710
await page.setContent(`
766711
<button id=button>Click me</button>

0 commit comments

Comments
 (0)