fix(webkit): do not update console counter on unhandled rejections (#22890)

Fixes https://github.com/microsoft/playwright/issues/22886
This commit is contained in:
Pavel Feldman 2023-05-08 18:50:40 -07:00 committed by GitHub
parent 1f209204cd
commit 5fb426e7db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View file

@ -550,6 +550,7 @@ export class WKPage implements PageDelegate {
stack = '';
}
this._lastConsoleMessage = null;
const error = new Error(message);
error.stack = stack;
error.name = name;

View file

@ -145,3 +145,21 @@ it('should check the box using setChecked', async ({ page }) => {
await page.setChecked('input', false);
expect(await page.evaluate(() => window['checkbox'].checked)).toBe(false);
});
it('do not update console count on unhandled rejections', async ({ page }) => {
const messages: string[] = [];
const consoleEventListener = m => messages.push(m.text());
page.addListener('console', consoleEventListener);
await page.evaluate(() => {
const fail = async () => Promise.reject(new Error('error'));
console.log('begin');
fail();
fail();
fail().catch(() => {
console.log('end');
});
});
await expect.poll(() => messages).toEqual(['begin', 'end']);
});