chore: release from pause when the page closes (#19975)

Fixes: https://github.com/microsoft/playwright/issues/19168
This commit is contained in:
Pavel Feldman 2023-01-09 18:49:18 -08:00 committed by GitHub
parent 8f62aa9335
commit 3f0adf5dd0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View file

@ -1,6 +1,7 @@
/* eslint-disable notice/notice */
import { test, expect, Page } from '@playwright/test';
import { test, expect } from '@playwright/test';
import type { Page } from '@playwright/test';
test.describe.configure({ mode: 'parallel' });
@ -396,8 +397,7 @@ test.describe('Routing', () => {
await expect(page.getByRole('link', { name: 'All' })).toHaveClass('selected');
await page.getByRole('link', { name: 'Active' }).click();
// Page change - active items.
await expect(page.getByRole('link', { name: 'Active' })).
toHaveClass('selected');
await expect(page.getByRole('link', { name: 'Active' })).toHaveClass('selected');
await page.getByRole('link', { name: 'Completed' }).click();
// Page change - completed items.
await expect(page.getByRole('link', { name: 'Completed' })).toHaveClass('selected');

View file

@ -697,8 +697,12 @@ export class Page extends ChannelOwner<channels.PageChannel> implements api.Page
}
async pause() {
if (!require('inspector').url())
await this.context()._channel.pause();
if (require('inspector').url())
return;
await Promise.race([
this.context()._channel.pause(),
this._closedOrCrashedPromise
]);
}
async pdf(options: PDFOptions = {}): Promise<Buffer> {