spec: WebView is disabled when nodeIntegration is disabled
This commit is contained in:
parent
c1399f9bdc
commit
0140015500
2 changed files with 30 additions and 2 deletions
5
spec/fixtures/module/preload-webview.js
vendored
Normal file
5
spec/fixtures/module/preload-webview.js
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
const {ipcRenderer} = require('electron')
|
||||
|
||||
window.onload = function () {
|
||||
ipcRenderer.send('webview', typeof WebView)
|
||||
}
|
|
@ -8,7 +8,9 @@ describe('<webview> tag', function () {
|
|||
this.timeout(20000)
|
||||
|
||||
var fixtures = path.join(__dirname, 'fixtures')
|
||||
|
||||
var webview = null
|
||||
let w = null
|
||||
|
||||
beforeEach(function () {
|
||||
webview = new WebView()
|
||||
|
@ -18,17 +20,38 @@ describe('<webview> tag', function () {
|
|||
if (document.body.contains(webview)) {
|
||||
document.body.removeChild(webview)
|
||||
}
|
||||
if (w) {
|
||||
w.destroy()
|
||||
w = null
|
||||
}
|
||||
})
|
||||
|
||||
it('works without script tag in page', function (done) {
|
||||
let w = new BrowserWindow({show: false})
|
||||
w = new BrowserWindow({show: false})
|
||||
ipcMain.once('pong', function () {
|
||||
w.destroy()
|
||||
done()
|
||||
})
|
||||
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')
|
||||
})
|
||||
|
||||
describe('src attribute', function () {
|
||||
it('specifies the page to load', function (done) {
|
||||
webview.addEventListener('console-message', function (e) {
|
||||
|
|
Loading…
Add table
Reference in a new issue