Skip to content

Commit

Permalink
test: fulfill/continue/fallback do not throw if page has been closed
Browse files Browse the repository at this point in the history
Reference microsoft#23781
  • Loading branch information
yury-s committed Dec 15, 2023
1 parent f8d0204 commit d6b4e5d
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/page/page-route.spec.ts
Expand Up @@ -1198,3 +1198,45 @@ it('page.close does not wait for active route handlers with noWaitForFinish: tru
await new Promise(f => setTimeout(f, 500));
expect(secondHandlerCalled).toBe(false);
});

it('route.continue should not throw if page has been closed', async ({ page, server }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/23781' });
let routeCallback;
const routePromise = new Promise<Route>(f => routeCallback = f);
await page.route(/.*/, async route => {
routeCallback(route);
});
page.goto(server.EMPTY_PAGE).catch(() => {});
const route = await routePromise;
await page.close();
// Should not throw.
await route.continue();
});

it('route.fallback should not throw if page has been closed', async ({ page, server }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/23781' });
let routeCallback;
const routePromise = new Promise<Route>(f => routeCallback = f);
await page.route(/.*/, async route => {
routeCallback(route);
});
page.goto(server.EMPTY_PAGE).catch(() => {});
const route = await routePromise;
await page.close();
// Should not throw.
await route.fallback();
});

it('route.fulfill should not throw if page has been closed', async ({ page, server }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/23781' });
let routeCallback;
const routePromise = new Promise<Route>(f => routeCallback = f);
await page.route(/.*/, async route => {
routeCallback(route);
});
page.goto(server.EMPTY_PAGE).catch(() => {});
const route = await routePromise;
await page.close();
// Should not throw.
await route.fulfill();
});

0 comments on commit d6b4e5d

Please sign in to comment.