Add spec for useNativeWindowOpen

This commit is contained in:
Ryohei Ikegami 2017-03-19 18:11:20 +09:00
parent 319a7759d0
commit 6bbfe89f96
2 changed files with 28 additions and 0 deletions

View file

@ -1069,6 +1069,23 @@ describe('BrowserWindow module', function () {
w.loadURL('file://' + path.join(fixtures, 'pages', 'window-open.html')) w.loadURL('file://' + path.join(fixtures, 'pages', 'window-open.html'))
}) })
}) })
describe('useNativeWindowOpen option', () => {
it('allows synchronous access to window opened by window.open()', (done) => {
ipcMain.once('answer', function (event, content) {
assert.equal(content, 'Hello')
done()
})
w.destroy()
w = new BrowserWindow({
show: false,
webPreferences: {
nativeWindowOpen: true
}
})
w.loadURL('file://' + path.join(fixtures, 'api', 'native-window-open.html'))
})
})
}) })
describe('beforeunload handler', function () { describe('beforeunload handler', function () {

View file

@ -0,0 +1,11 @@
<html>
<body>
<script type="text/javascript" charset="utf-8">
const {ipcRenderer} = require("electron");
const otherWin = window.open();
otherWin.document.write("<h1>Hello</h1>");
const content = otherWin.document.querySelector("h1").innerText;
ipcRenderer.send('answer', content);
</script>
</body>
</html>