From 46f1a49594467256d33328e2254aecb3a12c579e Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 3 Feb 2017 12:55:37 -0800 Subject: [PATCH] new-webview -> will-attach-webview --- lib/browser/guest-view-manager.js | 2 +- spec/static/main.js | 8 ++++---- spec/webview-spec.js | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/browser/guest-view-manager.js b/lib/browser/guest-view-manager.js index 95e4e0d47f8d..5a47a52747cd 100644 --- a/lib/browser/guest-view-manager.js +++ b/lib/browser/guest-view-manager.js @@ -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) diff --git a/spec/static/main.js b/spec/static/main.js index 735e7e8b5f83..0e89fad20df7 100644 --- a/spec/static/main.js +++ b/spec/static/main.js @@ -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 }) }) diff --git a/spec/webview-spec.js b/spec/webview-spec.js index 02354eb8633a..fb360db781f4 100644 --- a/spec/webview-spec.js +++ b/spec/webview-spec.js @@ -1100,9 +1100,9 @@ describe(' 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(' 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() })