Enable webview in sandbox renderer Security: Inherit embedder prefs onto webview

This commit is contained in:
Hari Juturu 2018-06-25 15:08:00 -07:00 committed by Electron Bot
parent 8585372e11
commit 32e40cb4c3
4 changed files with 50 additions and 1 deletions

View file

@ -240,6 +240,22 @@ const attachGuest = function (event, elementInstanceId, guestInstanceId, params)
webPreferences.disablePopups = true
}
// Security options that guest will always inherit from embedder
const inheritedWebPreferences = new Map([
['contextIsolation', true],
['javascript', false],
['nativeWindowOpen', true],
['nodeIntegration', false],
['sandbox', true]
])
// Inherit certain option values from embedder
for (const [name, value] of inheritedWebPreferences) {
if (embedder.getLastWebPreferences()[name] === value) {
webPreferences[name] = value
}
}
embedder.emit('will-attach-webview', event, webPreferences, params)
if (event.defaultPrevented) {
if (guest.viewInstanceId == null) guest.viewInstanceId = params.instanceId