fix(binding): catch binding resolution against the closed page (#4583)

This commit is contained in:
Pavel Feldman 2020-12-03 10:51:59 -08:00 committed by GitHub
parent 5002b83b4a
commit 7e30669eb0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View file

@ -649,9 +649,9 @@ export class BindingCall extends ChannelOwner<channels.BindingCallChannel, chann
result = await func(source, JSHandle.from(this._initializer.handle));
else
result = await func(source, ...this._initializer.args!.map(parseResult));
this._channel.resolve({ result: serializeArgument(result) });
this._channel.resolve({ result: serializeArgument(result) }).catch(() => {});
} catch (e) {
this._channel.reject({ error: serializeError(e) });
this._channel.reject({ error: serializeError(e) }).catch(() => {});
}
}
}

View file

@ -222,3 +222,12 @@ it('exposeBindingHandle should throw for multiple arguments', async ({page}) =>
}).catch(e => e);
expect(error.message).toContain('exposeBindingHandle supports a single argument, 2 received');
});
it('should not result in unhandled rejection', async ({page}) => {
await page.exposeFunction('foo', async () => {
await page.close();
});
await page.evaluate(() => {
(window as any).foo();
});
});