@vscode/test-web 0.0.27 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -5
- package/README.md +1 -0
- package/out/index.d.ts +4 -0
- package/out/index.js +17 -11
- package/out/server/app.js +19 -3
- package/out/server/workbench.js +4 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
|
-
|
|
2
|
+
## 0.0.28
|
|
3
|
+
* new option `--coi` to enable cross origin isolation.
|
|
3
4
|
|
|
4
5
|
## 0.0.22
|
|
5
|
-
* new option `--printServerLog` replacing `--hideServerLog
|
|
6
|
-
* new option `--browser` replacing `--browserType
|
|
6
|
+
* new option `--printServerLog` replacing `--hideServerLog`.
|
|
7
|
+
* new option `--browser` replacing `--browserType`.
|
|
7
8
|
|
|
8
9
|
## 0.0.20
|
|
9
|
-
* new option `--extensionId publisher.name[@prerelease]` to include one or more extensions
|
|
10
|
+
* new option `--extensionId publisher.name[@prerelease]` to include one or more extensions.
|
|
10
11
|
|
|
11
12
|
## 0.0.18
|
|
12
13
|
* new option `--browserType none` to start the server without opening a browser.
|
|
@@ -17,7 +18,7 @@
|
|
|
17
18
|
|
|
18
19
|
## 0.0.16
|
|
19
20
|
* new option `--sourcesPath`: If provided, runs the server from VS Code sources at the given location.
|
|
20
|
-
* option `--version` is deprecated and replaced with `quality`. Supported values: `stable`, `insiders`. Instead of `sources` use `--insiders
|
|
21
|
+
* option `--version` is deprecated and replaced with `quality`. Supported values: `stable`, `insiders`. Instead of `sources` use `--insiders`.
|
|
21
22
|
|
|
22
23
|
## 0.0.14
|
|
23
24
|
* new option `--extensionPath` : A path pointing to a folder containing additional extensions to include. Argument can be provided multiple times.
|
package/README.md
CHANGED
|
@@ -74,6 +74,7 @@ CLI options:
|
|
|
74
74
|
| --sourcesPath | If set, runs the server from VS Code sources located at the given path. Make sure the sources and extensions are compiled (`yarn compile` and `yarn compile-web`). |
|
|
75
75
|
| --headless | If set, hides the browser. Defaults to true when an extensionTestsPath is provided, otherwise false. |
|
|
76
76
|
| --permission | Permission granted to the opened browser: e.g. `clipboard-read`, `clipboard-write`. See [full list of options](https://playwright.dev/docs/api/class-browsercontext#browser-context-grant-permissions). Argument can be provided multiple times. |
|
|
77
|
+
| --coi | If set, enables cross origin isolation. Defaults to false. |
|
|
77
78
|
| --folder-uri | URI of the workspace to open VS Code on. Ignored when `folderPath` is provided. |
|
|
78
79
|
| --extensionPath | A path pointing to a folder containing additional extensions to include. Argument can be provided multiple times. |
|
|
79
80
|
| --extensionId | The id of an extension include. The format is `${publisher}.${name}`. Append `@prerelease` to use the prerelease version. |
|
package/out/index.d.ts
CHANGED
|
@@ -50,6 +50,10 @@ export interface Options {
|
|
|
50
50
|
* Do not show the browser. Defaults to `true` if a `extensionTestsPath` is provided, `false` otherwise.
|
|
51
51
|
*/
|
|
52
52
|
headless?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* If set, opens the page with cross origin isolation enabled.
|
|
55
|
+
*/
|
|
56
|
+
coi?: boolean;
|
|
53
57
|
/**
|
|
54
58
|
* @deprecated. Use `printServerLog` instead.
|
|
55
59
|
*/
|
package/out/index.js
CHANGED
|
@@ -27,7 +27,8 @@ async function runTests(options) {
|
|
|
27
27
|
folderMountPath: options.folderPath,
|
|
28
28
|
printServerLog: (_a = options.printServerLog) !== null && _a !== void 0 ? _a : options.hideServerLog === false,
|
|
29
29
|
extensionPaths: options.extensionPaths,
|
|
30
|
-
extensionIds: options.extensionIds
|
|
30
|
+
extensionIds: options.extensionIds,
|
|
31
|
+
coi: !!options.coi
|
|
31
32
|
};
|
|
32
33
|
const host = (_b = options.host) !== null && _b !== void 0 ? _b : 'localhost';
|
|
33
34
|
const port = (_c = options.port) !== null && _c !== void 0 ? _c : 3000;
|
|
@@ -84,7 +85,8 @@ async function open(options) {
|
|
|
84
85
|
folderMountPath: options.folderPath,
|
|
85
86
|
printServerLog: (_a = options.printServerLog) !== null && _a !== void 0 ? _a : options.hideServerLog === false,
|
|
86
87
|
extensionPaths: options.extensionPaths,
|
|
87
|
-
extensionIds: options.extensionIds
|
|
88
|
+
extensionIds: options.extensionIds,
|
|
89
|
+
coi: !!options.coi
|
|
88
90
|
};
|
|
89
91
|
const host = (_b = options.host) !== null && _b !== void 0 ? _b : 'localhost';
|
|
90
92
|
const port = (_c = options.port) !== null && _c !== void 0 ? _c : 3000;
|
|
@@ -180,7 +182,7 @@ function validatePrintServerLog(options) {
|
|
|
180
182
|
}
|
|
181
183
|
return false;
|
|
182
184
|
}
|
|
183
|
-
function
|
|
185
|
+
function validateBrowserType(options) {
|
|
184
186
|
const browserType = options.browser || options.browserType;
|
|
185
187
|
if (browserType === undefined) {
|
|
186
188
|
return 'chromium';
|
|
@@ -195,7 +197,7 @@ function valdiateBrowserType(options) {
|
|
|
195
197
|
showHelp();
|
|
196
198
|
process.exit(-1);
|
|
197
199
|
}
|
|
198
|
-
function
|
|
200
|
+
function validatePermissions(permissions) {
|
|
199
201
|
if (permissions === undefined) {
|
|
200
202
|
return undefined;
|
|
201
203
|
}
|
|
@@ -212,7 +214,7 @@ function valdiatePermissions(permissions) {
|
|
|
212
214
|
showHelp();
|
|
213
215
|
process.exit(-1);
|
|
214
216
|
}
|
|
215
|
-
async function
|
|
217
|
+
async function validateExtensionPaths(extensionPaths) {
|
|
216
218
|
if (extensionPaths === undefined) {
|
|
217
219
|
return undefined;
|
|
218
220
|
}
|
|
@@ -236,7 +238,7 @@ async function valdiateExtensionPaths(extensionPaths) {
|
|
|
236
238
|
process.exit(-1);
|
|
237
239
|
}
|
|
238
240
|
const EXTENSION_IDENTIFIER_PATTERN = /^([a-z0-9A-Z][a-z0-9-A-Z]*\.[a-z0-9A-Z][a-z0-9-A-Z]*)(@prerelease)?$/;
|
|
239
|
-
async function
|
|
241
|
+
async function validateExtensionIds(extensionIds) {
|
|
240
242
|
if (extensionIds === undefined) {
|
|
241
243
|
return undefined;
|
|
242
244
|
}
|
|
@@ -324,6 +326,7 @@ function showHelp() {
|
|
|
324
326
|
console.log(` --open-devtools: If set, opens the dev tools. [Optional]`);
|
|
325
327
|
console.log(` --headless: Whether to hide the browser. Defaults to true when an extensionTestsPath is provided, otherwise false. [Optional]`);
|
|
326
328
|
console.log(` --permission: Permission granted in the opened browser: e.g. 'clipboard-read', 'clipboard-write'. [Optional, Multiple]`);
|
|
329
|
+
console.log(` --coi: Enables cross origin isolation [Optional]`);
|
|
327
330
|
console.log(` --folder-uri: workspace to open VS Code on. Ignored when folderPath is provided. [Optional]`);
|
|
328
331
|
console.log(` --extensionPath: A path pointing to a folder containing additional extensions to include [Optional, Multiple]`);
|
|
329
332
|
console.log(` --extensionId: The id of an extension include. The format is '\${publisher}.\${name}'. Append '@prerelease' to use a prerelease version [Optional, Multiple]`);
|
|
@@ -340,7 +343,7 @@ async function cliMain() {
|
|
|
340
343
|
console.log(`${manifest.name}: ${manifest.version}`);
|
|
341
344
|
const options = {
|
|
342
345
|
string: ['extensionDevelopmentPath', 'extensionTestsPath', 'browser', 'browserType', 'quality', 'version', 'waitForDebugger', 'folder-uri', 'permission', 'extensionPath', 'extensionId', 'sourcesPath', 'host', 'port'],
|
|
343
|
-
boolean: ['open-devtools', 'headless', 'hideServerLog', 'printServerLog', 'help', 'verbose'],
|
|
346
|
+
boolean: ['open-devtools', 'headless', 'hideServerLog', 'printServerLog', 'help', 'verbose', 'coi'],
|
|
344
347
|
unknown: arg => {
|
|
345
348
|
if (arg.startsWith('-')) {
|
|
346
349
|
console.log(`Unknown argument ${arg}`);
|
|
@@ -355,20 +358,21 @@ async function cliMain() {
|
|
|
355
358
|
showHelp();
|
|
356
359
|
process.exit();
|
|
357
360
|
}
|
|
358
|
-
const browserType =
|
|
361
|
+
const browserType = validateBrowserType(args);
|
|
359
362
|
const extensionTestsPath = await validatePathOrUndefined(args, 'extensionTestsPath', true);
|
|
360
363
|
const extensionDevelopmentPath = await validatePathOrUndefined(args, 'extensionDevelopmentPath');
|
|
361
|
-
const extensionPaths = await
|
|
362
|
-
const extensionIds = await
|
|
364
|
+
const extensionPaths = await validateExtensionPaths(args.extensionPath);
|
|
365
|
+
const extensionIds = await validateExtensionIds(args.extensionId);
|
|
363
366
|
const vsCodeDevPath = await validatePathOrUndefined(args, 'sourcesPath');
|
|
364
367
|
const quality = validateQuality(args.quality, args.version, vsCodeDevPath);
|
|
365
368
|
const devTools = validateBooleanOrUndefined(args, 'open-devtools');
|
|
366
369
|
const headless = validateBooleanOrUndefined(args, 'headless');
|
|
367
|
-
const permissions =
|
|
370
|
+
const permissions = validatePermissions(args.permission);
|
|
368
371
|
const printServerLog = validatePrintServerLog(args);
|
|
369
372
|
const verbose = validateBooleanOrUndefined(args, 'verbose');
|
|
370
373
|
const port = validatePortNumber(args.port);
|
|
371
374
|
const host = validateStringOrUndefined(args, 'host');
|
|
375
|
+
const coi = validateBooleanOrUndefined(args, 'coi');
|
|
372
376
|
const waitForDebugger = validatePortNumber(args.waitForDebugger);
|
|
373
377
|
let folderUri = validateStringOrUndefined(args, 'folder-uri');
|
|
374
378
|
let folderPath;
|
|
@@ -400,6 +404,7 @@ async function cliMain() {
|
|
|
400
404
|
extensionIds,
|
|
401
405
|
vsCodeDevPath,
|
|
402
406
|
verbose,
|
|
407
|
+
coi,
|
|
403
408
|
host,
|
|
404
409
|
port
|
|
405
410
|
}).catch(e => {
|
|
@@ -423,6 +428,7 @@ async function cliMain() {
|
|
|
423
428
|
extensionIds,
|
|
424
429
|
vsCodeDevPath,
|
|
425
430
|
verbose,
|
|
431
|
+
coi,
|
|
426
432
|
host,
|
|
427
433
|
port
|
|
428
434
|
});
|
package/out/server/app.js
CHANGED
|
@@ -23,15 +23,31 @@ async function createApp(config) {
|
|
|
23
23
|
allowMethods: ['GET'],
|
|
24
24
|
credentials: true,
|
|
25
25
|
origin: (ctx) => {
|
|
26
|
-
if (/^https:\/\/[^.]+\.vscode-
|
|
26
|
+
if (/^https:\/\/[^.]+\.vscode-cdn\.net$/.test(ctx.get('Origin')) || // needed for the webviewContent
|
|
27
|
+
/^https:\/\/[^.]+\.vscode-webview\.net$/.test(ctx.get('Origin'))) {
|
|
27
28
|
return ctx.get('Origin');
|
|
28
29
|
}
|
|
29
30
|
return undefined;
|
|
30
31
|
},
|
|
31
32
|
}));
|
|
32
|
-
//
|
|
33
|
+
// CSP: frame-ancestors
|
|
33
34
|
app.use((ctx, next) => {
|
|
34
|
-
ctx.set('
|
|
35
|
+
ctx.set('Content-Security-Policy', `frame-ancestors 'none'`);
|
|
36
|
+
return next();
|
|
37
|
+
});
|
|
38
|
+
// COI
|
|
39
|
+
app.use((ctx, next) => {
|
|
40
|
+
const value = ctx.query['vscode-coi'];
|
|
41
|
+
if (value === '1') {
|
|
42
|
+
ctx.set('Cross-Origin-Opener-Policy', 'same-origin');
|
|
43
|
+
}
|
|
44
|
+
else if (value === '2') {
|
|
45
|
+
ctx.set('Cross-Origin-Embedder-Policy', 'require-corp');
|
|
46
|
+
}
|
|
47
|
+
else if (value === '3' || value === '') {
|
|
48
|
+
ctx.set('Cross-Origin-Opener-Policy', 'same-origin');
|
|
49
|
+
ctx.set('Cross-Origin-Embedder-Policy', 'require-corp');
|
|
50
|
+
}
|
|
35
51
|
return next();
|
|
36
52
|
});
|
|
37
53
|
// shift the line numbers of source maps in extensions by 2 as the content is wrapped by an anonymous function
|
package/out/server/workbench.js
CHANGED
|
@@ -117,6 +117,10 @@ function default_1(config) {
|
|
|
117
117
|
router.get('/', async (ctx) => {
|
|
118
118
|
const options = await getWorkbenchOptions(ctx, config);
|
|
119
119
|
ctx.body = await ctx.state.workbench.render(options);
|
|
120
|
+
if (config.coi) {
|
|
121
|
+
ctx.set('Cross-Origin-Opener-Policy', 'same-origin');
|
|
122
|
+
ctx.set('Cross-Origin-Embedder-Policy', 'require-corp');
|
|
123
|
+
}
|
|
120
124
|
});
|
|
121
125
|
return router.routes();
|
|
122
126
|
}
|