fix: load window-setup in sandboxed renderer (#21416)
This commit is contained in:
parent
d56f67b7af
commit
31c93fec67
7 changed files with 89 additions and 61 deletions
|
@ -30,7 +30,13 @@ const { ipcRendererInternal } = require('@electron/internal/renderer/ipc-rendere
|
|||
const ipcRendererUtils = require('@electron/internal/renderer/ipc-renderer-internal-utils')
|
||||
|
||||
const {
|
||||
contentScripts, preloadScripts, isRemoteModuleEnabled, isWebViewTagEnabled, process: processProps
|
||||
contentScripts,
|
||||
preloadScripts,
|
||||
isRemoteModuleEnabled,
|
||||
isWebViewTagEnabled,
|
||||
guestInstanceId,
|
||||
openerId,
|
||||
process: processProps
|
||||
} = ipcRendererUtils.invokeSync('ELECTRON_BROWSER_SANDBOX_LOAD')
|
||||
|
||||
process.isRemoteModuleEnabled = isRemoteModuleEnabled
|
||||
|
@ -109,6 +115,11 @@ function preloadRequire (module) {
|
|||
const { hasSwitch } = process.electronBinding('command_line')
|
||||
|
||||
const contextIsolation = hasSwitch('context-isolation')
|
||||
const isHiddenPage = hasSwitch('hidden-page')
|
||||
const usesNativeWindowOpen = true
|
||||
|
||||
// The arguments to be passed to isolated world.
|
||||
const isolatedWorldArgs = { ipcRendererInternal, guestInstanceId, isHiddenPage, openerId, usesNativeWindowOpen }
|
||||
|
||||
switch (window.location.protocol) {
|
||||
case 'devtools:': {
|
||||
|
@ -127,6 +138,10 @@ switch (window.location.protocol) {
|
|||
break
|
||||
}
|
||||
default: {
|
||||
// Override default web functions.
|
||||
const { windowSetup } = require('@electron/internal/renderer/window-setup')
|
||||
windowSetup(guestInstanceId, openerId, isHiddenPage, usesNativeWindowOpen)
|
||||
|
||||
// Inject content scripts.
|
||||
if (!process.electronBinding('features').isExtensionsEnabled()) {
|
||||
require('@electron/internal/renderer/content-scripts-injector')(contentScripts)
|
||||
|
@ -134,14 +149,17 @@ switch (window.location.protocol) {
|
|||
}
|
||||
}
|
||||
|
||||
const guestInstanceId = binding.guestInstanceId && parseInt(binding.guestInstanceId)
|
||||
|
||||
// Load webview tag implementation.
|
||||
if (process.isMainFrame) {
|
||||
const { webViewInit } = require('@electron/internal/renderer/web-view/web-view-init')
|
||||
webViewInit(contextIsolation, isWebViewTagEnabled, guestInstanceId)
|
||||
}
|
||||
|
||||
// Pass the arguments to isolatedWorld.
|
||||
if (contextIsolation) {
|
||||
v8Util.setHiddenValue(global, 'isolated-world-args', isolatedWorldArgs)
|
||||
}
|
||||
|
||||
// Wrap the script into a function executed in global scope. It won't have
|
||||
// access to the current scope, so we'll expose a few objects as arguments:
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue