Don't log blocked messages when guestWindow is null
This commit is contained in:
parent
04c68745db
commit
92577c37c8
1 changed files with 15 additions and 6 deletions
|
@ -188,7 +188,9 @@ ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_OPEN', function (event, url, fr
|
|||
|
||||
ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_CLOSE', function (event, guestId) {
|
||||
const guestWindow = getGuestWindow(guestId)
|
||||
if (guestWindow != null && canAccessWindow(event.sender, guestWindow.webContents)) {
|
||||
if (guestWindow == null) return
|
||||
|
||||
if (canAccessWindow(event.sender, guestWindow.webContents)) {
|
||||
guestWindow.destroy()
|
||||
} else {
|
||||
console.error(`Blocked ${event.sender.getURL()} from closing its opener.`)
|
||||
|
@ -197,10 +199,15 @@ ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_CLOSE', function (event, guestI
|
|||
|
||||
ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_METHOD', function (event, guestId, method, ...args) {
|
||||
const guestWindow = getGuestWindow(guestId)
|
||||
if (guestWindow != null && canAccessWindow(event.sender, guestWindow.webContents)) {
|
||||
if (guestWindow == null) {
|
||||
event.returnValue = null
|
||||
return
|
||||
}
|
||||
|
||||
if (canAccessWindow(event.sender, guestWindow.webContents)) {
|
||||
event.returnValue = guestWindow[method].apply(guestWindow, args)
|
||||
} else {
|
||||
console.error(`Blocked ${event.sender.getURL()} from calling ${method} of its opener.`)
|
||||
console.error(`Blocked ${event.sender.getURL()} from calling ${method} on its opener.`)
|
||||
event.returnValue = null
|
||||
}
|
||||
})
|
||||
|
@ -211,7 +218,7 @@ ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', function (event,
|
|||
|
||||
// The W3C does not seem to have word on how postMessage should work when the
|
||||
// origins do not match, so we do not do |canAccessWindow| check here since
|
||||
// postMessage across origins is usefull and not harmful.
|
||||
// postMessage across origins is useful and not harmful.
|
||||
if (guestContents.getURL().indexOf(targetOrigin) === 0 || targetOrigin === '*') {
|
||||
const sourceId = event.sender.id
|
||||
guestContents.send('ELECTRON_GUEST_WINDOW_POSTMESSAGE', sourceId, message, sourceOrigin)
|
||||
|
@ -220,9 +227,11 @@ ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', function (event,
|
|||
|
||||
ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', function (event, guestId, method, ...args) {
|
||||
const guestContents = webContents.fromId(guestId)
|
||||
if (guestContents != null && canAccessWindow(event.sender, guestContents)) {
|
||||
if (guestContents == null) return
|
||||
|
||||
if (canAccessWindow(event.sender, guestContents)) {
|
||||
guestContents[method].apply(guestContents, args)
|
||||
} else {
|
||||
console.error(`Blocked ${event.sender.getURL()} from calling ${method} of its opener.`)
|
||||
console.error(`Blocked ${event.sender.getURL()} from calling ${method} on its opener.`)
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue