|
@@ -130,7 +130,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.`)
|
|
@@ -139,10 +141,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
|
|
|
}
|
|
|
})
|
|
@@ -153,7 +160,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)
|
|
@@ -162,9 +169,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.`)
|
|
|
}
|
|
|
})
|