fix: exceptions in nested conversions live in the target world (#37895)
This commit is contained in:
parent
1e206deec3
commit
6958668448
5 changed files with 46 additions and 30 deletions
|
@ -806,6 +806,14 @@ describe('contextBridge', () => {
|
|||
throwNotClonable: () => {
|
||||
return Object(Symbol('foo'));
|
||||
},
|
||||
throwNotClonableNestedArray: () => {
|
||||
return [Object(Symbol('foo'))];
|
||||
},
|
||||
throwNotClonableNestedObject: () => {
|
||||
return {
|
||||
bad: Object(Symbol('foo'))
|
||||
};
|
||||
},
|
||||
argumentConvert: () => {}
|
||||
});
|
||||
});
|
||||
|
@ -821,10 +829,12 @@ describe('contextBridge', () => {
|
|||
const normalIsError = Object.getPrototypeOf(getError(root.example.throwNormal)) === Error.prototype;
|
||||
const weirdIsError = Object.getPrototypeOf(getError(root.example.throwWeird)) === Error.prototype;
|
||||
const notClonableIsError = Object.getPrototypeOf(getError(root.example.throwNotClonable)) === Error.prototype;
|
||||
const notClonableNestedArrayIsError = Object.getPrototypeOf(getError(root.example.throwNotClonableNestedArray)) === Error.prototype;
|
||||
const notClonableNestedObjectIsError = Object.getPrototypeOf(getError(root.example.throwNotClonableNestedObject)) === Error.prototype;
|
||||
const argumentConvertIsError = Object.getPrototypeOf(getError(() => root.example.argumentConvert(Object(Symbol('test'))))) === Error.prototype;
|
||||
return [normalIsError, weirdIsError, notClonableIsError, argumentConvertIsError];
|
||||
return [normalIsError, weirdIsError, notClonableIsError, notClonableNestedArrayIsError, notClonableNestedObjectIsError, argumentConvertIsError];
|
||||
});
|
||||
expect(result).to.deep.equal([true, true, true, true], 'should all be errors in the current context');
|
||||
expect(result).to.deep.equal([true, true, true, true, true, true], 'should all be errors in the current context');
|
||||
});
|
||||
|
||||
it('should not leak prototypes', async () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue