@checkly/playwright-core 1.48.24-maxi → 1.48.25-beta.0

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.
Files changed (113) hide show
  1. package/lib/generated/bindingsControllerSource.js +7 -0
  2. package/lib/generated/storageScriptSource.js +7 -0
  3. package/lib/server/har/harRecorder.js +3 -1
  4. package/lib/server/trace/recorder/tracing.js +9 -20
  5. package/lib/utils/fileUtils.js +65 -2
  6. package/lib/vite/{traceViewer/assets/codeMirrorModule-tzBrK1V4.js → recorder/assets/codeMirrorModule-baozm8ur.js} +10 -10
  7. package/lib/vite/recorder/assets/{index-BcaUAUCW.js → index-2ElAIWFB.js} +2 -2
  8. package/lib/vite/recorder/index.html +1 -1
  9. package/lib/vite/traceViewer/assets/{codeMirrorModule-CB-2okZ8.js → codeMirrorModule-DblsdhjA.js} +2096 -2331
  10. package/lib/vite/{recorder/assets/codeMirrorModule-CR6kB851.js → traceViewer/assets/codeMirrorModule-lDjkI8Ax.js} +1 -1
  11. package/lib/vite/traceViewer/assets/{inspectorTab-BHcfR9dD.js → inspectorTab-BPzhNk9r.js} +2 -2
  12. package/lib/vite/traceViewer/assets/inspectorTab-DOc4D3cX.js +17361 -0
  13. package/lib/vite/traceViewer/assets/{defaultSettingsView-CBiB4avC.js → testServerConnection-D-tXL3sj.js} +49 -42
  14. package/lib/vite/traceViewer/assets/{workbench-DZqNXdoV.js → workbench-DLv_q9ji.js} +1 -1
  15. package/lib/vite/traceViewer/assets/workbench-DNolpp3y.js +1473 -0
  16. package/lib/vite/traceViewer/assets/xtermModule-DZP0glxx.js +5982 -0
  17. package/lib/vite/traceViewer/{embedded.DInvAijy.js → embedded.BIubxTi3.js} +1 -1
  18. package/lib/vite/traceViewer/{embedded.gzudoghF.js → embedded.DeCrOtlO.js} +4 -4
  19. package/lib/vite/traceViewer/embedded.html +3 -3
  20. package/lib/vite/traceViewer/{index.DilotR1h.js → index.CM_h9lHr.js} +7 -124
  21. package/lib/vite/traceViewer/{index.Dha3cgqs.js → index.DPD22sZn.js} +1 -1
  22. package/lib/vite/traceViewer/index.html +3 -3
  23. package/lib/vite/traceViewer/{inspectorTab.DnGm18kV.css → inspectorTab.DGJWXOSd.css} +1488 -1521
  24. package/lib/vite/traceViewer/{recorder.C88JDknq.js → recorder.BaRuS6Pc.js} +1 -1
  25. package/lib/vite/traceViewer/{recorder.DVrkq3Um.js → recorder.Fwf59ZKh.js} +3 -3
  26. package/lib/vite/traceViewer/recorder.html +2 -2
  27. package/lib/vite/traceViewer/{uiMode.2tr9k625.js → uiMode.B11wexdJ.js} +1 -1
  28. package/lib/vite/traceViewer/{uiMode.C9_OcpPU.js → uiMode.CYBsUhm_.js} +58 -90
  29. package/lib/vite/traceViewer/{uiMode.c5ORgcrX.css → uiMode.DRmgrHSk.css} +45 -7
  30. package/lib/vite/traceViewer/uiMode.html +3 -3
  31. package/lib/vite/traceViewer/{workbench.xUZSA8PY.css → workbench.BQNDbcQ0.css} +83 -320
  32. package/package.json +1 -1
  33. package/lib/client/clientStackTrace.js +0 -66
  34. package/lib/client/fileUtils.js +0 -33
  35. package/lib/client/platform.js +0 -72
  36. package/lib/client/timeoutSettings.js +0 -66
  37. package/lib/client/webSocket.js +0 -107
  38. package/lib/generated/recorderSource.js +0 -7
  39. package/lib/server/callLog.js +0 -80
  40. package/lib/server/harBackend.js +0 -158
  41. package/lib/server/localUtils.js +0 -204
  42. package/lib/server/recorder/chat.js +0 -178
  43. package/lib/server/recorder/codeGenerator.js +0 -154
  44. package/lib/server/recorder/csharp.js +0 -311
  45. package/lib/server/recorder/java.js +0 -249
  46. package/lib/server/recorder/javascript.js +0 -230
  47. package/lib/server/recorder/jsonl.js +0 -48
  48. package/lib/server/recorder/language.js +0 -45
  49. package/lib/server/recorder/python.js +0 -276
  50. package/lib/server/recorder/recorderActions.js +0 -6
  51. package/lib/server/recorder/utils.js +0 -46
  52. package/lib/server/storageScript.js +0 -161
  53. package/lib/server/timeoutSettings.js +0 -75
  54. package/lib/server/utils/ascii.js +0 -32
  55. package/lib/server/utils/comparators.js +0 -160
  56. package/lib/server/utils/crypto.js +0 -172
  57. package/lib/server/utils/debug.js +0 -39
  58. package/lib/server/utils/debugLogger.js +0 -94
  59. package/lib/server/utils/env.js +0 -54
  60. package/lib/server/utils/eventsHelper.js +0 -39
  61. package/lib/server/utils/expectUtils.js +0 -34
  62. package/lib/server/utils/fileUtils.js +0 -205
  63. package/lib/server/utils/happyEyeballs.js +0 -210
  64. package/lib/server/utils/hostPlatform.js +0 -146
  65. package/lib/server/utils/httpServer.js +0 -234
  66. package/lib/server/utils/image_tools/colorUtils.js +0 -99
  67. package/lib/server/utils/image_tools/compare.js +0 -109
  68. package/lib/server/utils/image_tools/imageChannel.js +0 -71
  69. package/lib/server/utils/image_tools/stats.js +0 -103
  70. package/lib/server/utils/linuxUtils.js +0 -59
  71. package/lib/server/utils/network.js +0 -161
  72. package/lib/server/utils/nodePlatform.js +0 -141
  73. package/lib/server/utils/pipeTransport.js +0 -83
  74. package/lib/server/utils/processLauncher.js +0 -249
  75. package/lib/server/utils/profiler.js +0 -53
  76. package/lib/server/utils/socksProxy.js +0 -571
  77. package/lib/server/utils/spawnAsync.js +0 -46
  78. package/lib/server/utils/task.js +0 -59
  79. package/lib/server/utils/userAgent.js +0 -92
  80. package/lib/server/utils/wsServer.js +0 -129
  81. package/lib/server/utils/zipFile.js +0 -76
  82. package/lib/server/utils/zones.js +0 -55
  83. package/lib/utils/glob.js +0 -84
  84. package/lib/utils/isomorphic/ariaSnapshot.js +0 -393
  85. package/lib/utils/isomorphic/assert.js +0 -26
  86. package/lib/utils/isomorphic/colors.js +0 -66
  87. package/lib/utils/isomorphic/headers.js +0 -53
  88. package/lib/utils/isomorphic/manualPromise.js +0 -108
  89. package/lib/utils/isomorphic/multimap.js +0 -74
  90. package/lib/utils/isomorphic/rtti.js +0 -42
  91. package/lib/utils/isomorphic/semaphore.js +0 -52
  92. package/lib/utils/isomorphic/stackTrace.js +0 -170
  93. package/lib/utils/isomorphic/time.js +0 -26
  94. package/lib/utils/isomorphic/timeoutRunner.js +0 -67
  95. package/lib/utils/isomorphic/types.js +0 -6
  96. package/lib/utils/mimeType.js +0 -30
  97. package/lib/utils.js +0 -448
  98. package/lib/vite/traceViewer/assets/codeMirrorModule-DZoSgqUd.js +0 -24
  99. package/lib/vite/traceViewer/assets/inspectorTab-BuJ3wAX_.js +0 -64
  100. package/lib/vite/traceViewer/assets/inspectorTab-CwgfffWb.js +0 -25143
  101. package/lib/vite/traceViewer/assets/workbench-CWZselvp.js +0 -2470
  102. package/lib/vite/traceViewer/assets/workbench-DdmJ9AJV.js +0 -9
  103. package/lib/vite/traceViewer/assets/xtermModule-Es_gt_u7.js +0 -5994
  104. package/lib/vite/traceViewer/defaultSettingsView.Dp3b_92q.css +0 -41
  105. package/lib/vite/traceViewer/embedded.Dxe2heQk.js +0 -2
  106. package/lib/vite/traceViewer/index.CB297BuW.js +0 -2
  107. package/lib/vite/traceViewer/recorder.DNMfnSiu.js +0 -2
  108. package/lib/vite/traceViewer/uiMode.Cr1tvTWS.js +0 -5
  109. /package/lib/vite/traceViewer/{codeMirrorModule.DuST8d_k.css → codeMirrorModule.Cy8X9Wtw.css} +0 -0
  110. /package/lib/vite/traceViewer/{embedded.BeldSa2G.css → embedded.DjZq4InJ.css} +0 -0
  111. /package/lib/vite/traceViewer/{index.QewjJ85u.css → index.QanXxRUb.css} +0 -0
  112. /package/lib/vite/traceViewer/{recorder.DLgqV9db.css → recorder.DBDpiNOK.css} +0 -0
  113. /package/lib/vite/traceViewer/{xtermModule.EsaqrrTX.css → xtermModule.4oRVGWQ-.css} +0 -0
@@ -1,161 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.collect = collect;
7
- exports.restore = restore;
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
- async function collect(serializers, isFirefox, recordIndexedDB) {
25
- async function collectDB(dbInfo) {
26
- if (!dbInfo.name) throw new Error('Database name is empty');
27
- if (!dbInfo.version) throw new Error('Database version is unset');
28
- function idbRequestToPromise(request) {
29
- return new Promise((resolve, reject) => {
30
- request.addEventListener('success', () => resolve(request.result));
31
- request.addEventListener('error', () => reject(request.error));
32
- });
33
- }
34
- function isPlainObject(v) {
35
- const ctor = v === null || v === void 0 ? void 0 : v.constructor;
36
- if (isFirefox) {
37
- const constructorImpl = ctor === null || ctor === void 0 ? void 0 : ctor.toString();
38
- if (constructorImpl.startsWith('function Object() {') && constructorImpl.includes('[native code]')) return true;
39
- }
40
- return ctor === Object;
41
- }
42
- function trySerialize(value) {
43
- let trivial = true;
44
- const encoded = serializers.serializeAsCallArgument(value, v => {
45
- const isTrivial = isPlainObject(v) || Array.isArray(v) || typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean' || Object.is(v, null);
46
- if (!isTrivial) trivial = false;
47
- return {
48
- fallThrough: v
49
- };
50
- });
51
- if (trivial) return {
52
- trivial: value
53
- };
54
- return {
55
- encoded
56
- };
57
- }
58
- const db = await idbRequestToPromise(indexedDB.open(dbInfo.name));
59
- const transaction = db.transaction(db.objectStoreNames, 'readonly');
60
- const stores = await Promise.all([...db.objectStoreNames].map(async storeName => {
61
- const objectStore = transaction.objectStore(storeName);
62
- const keys = await idbRequestToPromise(objectStore.getAllKeys());
63
- const records = await Promise.all(keys.map(async key => {
64
- const record = {};
65
- if (objectStore.keyPath === null) {
66
- const {
67
- encoded,
68
- trivial
69
- } = trySerialize(key);
70
- if (trivial) record.key = trivial;else record.keyEncoded = encoded;
71
- }
72
- const value = await idbRequestToPromise(objectStore.get(key));
73
- const {
74
- encoded,
75
- trivial
76
- } = trySerialize(value);
77
- if (trivial) record.value = trivial;else record.valueEncoded = encoded;
78
- return record;
79
- }));
80
- const indexes = [...objectStore.indexNames].map(indexName => {
81
- const index = objectStore.index(indexName);
82
- return {
83
- name: index.name,
84
- keyPath: typeof index.keyPath === 'string' ? index.keyPath : undefined,
85
- keyPathArray: Array.isArray(index.keyPath) ? index.keyPath : undefined,
86
- multiEntry: index.multiEntry,
87
- unique: index.unique
88
- };
89
- });
90
- return {
91
- name: storeName,
92
- records: records,
93
- indexes,
94
- autoIncrement: objectStore.autoIncrement,
95
- keyPath: typeof objectStore.keyPath === 'string' ? objectStore.keyPath : undefined,
96
- keyPathArray: Array.isArray(objectStore.keyPath) ? objectStore.keyPath : undefined
97
- };
98
- }));
99
- return {
100
- name: dbInfo.name,
101
- version: dbInfo.version,
102
- stores
103
- };
104
- }
105
- return {
106
- localStorage: Object.keys(localStorage).map(name => ({
107
- name,
108
- value: localStorage.getItem(name)
109
- })),
110
- indexedDB: recordIndexedDB ? await Promise.all((await indexedDB.databases()).map(collectDB)).catch(e => {
111
- throw new Error('Unable to serialize IndexedDB: ' + e.message);
112
- }) : undefined
113
- };
114
- }
115
- async function restore(originState, serializers) {
116
- var _originState$indexedD;
117
- for (const {
118
- name,
119
- value
120
- } of originState.localStorage || []) localStorage.setItem(name, value);
121
- await Promise.all(((_originState$indexedD = originState.indexedDB) !== null && _originState$indexedD !== void 0 ? _originState$indexedD : []).map(async dbInfo => {
122
- const openRequest = indexedDB.open(dbInfo.name, dbInfo.version);
123
- openRequest.addEventListener('upgradeneeded', () => {
124
- const db = openRequest.result;
125
- for (const store of dbInfo.stores) {
126
- var _store$keyPathArray;
127
- const objectStore = db.createObjectStore(store.name, {
128
- autoIncrement: store.autoIncrement,
129
- keyPath: (_store$keyPathArray = store.keyPathArray) !== null && _store$keyPathArray !== void 0 ? _store$keyPathArray : store.keyPath
130
- });
131
- for (const index of store.indexes) {
132
- var _index$keyPathArray;
133
- objectStore.createIndex(index.name, (_index$keyPathArray = index.keyPathArray) !== null && _index$keyPathArray !== void 0 ? _index$keyPathArray : index.keyPath, {
134
- unique: index.unique,
135
- multiEntry: index.multiEntry
136
- });
137
- }
138
- }
139
- });
140
- function idbRequestToPromise(request) {
141
- return new Promise((resolve, reject) => {
142
- request.addEventListener('success', () => resolve(request.result));
143
- request.addEventListener('error', () => reject(request.error));
144
- });
145
- }
146
-
147
- // after `upgradeneeded` finishes, `success` event is fired.
148
- const db = await idbRequestToPromise(openRequest);
149
- const transaction = db.transaction(db.objectStoreNames, 'readwrite');
150
- await Promise.all(dbInfo.stores.map(async store => {
151
- const objectStore = transaction.objectStore(store.name);
152
- await Promise.all(store.records.map(async record => {
153
- var _record$value, _record$key;
154
- await idbRequestToPromise(objectStore.add((_record$value = record.value) !== null && _record$value !== void 0 ? _record$value : serializers.parseEvaluationResultValue(record.valueEncoded), (_record$key = record.key) !== null && _record$key !== void 0 ? _record$key : serializers.parseEvaluationResultValue(record.keyEncoded)));
155
- }));
156
- }));
157
- })).catch(e => {
158
- throw new Error('Unable to restore IndexedDB: ' + e.message);
159
- });
160
- }
161
- //# sourceMappingURL=storageScript.js.map
@@ -1,75 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.TimeoutSettings = exports.DEFAULT_TIMEOUT = exports.DEFAULT_LAUNCH_TIMEOUT = void 0;
7
- var _debug = require("./utils/debug");
8
- /**
9
- * Copyright 2019 Google Inc. All rights reserved.
10
- * Modifications copyright (c) Microsoft Corporation.
11
- *
12
- * Licensed under the Apache License, Version 2.0 (the "License");
13
- * you may not use this file except in compliance with the License.
14
- * You may obtain a copy of the License at
15
- *
16
- * http://www.apache.org/licenses/LICENSE-2.0
17
- *
18
- * Unless required by applicable law or agreed to in writing, software
19
- * distributed under the License is distributed on an "AS IS" BASIS,
20
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
- * See the License for the specific language governing permissions and
22
- * limitations under the License.
23
- */
24
-
25
- // Keep in sync with client.
26
- const DEFAULT_TIMEOUT = exports.DEFAULT_TIMEOUT = 30000;
27
- const DEFAULT_LAUNCH_TIMEOUT = exports.DEFAULT_LAUNCH_TIMEOUT = 3 * 60 * 1000; // 3 minutes
28
-
29
- class TimeoutSettings {
30
- constructor(parent) {
31
- this._parent = void 0;
32
- this._defaultTimeout = void 0;
33
- this._defaultNavigationTimeout = void 0;
34
- this._parent = parent;
35
- }
36
- setDefaultTimeout(timeout) {
37
- this._defaultTimeout = timeout;
38
- }
39
- setDefaultNavigationTimeout(timeout) {
40
- this._defaultNavigationTimeout = timeout;
41
- }
42
- defaultNavigationTimeout() {
43
- return this._defaultNavigationTimeout;
44
- }
45
- defaultTimeout() {
46
- return this._defaultTimeout;
47
- }
48
- navigationTimeout(options) {
49
- if (typeof options.timeout === 'number') return options.timeout;
50
- if (this._defaultNavigationTimeout !== undefined) return this._defaultNavigationTimeout;
51
- if ((0, _debug.debugMode)()) return 0;
52
- if (this._defaultTimeout !== undefined) return this._defaultTimeout;
53
- if (this._parent) return this._parent.navigationTimeout(options);
54
- return DEFAULT_TIMEOUT;
55
- }
56
- timeout(options) {
57
- if (typeof options.timeout === 'number') return options.timeout;
58
- if ((0, _debug.debugMode)()) return 0;
59
- if (this._defaultTimeout !== undefined) return this._defaultTimeout;
60
- if (this._parent) return this._parent.timeout(options);
61
- return DEFAULT_TIMEOUT;
62
- }
63
- static timeout(options) {
64
- if (typeof options.timeout === 'number') return options.timeout;
65
- if ((0, _debug.debugMode)()) return 0;
66
- return DEFAULT_TIMEOUT;
67
- }
68
- static launchTimeout(options) {
69
- if (typeof options.timeout === 'number') return options.timeout;
70
- if ((0, _debug.debugMode)()) return 0;
71
- return DEFAULT_LAUNCH_TIMEOUT;
72
- }
73
- }
74
- exports.TimeoutSettings = TimeoutSettings;
75
- //# sourceMappingURL=timeoutSettings.js.map
@@ -1,32 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.jsonStringifyForceASCII = jsonStringifyForceASCII;
7
- exports.wrapInASCIIBox = wrapInASCIIBox;
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 wrapInASCIIBox(text, padding = 0) {
25
- const lines = text.split('\n');
26
- const maxLength = Math.max(...lines.map(line => line.length));
27
- return ['╔' + '═'.repeat(maxLength + padding * 2) + '╗', ...lines.map(line => '║' + ' '.repeat(padding) + line + ' '.repeat(maxLength - line.length + padding) + '║'), '╚' + '═'.repeat(maxLength + padding * 2) + '╝'].join('\n');
28
- }
29
- function jsonStringifyForceASCII(object) {
30
- return JSON.stringify(object).replace(/[\u007f-\uffff]/g, c => '\\u' + ('0000' + c.charCodeAt(0).toString(16)).slice(-4));
31
- }
32
- //# sourceMappingURL=ascii.js.map
@@ -1,160 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.compareBuffersOrStrings = compareBuffersOrStrings;
7
- exports.getComparator = getComparator;
8
- var _compare = require("./image_tools/compare");
9
- var _pixelmatch = _interopRequireDefault(require("../../third_party/pixelmatch"));
10
- var _utilsBundle = require("../../utilsBundle");
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- /**
13
- * Copyright 2017 Google Inc. All rights reserved.
14
- * Modifications copyright (c) Microsoft Corporation.
15
- *
16
- * Licensed under the Apache License, Version 2.0 (the "License");
17
- * you may not use this file except in compliance with the License.
18
- * You may obtain a copy of the License at
19
- *
20
- * http://www.apache.org/licenses/LICENSE-2.0
21
- *
22
- * Unless required by applicable law or agreed to in writing, software
23
- * distributed under the License is distributed on an "AS IS" BASIS,
24
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25
- * See the License for the specific language governing permissions and
26
- * limitations under the License.
27
- */
28
-
29
- // @ts-ignore
30
-
31
- function getComparator(mimeType) {
32
- if (mimeType === 'image/png') return compareImages.bind(null, 'image/png');
33
- if (mimeType === 'image/jpeg') return compareImages.bind(null, 'image/jpeg');
34
- if (mimeType === 'text/plain') return compareText;
35
- return compareBuffersOrStrings;
36
- }
37
- const JPEG_JS_MAX_BUFFER_SIZE_IN_MB = 5 * 1024; // ~5 GB
38
-
39
- function compareBuffersOrStrings(actualBuffer, expectedBuffer) {
40
- if (typeof actualBuffer === 'string') return compareText(actualBuffer, expectedBuffer);
41
- if (!actualBuffer || !(actualBuffer instanceof Buffer)) return {
42
- errorMessage: 'Actual result should be a Buffer or a string.'
43
- };
44
- if (Buffer.compare(actualBuffer, expectedBuffer)) return {
45
- errorMessage: 'Buffers differ'
46
- };
47
- return null;
48
- }
49
- function compareImages(mimeType, actualBuffer, expectedBuffer, options = {}) {
50
- var _options$comparator, _ref;
51
- if (!actualBuffer || !(actualBuffer instanceof Buffer)) return {
52
- errorMessage: 'Actual result should be a Buffer.'
53
- };
54
- validateBuffer(expectedBuffer, mimeType);
55
- let actual = mimeType === 'image/png' ? _utilsBundle.PNG.sync.read(actualBuffer) : _utilsBundle.jpegjs.decode(actualBuffer, {
56
- maxMemoryUsageInMB: JPEG_JS_MAX_BUFFER_SIZE_IN_MB
57
- });
58
- let expected = mimeType === 'image/png' ? _utilsBundle.PNG.sync.read(expectedBuffer) : _utilsBundle.jpegjs.decode(expectedBuffer, {
59
- maxMemoryUsageInMB: JPEG_JS_MAX_BUFFER_SIZE_IN_MB
60
- });
61
- const size = {
62
- width: Math.max(expected.width, actual.width),
63
- height: Math.max(expected.height, actual.height)
64
- };
65
- let sizesMismatchError = '';
66
- if (expected.width !== actual.width || expected.height !== actual.height) {
67
- sizesMismatchError = `Expected an image ${expected.width}px by ${expected.height}px, received ${actual.width}px by ${actual.height}px. `;
68
- actual = resizeImage(actual, size);
69
- expected = resizeImage(expected, size);
70
- }
71
- const diff = new _utilsBundle.PNG({
72
- width: size.width,
73
- height: size.height
74
- });
75
- let count;
76
- if (options.comparator === 'ssim-cie94') {
77
- count = (0, _compare.compare)(expected.data, actual.data, diff.data, size.width, size.height, {
78
- // All ΔE* formulae are originally designed to have the difference of 1.0 stand for a "just noticeable difference" (JND).
79
- // See https://en.wikipedia.org/wiki/Color_difference#CIELAB_%CE%94E*
80
- maxColorDeltaE94: 1.0
81
- });
82
- } else if (((_options$comparator = options.comparator) !== null && _options$comparator !== void 0 ? _options$comparator : 'pixelmatch') === 'pixelmatch') {
83
- var _options$threshold;
84
- count = (0, _pixelmatch.default)(expected.data, actual.data, diff.data, size.width, size.height, {
85
- threshold: (_options$threshold = options.threshold) !== null && _options$threshold !== void 0 ? _options$threshold : 0.2
86
- });
87
- } else {
88
- throw new Error(`Configuration specifies unknown comparator "${options.comparator}"`);
89
- }
90
- const maxDiffPixels1 = options.maxDiffPixels;
91
- const maxDiffPixels2 = options.maxDiffPixelRatio !== undefined ? expected.width * expected.height * options.maxDiffPixelRatio : undefined;
92
- let maxDiffPixels;
93
- if (maxDiffPixels1 !== undefined && maxDiffPixels2 !== undefined) maxDiffPixels = Math.min(maxDiffPixels1, maxDiffPixels2);else maxDiffPixels = (_ref = maxDiffPixels1 !== null && maxDiffPixels1 !== void 0 ? maxDiffPixels1 : maxDiffPixels2) !== null && _ref !== void 0 ? _ref : 0;
94
- const ratio = Math.ceil(count / (expected.width * expected.height) * 100) / 100;
95
- const pixelsMismatchError = count > maxDiffPixels ? `${count} pixels (ratio ${ratio.toFixed(2)} of all image pixels) are different.` : '';
96
- if (pixelsMismatchError || sizesMismatchError) return {
97
- errorMessage: sizesMismatchError + pixelsMismatchError,
98
- diff: _utilsBundle.PNG.sync.write(diff)
99
- };
100
- return null;
101
- }
102
- function validateBuffer(buffer, mimeType) {
103
- if (mimeType === 'image/png') {
104
- const pngMagicNumber = [137, 80, 78, 71, 13, 10, 26, 10];
105
- if (buffer.length < pngMagicNumber.length || !pngMagicNumber.every((byte, index) => buffer[index] === byte)) throw new Error('could not decode image as PNG.');
106
- } else if (mimeType === 'image/jpeg') {
107
- const jpegMagicNumber = [255, 216];
108
- if (buffer.length < jpegMagicNumber.length || !jpegMagicNumber.every((byte, index) => buffer[index] === byte)) throw new Error('could not decode image as JPEG.');
109
- }
110
- }
111
- function compareText(actual, expectedBuffer) {
112
- if (typeof actual !== 'string') return {
113
- errorMessage: 'Actual result should be a string'
114
- };
115
- let expected = expectedBuffer.toString('utf-8');
116
- if (expected === actual) return null;
117
- // Eliminate '\'
118
- if (!actual.endsWith('\n')) actual += '\n';
119
- if (!expected.endsWith('\n')) expected += '\n';
120
- const lines = _utilsBundle.diff.createPatch('file', expected, actual, undefined, undefined, {
121
- context: 5
122
- }).split('\n');
123
- const coloredLines = lines.slice(4).map(line => {
124
- if (line.startsWith('-')) return _utilsBundle.colors.red(line);
125
- if (line.startsWith('+')) return _utilsBundle.colors.green(line);
126
- if (line.startsWith('@@')) return _utilsBundle.colors.dim(line);
127
- return line;
128
- });
129
- const errorMessage = coloredLines.join('\n');
130
- return {
131
- errorMessage
132
- };
133
- }
134
- function resizeImage(image, size) {
135
- if (image.width === size.width && image.height === size.height) return image;
136
- const buffer = new Uint8Array(size.width * size.height * 4);
137
- for (let y = 0; y < size.height; y++) {
138
- for (let x = 0; x < size.width; x++) {
139
- const to = (y * size.width + x) * 4;
140
- if (y < image.height && x < image.width) {
141
- const from = (y * image.width + x) * 4;
142
- buffer[to] = image.data[from];
143
- buffer[to + 1] = image.data[from + 1];
144
- buffer[to + 2] = image.data[from + 2];
145
- buffer[to + 3] = image.data[from + 3];
146
- } else {
147
- buffer[to] = 0;
148
- buffer[to + 1] = 0;
149
- buffer[to + 2] = 0;
150
- buffer[to + 3] = 0;
151
- }
152
- }
153
- }
154
- return {
155
- data: Buffer.from(buffer),
156
- width: size.width,
157
- height: size.height
158
- };
159
- }
160
- //# sourceMappingURL=comparators.js.map
@@ -1,172 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.calculateSha1 = calculateSha1;
7
- exports.createGuid = createGuid;
8
- exports.generateSelfSignedCertificate = generateSelfSignedCertificate;
9
- var _crypto = _interopRequireDefault(require("crypto"));
10
- var _assert = require("../../utils/isomorphic/assert");
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- /**
13
- * Copyright (c) Microsoft Corporation.
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
- function createGuid() {
29
- return _crypto.default.randomBytes(16).toString('hex');
30
- }
31
- function calculateSha1(buffer) {
32
- const hash = _crypto.default.createHash('sha1');
33
- hash.update(buffer);
34
- return hash.digest('hex');
35
- }
36
-
37
- // Variable-length quantity encoding aka. base-128 encoding
38
- function encodeBase128(value) {
39
- const bytes = [];
40
- do {
41
- let byte = value & 0x7f;
42
- value >>>= 7;
43
- if (bytes.length > 0) byte |= 0x80;
44
- bytes.push(byte);
45
- } while (value > 0);
46
- return Buffer.from(bytes.reverse());
47
- }
48
-
49
- // ASN1/DER Speficiation: https://www.itu.int/rec/T-REC-X.680-X.693-202102-I/en
50
- class DER {
51
- static encodeSequence(data) {
52
- return this._encode(0x30, Buffer.concat(data));
53
- }
54
- static encodeInteger(data) {
55
- (0, _assert.assert)(data >= -128 && data <= 127);
56
- return this._encode(0x02, Buffer.from([data]));
57
- }
58
- static encodeObjectIdentifier(oid) {
59
- const parts = oid.split('.').map(v => Number(v));
60
- // Encode the second part, which could be large, using base-128 encoding if necessary
61
- const output = [encodeBase128(40 * parts[0] + parts[1])];
62
- for (let i = 2; i < parts.length; i++) output.push(encodeBase128(parts[i]));
63
- return this._encode(0x06, Buffer.concat(output));
64
- }
65
- static encodeNull() {
66
- return Buffer.from([0x05, 0x00]);
67
- }
68
- static encodeSet(data) {
69
- (0, _assert.assert)(data.length === 1, 'Only one item in the set is supported. We\'d need to sort the data to support more.');
70
- // We expect the data to be already sorted.
71
- return this._encode(0x31, Buffer.concat(data));
72
- }
73
- static encodeExplicitContextDependent(tag, data) {
74
- return this._encode(0xa0 + tag, data);
75
- }
76
- static encodePrintableString(data) {
77
- return this._encode(0x13, Buffer.from(data));
78
- }
79
- static encodeBitString(data) {
80
- // The first byte of the content is the number of unused bits at the end
81
- const unusedBits = 0; // Assuming all bits are used
82
- const content = Buffer.concat([Buffer.from([unusedBits]), data]);
83
- return this._encode(0x03, content);
84
- }
85
- static encodeDate(date) {
86
- const year = date.getUTCFullYear();
87
- const isGeneralizedTime = year >= 2050;
88
- const parts = [isGeneralizedTime ? year.toString() : year.toString().slice(-2), (date.getUTCMonth() + 1).toString().padStart(2, '0'), date.getUTCDate().toString().padStart(2, '0'), date.getUTCHours().toString().padStart(2, '0'), date.getUTCMinutes().toString().padStart(2, '0'), date.getUTCSeconds().toString().padStart(2, '0')];
89
- const encodedDate = parts.join('') + 'Z';
90
- const tag = isGeneralizedTime ? 0x18 : 0x17; // 0x18 for GeneralizedTime, 0x17 for UTCTime
91
- return this._encode(tag, Buffer.from(encodedDate));
92
- }
93
- static _encode(tag, data) {
94
- const lengthBytes = this._encodeLength(data.length);
95
- return Buffer.concat([Buffer.from([tag]), lengthBytes, data]);
96
- }
97
- static _encodeLength(length) {
98
- if (length < 128) {
99
- return Buffer.from([length]);
100
- } else {
101
- const lengthBytes = [];
102
- while (length > 0) {
103
- lengthBytes.unshift(length & 0xFF);
104
- length >>= 8;
105
- }
106
- return Buffer.from([0x80 | lengthBytes.length, ...lengthBytes]);
107
- }
108
- }
109
- }
110
-
111
- // X.509 Specification: https://datatracker.ietf.org/doc/html/rfc2459#section-4.1
112
- function generateSelfSignedCertificate() {
113
- const {
114
- privateKey,
115
- publicKey
116
- } = _crypto.default.generateKeyPairSync('rsa', {
117
- modulusLength: 2048
118
- });
119
- const publicKeyDer = publicKey.export({
120
- type: 'pkcs1',
121
- format: 'der'
122
- });
123
- const oneYearInMilliseconds = 365 * 24 * 60 * 60 * 1_000;
124
- const notBefore = new Date(new Date().getTime() - oneYearInMilliseconds);
125
- const notAfter = new Date(new Date().getTime() + oneYearInMilliseconds);
126
-
127
- // List of fields / structure: https://datatracker.ietf.org/doc/html/rfc2459#section-4.1
128
- const tbsCertificate = DER.encodeSequence([DER.encodeExplicitContextDependent(0, DER.encodeInteger(1)),
129
- // version
130
- DER.encodeInteger(1),
131
- // serialNumber
132
- DER.encodeSequence([DER.encodeObjectIdentifier('1.2.840.113549.1.1.11'),
133
- // sha256WithRSAEncryption PKCS #1
134
- DER.encodeNull()]),
135
- // signature
136
- DER.encodeSequence([DER.encodeSet([DER.encodeSequence([DER.encodeObjectIdentifier('2.5.4.3'),
137
- // commonName X.520 DN component
138
- DER.encodePrintableString('localhost')])]), DER.encodeSet([DER.encodeSequence([DER.encodeObjectIdentifier('2.5.4.10'),
139
- // organizationName X.520 DN component
140
- DER.encodePrintableString('Playwright Client Certificate Support')])])]),
141
- // issuer
142
- DER.encodeSequence([DER.encodeDate(notBefore),
143
- // notBefore
144
- DER.encodeDate(notAfter) // notAfter
145
- ]),
146
- // validity
147
- DER.encodeSequence([DER.encodeSet([DER.encodeSequence([DER.encodeObjectIdentifier('2.5.4.3'),
148
- // commonName X.520 DN component
149
- DER.encodePrintableString('localhost')])]), DER.encodeSet([DER.encodeSequence([DER.encodeObjectIdentifier('2.5.4.10'),
150
- // organizationName X.520 DN component
151
- DER.encodePrintableString('Playwright Client Certificate Support')])])]),
152
- // subject
153
- DER.encodeSequence([DER.encodeSequence([DER.encodeObjectIdentifier('1.2.840.113549.1.1.1'),
154
- // rsaEncryption PKCS #1
155
- DER.encodeNull()]), DER.encodeBitString(publicKeyDer)]) // SubjectPublicKeyInfo
156
- ]);
157
- const signature = _crypto.default.sign('sha256', tbsCertificate, privateKey);
158
- const certificate = DER.encodeSequence([tbsCertificate, DER.encodeSequence([DER.encodeObjectIdentifier('1.2.840.113549.1.1.11'),
159
- // sha256WithRSAEncryption PKCS #1
160
- DER.encodeNull()]), DER.encodeBitString(signature)]);
161
- const certPem = ['-----BEGIN CERTIFICATE-----',
162
- // Split the base64 string into lines of 64 characters
163
- certificate.toString('base64').match(/.{1,64}/g).join('\n'), '-----END CERTIFICATE-----'].join('\n');
164
- return {
165
- cert: certPem,
166
- key: privateKey.export({
167
- type: 'pkcs1',
168
- format: 'pem'
169
- })
170
- };
171
- }
172
- //# sourceMappingURL=crypto.js.map
@@ -1,39 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.debugMode = debugMode;
7
- exports.isUnderTest = isUnderTest;
8
- exports.setUnderTest = setUnderTest;
9
- var _env = require("./env");
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
- const _debugMode = (0, _env.getFromENV)('PWDEBUG') || '';
27
- function debugMode() {
28
- if (_debugMode === 'console') return 'console';
29
- if (_debugMode === '0' || _debugMode === 'false') return '';
30
- return _debugMode ? 'inspector' : '';
31
- }
32
- let _isUnderTest = !!process.env.PWTEST_UNDER_TEST;
33
- function setUnderTest() {
34
- _isUnderTest = true;
35
- }
36
- function isUnderTest() {
37
- return _isUnderTest;
38
- }
39
- //# sourceMappingURL=debug.js.map