Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/playwright-core/src/client/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import { ChannelOwner } from './channelOwner';
import { Page } from './page';
import { isTargetClosedError } from './errors';

import type * as api from '../../types/types';
import type * as channels from '@protocol/channels';
Expand Down Expand Up @@ -56,6 +57,12 @@ export class Dialog extends ChannelOwner<channels.DialogChannel> implements api.
}

async dismiss() {
await this._channel.dismiss();
try {
await this._channel.dismiss();
} catch (e) {
if (isTargetClosedError(e))
return;
throw e;
}
}
}
10 changes: 0 additions & 10 deletions tests/library/page-close.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@ test('should close page with active dialog', async ({ page }) => {
await page.close();
});

test('should not accept dialog after close', async ({ page, mode }) => {
test.fixme(mode.startsWith('service2'), 'Times out');
const promise = page.waitForEvent('dialog');
page.evaluate(() => alert()).catch(() => {});
const dialog = await promise;
await page.close();
const e = await dialog.dismiss().catch(e => e);
expect(e.message).toContain('Target page, context or browser has been closed');
});

test('expect should not print timed out error message when page closes', async ({ page }) => {
await page.setContent('<div id=node>Text content</div>');
const [error] = await Promise.all([
Expand Down
Loading