Assert context state after reload
This commit is contained in:
parent
dacfb2f596
commit
33b6ab11f2
1 changed files with 39 additions and 7 deletions
|
@ -1836,9 +1836,18 @@ describe('BrowserWindow module', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('contextIsolation option', () => {
|
describe('contextIsolation option', () => {
|
||||||
it('separates the page context from the Electron/preload context', (done) => {
|
beforeEach(() => {
|
||||||
if (w != null) w.destroy()
|
if (w != null) w.destroy()
|
||||||
|
w = new BrowserWindow({
|
||||||
|
show: false,
|
||||||
|
webPreferences: {
|
||||||
|
contextIsolation: true,
|
||||||
|
preload: path.join(fixtures, 'api', 'isolated-preload.js')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('separates the page context from the Electron/preload context', (done) => {
|
||||||
ipcMain.once('isolated-world', (event, data) => {
|
ipcMain.once('isolated-world', (event, data) => {
|
||||||
assert.deepEqual(data, {
|
assert.deepEqual(data, {
|
||||||
preloadContext: {
|
preloadContext: {
|
||||||
|
@ -1862,13 +1871,36 @@ describe('BrowserWindow module', function () {
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
|
||||||
w = new BrowserWindow({
|
w.loadURL('file://' + fixtures + '/api/isolated.html')
|
||||||
show: false,
|
})
|
||||||
webPreferences: {
|
|
||||||
contextIsolation: true,
|
it('recreates the contexts on reload', (done) => {
|
||||||
preload: path.join(fixtures, 'api', 'isolated-preload.js')
|
w.webContents.once('did-finish-load', () => {
|
||||||
|
ipcMain.once('isolated-world', (event, data) => {
|
||||||
|
assert.deepEqual(data, {
|
||||||
|
preloadContext: {
|
||||||
|
preloadProperty: 'number',
|
||||||
|
pageProperty: 'undefined',
|
||||||
|
typeofRequire: 'function',
|
||||||
|
typeofProcess: 'object',
|
||||||
|
typeofArrayPush: 'function',
|
||||||
|
typeofFunctionApply: 'function'
|
||||||
|
},
|
||||||
|
pageContext: {
|
||||||
|
preloadProperty: 'undefined',
|
||||||
|
pageProperty: 'string',
|
||||||
|
typeofRequire: 'undefined',
|
||||||
|
typeofProcess: 'undefined',
|
||||||
|
typeofArrayPush: 'number',
|
||||||
|
typeofFunctionApply: 'boolean',
|
||||||
|
typeofPreloadExecuteJavaScriptProperty: 'number'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
|
||||||
|
w.webContents.reload()
|
||||||
|
})
|
||||||
w.loadURL('file://' + fixtures + '/api/isolated.html')
|
w.loadURL('file://' + fixtures + '/api/isolated.html')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue