feat: enable world safe JS by default (#26889)
* feat: enable world safe JS by default * refactor: use the ctx bridge to send executeJavaScript results in a world safe way * docs: add more info about the breaking change * include default in IsEnabled check
This commit is contained in:
parent
78d4cb9f5c
commit
db08f08b88
6 changed files with 90 additions and 33 deletions
|
@ -283,7 +283,7 @@ describe('contextBridge', () => {
|
|||
return err;
|
||||
}
|
||||
});
|
||||
expect(result).to.be.an.instanceOf(Error).with.property('message', 'Uncaught Error: i-rejected');
|
||||
expect(result).to.be.an.instanceOf(Error).with.property('message', 'i-rejected');
|
||||
});
|
||||
|
||||
it('should proxy nested promises and reject with the correct value', async () => {
|
||||
|
@ -300,7 +300,7 @@ describe('contextBridge', () => {
|
|||
return err;
|
||||
}
|
||||
});
|
||||
expect(result).to.be.an.instanceOf(Error).with.property('message', 'Uncaught Error: i-rejected');
|
||||
expect(result).to.be.an.instanceOf(Error).with.property('message', 'i-rejected');
|
||||
});
|
||||
|
||||
it('should proxy promises and resolve with the correct value if it resolves later', async () => {
|
||||
|
@ -862,6 +862,12 @@ describe('contextBridge', () => {
|
|||
getArr: () => [123, 'string', true, ['foo']],
|
||||
getPromise: async () => ({ number: 123, string: 'string', boolean: true, fn: () => 'string', arr: [123, 'string', true, ['foo']] }),
|
||||
getFunctionFromFunction: async () => () => null,
|
||||
getError: () => new Error('foo'),
|
||||
getWeirdError: () => {
|
||||
const e = new Error('foo');
|
||||
e.message = { garbage: true } as any;
|
||||
return e;
|
||||
},
|
||||
object: {
|
||||
number: 123,
|
||||
string: 'string',
|
||||
|
@ -921,6 +927,10 @@ describe('contextBridge', () => {
|
|||
[cleanedRoot.getFunctionFromFunction, Function],
|
||||
[cleanedRoot.getFunctionFromFunction(), Promise],
|
||||
[await cleanedRoot.getFunctionFromFunction(), Function],
|
||||
[cleanedRoot.getError(), Error],
|
||||
[cleanedRoot.getError().message, String],
|
||||
[cleanedRoot.getWeirdError(), Error],
|
||||
[cleanedRoot.getWeirdError().message, String],
|
||||
[cleanedRoot.getPromise(), Promise],
|
||||
[await cleanedRoot.getPromise(), Object],
|
||||
[(await cleanedRoot.getPromise()).number, Number],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue