feat(dialog): handle dialogs (#212)

This commit is contained in:
Pavel Feldman
2025-04-17 14:03:13 -07:00
committed by GitHub
parent 4b261286bf
commit 6481100bdf
10 changed files with 461 additions and 15 deletions

View File

@@ -15,8 +15,9 @@
*/
import type * as playwright from 'playwright';
import type { Context } from '../context';
export async function waitForCompletion<R>(page: playwright.Page, callback: () => Promise<R>): Promise<R> {
export async function waitForCompletion<R>(context: Context, page: playwright.Page, callback: () => Promise<R>): Promise<R> {
const requests = new Set<playwright.Request>();
let frameNavigated = false;
let waitCallback: () => void = () => {};
@@ -62,7 +63,7 @@ export async function waitForCompletion<R>(page: playwright.Page, callback: () =
if (!requests.size && !frameNavigated)
waitCallback();
await waitBarrier;
await page.evaluate(() => new Promise(f => setTimeout(f, 1000)));
await context.waitForTimeout(1000);
return result;
} finally {
dispose();