Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: remove page pause support (#2431)
Dmitry Gozmande0bbd3031c5
diff --git a/src/chromium/crPage.ts b/src/chromium/crPage.tsindex 7c31c07f08..70b56a557b 100644--- a/src/chromium/crPage.ts+++ b/src/chromium/crPage.ts@@ -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._objectIddiff --git a/src/dom.ts b/src/dom.tsindex c777a1ef22..cea19877d0 100644--- a/src/dom.ts+++ b/src/dom.ts@@ -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');+ 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, '...done scrolling');+ this._page._log(inputLog, `...element does receive pointer events, continuing input action`);+ }- 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...');+ if (restoreModifiers)+ await this._page.keyboard._ensureModifiers(restoreModifiers);+ }, deadline, options, true);+ this._page._log(inputLog, '...navigations have finished');- 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);- }+ return 'done';}hover(options?: PointerActionOptions & types.PointerActionWaitOptions): Promise<void> {diff --git a/src/firefox/ffPage.ts b/src/firefox/ffPage.tsindex db7da349cd..406333abf8 100644--- a/src/firefox/ffPage.ts+++ b/src/firefox/ffPage.ts@@ -424,9 +424,6 @@ export class FFPage implements PageDelegate {});}- async setActivityPaused(paused: boolean): Promise<void> {- }-rafCountForStablePosition(): number {return 1;}diff --git a/src/page.ts b/src/page.tsindex eb20e9107f..c09664307a 100644--- a/src/page.ts+++ b/src/page.ts@@ -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}>;diff --git a/src/webkit/wkPage.ts b/src/webkit/wkPage.tsindex e56c65fdc0..a3700e160a 100644--- a/src/webkit/wkPage.ts+++ b/src/webkit/wkPage.ts@@ -762,9 +762,6 @@ export class WKPage implements PageDelegate {});}- async setActivityPaused(paused: boolean): Promise<void> {- }-rafCountForStablePosition(): number {return process.platform === 'win32' ? 5 : 1;}diff --git a/test/click.spec.js b/test/click.spec.jsindex 319855e921..54f4449819 100644--- a/test/click.spec.js+++ b/test/click.spec.js@@ -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>