@checkly/playwright-core 1.51.17-beta.0 → 1.51.17-beta.1
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/lib/checkly/secretsFilter.js +28 -7
- package/lib/common/socksProxy.js +569 -0
- package/lib/common/timeoutSettings.js +73 -0
- package/lib/common/types.js +5 -0
- package/lib/image_tools/colorUtils.js +98 -0
- package/lib/image_tools/compare.js +108 -0
- package/lib/image_tools/imageChannel.js +70 -0
- package/lib/image_tools/stats.js +102 -0
- package/lib/protocol/transport.js +82 -0
- package/lib/third_party/diff_match_patch.js +2222 -0
- package/lib/utils/ascii.js +31 -0
- package/lib/utils/comparators.js +171 -0
- package/lib/utils/crypto.js +174 -0
- package/lib/utils/debug.js +46 -0
- package/lib/utils/debugLogger.js +91 -0
- package/lib/utils/env.js +49 -0
- package/lib/utils/eventsHelper.js +38 -0
- package/lib/utils/happy-eyeballs.js +210 -0
- package/lib/utils/headers.js +52 -0
- package/lib/utils/hostPlatform.js +133 -0
- package/lib/utils/httpServer.js +237 -0
- package/lib/utils/linuxUtils.js +78 -0
- package/lib/utils/manualPromise.js +109 -0
- package/lib/utils/multimap.js +75 -0
- package/lib/utils/network.js +160 -0
- package/lib/utils/processLauncher.js +248 -0
- package/lib/utils/profiler.js +53 -0
- package/lib/utils/rtti.js +44 -0
- package/lib/utils/semaphore.js +51 -0
- package/lib/utils/spawnAsync.js +45 -0
- package/lib/utils/task.js +58 -0
- package/lib/utils/time.js +37 -0
- package/lib/utils/traceUtils.js +44 -0
- package/lib/utils/userAgent.js +105 -0
- package/lib/utils/wsServer.js +127 -0
- package/lib/utils/zipFile.js +75 -0
- package/package.json +1 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.startProfiling = startProfiling;
|
|
7
|
+
exports.stopProfiling = stopProfiling;
|
|
8
|
+
var fs = _interopRequireWildcard(require("fs"));
|
|
9
|
+
var path = _interopRequireWildcard(require("path"));
|
|
10
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
11
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
12
|
+
/**
|
|
13
|
+
* Copyright Microsoft Corporation. All rights reserved.
|
|
14
|
+
*
|
|
15
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
16
|
+
* you may not use this file except in compliance with the License.
|
|
17
|
+
* You may obtain a copy of the License at
|
|
18
|
+
*
|
|
19
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
20
|
+
*
|
|
21
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
22
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
23
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
24
|
+
* See the License for the specific language governing permissions and
|
|
25
|
+
* limitations under the License.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
const profileDir = process.env.PWTEST_PROFILE_DIR || '';
|
|
29
|
+
let session;
|
|
30
|
+
async function startProfiling() {
|
|
31
|
+
if (!profileDir) return;
|
|
32
|
+
session = new (require('inspector').Session)();
|
|
33
|
+
session.connect();
|
|
34
|
+
await new Promise(f => {
|
|
35
|
+
session.post('Profiler.enable', () => {
|
|
36
|
+
session.post('Profiler.start', f);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
async function stopProfiling(profileName) {
|
|
41
|
+
if (!profileDir) return;
|
|
42
|
+
await new Promise(f => session.post('Profiler.stop', (err, {
|
|
43
|
+
profile
|
|
44
|
+
}) => {
|
|
45
|
+
if (!err) {
|
|
46
|
+
fs.mkdirSync(profileDir, {
|
|
47
|
+
recursive: true
|
|
48
|
+
});
|
|
49
|
+
fs.writeFileSync(path.join(profileDir, profileName + '.json'), JSON.stringify(profile));
|
|
50
|
+
}
|
|
51
|
+
f();
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isError = isError;
|
|
7
|
+
exports.isLikelyNpxGlobal = void 0;
|
|
8
|
+
exports.isObject = isObject;
|
|
9
|
+
exports.isRegExp = isRegExp;
|
|
10
|
+
Object.defineProperty(exports, "isString", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _stringUtils.isString;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
var _stringUtils = require("./isomorphic/stringUtils");
|
|
17
|
+
/**
|
|
18
|
+
* Copyright (c) Microsoft Corporation.
|
|
19
|
+
*
|
|
20
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
21
|
+
* you may not use this file except in compliance with the License.
|
|
22
|
+
* You may obtain a copy of the License at
|
|
23
|
+
*
|
|
24
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
25
|
+
*
|
|
26
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
27
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
28
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
29
|
+
* See the License for the specific language governing permissions and
|
|
30
|
+
* limitations under the License.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
function isRegExp(obj) {
|
|
34
|
+
return obj instanceof RegExp || Object.prototype.toString.call(obj) === '[object RegExp]';
|
|
35
|
+
}
|
|
36
|
+
function isObject(obj) {
|
|
37
|
+
return typeof obj === 'object' && obj !== null;
|
|
38
|
+
}
|
|
39
|
+
function isError(obj) {
|
|
40
|
+
var _Object$getPrototypeO;
|
|
41
|
+
return obj instanceof Error || obj && ((_Object$getPrototypeO = Object.getPrototypeOf(obj)) === null || _Object$getPrototypeO === void 0 ? void 0 : _Object$getPrototypeO.name) === 'Error';
|
|
42
|
+
}
|
|
43
|
+
const isLikelyNpxGlobal = () => process.argv.length >= 2 && process.argv[1].includes('_npx');
|
|
44
|
+
exports.isLikelyNpxGlobal = isLikelyNpxGlobal;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Semaphore = void 0;
|
|
7
|
+
var _manualPromise = require("./manualPromise");
|
|
8
|
+
/**
|
|
9
|
+
* Copyright (c) Microsoft Corporation.
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
class Semaphore {
|
|
25
|
+
constructor(max) {
|
|
26
|
+
this._max = void 0;
|
|
27
|
+
this._acquired = 0;
|
|
28
|
+
this._queue = [];
|
|
29
|
+
this._max = max;
|
|
30
|
+
}
|
|
31
|
+
setMax(max) {
|
|
32
|
+
this._max = max;
|
|
33
|
+
}
|
|
34
|
+
acquire() {
|
|
35
|
+
const lock = new _manualPromise.ManualPromise();
|
|
36
|
+
this._queue.push(lock);
|
|
37
|
+
this._flush();
|
|
38
|
+
return lock;
|
|
39
|
+
}
|
|
40
|
+
release() {
|
|
41
|
+
--this._acquired;
|
|
42
|
+
this._flush();
|
|
43
|
+
}
|
|
44
|
+
_flush() {
|
|
45
|
+
while (this._acquired < this._max && this._queue.length) {
|
|
46
|
+
++this._acquired;
|
|
47
|
+
this._queue.shift().resolve();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.Semaphore = Semaphore;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.spawnAsync = spawnAsync;
|
|
7
|
+
var _child_process = require("child_process");
|
|
8
|
+
/**
|
|
9
|
+
* Copyright (c) Microsoft Corporation.
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
function spawnAsync(cmd, args, options = {}) {
|
|
25
|
+
const process = (0, _child_process.spawn)(cmd, args, Object.assign({
|
|
26
|
+
windowsHide: true
|
|
27
|
+
}, options));
|
|
28
|
+
return new Promise(resolve => {
|
|
29
|
+
let stdout = '';
|
|
30
|
+
let stderr = '';
|
|
31
|
+
if (process.stdout) process.stdout.on('data', data => stdout += data.toString());
|
|
32
|
+
if (process.stderr) process.stderr.on('data', data => stderr += data.toString());
|
|
33
|
+
process.on('close', code => resolve({
|
|
34
|
+
stdout,
|
|
35
|
+
stderr,
|
|
36
|
+
code
|
|
37
|
+
}));
|
|
38
|
+
process.on('error', error => resolve({
|
|
39
|
+
stdout,
|
|
40
|
+
stderr,
|
|
41
|
+
code: 0,
|
|
42
|
+
error
|
|
43
|
+
}));
|
|
44
|
+
});
|
|
45
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.makeWaitForNextTask = makeWaitForNextTask;
|
|
7
|
+
/**
|
|
8
|
+
* Copyright (c) Microsoft Corporation.
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
11
|
+
* you may not use this file except in compliance with the License.
|
|
12
|
+
* You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
// See https://joel.tools/microtasks/
|
|
24
|
+
function makeWaitForNextTask() {
|
|
25
|
+
// As of Mar 2021, Electron v12 doesn't create new task with `setImmediate` despite
|
|
26
|
+
// using Node 14 internally, so we fallback to `setTimeout(0)` instead.
|
|
27
|
+
// @see https://github.com/electron/electron/issues/28261
|
|
28
|
+
if (process.versions.electron) return callback => setTimeout(callback, 0);
|
|
29
|
+
if (parseInt(process.versions.node, 10) >= 11) return setImmediate;
|
|
30
|
+
|
|
31
|
+
// Unlike Node 11, Node 10 and less have a bug with Task and MicroTask execution order:
|
|
32
|
+
// - https://github.com/nodejs/node/issues/22257
|
|
33
|
+
//
|
|
34
|
+
// So we can't simply run setImmediate to dispatch code in a following task.
|
|
35
|
+
// However, we can run setImmediate from-inside setImmediate to make sure we're getting
|
|
36
|
+
// in the following task.
|
|
37
|
+
|
|
38
|
+
let spinning = false;
|
|
39
|
+
const callbacks = [];
|
|
40
|
+
const loop = () => {
|
|
41
|
+
const callback = callbacks.shift();
|
|
42
|
+
if (!callback) {
|
|
43
|
+
spinning = false;
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
setImmediate(loop);
|
|
47
|
+
// Make sure to call callback() as the last thing since it's
|
|
48
|
+
// untrusted code that might throw.
|
|
49
|
+
callback();
|
|
50
|
+
};
|
|
51
|
+
return callback => {
|
|
52
|
+
callbacks.push(callback);
|
|
53
|
+
if (!spinning) {
|
|
54
|
+
spinning = true;
|
|
55
|
+
setImmediate(loop);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.monotonicTime = monotonicTime;
|
|
7
|
+
/**
|
|
8
|
+
* Copyright (c) Microsoft Corporation.
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
11
|
+
* you may not use this file except in compliance with the License.
|
|
12
|
+
* You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
// The `process.hrtime()` returns a time from some arbitrary
|
|
24
|
+
// date in the past; on certain systems, this is the time from the system boot.
|
|
25
|
+
// The `monotonicTime()` converts this to milliseconds.
|
|
26
|
+
//
|
|
27
|
+
// For a Linux server with uptime of 36 days, the `monotonicTime()` value
|
|
28
|
+
// will be 36 * 86400 * 1000 = 3_110_400_000, which is larger than
|
|
29
|
+
// the maximum value that `setTimeout` accepts as an argument: 2_147_483_647.
|
|
30
|
+
//
|
|
31
|
+
// To make the `monotonicTime()` a reasonable value, we anchor
|
|
32
|
+
// it to the time of the first import of this utility.
|
|
33
|
+
const initialTime = process.hrtime();
|
|
34
|
+
function monotonicTime() {
|
|
35
|
+
const [seconds, nanoseconds] = process.hrtime(initialTime);
|
|
36
|
+
return seconds * 1000 + (nanoseconds / 1000 | 0) / 1000;
|
|
37
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.serializeClientSideCallMetadata = serializeClientSideCallMetadata;
|
|
7
|
+
/**
|
|
8
|
+
* Copyright (c) Microsoft Corporation.
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
11
|
+
* you may not use this file except in compliance with the License.
|
|
12
|
+
* You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
function serializeClientSideCallMetadata(metadatas) {
|
|
24
|
+
const fileNames = new Map();
|
|
25
|
+
const stacks = [];
|
|
26
|
+
for (const m of metadatas) {
|
|
27
|
+
if (!m.stack || !m.stack.length) continue;
|
|
28
|
+
const stack = [];
|
|
29
|
+
for (const frame of m.stack) {
|
|
30
|
+
let ordinal = fileNames.get(frame.file);
|
|
31
|
+
if (typeof ordinal !== 'number') {
|
|
32
|
+
ordinal = fileNames.size;
|
|
33
|
+
fileNames.set(frame.file, ordinal);
|
|
34
|
+
}
|
|
35
|
+
const stackFrame = [ordinal, frame.line || 0, frame.column || 0, frame.function || ''];
|
|
36
|
+
stack.push(stackFrame);
|
|
37
|
+
}
|
|
38
|
+
stacks.push([m.id, stack]);
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
files: [...fileNames.keys()],
|
|
42
|
+
stacks
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getEmbedderName = getEmbedderName;
|
|
7
|
+
exports.getPlaywrightVersion = getPlaywrightVersion;
|
|
8
|
+
exports.getUserAgent = getUserAgent;
|
|
9
|
+
exports.userAgentVersionMatchesErrorMessage = userAgentVersionMatchesErrorMessage;
|
|
10
|
+
var _child_process = require("child_process");
|
|
11
|
+
var _os = _interopRequireDefault(require("os"));
|
|
12
|
+
var _linuxUtils = require("../utils/linuxUtils");
|
|
13
|
+
var _ascii = require("./ascii");
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
/**
|
|
16
|
+
* Copyright (c) Microsoft Corporation.
|
|
17
|
+
*
|
|
18
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
19
|
+
* you may not use this file except in compliance with the License.
|
|
20
|
+
* You may obtain a copy of the License at
|
|
21
|
+
*
|
|
22
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
23
|
+
*
|
|
24
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
25
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
26
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
27
|
+
* See the License for the specific language governing permissions and
|
|
28
|
+
* limitations under the License.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
let cachedUserAgent;
|
|
32
|
+
function getUserAgent() {
|
|
33
|
+
if (cachedUserAgent) return cachedUserAgent;
|
|
34
|
+
try {
|
|
35
|
+
cachedUserAgent = determineUserAgent();
|
|
36
|
+
} catch (e) {
|
|
37
|
+
cachedUserAgent = 'Playwright/unknown';
|
|
38
|
+
}
|
|
39
|
+
return cachedUserAgent;
|
|
40
|
+
}
|
|
41
|
+
function determineUserAgent() {
|
|
42
|
+
let osIdentifier = 'unknown';
|
|
43
|
+
let osVersion = 'unknown';
|
|
44
|
+
if (process.platform === 'win32') {
|
|
45
|
+
const version = _os.default.release().split('.');
|
|
46
|
+
osIdentifier = 'windows';
|
|
47
|
+
osVersion = `${version[0]}.${version[1]}`;
|
|
48
|
+
} else if (process.platform === 'darwin') {
|
|
49
|
+
const version = (0, _child_process.execSync)('sw_vers -productVersion', {
|
|
50
|
+
stdio: ['ignore', 'pipe', 'ignore']
|
|
51
|
+
}).toString().trim().split('.');
|
|
52
|
+
osIdentifier = 'macOS';
|
|
53
|
+
osVersion = `${version[0]}.${version[1]}`;
|
|
54
|
+
} else if (process.platform === 'linux') {
|
|
55
|
+
const distroInfo = (0, _linuxUtils.getLinuxDistributionInfoSync)();
|
|
56
|
+
if (distroInfo) {
|
|
57
|
+
osIdentifier = distroInfo.id || 'linux';
|
|
58
|
+
osVersion = distroInfo.version || 'unknown';
|
|
59
|
+
} else {
|
|
60
|
+
// Linux distribution without /etc/os-release.
|
|
61
|
+
// Default to linux/unknown.
|
|
62
|
+
osIdentifier = 'linux';
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const additionalTokens = [];
|
|
66
|
+
if (process.env.CI) additionalTokens.push('CI/1');
|
|
67
|
+
const serializedTokens = additionalTokens.length ? ' ' + additionalTokens.join(' ') : '';
|
|
68
|
+
const {
|
|
69
|
+
embedderName,
|
|
70
|
+
embedderVersion
|
|
71
|
+
} = getEmbedderName();
|
|
72
|
+
return `Playwright/${getPlaywrightVersion()} (${_os.default.arch()}; ${osIdentifier} ${osVersion}) ${embedderName}/${embedderVersion}${serializedTokens}`;
|
|
73
|
+
}
|
|
74
|
+
function getEmbedderName() {
|
|
75
|
+
let embedderName = 'unknown';
|
|
76
|
+
let embedderVersion = 'unknown';
|
|
77
|
+
if (!process.env.PW_LANG_NAME) {
|
|
78
|
+
embedderName = 'node';
|
|
79
|
+
embedderVersion = process.version.substring(1).split('.').slice(0, 2).join('.');
|
|
80
|
+
} else if (['node', 'python', 'java', 'csharp'].includes(process.env.PW_LANG_NAME)) {
|
|
81
|
+
var _process$env$PW_LANG_;
|
|
82
|
+
embedderName = process.env.PW_LANG_NAME;
|
|
83
|
+
embedderVersion = (_process$env$PW_LANG_ = process.env.PW_LANG_NAME_VERSION) !== null && _process$env$PW_LANG_ !== void 0 ? _process$env$PW_LANG_ : 'unknown';
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
embedderName,
|
|
87
|
+
embedderVersion
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function getPlaywrightVersion(majorMinorOnly = false) {
|
|
91
|
+
const version = process.env.PW_VERSION_OVERRIDE || require('./../../package.json').version;
|
|
92
|
+
return majorMinorOnly ? version.split('.').slice(0, 2).join('.') : version;
|
|
93
|
+
}
|
|
94
|
+
function userAgentVersionMatchesErrorMessage(userAgent) {
|
|
95
|
+
const match = userAgent.match(/^Playwright\/(\d+\.\d+\.\d+)/);
|
|
96
|
+
if (!match) {
|
|
97
|
+
// Cannot parse user agent - be lax.
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const received = match[1].split('.').slice(0, 2).join('.');
|
|
101
|
+
const expected = getPlaywrightVersion(true);
|
|
102
|
+
if (received !== expected) {
|
|
103
|
+
return (0, _ascii.wrapInASCIIBox)([`Playwright version mismatch:`, ` - server version: v${expected}`, ` - client version: v${received}`, ``, `If you are using VSCode extension, restart VSCode.`, ``, `If you are connecting to a remote service,`, `keep your local Playwright version in sync`, `with the remote service version.`, ``, `<3 Playwright Team`].join('\n'), 1);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.perMessageDeflate = exports.WSServer = void 0;
|
|
7
|
+
var _utils = require("../utils");
|
|
8
|
+
var _utilsBundle = require("../utilsBundle");
|
|
9
|
+
var _debugLogger = require("./debugLogger");
|
|
10
|
+
/**
|
|
11
|
+
* Copyright (c) Microsoft Corporation.
|
|
12
|
+
*
|
|
13
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
14
|
+
* you may not use this file except in compliance with the License.
|
|
15
|
+
* You may obtain a copy of the License at
|
|
16
|
+
*
|
|
17
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
18
|
+
*
|
|
19
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
20
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
21
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
22
|
+
* See the License for the specific language governing permissions and
|
|
23
|
+
* limitations under the License.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
let lastConnectionId = 0;
|
|
27
|
+
const kConnectionSymbol = Symbol('kConnection');
|
|
28
|
+
const perMessageDeflate = exports.perMessageDeflate = {
|
|
29
|
+
zlibDeflateOptions: {
|
|
30
|
+
level: 3
|
|
31
|
+
},
|
|
32
|
+
zlibInflateOptions: {
|
|
33
|
+
chunkSize: 10 * 1024
|
|
34
|
+
},
|
|
35
|
+
threshold: 10 * 1024
|
|
36
|
+
};
|
|
37
|
+
class WSServer {
|
|
38
|
+
constructor(delegate) {
|
|
39
|
+
this._wsServer = void 0;
|
|
40
|
+
this.server = void 0;
|
|
41
|
+
this._delegate = void 0;
|
|
42
|
+
this._delegate = delegate;
|
|
43
|
+
}
|
|
44
|
+
async listen(port = 0, hostname, path) {
|
|
45
|
+
_debugLogger.debugLogger.log('server', `Server started at ${new Date()}`);
|
|
46
|
+
const server = (0, _utils.createHttpServer)((request, response) => {
|
|
47
|
+
if (request.method === 'GET' && request.url === '/json') {
|
|
48
|
+
response.setHeader('Content-Type', 'application/json');
|
|
49
|
+
response.end(JSON.stringify({
|
|
50
|
+
wsEndpointPath: path
|
|
51
|
+
}));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
response.end('Running');
|
|
55
|
+
});
|
|
56
|
+
server.on('error', error => _debugLogger.debugLogger.log('server', String(error)));
|
|
57
|
+
this.server = server;
|
|
58
|
+
const wsEndpoint = await new Promise((resolve, reject) => {
|
|
59
|
+
server.listen(port, hostname, () => {
|
|
60
|
+
const address = server.address();
|
|
61
|
+
if (!address) {
|
|
62
|
+
reject(new Error('Could not bind server socket'));
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const wsEndpoint = typeof address === 'string' ? `${address}${path}` : `ws://${hostname || 'localhost'}:${address.port}${path}`;
|
|
66
|
+
resolve(wsEndpoint);
|
|
67
|
+
}).on('error', reject);
|
|
68
|
+
});
|
|
69
|
+
_debugLogger.debugLogger.log('server', 'Listening at ' + wsEndpoint);
|
|
70
|
+
this._wsServer = new _utilsBundle.wsServer({
|
|
71
|
+
noServer: true,
|
|
72
|
+
perMessageDeflate
|
|
73
|
+
});
|
|
74
|
+
if (this._delegate.onHeaders) this._wsServer.on('headers', headers => this._delegate.onHeaders(headers));
|
|
75
|
+
server.on('upgrade', (request, socket, head) => {
|
|
76
|
+
var _this$_delegate$onUpg, _this$_delegate, _this$_wsServer;
|
|
77
|
+
const pathname = new URL('http://localhost' + request.url).pathname;
|
|
78
|
+
if (pathname !== path) {
|
|
79
|
+
socket.write(`HTTP/${request.httpVersion} 400 Bad Request\r\n\r\n`);
|
|
80
|
+
socket.destroy();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const upgradeResult = (_this$_delegate$onUpg = (_this$_delegate = this._delegate).onUpgrade) === null || _this$_delegate$onUpg === void 0 ? void 0 : _this$_delegate$onUpg.call(_this$_delegate, request, socket);
|
|
84
|
+
if (upgradeResult) {
|
|
85
|
+
socket.write(upgradeResult.error);
|
|
86
|
+
socket.destroy();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
(_this$_wsServer = this._wsServer) === null || _this$_wsServer === void 0 || _this$_wsServer.handleUpgrade(request, socket, head, ws => {
|
|
90
|
+
var _this$_wsServer2;
|
|
91
|
+
return (_this$_wsServer2 = this._wsServer) === null || _this$_wsServer2 === void 0 ? void 0 : _this$_wsServer2.emit('connection', ws, request);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
this._wsServer.on('connection', (ws, request) => {
|
|
95
|
+
_debugLogger.debugLogger.log('server', 'Connected client ws.extension=' + ws.extensions);
|
|
96
|
+
const url = new URL('http://localhost' + (request.url || ''));
|
|
97
|
+
const id = String(++lastConnectionId);
|
|
98
|
+
_debugLogger.debugLogger.log('server', `[${id}] serving connection: ${request.url}`);
|
|
99
|
+
const connection = this._delegate.onConnection(request, url, ws, id);
|
|
100
|
+
ws[kConnectionSymbol] = connection;
|
|
101
|
+
});
|
|
102
|
+
return wsEndpoint;
|
|
103
|
+
}
|
|
104
|
+
async close() {
|
|
105
|
+
var _this$_delegate$onClo, _this$_delegate2;
|
|
106
|
+
const server = this._wsServer;
|
|
107
|
+
if (!server) return;
|
|
108
|
+
_debugLogger.debugLogger.log('server', 'closing websocket server');
|
|
109
|
+
const waitForClose = new Promise(f => server.close(f));
|
|
110
|
+
// First disconnect all remaining clients.
|
|
111
|
+
await Promise.all(Array.from(server.clients).map(async ws => {
|
|
112
|
+
const connection = ws[kConnectionSymbol];
|
|
113
|
+
if (connection) await connection.close();
|
|
114
|
+
try {
|
|
115
|
+
ws.terminate();
|
|
116
|
+
} catch (e) {}
|
|
117
|
+
}));
|
|
118
|
+
await waitForClose;
|
|
119
|
+
_debugLogger.debugLogger.log('server', 'closing http server');
|
|
120
|
+
if (this.server) await new Promise(f => this.server.close(f));
|
|
121
|
+
this._wsServer = undefined;
|
|
122
|
+
this.server = undefined;
|
|
123
|
+
_debugLogger.debugLogger.log('server', 'closed server');
|
|
124
|
+
await ((_this$_delegate$onClo = (_this$_delegate2 = this._delegate).onClose) === null || _this$_delegate$onClo === void 0 ? void 0 : _this$_delegate$onClo.call(_this$_delegate2));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.WSServer = WSServer;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ZipFile = void 0;
|
|
7
|
+
var _zipBundle = require("../zipBundle");
|
|
8
|
+
/**
|
|
9
|
+
* Copyright (c) Microsoft Corporation.
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
class ZipFile {
|
|
25
|
+
constructor(fileName) {
|
|
26
|
+
this._fileName = void 0;
|
|
27
|
+
this._zipFile = void 0;
|
|
28
|
+
this._entries = new Map();
|
|
29
|
+
this._openedPromise = void 0;
|
|
30
|
+
this._fileName = fileName;
|
|
31
|
+
this._openedPromise = this._open();
|
|
32
|
+
}
|
|
33
|
+
async _open() {
|
|
34
|
+
await new Promise((fulfill, reject) => {
|
|
35
|
+
_zipBundle.yauzl.open(this._fileName, {
|
|
36
|
+
autoClose: false
|
|
37
|
+
}, (e, z) => {
|
|
38
|
+
if (e) {
|
|
39
|
+
reject(e);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
this._zipFile = z;
|
|
43
|
+
this._zipFile.on('entry', entry => {
|
|
44
|
+
this._entries.set(entry.fileName, entry);
|
|
45
|
+
});
|
|
46
|
+
this._zipFile.on('end', fulfill);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
async entries() {
|
|
51
|
+
await this._openedPromise;
|
|
52
|
+
return [...this._entries.keys()];
|
|
53
|
+
}
|
|
54
|
+
async read(entryPath) {
|
|
55
|
+
await this._openedPromise;
|
|
56
|
+
const entry = this._entries.get(entryPath);
|
|
57
|
+
if (!entry) throw new Error(`${entryPath} not found in file ${this._fileName}`);
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
this._zipFile.openReadStream(entry, (error, readStream) => {
|
|
60
|
+
if (error || !readStream) {
|
|
61
|
+
reject(error || 'Entry not found');
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const buffers = [];
|
|
65
|
+
readStream.on('data', data => buffers.push(data));
|
|
66
|
+
readStream.on('end', () => resolve(Buffer.concat(buffers)));
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
close() {
|
|
71
|
+
var _this$_zipFile;
|
|
72
|
+
(_this$_zipFile = this._zipFile) === null || _this$_zipFile === void 0 || _this$_zipFile.close();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.ZipFile = ZipFile;
|