Add option to override webview security

This commit is contained in:
Hari Krishna Reddy Juturu 2017-05-06 22:10:42 -07:00
parent b4a8ed01f1
commit 94d054cf11
7 changed files with 64 additions and 2 deletions

View file

@ -8,7 +8,7 @@ const {closeWindow} = require('./window-helpers')
const isCI = remote.getGlobal('isCi')
describe('<webview> tag', function () {
describe.only('<webview> tag', function () {
this.timeout(3 * 60 * 1000)
var fixtures = path.join(__dirname, 'fixtures')
@ -36,6 +36,43 @@ describe('<webview> tag', function () {
w.loadURL('file://' + fixtures + '/pages/webview-no-script.html')
})
it('is disabled when nodeIntegration is disabled', function (done) {
w = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: false,
preload: path.join(fixtures, 'module', 'preload-webview.js')
}
})
ipcMain.once('webview', function (event, type) {
if (type === 'undefined') {
done()
} else {
done('WebView still exists')
}
})
w.loadURL('file://' + fixtures + '/pages/webview-no-script.html')
})
it('is enabled when override is set', function (done) {
w = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: false,
preload: path.join(fixtures, 'module', 'preload-webview.js'),
enableWebViewOverride: true
}
})
ipcMain.once('webview', function (event, type) {
if (type !== 'undefined') {
done()
} else {
done('WebView is not created')
}
})
w.loadURL('file://' + fixtures + '/pages/webview-no-script.html')
})
describe('src attribute', function () {
it('specifies the page to load', function (done) {
webview.addEventListener('console-message', function (e) {