Remove guest from will-attach-webview event

This commit is contained in:
Kevin Sawicki 2017-02-09 11:47:40 -08:00
parent acff2f6baf
commit a7c050107b
4 changed files with 3 additions and 4 deletions

View file

@ -507,7 +507,6 @@ Emitted when the devtools window instructs the webContents to reload
Returns: Returns:
* `event` Event * `event` Event
* `guest` WebContents - The contents of the guest page.
* `webPreferences` Object - The web preferences that will be used by the guest * `webPreferences` Object - The web preferences that will be used by the guest
page. This object can be modified to adjust the preferences for the guest page. This object can be modified to adjust the preferences for the guest
page. page.

View file

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

View file

@ -255,7 +255,7 @@ ipcMain.on('prevent-next-will-attach-webview', (event) => {
}) })
ipcMain.on('disable-node-on-next-will-attach-webview', (event, id) => { ipcMain.on('disable-node-on-next-will-attach-webview', (event, id) => {
event.sender.once('will-attach-webview', (event, guest, webPreferences, params) => { event.sender.once('will-attach-webview', (event, webPreferences, params) => {
params.src = `file://${path.join(__dirname, '..', 'fixtures', 'pages', 'c.html')}` params.src = `file://${path.join(__dirname, '..', 'fixtures', 'pages', 'c.html')}`
webPreferences.nodeIntegration = false webPreferences.nodeIntegration = false
}) })

View file

@ -1100,7 +1100,7 @@ describe('<webview> tag', function () {
w.loadURL('file://' + fixtures + '/pages/webview-visibilitychange.html') w.loadURL('file://' + fixtures + '/pages/webview-visibilitychange.html')
}) })
describe('will-attach-webview event', () => { describe.only('will-attach-webview event', () => {
it('supports changing the web preferences', (done) => { it('supports changing the web preferences', (done) => {
ipcRenderer.send('disable-node-on-next-will-attach-webview') ipcRenderer.send('disable-node-on-next-will-attach-webview')
webview.addEventListener('console-message', (event) => { webview.addEventListener('console-message', (event) => {