mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-02 14:31:31 +01:00
sandbox - prefer sandbox types over node.js types
This commit is contained in:
18
src/bootstrap.js
vendored
18
src/bootstrap.js
vendored
@@ -173,7 +173,7 @@
|
||||
/**
|
||||
* @returns {typeof import('./vs/base/parts/sandbox/electron-sandbox/globals') | undefined}
|
||||
*/
|
||||
function safeGlobals() {
|
||||
function safeSandboxGlobals() {
|
||||
const globals = (typeof self === 'object' ? self : typeof global === 'object' ? global : {});
|
||||
|
||||
return globals.vscode;
|
||||
@@ -183,13 +183,13 @@
|
||||
* @returns {import('./vs/base/parts/sandbox/electron-sandbox/globals').ISandboxNodeProcess | NodeJS.Process}
|
||||
*/
|
||||
function safeProcess() {
|
||||
if (typeof process !== 'undefined') {
|
||||
return process; // Native environment (non-sandboxed)
|
||||
const sandboxGlobals = safeSandboxGlobals();
|
||||
if (sandboxGlobals) {
|
||||
return sandboxGlobals.process; // Native environment (sandboxed)
|
||||
}
|
||||
|
||||
const globals = safeGlobals();
|
||||
if (globals) {
|
||||
return globals.process; // Native environment (sandboxed)
|
||||
if (typeof process !== 'undefined') {
|
||||
return process; // Native environment (non-sandboxed)
|
||||
}
|
||||
|
||||
return undefined;
|
||||
@@ -199,9 +199,9 @@
|
||||
* @returns {import('./vs/base/parts/sandbox/electron-sandbox/electronTypes').IpcRenderer | undefined}
|
||||
*/
|
||||
function safeIpcRenderer() {
|
||||
const globals = safeGlobals();
|
||||
if (globals) {
|
||||
return globals.ipcRenderer;
|
||||
const sandboxGlobals = safeSandboxGlobals();
|
||||
if (sandboxGlobals) {
|
||||
return sandboxGlobals.ipcRenderer;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
|
||||
Reference in New Issue
Block a user