fix: load the chrome.* API on chrome-extension pages in sandbox mode (#15563)
With mixed sandbox enabled we need to load the chrome.* APIs in the sandbox init.js so that chrome extensions load correctly. This mirrors the equivilant impl in `atom_renderer_client.cc` Fixes #15561
This commit is contained in:
parent
a68e3371f3
commit
0b0a17ff91
2 changed files with 20 additions and 5 deletions
|
@ -103,16 +103,25 @@ function preloadRequire (module) {
|
|||
throw new Error('module not found')
|
||||
}
|
||||
|
||||
if (window.location.protocol === 'chrome-devtools:') {
|
||||
// Override some inspector APIs.
|
||||
require('@electron/internal/renderer/inspector')
|
||||
switch (window.location.protocol) {
|
||||
case 'chrome-devtools:': {
|
||||
// Override some inspector APIs.
|
||||
require('@electron/internal/renderer/inspector')
|
||||
break
|
||||
}
|
||||
case 'chrome-extension:': {
|
||||
// Inject the chrome.* APIs that chrome extensions require
|
||||
const isBackgroundPage = preloadProcess.argv.includes('--background-page')
|
||||
require('@electron/internal/renderer/chrome-api').injectTo(window.location.hostname, isBackgroundPage, window)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (binding.guestInstanceId) {
|
||||
process.guestInstanceId = parseInt(binding.guestInstanceId)
|
||||
}
|
||||
|
||||
if (!process.guestInstanceId && preloadProcess.argv.indexOf('--webview-tag=true') !== -1) {
|
||||
if (!process.guestInstanceId && preloadProcess.argv.includes('--webview-tag=true')) {
|
||||
// don't allow recursive `<webview>`
|
||||
require('@electron/internal/renderer/web-view/web-view')
|
||||
require('@electron/internal/renderer/web-view/web-view-attributes')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue