fix: <webview> not working with contextIsolation + sandbox (#16469)

This commit is contained in:
Milan Burda 2019-01-22 02:08:16 +01:00 committed by Cheng Zhao
parent a9ac75c1f9
commit b965e54efc
8 changed files with 164 additions and 82 deletions

View file

@ -105,8 +105,12 @@ function preloadRequire (module) {
throw new Error('module not found')
}
// Process command line arguments.
const { hasSwitch } = process.atomBinding('command_line')
const isBackgroundPage = hasSwitch('background-page')
const contextIsolation = hasSwitch('context-isolation')
switch (window.location.protocol) {
case 'chrome-devtools:': {
// Override some inspector APIs.
@ -115,22 +119,15 @@ switch (window.location.protocol) {
}
case 'chrome-extension:': {
// Inject the chrome.* APIs that chrome extensions require
const isBackgroundPage = hasSwitch('background-page')
require('@electron/internal/renderer/chrome-api').injectTo(window.location.hostname, isBackgroundPage, window)
break
}
}
if (binding.guestInstanceId) {
process.guestInstanceId = parseInt(binding.guestInstanceId)
}
const guestInstanceId = binding.guestInstanceId && parseInt(binding.guestInstanceId)
// Don't allow recursive `<webview>`.
if (!process.guestInstanceId && isWebViewTagEnabled) {
const webViewImpl = require('@electron/internal/renderer/web-view/web-view-impl')
const { setupWebView } = require('@electron/internal/renderer/web-view/web-view-element')
setupWebView(v8Util, webViewImpl)
}
// Load webview tag implementation.
require('@electron/internal/renderer/web-view/web-view-init')(contextIsolation, isWebViewTagEnabled, guestInstanceId)
const errorUtils = require('@electron/internal/common/error-utils')