Add failing spec for webview nodeIntegration inheritance

This commit is contained in:
Kevin Sawicki 2016-03-30 10:33:15 -07:00
parent 4890734f66
commit fd12e1f506
2 changed files with 38 additions and 0 deletions

View file

@ -0,0 +1,9 @@
<html>
<body>
<script type="text/javascript" charset="utf-8">
var windowUrl = decodeURIComponent(window.location.search.substring(3))
window.open('file://' + windowUrl, '', 'nodeIntegration=yes,show=no')
console.log('window opened')
</script>
</body>
</html>

View file

@ -3,6 +3,9 @@ const path = require('path')
const http = require('http')
const url = require('url')
const {remote} = require('electron')
const {BrowserWindow} = remote
describe('<webview> tag', function () {
this.timeout(10000)
@ -74,6 +77,32 @@ describe('<webview> tag', function () {
document.body.appendChild(webview)
})
it('disables node integration on child windows when it is disabled on the webview', function (done) {
webview.addEventListener('console-message', function (e) {
assert.equal(e.message, 'window opened')
const sourceId = remote.getCurrentWindow().id
const windows = BrowserWindow.getAllWindows().filter(function (window) {
return window.id !== sourceId
})
assert.equal(windows.length, 1)
assert.equal(windows[0].webContents.getWebPreferences().nodeIntegration, false)
done()
})
webview.setAttribute('allowpopups', 'on')
webview.src = require('url').format({
pathname: `${fixtures}/pages/webview-opener-no-node-integration.html`,
protocol: 'file',
query: {
p: `${fixtures}/pages/window-opener-node.html`
},
slashes: true
})
document.body.appendChild(webview)
})
if (process.platform !== 'win32' || process.execPath.toLowerCase().indexOf('\\out\\d\\') === -1) {
it('loads native modules when navigation happens', function (done) {
var listener = function () {