mirror of
https://github.com/electron/electron.git
synced 2026-05-02 03:00:22 -04:00
fix: regressions introduced by adding world isolation to Chrome extension content scripts (#17422)
This commit is contained in:
committed by
Alexey Kuzmin
parent
2fb9085e5b
commit
53f4af7722
@@ -7,9 +7,11 @@ const { EventEmitter } = require('events')
|
||||
process.electronBinding = require('@electron/internal/common/atom-binding-setup').electronBindingSetup(nodeProcess.binding, 'renderer')
|
||||
|
||||
const v8Util = process.electronBinding('v8_util')
|
||||
|
||||
// The `lib/renderer/ipc-renderer-internal.js` module looks for the ipc object in the
|
||||
// "ipc-internal" hidden value
|
||||
v8Util.setHiddenValue(global, 'ipc-internal', new EventEmitter())
|
||||
v8Util.setHiddenValue(global, 'ipc-internal', v8Util.getHiddenValue(isolatedWorld, 'ipc-internal'))
|
||||
|
||||
// The process object created by browserify is not an event emitter, fix it so
|
||||
// the API is more compatible with non-sandboxed renderers.
|
||||
for (const prop of Object.keys(EventEmitter.prototype)) {
|
||||
|
||||
@@ -45,7 +45,7 @@ const runContentScript = function (this: any, extensionId: string, url: string,
|
||||
})
|
||||
|
||||
const sources = [{ code, url }]
|
||||
webFrame.executeJavaScriptInIsolatedWorld(worldId, sources)
|
||||
return webFrame.executeJavaScriptInIsolatedWorld(worldId, sources)
|
||||
}
|
||||
|
||||
const runAllContentScript = function (scripts: Array<Electron.InjectionBase>, extensionId: string) {
|
||||
@@ -102,8 +102,9 @@ ipcRendererInternal.on('CHROME_TABS_EXECUTESCRIPT', function (
|
||||
url: string,
|
||||
code: string
|
||||
) {
|
||||
const result = runContentScript.call(window, extensionId, url, code)
|
||||
ipcRendererInternal.sendToAll(senderWebContentsId, `CHROME_TABS_EXECUTESCRIPT_RESULT_${requestId}`, result)
|
||||
runContentScript.call(window, extensionId, url, code).then(result => {
|
||||
ipcRendererInternal.sendToAll(senderWebContentsId, `CHROME_TABS_EXECUTESCRIPT_RESULT_${requestId}`, result)
|
||||
})
|
||||
})
|
||||
|
||||
module.exports = (getRenderProcessPreferences: typeof process.getRenderProcessPreferences) => {
|
||||
|
||||
Reference in New Issue
Block a user