|
@@ -288,6 +288,11 @@ ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_CLOSE', function (event, guestI
|
|
|
if (guestWindow != null) guestWindow.destroy()
|
|
|
})
|
|
|
|
|
|
+const windowMethods = new Set([
|
|
|
+ 'focus',
|
|
|
+ 'blur'
|
|
|
+])
|
|
|
+
|
|
|
ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_METHOD', function (event, guestId, method, ...args) {
|
|
|
const guestContents = webContents.fromId(guestId)
|
|
|
if (guestContents == null) {
|
|
@@ -295,7 +300,7 @@ ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_METHOD', function (event, guest
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if (!canAccessWindow(event.sender, guestContents)) {
|
|
|
+ if (!canAccessWindow(event.sender, guestContents) || !windowMethods.has(method)) {
|
|
|
console.error(`Blocked ${event.sender.getURL()} from calling ${method} on its opener.`)
|
|
|
event.returnValue = null
|
|
|
return
|
|
@@ -326,17 +331,27 @@ ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', function (event,
|
|
|
}
|
|
|
})
|
|
|
|
|
|
+const webContentsMethods = new Set([
|
|
|
+ 'print',
|
|
|
+ 'executeJavaScript'
|
|
|
+])
|
|
|
+
|
|
|
ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', function (event, guestId, method, ...args) {
|
|
|
const guestContents = webContents.fromId(guestId)
|
|
|
if (guestContents == null) return
|
|
|
|
|
|
- if (canAccessWindow(event.sender, guestContents)) {
|
|
|
+ if (canAccessWindow(event.sender, guestContents) && webContentsMethods.has(method)) {
|
|
|
guestContents[method](...args)
|
|
|
} else {
|
|
|
console.error(`Blocked ${event.sender.getURL()} from calling ${method} on its opener.`)
|
|
|
}
|
|
|
})
|
|
|
|
|
|
+const webContentsSyncMethods = new Set([
|
|
|
+ 'getURL',
|
|
|
+ 'loadURL'
|
|
|
+])
|
|
|
+
|
|
|
ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD_SYNC', function (event, guestId, method, ...args) {
|
|
|
const guestContents = webContents.fromId(guestId)
|
|
|
if (guestContents == null) {
|
|
@@ -344,7 +359,7 @@ ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD_SYNC', function (e
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if (canAccessWindow(event.sender, guestContents)) {
|
|
|
+ if (canAccessWindow(event.sender, guestContents) && webContentsSyncMethods.has(method)) {
|
|
|
event.returnValue = guestContents[method](...args)
|
|
|
} else {
|
|
|
console.error(`Blocked ${event.sender.getURL()} from calling ${method} on its opener.`)
|