Skip to content

Commit 0fffd35

Browse files
authored
Sandbox: Enable on Insiders by default (fix #156440) (#156733)
* Sandbox: Enable on Insiders by default (fix #156440) * fix tests
1 parent 887536f commit 0fffd35

File tree

7 files changed

+27
-5
lines changed

7 files changed

+27
-5
lines changed

src/vs/code/electron-sandbox/issue/issueReporterModel.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export interface IssueReporterData {
3434
experimentInfo?: string;
3535
restrictedMode?: boolean;
3636
isUnsupported?: boolean;
37+
isSandboxed?: boolean;
3738
}
3839

3940
export class IssueReporterModel {
@@ -77,6 +78,7 @@ ${this.getExtensionVersion()}
7778
VS Code version: ${this._data.versionInfo && this._data.versionInfo.vscodeVersion}
7879
OS version: ${this._data.versionInfo && this._data.versionInfo.os}
7980
Modes:${modes.length ? ' ' + modes.join(', ') : ''}
81+
Sandboxed: ${this._data.isSandboxed ? 'Yes' : 'No'}
8082
${this.getRemoteOSes()}
8183
${this.getInfos()}
8284
<!-- generated by issue reporter -->`;

src/vs/code/test/electron-sandbox/issue/testReporterModel.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ undefined
3434
VS Code version: undefined
3535
OS version: undefined
3636
Modes:
37+
Sandboxed: No
3738
3839
Extensions: none
3940
<!-- generated by issue reporter -->`);
@@ -65,6 +66,7 @@ undefined
6566
VS Code version: undefined
6667
OS version: undefined
6768
Modes:
69+
Sandboxed: No
6870
6971
<details>
7072
<summary>System Info</summary>
@@ -109,6 +111,7 @@ undefined
109111
VS Code version: undefined
110112
OS version: undefined
111113
Modes:
114+
Sandboxed: No
112115
113116
<details>
114117
<summary>System Info</summary>
@@ -164,6 +167,7 @@ undefined
164167
VS Code version: undefined
165168
OS version: undefined
166169
Modes:
170+
Sandboxed: No
167171
168172
<details>
169173
<summary>System Info</summary>
@@ -221,6 +225,7 @@ undefined
221225
VS Code version: undefined
222226
OS version: undefined
223227
Modes:
228+
Sandboxed: No
224229
Remote OS version: Linux x64 4.18.0
225230
226231
<details>
@@ -270,6 +275,7 @@ undefined
270275
VS Code version: undefined
271276
OS version: undefined
272277
Modes:
278+
Sandboxed: No
273279
274280
<details>
275281
<summary>System Info</summary>
@@ -301,6 +307,7 @@ undefined
301307
VS Code version: undefined
302308
OS version: undefined
303309
Modes: Restricted, Unsupported
310+
Sandboxed: No
304311
305312
Extensions: none
306313
<!-- generated by issue reporter -->`);

src/vs/platform/issue/common/issue.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export interface IssueReporterData extends WindowData {
6060
experiments?: string;
6161
restrictedMode: boolean;
6262
isUnsupported: boolean;
63+
isSandboxed: boolean; // TODO@bpasero remove me once sandbox is final
6364
githubAccessToken: string;
6465
readonly issueTitle?: string;
6566
readonly issueBody?: string;

src/vs/platform/windows/electron-main/window.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import { Color } from 'vs/base/common/color';
4242
import { IPolicyService } from 'vs/platform/policy/common/policy';
4343
import { IUserDataProfile, IUserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';
4444
import { revive } from 'vs/base/common/marshalling';
45+
import product from 'vs/platform/product/common/product';
4546

4647
export interface IWindowCreationOptions {
4748
state: IWindowState;
@@ -189,6 +190,13 @@ export class CodeWindow extends Disposable implements ICodeWindow {
189190

190191
const windowSettings = this.configurationService.getValue<IWindowSettings | undefined>('window');
191192

193+
let useSandbox = false;
194+
if (typeof windowSettings?.experimental?.useSandbox === 'boolean') {
195+
useSandbox = windowSettings.experimental.useSandbox;
196+
} else {
197+
useSandbox = typeof product.quality === 'string' && product.quality !== 'stable';
198+
}
199+
192200
const options: BrowserWindowConstructorOptions & { experimentalDarkMode: boolean } = {
193201
width: this.windowState.width,
194202
height: this.windowState.height,
@@ -209,7 +217,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
209217
// Enable experimental css highlight api https://chromestatus.com/feature/5436441440026624
210218
// Refs https://github.com/microsoft/vscode/issues/140098
211219
enableBlinkFeatures: 'HighlightAPI',
212-
...windowSettings?.experimental?.useSandbox ?
220+
...useSandbox ?
213221

214222
// Sandbox
215223
{

src/vs/workbench/electron-sandbox/desktop.contribution.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
2626
import { ShutdownReason } from 'vs/workbench/services/lifecycle/common/lifecycle';
2727
import { NativeWindow } from 'vs/workbench/electron-sandbox/window';
2828
import { ModifierKeyEmitter } from 'vs/base/browser/dom';
29+
import product from 'vs/platform/product/common/product';
2930

3031
// Actions
3132
(function registerActions(): void {
@@ -238,10 +239,10 @@ import { ModifierKeyEmitter } from 'vs/base/browser/dom';
238239
'description': localize('window.clickThroughInactive', "If enabled, clicking on an inactive window will both activate the window and trigger the element under the mouse if it is clickable. If disabled, clicking anywhere on an inactive window will activate it only and a second click is required on the element."),
239240
'included': isMacintosh
240241
},
241-
'window.experimental.useSandbox': {
242+
'window.experimental.useSandbox': { // TODO@bpasero remove me once sandbox is final
242243
type: 'boolean',
243244
description: localize('experimentalUseSandbox', "Experimental: When enabled, the window will have sandbox mode enabled via Electron API."),
244-
default: false,
245+
default: typeof product.quality === 'string' && product.quality !== 'stable', // disabled by default in stable for now
245246
'scope': ConfigurationScope.APPLICATION,
246247
ignoreSync: true
247248
},

src/vs/workbench/electron-sandbox/parts/dialogs/dialogHandler.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,16 @@ export class NativeDialogHandler implements IDialogHandler {
167167

168168
const detailString = (useAgo: boolean): string => {
169169
return localize({ key: 'aboutDetail', comment: ['Electron, Chromium, Node.js and V8 are product names that need no translation'] },
170-
"Version: {0}\nCommit: {1}\nDate: {2}\nElectron: {3}\nChromium: {4}\nNode.js: {5}\nV8: {6}\nOS: {7}",
170+
"Version: {0}\nCommit: {1}\nDate: {2}\nElectron: {3}\nChromium: {4}\nNode.js: {5}\nV8: {6}\nOS: {7}\nSandboxed: {8}",
171171
version,
172172
this.productService.commit || 'Unknown',
173173
this.productService.date ? `${this.productService.date}${useAgo ? ' (' + fromNow(new Date(this.productService.date), true) + ')' : ''}` : 'Unknown',
174174
process.versions['electron'],
175175
process.versions['chrome'],
176176
process.versions['node'],
177177
process.versions['v8'],
178-
`${osProps.type} ${osProps.arch} ${osProps.release}${isLinuxSnap ? ' snap' : ''}`
178+
`${osProps.type} ${osProps.arch} ${osProps.release}${isLinuxSnap ? ' snap' : ''}`,
179+
process.sandboxed ? 'Yes' : 'No' // TODO@bpasero remove me once sandbox is final
179180
);
180181
};
181182

src/vs/workbench/services/issue/electron-sandbox/issueService.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { IAuthenticationService } from 'vs/workbench/services/authentication/com
2121
import { registerMainProcessRemoteService } from 'vs/platform/ipc/electron-sandbox/services';
2222
import { IWorkspaceTrustManagementService } from 'vs/platform/workspace/common/workspaceTrust';
2323
import { IIntegrityService } from 'vs/workbench/services/integrity/common/integrity';
24+
import { process } from 'vs/base/parts/sandbox/electron-sandbox/globals';
2425

2526
export class WorkbenchIssueService implements IWorkbenchIssueService {
2627
declare readonly _serviceBrand: undefined;
@@ -101,6 +102,7 @@ export class WorkbenchIssueService implements IWorkbenchIssueService {
101102
restrictedMode: !this.workspaceTrustManagementService.isWorkspaceTrusted(),
102103
isUnsupported,
103104
githubAccessToken,
105+
isSandboxed: process.sandboxed
104106
}, dataOverrides);
105107
return this.issueService.openReporter(issueReporterData);
106108
}

0 commit comments

Comments
 (0)