chore: remove page pause support (#2431)

This commit is contained in:
Dmitry Gozman 2020-06-01 11:14:16 -07:00 committed by GitHub
parent e5875310db
commit de0bbd3031
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 50 additions and 132 deletions

View File

@ -273,10 +273,6 @@ export class CRPage implements PageDelegate {
return this._sessionForHandle(handle)._scrollRectIntoViewIfNeeded(handle, rect);
}
async setActivityPaused(paused: boolean): Promise<void> {
await this._forAllFrameSessions(frame => frame._setActivityPaused(paused));
}
rafCountForStablePosition(): number {
return 1;
}
@ -834,9 +830,6 @@ class FrameSession {
});
}
async _setActivityPaused(paused: boolean): Promise<void> {
}
async _getContentQuads(handle: dom.ElementHandle): Promise<types.Quad[] | null> {
const result = await this._client.send('DOM.getContentQuads', {
objectId: handle._objectId

View File

@ -255,70 +255,57 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
if (!force)
await this._waitForDisplayedAtStablePositionAndEnabled(deadline);
let paused = false;
try {
await this._page._delegate.setActivityPaused(true);
paused = true;
this._page._log(inputLog, 'scrolling into view if needed...');
const scrolled = await this._scrollRectIntoViewIfNeeded(position ? { x: position.x, y: position.y, width: 0, height: 0 } : undefined);
if (scrolled === 'invisible') {
if (force)
throw new Error('Element is not visible');
this._page._log(inputLog, '...element is not visible, retrying input action');
return 'retry';
}
this._page._log(inputLog, '...done scrolling');
const maybePoint = position ? await this._offsetPoint(position) : await this._clickablePoint();
if (maybePoint === 'invisible') {
if (force)
throw new Error('Element is not visible');
this._page._log(inputLog, 'element is not visibile, retrying input action');
return 'retry';
}
if (maybePoint === 'outsideviewport') {
if (force)
throw new Error('Element is outside of the viewport');
this._page._log(inputLog, 'element is outside of the viewport, retrying input action');
return 'retry';
}
const point = roundPoint(maybePoint);
if (!force) {
if ((options as any).__testHookBeforeHitTarget)
await (options as any).__testHookBeforeHitTarget();
this._page._log(inputLog, `checking that element receives pointer events at (${point.x},${point.y})...`);
const matchesHitTarget = await this._checkHitTargetAt(point);
if (!matchesHitTarget) {
this._page._log(inputLog, '...element does not receive pointer events, retrying input action');
await this._page._delegate.setActivityPaused(false);
paused = false;
return 'retry';
}
this._page._log(inputLog, `...element does receive pointer events, continuing input action`);
}
await this._page._frameManager.waitForSignalsCreatedBy(async () => {
let restoreModifiers: input.Modifier[] | undefined;
if (options && options.modifiers)
restoreModifiers = await this._page.keyboard._ensureModifiers(options.modifiers);
this._page._log(inputLog, `performing "${actionName}" action...`);
await action(point);
this._page._log(inputLog, `... "${actionName}" action done`);
this._page._log(inputLog, 'waiting for scheduled navigations to finish...');
await this._page._delegate.setActivityPaused(false);
paused = false;
if (restoreModifiers)
await this._page.keyboard._ensureModifiers(restoreModifiers);
}, deadline, options, true);
this._page._log(inputLog, '...navigations have finished');
return 'done';
} finally {
if (paused)
await this._page._delegate.setActivityPaused(false);
this._page._log(inputLog, 'scrolling into view if needed...');
const scrolled = await this._scrollRectIntoViewIfNeeded(position ? { x: position.x, y: position.y, width: 0, height: 0 } : undefined);
if (scrolled === 'invisible') {
if (force)
throw new Error('Element is not visible');
this._page._log(inputLog, '...element is not visible, retrying input action');
return 'retry';
}
this._page._log(inputLog, '...done scrolling');
const maybePoint = position ? await this._offsetPoint(position) : await this._clickablePoint();
if (maybePoint === 'invisible') {
if (force)
throw new Error('Element is not visible');
this._page._log(inputLog, 'element is not visibile, retrying input action');
return 'retry';
}
if (maybePoint === 'outsideviewport') {
if (force)
throw new Error('Element is outside of the viewport');
this._page._log(inputLog, 'element is outside of the viewport, retrying input action');
return 'retry';
}
const point = roundPoint(maybePoint);
if (!force) {
if ((options as any).__testHookBeforeHitTarget)
await (options as any).__testHookBeforeHitTarget();
this._page._log(inputLog, `checking that element receives pointer events at (${point.x},${point.y})...`);
const matchesHitTarget = await this._checkHitTargetAt(point);
if (!matchesHitTarget) {
this._page._log(inputLog, '...element does not receive pointer events, retrying input action');
return 'retry';
}
this._page._log(inputLog, `...element does receive pointer events, continuing input action`);
}
await this._page._frameManager.waitForSignalsCreatedBy(async () => {
let restoreModifiers: input.Modifier[] | undefined;
if (options && options.modifiers)
restoreModifiers = await this._page.keyboard._ensureModifiers(options.modifiers);
this._page._log(inputLog, `performing "${actionName}" action...`);
await action(point);
this._page._log(inputLog, `... "${actionName}" action done`);
this._page._log(inputLog, 'waiting for scheduled navigations to finish...');
if (restoreModifiers)
await this._page.keyboard._ensureModifiers(restoreModifiers);
}, deadline, options, true);
this._page._log(inputLog, '...navigations have finished');
return 'done';
}
hover(options?: PointerActionOptions & types.PointerActionWaitOptions): Promise<void> {

View File

@ -424,9 +424,6 @@ export class FFPage implements PageDelegate {
});
}
async setActivityPaused(paused: boolean): Promise<void> {
}
rafCountForStablePosition(): number {
return 1;
}

View File

@ -69,7 +69,6 @@ export interface PageDelegate {
getBoundingBox(handle: dom.ElementHandle): Promise<types.Rect | null>;
getFrameElement(frame: frames.Frame): Promise<dom.ElementHandle>;
scrollRectIntoViewIfNeeded(handle: dom.ElementHandle, rect?: types.Rect): Promise<'success' | 'invisible'>;
setActivityPaused(paused: boolean): Promise<void>;
rafCountForStablePosition(): number;
getAccessibilityTree(needle?: dom.ElementHandle): Promise<{tree: accessibility.AXNode, needle: accessibility.AXNode | null}>;

View File

@ -762,9 +762,6 @@ export class WKPage implements PageDelegate {
});
}
async setActivityPaused(paused: boolean): Promise<void> {
}
rafCountForStablePosition(): number {
return process.platform === 'win32' ? 5 : 1;
}

View File

@ -706,61 +706,6 @@ describe('Page.click', function() {
expect(error.message).toContain('timeout exceeded');
expect(error.message).toContain('DEBUG=pw:input');
});
it.skip(true)('should pause animations', async({page}) => {
// This test requires pausing the page.
await page.setContent(`<style>
@keyframes spinner {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
.spinner {
animation: spinner 2s linear infinite;
animation-delay: 500ms;
}
</style>
<div class="spinner" style="width: 500px; height: 500px; display: flex; justify-content: center;" >
<button id="target"
style="width: 30px; height: 30px; background-color: green"
onclick="window.clicked=true"></button>
</div>
`);
await page.click('#target', { __testHookBeforeHitTarget: () => new Promise(f => setTimeout(f, 1000)) });
expect(await page.evaluate(() => window.clicked)).toBe(true);
});
it.skip(true)('should defer timers', async({page}) => {
// This test requires pausing the page.
await page.setContent(`<button id=button onclick="window.clicked=true">Click me</button>`);
await page.click('button', { __testHookBeforeHitTarget: async () => {
// Schedule a timer that hides the element
await page.evaluate(() => setTimeout(() => button.style.display = 'none', 0));
// Allow enough time for timer to fire
await page.waitForTimeout(500);
}});
expect(await page.evaluate(() => window.clicked)).toBe(true);
});
it.skip(true)('should defer rafs', async({page}) => {
// This test requires pausing the page.
await page.setContent(`<button id=button onclick="window.clicked=true">Click me</button>`);
await page.click('button', { __testHookBeforeHitTarget: async () => {
// Schedule a timer that hides the element
await page.evaluate(() => requestAnimationFrame(() => button.style.display = 'none'));
// Allow enough time for raf to fire
await page.waitForTimeout(500);
}});
expect(await page.evaluate(() => window.clicked)).toBe(true);
});
it.skip(true)('should defer fetch', async({page, server}) => {
// This test requires pausing the page.
await page.goto(server.EMPTY_PAGE);
await page.setContent(`<button id=button onclick="window.clicked=true">Click me</button>`);
await page.click('button', { __testHookBeforeHitTarget: async () => {
// Fetch that would immediately delete button.
page.evaluate(() => fetch(window.location.href).then(() => button.style.display = 'none'));
// Allow enough time for raf to fire
await page.waitForTimeout(500);
}});
expect(await page.evaluate(() => window.clicked)).toBe(true);
});
it('should dispatch microtasks in order', async({page, server}) => {
await page.setContent(`
<button id=button>Click me</button>