@vscode/test-web 0.0.38 → 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 +11 -8
- package/out/server/workbench.js +13 -2
- package/package.json +1 -1
- package/views/workbench-esm.html +3 -0
- package/views/workbench.html +3 -0
package/out/index.js
CHANGED
|
@@ -35,9 +35,7 @@ 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());
|
|
42
40
|
const unreportedOutput = [];
|
|
43
41
|
await context.exposeFunction('codeAutomationLog', (type, args) => {
|
|
@@ -67,8 +65,10 @@ async function runTests(options) {
|
|
|
67
65
|
e(new Error('Test failed'));
|
|
68
66
|
}
|
|
69
67
|
});
|
|
70
|
-
}
|
|
71
|
-
|
|
68
|
+
};
|
|
69
|
+
console.log(`Opening browser on ${endpoint}...`);
|
|
70
|
+
const context = await openBrowser(endpoint, options, configContext);
|
|
71
|
+
if (!context) {
|
|
72
72
|
server.close();
|
|
73
73
|
e(new Error('Can not run test as opening of browser failed.'));
|
|
74
74
|
}
|
|
@@ -103,8 +103,10 @@ async function open(options) {
|
|
|
103
103
|
const port = options.port ?? 3000;
|
|
104
104
|
const server = await (0, main_1.runServer)(host, port, config);
|
|
105
105
|
const endpoint = `http://${host}:${port}`;
|
|
106
|
-
const
|
|
107
|
-
|
|
106
|
+
const configContext = async (context) => {
|
|
107
|
+
context.once('close', () => server.close());
|
|
108
|
+
};
|
|
109
|
+
const context = await openBrowser(endpoint, options, configContext);
|
|
108
110
|
return {
|
|
109
111
|
dispose: () => {
|
|
110
112
|
server.close();
|
|
@@ -113,7 +115,7 @@ async function open(options) {
|
|
|
113
115
|
};
|
|
114
116
|
}
|
|
115
117
|
exports.open = open;
|
|
116
|
-
async function openBrowser(endpoint, options) {
|
|
118
|
+
async function openBrowser(endpoint, options, configureContext) {
|
|
117
119
|
if (options.browserType === 'none') {
|
|
118
120
|
return undefined;
|
|
119
121
|
}
|
|
@@ -135,6 +137,7 @@ async function openBrowser(endpoint, options) {
|
|
|
135
137
|
if (options.permissions) {
|
|
136
138
|
context.grantPermissions(options.permissions);
|
|
137
139
|
}
|
|
140
|
+
await configureContext(context);
|
|
138
141
|
// forcefully close browser if last page is closed. workaround for https://github.com/microsoft/playwright/issues/2946
|
|
139
142
|
let openPages = 0;
|
|
140
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
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">
|