@vscode/test-web 0.0.37 → 0.0.39
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/out/index.js +22 -9
- package/out/server/workbench.js +13 -2
- package/package.json +3 -3
- package/views/workbench-esm.html +3 -0
- package/views/workbench.html +3 -0
package/out/index.js
CHANGED
|
@@ -35,12 +35,16 @@ async function runTests(options) {
|
|
|
35
35
|
const server = await (0, main_1.runServer)(host, port, config);
|
|
36
36
|
return new Promise(async (s, e) => {
|
|
37
37
|
const endpoint = `http://${host}:${port}`;
|
|
38
|
-
|
|
39
|
-
const context = await openBrowser(endpoint, options);
|
|
40
|
-
if (context) {
|
|
38
|
+
const configContext = async (context) => {
|
|
41
39
|
context.once('close', () => server.close());
|
|
40
|
+
const unreportedOutput = [];
|
|
42
41
|
await context.exposeFunction('codeAutomationLog', (type, args) => {
|
|
43
|
-
|
|
42
|
+
try {
|
|
43
|
+
console[type](...args);
|
|
44
|
+
}
|
|
45
|
+
catch (_e) {
|
|
46
|
+
unreportedOutput.push({ type, args });
|
|
47
|
+
}
|
|
44
48
|
});
|
|
45
49
|
await context.exposeFunction('codeAutomationExit', async (code) => {
|
|
46
50
|
try {
|
|
@@ -49,6 +53,10 @@ async function runTests(options) {
|
|
|
49
53
|
catch (error) {
|
|
50
54
|
console.error(`Error when closing browser: ${error}`);
|
|
51
55
|
}
|
|
56
|
+
if (unreportedOutput.length) {
|
|
57
|
+
console.error(`There were ${unreportedOutput.length} messages that could not be reported to the console:`);
|
|
58
|
+
unreportedOutput.forEach(({ type, args }) => console[type](...args));
|
|
59
|
+
}
|
|
52
60
|
server.close();
|
|
53
61
|
if (code === 0) {
|
|
54
62
|
s();
|
|
@@ -57,8 +65,10 @@ async function runTests(options) {
|
|
|
57
65
|
e(new Error('Test failed'));
|
|
58
66
|
}
|
|
59
67
|
});
|
|
60
|
-
}
|
|
61
|
-
|
|
68
|
+
};
|
|
69
|
+
console.log(`Opening browser on ${endpoint}...`);
|
|
70
|
+
const context = await openBrowser(endpoint, options, configContext);
|
|
71
|
+
if (!context) {
|
|
62
72
|
server.close();
|
|
63
73
|
e(new Error('Can not run test as opening of browser failed.'));
|
|
64
74
|
}
|
|
@@ -93,8 +103,10 @@ async function open(options) {
|
|
|
93
103
|
const port = options.port ?? 3000;
|
|
94
104
|
const server = await (0, main_1.runServer)(host, port, config);
|
|
95
105
|
const endpoint = `http://${host}:${port}`;
|
|
96
|
-
const
|
|
97
|
-
|
|
106
|
+
const configContext = async (context) => {
|
|
107
|
+
context.once('close', () => server.close());
|
|
108
|
+
};
|
|
109
|
+
const context = await openBrowser(endpoint, options, configContext);
|
|
98
110
|
return {
|
|
99
111
|
dispose: () => {
|
|
100
112
|
server.close();
|
|
@@ -103,7 +115,7 @@ async function open(options) {
|
|
|
103
115
|
};
|
|
104
116
|
}
|
|
105
117
|
exports.open = open;
|
|
106
|
-
async function openBrowser(endpoint, options) {
|
|
118
|
+
async function openBrowser(endpoint, options, configureContext) {
|
|
107
119
|
if (options.browserType === 'none') {
|
|
108
120
|
return undefined;
|
|
109
121
|
}
|
|
@@ -125,6 +137,7 @@ async function openBrowser(endpoint, options) {
|
|
|
125
137
|
if (options.permissions) {
|
|
126
138
|
context.grantPermissions(options.permissions);
|
|
127
139
|
}
|
|
140
|
+
await configureContext(context);
|
|
128
141
|
// forcefully close browser if last page is closed. workaround for https://github.com/microsoft/playwright/issues/2946
|
|
129
142
|
let openPages = 0;
|
|
130
143
|
context.on('page', page => {
|
package/out/server/workbench.js
CHANGED
|
@@ -15,11 +15,12 @@ function asJSON(value) {
|
|
|
15
15
|
return JSON.stringify(value).replace(/"/g, '"');
|
|
16
16
|
}
|
|
17
17
|
class Workbench {
|
|
18
|
-
constructor(baseUrl, dev, esm, builtInExtensions = []) {
|
|
18
|
+
constructor(baseUrl, dev, esm, builtInExtensions = [], productOverrides = '') {
|
|
19
19
|
this.baseUrl = baseUrl;
|
|
20
20
|
this.dev = dev;
|
|
21
21
|
this.esm = esm;
|
|
22
22
|
this.builtInExtensions = builtInExtensions;
|
|
23
|
+
this.productOverrides = productOverrides;
|
|
23
24
|
}
|
|
24
25
|
async render(workbenchWebConfiguration) {
|
|
25
26
|
const values = {
|
|
@@ -27,6 +28,7 @@ class Workbench {
|
|
|
27
28
|
WORKBENCH_AUTH_SESSION: '',
|
|
28
29
|
WORKBENCH_WEB_BASE_URL: this.baseUrl,
|
|
29
30
|
WORKBENCH_BUILTIN_EXTENSIONS: asJSON(this.builtInExtensions),
|
|
31
|
+
WORKBENCH_PRODUCT_OVERRIDES: this.productOverrides,
|
|
30
32
|
WORKBENCH_MAIN: this.getMain()
|
|
31
33
|
};
|
|
32
34
|
try {
|
|
@@ -106,7 +108,8 @@ function default_1(config) {
|
|
|
106
108
|
router.use(async (ctx, next) => {
|
|
107
109
|
if (config.build.type === 'sources') {
|
|
108
110
|
const builtInExtensions = await (0, extensions_1.getScannedBuiltinExtensions)(config.build.location);
|
|
109
|
-
|
|
111
|
+
const productOverrides = await getProductOverridesContent(config.build.location);
|
|
112
|
+
ctx.state.workbench = new Workbench(`${ctx.protocol}://${ctx.host}/static/sources`, true, config.esm, builtInExtensions, productOverrides);
|
|
110
113
|
}
|
|
111
114
|
else if (config.build.type === 'static') {
|
|
112
115
|
ctx.state.workbench = new Workbench(`${ctx.protocol}://${ctx.host}/static/build`, false, config.esm);
|
|
@@ -130,3 +133,11 @@ function default_1(config) {
|
|
|
130
133
|
return router.routes();
|
|
131
134
|
}
|
|
132
135
|
exports.default = default_1;
|
|
136
|
+
async function getProductOverridesContent(vsCodeDevLocation) {
|
|
137
|
+
try {
|
|
138
|
+
return (await fs_1.promises.readFile(path.join(vsCodeDevLocation, 'product.overrides.json'))).toString();
|
|
139
|
+
}
|
|
140
|
+
catch (e) {
|
|
141
|
+
return '';
|
|
142
|
+
}
|
|
143
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vscode/test-web",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.39",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"install-extensions": "yarn --cwd=fs-provider && yarn --cwd=sample",
|
|
6
6
|
"compile": "tsc -p ./ && yarn compile-fs-provider",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"koa-mount": "^4.0.0",
|
|
31
31
|
"koa-static": "^5.0.0",
|
|
32
32
|
"minimist": "^1.2.8",
|
|
33
|
-
"playwright": "^1.32.
|
|
33
|
+
"playwright": "^1.32.2",
|
|
34
34
|
"vscode-uri": "^3.0.7",
|
|
35
35
|
"http-proxy-agent": "^5.0.0",
|
|
36
36
|
"https-proxy-agent": "^5.0.1",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@types/decompress": "^4.2.4",
|
|
52
52
|
"eslint": "^8.37.0",
|
|
53
53
|
"eslint-plugin-header": "^3.1.1",
|
|
54
|
-
"typescript": "^5.0.
|
|
54
|
+
"typescript": "^5.0.3"
|
|
55
55
|
},
|
|
56
56
|
"license": "MIT",
|
|
57
57
|
"author": "Visual Studio Code Team",
|
package/views/workbench-esm.html
CHANGED
|
@@ -25,6 +25,9 @@
|
|
|
25
25
|
<!-- Builtin Extensions (running out of sources) -->
|
|
26
26
|
<meta id="vscode-workbench-builtin-extensions" data-settings="{{WORKBENCH_BUILTIN_EXTENSIONS}}">
|
|
27
27
|
|
|
28
|
+
<!-- Product Overrides (running out of sources) -->
|
|
29
|
+
<meta id="vscode-workbench-product-overrides" data-settings="{{WORKBENCH_PRODUCT_OVERRIDES}}">
|
|
30
|
+
|
|
28
31
|
<!-- Workbench Icon/Manifest/CSS -->
|
|
29
32
|
<link rel="icon" href="{{WORKBENCH_WEB_BASE_URL}}/favicon.ico" type="image/x-icon" />
|
|
30
33
|
<link rel="manifest" href="{{WORKBENCH_WEB_BASE_URL}}/manifest.json">
|
package/views/workbench.html
CHANGED
|
@@ -25,6 +25,9 @@
|
|
|
25
25
|
<!-- Builtin Extensions (running out of sources) -->
|
|
26
26
|
<meta id="vscode-workbench-builtin-extensions" data-settings="{{WORKBENCH_BUILTIN_EXTENSIONS}}">
|
|
27
27
|
|
|
28
|
+
<!-- Product Overrides (running out of sources) -->
|
|
29
|
+
<meta id="vscode-workbench-product-overrides" data-settings="{{WORKBENCH_PRODUCT_OVERRIDES}}">
|
|
30
|
+
|
|
28
31
|
<!-- Workbench Icon/Manifest/CSS -->
|
|
29
32
|
<link rel="icon" href="{{WORKBENCH_WEB_BASE_URL}}/favicon.ico" type="image/x-icon" />
|
|
30
33
|
<link rel="manifest" href="{{WORKBENCH_WEB_BASE_URL}}/manifest.json">
|