new-webview -> will-attach-webview
This commit is contained in:
parent
7eda8fbdfb
commit
46f1a49594
3 changed files with 8 additions and 8 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
})
|
||||
})
|
||||
|
|
|
@ -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()
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue