2020-03-20 20:28:31 +00:00
|
|
|
'use strict';
|
2019-03-11 23:27:57 +00:00
|
|
|
|
|
|
|
/* global nodeProcess, isolatedWorld, worldId */
|
|
|
|
|
2020-03-20 20:28:31 +00:00
|
|
|
const { EventEmitter } = require('events');
|
2019-03-11 23:27:57 +00:00
|
|
|
|
2020-03-20 20:28:31 +00:00
|
|
|
process.electronBinding = require('@electron/internal/common/electron-binding-setup').electronBindingSetup(nodeProcess._linkedBinding, 'renderer');
|
2019-03-11 23:27:57 +00:00
|
|
|
|
2020-03-20 20:28:31 +00:00
|
|
|
const v8Util = process.electronBinding('v8_util');
|
2019-03-19 13:45:48 +00:00
|
|
|
|
2019-03-11 23:27:57 +00:00
|
|
|
// The `lib/renderer/ipc-renderer-internal.js` module looks for the ipc object in the
|
|
|
|
// "ipc-internal" hidden value
|
2020-03-20 20:28:31 +00:00
|
|
|
v8Util.setHiddenValue(global, 'ipc-internal', v8Util.getHiddenValue(isolatedWorld, 'ipc-internal'));
|
2019-03-19 13:45:48 +00:00
|
|
|
|
2019-06-02 20:03:03 +00:00
|
|
|
// The process object created by webpack is not an event emitter, fix it so
|
2019-03-11 23:27:57 +00:00
|
|
|
// the API is more compatible with non-sandboxed renderers.
|
|
|
|
for (const prop of Object.keys(EventEmitter.prototype)) {
|
2020-03-20 15:12:18 +00:00
|
|
|
if (Object.prototype.hasOwnProperty.call(process, prop)) {
|
2020-03-20 20:28:31 +00:00
|
|
|
delete process[prop];
|
2019-03-11 23:27:57 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-20 20:28:31 +00:00
|
|
|
Object.setPrototypeOf(process, EventEmitter.prototype);
|
2019-03-11 23:27:57 +00:00
|
|
|
|
2020-03-20 20:28:31 +00:00
|
|
|
const isolatedWorldArgs = v8Util.getHiddenValue(isolatedWorld, 'isolated-world-args');
|
2019-03-11 23:27:57 +00:00
|
|
|
|
|
|
|
if (isolatedWorldArgs) {
|
2020-03-20 20:28:31 +00:00
|
|
|
const { guestInstanceId, isHiddenPage, openerId, usesNativeWindowOpen, rendererProcessReuseEnabled } = isolatedWorldArgs;
|
|
|
|
const { windowSetup } = require('@electron/internal/renderer/window-setup');
|
|
|
|
windowSetup(guestInstanceId, openerId, isHiddenPage, usesNativeWindowOpen, rendererProcessReuseEnabled);
|
2019-03-11 23:27:57 +00:00
|
|
|
}
|
|
|
|
|
2020-03-20 20:28:31 +00:00
|
|
|
const extensionId = v8Util.getHiddenValue(isolatedWorld, `extension-${worldId}`);
|
2019-03-11 23:27:57 +00:00
|
|
|
|
|
|
|
if (extensionId) {
|
2020-03-20 20:28:31 +00:00
|
|
|
const chromeAPI = require('@electron/internal/renderer/chrome-api');
|
|
|
|
chromeAPI.injectTo(extensionId, window);
|
2019-03-11 23:27:57 +00:00
|
|
|
}
|