Add spec for useNativeWindowOpen
This commit is contained in:
parent
319a7759d0
commit
6bbfe89f96
2 changed files with 28 additions and 0 deletions
|
@ -1069,6 +1069,23 @@ describe('BrowserWindow module', function () {
|
|||
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 () {
|
||||
|
|
11
spec/fixtures/api/native-window-open.html
vendored
Normal file
11
spec/fixtures/api/native-window-open.html
vendored
Normal 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>
|
Loading…
Reference in a new issue