fix(binding): catch binding resolution against the closed page (#4583)
This commit is contained in:
parent
5002b83b4a
commit
7e30669eb0
|
|
@ -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(() => {});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue