new-webview -> will-attach-webview

This commit is contained in:
Kevin Sawicki 2017-02-03 12:55:37 -08:00
parent 7eda8fbdfb
commit 46f1a49594
3 changed files with 8 additions and 8 deletions

View file

@ -206,7 +206,7 @@ const attachGuest = function (event, elementInstanceId, guestInstanceId, params)
webPreferences.preloadURL = params.preload
}
event.sender.emit('new-webview', event, guest, webPreferences)
event.sender.emit('will-attach-webview', event, guest, webPreferences)
if (event.defaultPrevented) {
if (guest.viewInstanceId == null) guest.viewInstanceId = params.instanceId
destroyGuest(embedder, guestInstanceId)

View file

@ -250,12 +250,12 @@ ipcMain.on('prevent-next-new-window', (event, id) => {
webContents.fromId(id).once('new-window', event => event.preventDefault())
})
ipcMain.on('prevent-next-new-webview', (event) => {
event.sender.once('new-webview', event => event.preventDefault())
ipcMain.on('prevent-next-will-attach-webview', (event) => {
event.sender.once('will-attach-webview', event => event.preventDefault())
})
ipcMain.on('disable-node-on-next-new-webview', (event, id) => {
event.sender.once('new-webview', (event, guest, webPreferences) => {
ipcMain.on('disable-node-on-next-will-attach-webview', (event, id) => {
event.sender.once('will-attach-webview', (event, guest, webPreferences) => {
webPreferences.nodeIntegration = false
})
})

View file

@ -1100,9 +1100,9 @@ describe('<webview> tag', function () {
w.loadURL('file://' + fixtures + '/pages/webview-visibilitychange.html')
})
describe('new-webview event', () => {
describe('will-attach-webview event', () => {
it('supports changing the web preferences', (done) => {
ipcRenderer.send('disable-node-on-next-new-webview')
ipcRenderer.send('disable-node-on-next-will-attach-webview')
webview.addEventListener('console-message', (event) => {
assert.equal(event.message, 'undefined undefined undefined undefined')
done()
@ -1113,7 +1113,7 @@ describe('<webview> tag', function () {
})
it('supports preventing a webview from being created', (done) => {
ipcRenderer.send('prevent-next-new-webview')
ipcRenderer.send('prevent-next-will-attach-webview')
webview.addEventListener('destroyed', () => {
done()
})