fix: errors thrown in functions over the contextBridge
(#28346)
* fix: errors thrown in functions over the contextBridge * spec: add a test * fix: ensure exception is a v8::Object
This commit is contained in:
parent
9a7cfc42aa
commit
9fecf8369f
2 changed files with 33 additions and 9 deletions
|
@ -364,6 +364,20 @@ describe('contextBridge', () => {
|
|||
expect(result).equal(true);
|
||||
});
|
||||
|
||||
it('should properly handle errors thrown in proxied functions', async () => {
|
||||
await makeBindingWindow(() => {
|
||||
contextBridge.exposeInMainWorld('example', () => { throw new Error('oh no'); });
|
||||
});
|
||||
const result = await callWithBindings(async (root: any) => {
|
||||
try {
|
||||
root.example();
|
||||
} catch (e) {
|
||||
return e.message;
|
||||
}
|
||||
});
|
||||
expect(result).equal('oh no');
|
||||
});
|
||||
|
||||
it('should proxy methods that are callable multiple times', async () => {
|
||||
await makeBindingWindow(() => {
|
||||
contextBridge.exposeInMainWorld('example', {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue