Add test for nativeWindowOpen + contextIsolation

This commit is contained in:
Ryohei Ikegami 2017-04-30 19:09:52 +09:00
parent edeac2f59e
commit 0034b306f5
3 changed files with 37 additions and 0 deletions

View file

@ -1122,6 +1122,28 @@ describe('BrowserWindow module', function () {
})
})
describe('nativeWindowOpen + contextIsolation options', () => {
beforeEach(() => {
w.destroy()
w = new BrowserWindow({
show: false,
webPreferences: {
nativeWindowOpen: true,
contextIsolation: true,
preload: path.join(fixtures, 'api', 'native-window-open-isolated-preload.js')
}
})
})
it('opens window with cross-scripting enabled from isolated context', (done) => {
ipcMain.once('answer', (event, content) => {
assert.equal(content, 'Hello')
done()
})
w.loadURL('file://' + path.join(fixtures, 'api', 'native-window-open-isolated.html'))
})
})
describe('beforeunload handler', function () {
it('returning undefined would not prevent close', function (done) {
w.once('closed', function () {

View file

@ -0,0 +1,5 @@
const {ipcRenderer} = require('electron')
window.addEventListener('message', (event) => {
ipcRenderer.send('answer', event.data)
})

View file

@ -0,0 +1,10 @@
<html>
<body>
<script type="text/javascript" charset="utf-8">
const popup = window.open();
popup.document.write('<h1>Hello</h1>');
const content = popup.document.querySelector('h1').innerText;
window.postMessage(content, '*');
</script>
</body>
</html>