feat: expose executeJavaScriptInIsolatedWorld on webContents (#21190)
* feat: expose executeJavaScriptInIsolatedWorld on webContents * Apply suggestions from code review Co-Authored-By: loc <andy@slack-corp.com>
This commit is contained in:
parent
a7c2f79a94
commit
34452ee69e
3 changed files with 43 additions and 12 deletions
|
@ -214,6 +214,23 @@ describe('webContents module', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('webContents.executeJavaScriptInIsolatedWorld', () => {
|
||||
let w: BrowserWindow
|
||||
|
||||
before(async () => {
|
||||
w = new BrowserWindow({ show: false, webPreferences: { contextIsolation: true } })
|
||||
await w.loadURL('about:blank')
|
||||
})
|
||||
|
||||
it('resolves the returned promise with the result', async () => {
|
||||
await w.webContents.executeJavaScriptInIsolatedWorld(999, [{ code: 'window.X = 123' }])
|
||||
const isolatedResult = await w.webContents.executeJavaScriptInIsolatedWorld(999, [{ code: 'window.X' }])
|
||||
const mainWorldResult = await w.webContents.executeJavaScript('window.X')
|
||||
expect(isolatedResult).to.equal(123)
|
||||
expect(mainWorldResult).to.equal(undefined)
|
||||
})
|
||||
})
|
||||
|
||||
describe('loadURL() promise API', () => {
|
||||
let w: BrowserWindow
|
||||
beforeEach(async () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue