patchright-core 1.48.2 → 1.49.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.
Files changed (110) hide show
  1. package/README.md +2 -2
  2. package/ThirdPartyNotices.txt +70 -384
  3. package/bin/reinstall_chrome_beta_linux.sh +10 -8
  4. package/bin/reinstall_chrome_stable_linux.sh +10 -8
  5. package/bin/reinstall_msedge_beta_linux.sh +11 -9
  6. package/bin/reinstall_msedge_dev_linux.sh +11 -9
  7. package/bin/reinstall_msedge_stable_linux.sh +11 -9
  8. package/browsers.json +19 -11
  9. package/lib/cli/program.js +23 -5
  10. package/lib/client/channelOwner.js +2 -2
  11. package/lib/client/locator.js +7 -0
  12. package/lib/client/network.js +5 -0
  13. package/lib/client/page.js +4 -2
  14. package/lib/client/tracing.js +13 -0
  15. package/lib/client/waiter.js +15 -11
  16. package/lib/generated/consoleApiSource.js +1 -1
  17. package/lib/generated/injectedScriptSource.js +1 -1
  18. package/lib/generated/pollingRecorderSource.js +1 -1
  19. package/lib/generated/webSocketMockSource.js +1 -1
  20. package/lib/protocol/validator.js +23 -3
  21. package/lib/server/ariaSnapshot.js +33 -0
  22. package/lib/server/bidi/bidiChromium.js +1 -1
  23. package/lib/server/bidi/bidiConnection.js +0 -2
  24. package/lib/server/bidi/bidiExecutionContext.js +0 -3
  25. package/lib/server/browserType.js +4 -1
  26. package/lib/server/chromium/chromium.js +6 -2
  27. package/lib/server/chromium/crExecutionContext.js +0 -13
  28. package/lib/server/chromium/crNetworkManager.js +1 -1
  29. package/lib/server/chromium/crPage.js +4 -5
  30. package/lib/server/codegen/csharp.js +11 -16
  31. package/lib/server/codegen/java.js +4 -7
  32. package/lib/server/codegen/javascript.js +28 -6
  33. package/lib/server/codegen/python.js +12 -16
  34. package/lib/server/debugController.js +8 -5
  35. package/lib/server/deviceDescriptorsSource.json +127 -127
  36. package/lib/server/dispatchers/androidDispatcher.js +13 -2
  37. package/lib/server/dispatchers/debugControllerDispatcher.js +1 -1
  38. package/lib/server/dispatchers/dispatcher.js +1 -1
  39. package/lib/server/dispatchers/frameDispatcher.js +8 -1
  40. package/lib/server/dispatchers/tracingDispatcher.js +10 -0
  41. package/lib/server/dom.js +79 -36
  42. package/lib/server/fetch.js +30 -17
  43. package/lib/server/firefox/ffExecutionContext.js +0 -12
  44. package/lib/server/firefox/ffNetworkManager.js +1 -1
  45. package/lib/server/frames.js +55 -62
  46. package/lib/server/index.js +0 -6
  47. package/lib/server/javascript.js +0 -6
  48. package/lib/server/page.js +32 -5
  49. package/lib/server/progress.js +0 -3
  50. package/lib/server/recorder/recorderApp.js +6 -15
  51. package/lib/server/recorder/recorderInTraceViewer.js +3 -3
  52. package/lib/server/recorder/recorderUtils.js +2 -1
  53. package/lib/server/recorder.js +66 -31
  54. package/lib/server/registry/index.js +70 -23
  55. package/lib/server/registry/nativeDeps.js +6 -3
  56. package/lib/server/socksClientCertificatesInterceptor.js +1 -1
  57. package/lib/server/trace/recorder/snapshotter.js +1 -12
  58. package/lib/server/trace/recorder/snapshotterInjected.js +19 -1
  59. package/lib/server/trace/recorder/tracing.js +69 -15
  60. package/lib/server/trace/test/inMemorySnapshotter.js +3 -3
  61. package/lib/server/trace/viewer/traceViewer.js +2 -1
  62. package/lib/server/webkit/wkBrowser.js +2 -2
  63. package/lib/server/webkit/wkExecutionContext.js +0 -13
  64. package/lib/server/webkit/wkPage.js +4 -0
  65. package/lib/utils/comparators.js +12 -30
  66. package/lib/utils/crypto.js +1 -4
  67. package/lib/utils/hostPlatform.js +6 -0
  68. package/lib/utils/isomorphic/ariaSnapshot.js +267 -0
  69. package/lib/utils/isomorphic/locatorGenerators.js +23 -5
  70. package/lib/utils/isomorphic/recorderUtils.js +36 -4
  71. package/lib/utils/isomorphic/stringUtils.js +30 -0
  72. package/lib/utils/isomorphic/urlMatch.js +5 -1
  73. package/lib/utils/network.js +1 -1
  74. package/lib/utils/sequence.js +64 -0
  75. package/lib/utils/stackTrace.js +16 -3
  76. package/lib/utils/zones.js +32 -23
  77. package/lib/utilsBundle.js +4 -5
  78. package/lib/utilsBundleImpl/index.js +190 -33
  79. package/lib/vite/htmlReport/index.html +19 -16
  80. package/lib/vite/recorder/assets/codeMirrorModule-AFvV6hAs.js +24 -0
  81. package/lib/vite/recorder/assets/index-_cTWgVuJ.js +184 -0
  82. package/lib/vite/recorder/assets/{index-BW-aOBcL.css → index-iA1aAGZg.css} +1 -1
  83. package/lib/vite/recorder/index.html +2 -2
  84. package/lib/vite/traceViewer/assets/codeMirrorModule-BWCrdKft.js +24 -0
  85. package/lib/vite/traceViewer/assets/inspectorTab-C_9qyxv5.js +68 -0
  86. package/lib/vite/traceViewer/assets/workbench-DsQEOQud.js +9 -0
  87. package/lib/vite/traceViewer/{embedded.BlHoW5LY.js → embedded.D4x_-tXl.js} +1 -1
  88. package/lib/vite/traceViewer/embedded.html +5 -5
  89. package/lib/vite/traceViewer/{index.DaWVfou1.js → index.BskMikzx.js} +1 -1
  90. package/lib/vite/traceViewer/index.html +24 -7
  91. package/lib/vite/traceViewer/{inspectorTab.DLjBDrQR.css → inspectorTab.DEOUW62d.css} +1 -1
  92. package/lib/vite/traceViewer/recorder.Dsk1wX5k.js +2 -0
  93. package/lib/vite/traceViewer/recorder.html +3 -3
  94. package/lib/vite/traceViewer/sw.bundle.js +3 -3
  95. package/lib/vite/traceViewer/uiMode.CzKr-TMc.js +5 -0
  96. package/lib/vite/traceViewer/uiMode.html +6 -6
  97. package/lib/vite/traceViewer/{uiMode.CAYqod-m.css → uiMode.voC1ZiOQ.css} +1 -1
  98. package/lib/vite/traceViewer/workbench.C-zR9ysA.css +1 -0
  99. package/package.json +1 -1
  100. package/types/protocol.d.ts +58 -10
  101. package/types/types.d.ts +116 -20
  102. package/lib/third_party/diff_match_patch.js +0 -2222
  103. package/lib/vite/recorder/assets/codeMirrorModule-baozm8ur.js +0 -24
  104. package/lib/vite/recorder/assets/index-2ElAIWFB.js +0 -42
  105. package/lib/vite/traceViewer/assets/codeMirrorModule-Bh1rfd2w.js +0 -24
  106. package/lib/vite/traceViewer/assets/inspectorTab-7GHnKvSD.js +0 -64
  107. package/lib/vite/traceViewer/assets/workbench-DPQnTHYP.js +0 -9
  108. package/lib/vite/traceViewer/recorder.C4zxcvd2.js +0 -2
  109. package/lib/vite/traceViewer/uiMode.mTXWniJb.js +0 -5
  110. package/lib/vite/traceViewer/workbench.D3JVcA9K.css +0 -1
@@ -120,7 +120,8 @@ class Tracing extends _instrumentation.SdkObject {
120
120
  traceSha1s: new Set(),
121
121
  networkSha1s: new Set(),
122
122
  recording: false,
123
- callIds: new Set()
123
+ callIds: new Set(),
124
+ groupStack: []
124
125
  };
125
126
  this._fs.mkdir(this._state.resourcesDir);
126
127
  this._fs.writeFile(this._state.networkFile, '');
@@ -155,6 +156,52 @@ class Tracing extends _instrumentation.SdkObject {
155
156
  traceName: this._state.traceName
156
157
  };
157
158
  }
159
+ _currentGroupId() {
160
+ var _this$_state;
161
+ return (_this$_state = this._state) !== null && _this$_state !== void 0 && _this$_state.groupStack.length ? this._state.groupStack[this._state.groupStack.length - 1] : undefined;
162
+ }
163
+ async group(name, location, metadata) {
164
+ var _ref;
165
+ if (!this._state) return;
166
+ const stackFrames = [];
167
+ const {
168
+ file,
169
+ line,
170
+ column
171
+ } = (_ref = location !== null && location !== void 0 ? location : metadata.location) !== null && _ref !== void 0 ? _ref : {};
172
+ if (file) {
173
+ stackFrames.push({
174
+ file,
175
+ line: line !== null && line !== void 0 ? line : 0,
176
+ column: column !== null && column !== void 0 ? column : 0
177
+ });
178
+ }
179
+ const event = {
180
+ type: 'before',
181
+ callId: metadata.id,
182
+ startTime: metadata.startTime,
183
+ apiName: name,
184
+ class: 'Tracing',
185
+ method: 'tracingGroup',
186
+ params: {},
187
+ stepId: metadata.stepId,
188
+ stack: stackFrames
189
+ };
190
+ if (this._currentGroupId()) event.parentId = this._currentGroupId();
191
+ this._state.groupStack.push(event.callId);
192
+ this._appendTraceEvent(event);
193
+ }
194
+ groupEnd() {
195
+ if (!this._state) return;
196
+ const callId = this._state.groupStack.pop();
197
+ if (!callId) return;
198
+ const event = {
199
+ type: 'after',
200
+ callId,
201
+ endTime: (0, _utils.monotonicTime)()
202
+ };
203
+ this._appendTraceEvent(event);
204
+ }
158
205
  _startScreencast() {
159
206
  if (!(this._context instanceof _browserContext.BrowserContext)) return;
160
207
  for (const page of this._context.pages()) this._startScreencastInPage(page);
@@ -184,6 +231,7 @@ class Tracing extends _instrumentation.SdkObject {
184
231
  if (!this._state) return;
185
232
  if (this._isStopping) throw new Error(`Tracing is already stopping`);
186
233
  if (this._state.recording) throw new Error(`Must stop trace file before stopping tracing`);
234
+ this._closeAllGroups();
187
235
  this._harTracer.stop();
188
236
  this.flushHarEntries();
189
237
  await this._fs.syncAndGetError();
@@ -206,6 +254,9 @@ class Tracing extends _instrumentation.SdkObject {
206
254
  this.abort();
207
255
  await this._fs.syncAndGetError();
208
256
  }
257
+ _closeAllGroups() {
258
+ while (this._currentGroupId()) this.groupEnd();
259
+ }
209
260
  async stopChunk(params) {
210
261
  var _this$_snapshotter4;
211
262
  if (this._isStopping) throw new Error(`Tracing is already stopping`);
@@ -215,6 +266,7 @@ class Tracing extends _instrumentation.SdkObject {
215
266
  if (params.mode !== 'discard') throw new Error(`Must start tracing before stopping`);
216
267
  return {};
217
268
  }
269
+ this._closeAllGroups();
218
270
  this._context.instrumentation.removeListener(this);
219
271
  _utils.eventsHelper.removeEventListeners(this._eventListeners);
220
272
  if (this._state.options.screenshots) this._stopScreencast();
@@ -275,34 +327,34 @@ class Tracing extends _instrumentation.SdkObject {
275
327
  artifact
276
328
  };
277
329
  }
278
- async _captureSnapshot(snapshotName, sdkObject, metadata, element) {
330
+ async _captureSnapshot(snapshotName, sdkObject, metadata) {
279
331
  if (!this._snapshotter) return;
280
332
  if (!sdkObject.attribution.page) return;
281
333
  if (!this._snapshotter.started()) return;
282
334
  if (!shouldCaptureSnapshot(metadata)) return;
283
- await this._snapshotter.captureSnapshot(sdkObject.attribution.page, metadata.id, snapshotName, element).catch(() => {});
335
+ await this._snapshotter.captureSnapshot(sdkObject.attribution.page, metadata.id, snapshotName).catch(() => {});
284
336
  }
285
337
  onBeforeCall(sdkObject, metadata) {
286
- var _sdkObject$attributio, _this$_state;
338
+ var _sdkObject$attributio, _this$_state2;
287
339
  // IMPORTANT: no awaits before this._appendTraceEvent in this method.
288
- const event = createBeforeActionTraceEvent(metadata);
340
+ const event = createBeforeActionTraceEvent(metadata, this._currentGroupId());
289
341
  if (!event) return Promise.resolve();
290
342
  (_sdkObject$attributio = sdkObject.attribution.page) === null || _sdkObject$attributio === void 0 || _sdkObject$attributio.temporarilyDisableTracingScreencastThrottling();
291
343
  event.beforeSnapshot = `before@${metadata.id}`;
292
- (_this$_state = this._state) === null || _this$_state === void 0 || _this$_state.callIds.add(metadata.id);
344
+ (_this$_state2 = this._state) === null || _this$_state2 === void 0 || _this$_state2.callIds.add(metadata.id);
293
345
  this._appendTraceEvent(event);
294
346
  return this._captureSnapshot(event.beforeSnapshot, sdkObject, metadata);
295
347
  }
296
- onBeforeInputAction(sdkObject, metadata, element) {
297
- var _this$_state2, _sdkObject$attributio2;
298
- if (!((_this$_state2 = this._state) !== null && _this$_state2 !== void 0 && _this$_state2.callIds.has(metadata.id))) return Promise.resolve();
348
+ onBeforeInputAction(sdkObject, metadata) {
349
+ var _this$_state3, _sdkObject$attributio2;
350
+ if (!((_this$_state3 = this._state) !== null && _this$_state3 !== void 0 && _this$_state3.callIds.has(metadata.id))) return Promise.resolve();
299
351
  // IMPORTANT: no awaits before this._appendTraceEvent in this method.
300
352
  const event = createInputActionTraceEvent(metadata);
301
353
  if (!event) return Promise.resolve();
302
354
  (_sdkObject$attributio2 = sdkObject.attribution.page) === null || _sdkObject$attributio2 === void 0 || _sdkObject$attributio2.temporarilyDisableTracingScreencastThrottling();
303
355
  event.inputSnapshot = `input@${metadata.id}`;
304
356
  this._appendTraceEvent(event);
305
- return this._captureSnapshot(event.inputSnapshot, sdkObject, metadata, element);
357
+ return this._captureSnapshot(event.inputSnapshot, sdkObject, metadata);
306
358
  }
307
359
  onCallLog(sdkObject, metadata, logName, message) {
308
360
  if (metadata.isServerSide || metadata.internal) return;
@@ -311,9 +363,9 @@ class Tracing extends _instrumentation.SdkObject {
311
363
  if (event) this._appendTraceEvent(event);
312
364
  }
313
365
  async onAfterCall(sdkObject, metadata) {
314
- var _this$_state3, _this$_state4, _sdkObject$attributio3;
315
- if (!((_this$_state3 = this._state) !== null && _this$_state3 !== void 0 && _this$_state3.callIds.has(metadata.id))) return;
316
- (_this$_state4 = this._state) === null || _this$_state4 === void 0 || _this$_state4.callIds.delete(metadata.id);
366
+ var _this$_state4, _this$_state5, _sdkObject$attributio3;
367
+ if (!((_this$_state4 = this._state) !== null && _this$_state4 !== void 0 && _this$_state4.callIds.has(metadata.id))) return;
368
+ (_this$_state5 = this._state) === null || _this$_state5 === void 0 || _this$_state5.callIds.delete(metadata.id);
317
369
  const event = createAfterActionTraceEvent(metadata);
318
370
  if (!event) return;
319
371
  (_sdkObject$attributio3 = sdkObject.attribution.page) === null || _sdkObject$attributio3 === void 0 || _sdkObject$attributio3.temporarilyDisableTracingScreencastThrottling();
@@ -497,9 +549,9 @@ function visitTraceEvent(object, sha1s) {
497
549
  function shouldCaptureSnapshot(metadata) {
498
550
  return _debug.commandsWithTracingSnapshots.has(metadata.type + '.' + metadata.method);
499
551
  }
500
- function createBeforeActionTraceEvent(metadata) {
552
+ function createBeforeActionTraceEvent(metadata, parentId) {
501
553
  if (metadata.internal || metadata.method.startsWith('tracing')) return null;
502
- return {
554
+ const event = {
503
555
  type: 'before',
504
556
  callId: metadata.id,
505
557
  startTime: metadata.startTime,
@@ -510,6 +562,8 @@ function createBeforeActionTraceEvent(metadata) {
510
562
  stepId: metadata.stepId,
511
563
  pageId: metadata.pageId
512
564
  };
565
+ if (parentId) event.parentId = parentId;
566
+ return event;
513
567
  }
514
568
  function createInputActionTraceEvent(metadata) {
515
569
  if (metadata.internal || metadata.method.startsWith('tracing')) return null;
@@ -60,9 +60,9 @@ class InMemorySnapshotter {
60
60
  await this._harTracer.flush();
61
61
  this._harTracer.stop();
62
62
  }
63
- async captureSnapshot(page, callId, snapshotName, element) {
63
+ async captureSnapshot(page, callId, snapshotName) {
64
64
  if (this._snapshotReadyPromises.has(snapshotName)) throw new Error('Duplicate snapshot name: ' + snapshotName);
65
- this._snapshotter.captureSnapshot(page, callId, snapshotName, element).catch(() => {});
65
+ this._snapshotter.captureSnapshot(page, callId, snapshotName).catch(() => {});
66
66
  const promise = new _utils.ManualPromise();
67
67
  this._snapshotReadyPromises.set(snapshotName, promise);
68
68
  return promise;
@@ -80,7 +80,7 @@ class InMemorySnapshotter {
80
80
  onFrameSnapshot(snapshot) {
81
81
  var _this$_snapshotReadyP;
82
82
  ++this._snapshotCount;
83
- const renderer = this._storage.addFrameSnapshot(snapshot);
83
+ const renderer = this._storage.addFrameSnapshot(snapshot, []);
84
84
  (_this$_snapshotReadyP = this._snapshotReadyPromises.get(snapshot.snapshotName || '')) === null || _this$_snapshotReadyP === void 0 || _this$_snapshotReadyP.resolve(renderer);
85
85
  }
86
86
  async resourceContentForTest(sha1) {
@@ -135,7 +135,8 @@ async function openTraceViewerApp(url, browserName, options) {
135
135
  persistentContextOptions: {
136
136
  ...(options === null || options === void 0 ? void 0 : options.persistentContextOptions),
137
137
  useWebSocket: (0, _utils.isUnderTest)(),
138
- headless: !!(options !== null && options !== void 0 && options.headless)
138
+ headless: !!(options !== null && options !== void 0 && options.headless),
139
+ colorScheme: (0, _utils.isUnderTest)() ? 'light' : undefined
139
140
  }
140
141
  });
141
142
  const controller = new _progress.ProgressController((0, _instrumentation.serverSideCallMetadata)(), context._browser);
@@ -30,8 +30,8 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
30
30
  * limitations under the License.
31
31
  */
32
32
 
33
- const DEFAULT_USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Safari/605.1.15';
34
- const BROWSER_VERSION = '18.0';
33
+ const DEFAULT_USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.2 Safari/605.1.15';
34
+ const BROWSER_VERSION = '18.2';
35
35
  class WKBrowser extends _browser.Browser {
36
36
  static async connect(parent, transport, options) {
37
37
  const browser = new WKBrowser(parent, transport, options);
@@ -59,19 +59,6 @@ class WKExecutionContext {
59
59
  throw rewriteError(error);
60
60
  }
61
61
  }
62
- rawCallFunctionNoReply(func, ...args) {
63
- this._session.send('Runtime.callFunctionOn', {
64
- functionDeclaration: func.toString(),
65
- objectId: args.find(a => a instanceof js.JSHandle)._objectId,
66
- arguments: args.map(a => a instanceof js.JSHandle ? {
67
- objectId: a._objectId
68
- } : {
69
- value: a
70
- }),
71
- returnByValue: true,
72
- emulateUserGesture: true
73
- }).catch(() => {});
74
- }
75
62
  async evaluateWithArguments(expression, returnByValue, utilityScript, values, objectIds) {
76
63
  try {
77
64
  const response = await this._session.send('Runtime.callFunctionOn', {
@@ -247,6 +247,10 @@ class WKPage {
247
247
  setting: 'InputTypeWeekEnabled',
248
248
  value: contextOptions.isMobile
249
249
  }));
250
+ promises.push(session.send('Page.overrideSetting', {
251
+ setting: 'FixedBackgroundsPaintRelativeToDocument',
252
+ value: contextOptions.isMobile
253
+ }));
250
254
  await Promise.all(promises);
251
255
  }
252
256
  _onDidCommitProvisionalTarget(event) {
@@ -5,7 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getComparator = getComparator;
7
7
  var _utilsBundle = require("../utilsBundle");
8
+ var _pixelmatch = _interopRequireDefault(require("../third_party/pixelmatch"));
8
9
  var _compare = require("../image_tools/compare");
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
11
  /**
10
12
  * Copyright 2017 Google Inc. All rights reserved.
11
13
  * Modifications copyright (c) Microsoft Corporation.
@@ -23,13 +25,8 @@ var _compare = require("../image_tools/compare");
23
25
  * limitations under the License.
24
26
  */
25
27
 
26
- const pixelmatch = require('../third_party/pixelmatch');
27
- const {
28
- diff_match_patch,
29
- DIFF_INSERT,
30
- DIFF_DELETE,
31
- DIFF_EQUAL
32
- } = require('../third_party/diff_match_patch');
28
+ // @ts-ignore
29
+
33
30
  function getComparator(mimeType) {
34
31
  if (mimeType === 'image/png') return compareImages.bind(null, 'image/png');
35
32
  if (mimeType === 'image/jpeg') return compareImages.bind(null, 'image/jpeg');
@@ -83,7 +80,7 @@ function compareImages(mimeType, actualBuffer, expectedBuffer, options = {}) {
83
80
  });
84
81
  } else if (((_options$comparator = options.comparator) !== null && _options$comparator !== void 0 ? _options$comparator : 'pixelmatch') === 'pixelmatch') {
85
82
  var _options$threshold;
86
- count = pixelmatch(expected.data, actual.data, diff.data, size.width, size.height, {
83
+ count = (0, _pixelmatch.default)(expected.data, actual.data, diff.data, size.width, size.height, {
87
84
  threshold: (_options$threshold = options.threshold) !== null && _options$threshold !== void 0 ? _options$threshold : 0.2
88
85
  });
89
86
  } else {
@@ -116,32 +113,17 @@ function compareText(actual, expectedBuffer) {
116
113
  };
117
114
  const expected = expectedBuffer.toString('utf-8');
118
115
  if (expected === actual) return null;
119
- const dmp = new diff_match_patch();
120
- const d = dmp.diff_main(expected, actual);
121
- dmp.diff_cleanupSemantic(d);
116
+ const diffs = _utilsBundle.diff.diffChars(expected, actual);
122
117
  return {
123
- errorMessage: diff_prettyTerminal(d)
118
+ errorMessage: diff_prettyTerminal(diffs)
124
119
  };
125
120
  }
126
121
  function diff_prettyTerminal(diffs) {
127
- const html = [];
128
- for (let x = 0; x < diffs.length; x++) {
129
- const op = diffs[x][0]; // Operation (insert, delete, equal)
130
- const data = diffs[x][1]; // Text of change.
131
- const text = data;
132
- switch (op) {
133
- case DIFF_INSERT:
134
- html[x] = _utilsBundle.colors.green(text);
135
- break;
136
- case DIFF_DELETE:
137
- html[x] = _utilsBundle.colors.reset(_utilsBundle.colors.strikethrough(_utilsBundle.colors.red(text)));
138
- break;
139
- case DIFF_EQUAL:
140
- html[x] = text;
141
- break;
142
- }
143
- }
144
- return html.join('');
122
+ const result = diffs.map(part => {
123
+ const text = part.value;
124
+ if (part.added) return _utilsBundle.colors.green(text);else if (part.removed) return _utilsBundle.colors.reset(_utilsBundle.colors.strikethrough(_utilsBundle.colors.red(text)));else return text;
125
+ });
126
+ return result.join('');
145
127
  }
146
128
  function resizeImage(image, size) {
147
129
  if (image.width === size.width && image.height === size.height) return image;
@@ -45,7 +45,6 @@ function encodeBase128(value) {
45
45
  } while (value > 0);
46
46
  return Buffer.from(bytes.reverse());
47
47
  }
48
- ;
49
48
 
50
49
  // ASN1/DER Speficiation: https://www.itu.int/rec/T-REC-X.680-X.693-202102-I/en
51
50
  class DER {
@@ -60,9 +59,7 @@ class DER {
60
59
  const parts = oid.split('.').map(v => Number(v));
61
60
  // Encode the second part, which could be large, using base-128 encoding if necessary
62
61
  const output = [encodeBase128(40 * parts[0] + parts[1])];
63
- for (let i = 2; i < parts.length; i++) {
64
- output.push(encodeBase128(parts[i]));
65
- }
62
+ for (let i = 2; i < parts.length; i++) output.push(encodeBase128(parts[i]));
66
63
  return this._encode(0x06, Buffer.concat(output));
67
64
  }
68
65
  static encodeNull() {
@@ -24,6 +24,12 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
24
24
  */
25
25
 
26
26
  function calculatePlatform() {
27
+ if (process.env.PLAYWRIGHT_HOST_PLATFORM_OVERRIDE) {
28
+ return {
29
+ hostPlatform: process.env.PLAYWRIGHT_HOST_PLATFORM_OVERRIDE,
30
+ isOfficiallySupportedPlatform: false
31
+ };
32
+ }
27
33
  const platform = _os.default.platform();
28
34
  if (platform === 'darwin') {
29
35
  const ver = _os.default.release().split('.').map(a => parseInt(a, 10));
@@ -0,0 +1,267 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.AriaKeyError = void 0;
7
+ exports.parseAriaKey = parseAriaKey;
8
+ exports.parseYamlTemplate = parseYamlTemplate;
9
+ /**
10
+ * 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
+ // https://www.w3.org/TR/wai-aria-1.2/#role_definitions
26
+
27
+ function parseYamlTemplate(fragment) {
28
+ const result = {
29
+ kind: 'role',
30
+ role: 'fragment'
31
+ };
32
+ populateNode(result, fragment);
33
+ if (result.children && result.children.length === 1) return result.children[0];
34
+ return result;
35
+ }
36
+ function populateNode(node, container) {
37
+ for (const object of container) {
38
+ if (typeof object === 'string') {
39
+ const childNode = KeyParser.parse(object);
40
+ node.children = node.children || [];
41
+ node.children.push(childNode);
42
+ continue;
43
+ }
44
+ for (const key of Object.keys(object)) {
45
+ node.children = node.children || [];
46
+ const value = object[key];
47
+ if (key === 'text') {
48
+ node.children.push({
49
+ kind: 'text',
50
+ text: valueOrRegex(value)
51
+ });
52
+ continue;
53
+ }
54
+ const childNode = KeyParser.parse(key);
55
+ if (childNode.kind === 'text') {
56
+ node.children.push({
57
+ kind: 'text',
58
+ text: valueOrRegex(value)
59
+ });
60
+ continue;
61
+ }
62
+ if (typeof value === 'string') {
63
+ node.children.push({
64
+ ...childNode,
65
+ children: [{
66
+ kind: 'text',
67
+ text: valueOrRegex(value)
68
+ }]
69
+ });
70
+ continue;
71
+ }
72
+ node.children.push(childNode);
73
+ populateNode(childNode, value);
74
+ }
75
+ }
76
+ }
77
+ function normalizeWhitespace(text) {
78
+ return text.replace(/[\r\n\s\t]+/g, ' ').trim();
79
+ }
80
+ function valueOrRegex(value) {
81
+ return value.startsWith('/') && value.endsWith('/') ? new RegExp(value.slice(1, -1)) : normalizeWhitespace(value);
82
+ }
83
+ class KeyParser {
84
+ static parse(input) {
85
+ return new KeyParser(input)._parse();
86
+ }
87
+ constructor(input) {
88
+ this._input = void 0;
89
+ this._pos = void 0;
90
+ this._length = void 0;
91
+ this._input = input;
92
+ this._pos = 0;
93
+ this._length = input.length;
94
+ }
95
+ _peek() {
96
+ return this._input[this._pos] || '';
97
+ }
98
+ _next() {
99
+ if (this._pos < this._length) return this._input[this._pos++];
100
+ return null;
101
+ }
102
+ _eof() {
103
+ return this._pos >= this._length;
104
+ }
105
+ _isWhitespace() {
106
+ return !this._eof() && /\s/.test(this._peek());
107
+ }
108
+ _skipWhitespace() {
109
+ while (this._isWhitespace()) this._pos++;
110
+ }
111
+ _readIdentifier(type) {
112
+ if (this._eof()) this._throwError(`Unexpected end of input when expecting ${type}`);
113
+ const start = this._pos;
114
+ while (!this._eof() && /[a-zA-Z]/.test(this._peek())) this._pos++;
115
+ return this._input.slice(start, this._pos);
116
+ }
117
+ _readString() {
118
+ let result = '';
119
+ let escaped = false;
120
+ while (!this._eof()) {
121
+ const ch = this._next();
122
+ if (escaped) {
123
+ result += ch;
124
+ escaped = false;
125
+ } else if (ch === '\\') {
126
+ escaped = true;
127
+ } else if (ch === '"') {
128
+ return result;
129
+ } else {
130
+ result += ch;
131
+ }
132
+ }
133
+ this._throwError('Unterminated string');
134
+ }
135
+ _throwError(message, pos) {
136
+ throw new AriaKeyError(message, this._input, pos || this._pos);
137
+ }
138
+ _readRegex() {
139
+ let result = '';
140
+ let escaped = false;
141
+ let insideClass = false;
142
+ while (!this._eof()) {
143
+ const ch = this._next();
144
+ if (escaped) {
145
+ result += ch;
146
+ escaped = false;
147
+ } else if (ch === '\\') {
148
+ escaped = true;
149
+ result += ch;
150
+ } else if (ch === '/' && !insideClass) {
151
+ return result;
152
+ } else if (ch === '[') {
153
+ insideClass = true;
154
+ result += ch;
155
+ } else if (ch === ']' && insideClass) {
156
+ result += ch;
157
+ insideClass = false;
158
+ } else {
159
+ result += ch;
160
+ }
161
+ }
162
+ this._throwError('Unterminated regex');
163
+ }
164
+ _readStringOrRegex() {
165
+ const ch = this._peek();
166
+ if (ch === '"') {
167
+ this._next();
168
+ return this._readString();
169
+ }
170
+ if (ch === '/') {
171
+ this._next();
172
+ return new RegExp(this._readRegex());
173
+ }
174
+ return null;
175
+ }
176
+ _readAttributes(result) {
177
+ let errorPos = this._pos;
178
+ while (true) {
179
+ this._skipWhitespace();
180
+ if (this._peek() === '[') {
181
+ this._next();
182
+ this._skipWhitespace();
183
+ errorPos = this._pos;
184
+ const flagName = this._readIdentifier('attribute');
185
+ this._skipWhitespace();
186
+ let flagValue = '';
187
+ if (this._peek() === '=') {
188
+ this._next();
189
+ this._skipWhitespace();
190
+ errorPos = this._pos;
191
+ while (this._peek() !== ']' && !this._isWhitespace() && !this._eof()) flagValue += this._next();
192
+ }
193
+ this._skipWhitespace();
194
+ if (this._peek() !== ']') this._throwError('Expected ]');
195
+ this._next(); // Consume ']'
196
+ this._applyAttribute(result, flagName, flagValue || 'true', errorPos);
197
+ } else {
198
+ break;
199
+ }
200
+ }
201
+ }
202
+ _parse() {
203
+ this._skipWhitespace();
204
+ const role = this._readIdentifier('role');
205
+ this._skipWhitespace();
206
+ const name = this._readStringOrRegex() || '';
207
+ const result = {
208
+ kind: 'role',
209
+ role,
210
+ name
211
+ };
212
+ this._readAttributes(result);
213
+ this._skipWhitespace();
214
+ if (!this._eof()) this._throwError('Unexpected input');
215
+ return result;
216
+ }
217
+ _applyAttribute(node, key, value, errorPos) {
218
+ if (key === 'checked') {
219
+ this._assert(value === 'true' || value === 'false' || value === 'mixed', 'Value of "checked\" attribute must be a boolean or "mixed"', errorPos);
220
+ node.checked = value === 'true' ? true : value === 'false' ? false : 'mixed';
221
+ return;
222
+ }
223
+ if (key === 'disabled') {
224
+ this._assert(value === 'true' || value === 'false', 'Value of "disabled" attribute must be a boolean', errorPos);
225
+ node.disabled = value === 'true';
226
+ return;
227
+ }
228
+ if (key === 'expanded') {
229
+ this._assert(value === 'true' || value === 'false', 'Value of "expanded" attribute must be a boolean', errorPos);
230
+ node.expanded = value === 'true';
231
+ return;
232
+ }
233
+ if (key === 'level') {
234
+ this._assert(!isNaN(Number(value)), 'Value of "level" attribute must be a number', errorPos);
235
+ node.level = Number(value);
236
+ return;
237
+ }
238
+ if (key === 'pressed') {
239
+ this._assert(value === 'true' || value === 'false' || value === 'mixed', 'Value of "pressed" attribute must be a boolean or "mixed"', errorPos);
240
+ node.pressed = value === 'true' ? true : value === 'false' ? false : 'mixed';
241
+ return;
242
+ }
243
+ if (key === 'selected') {
244
+ this._assert(value === 'true' || value === 'false', 'Value of "selected" attribute must be a boolean', errorPos);
245
+ node.selected = value === 'true';
246
+ return;
247
+ }
248
+ this._assert(false, `Unsupported attribute [${key}]`, errorPos);
249
+ }
250
+ _assert(value, message, valuePos) {
251
+ if (!value) this._throwError(message || 'Assertion error', valuePos);
252
+ }
253
+ }
254
+ function parseAriaKey(key) {
255
+ return KeyParser.parse(key);
256
+ }
257
+ class AriaKeyError extends Error {
258
+ constructor(message, input, pos) {
259
+ super(message + ':\n\n' + input + '\n' + ' '.repeat(pos) + '^\n');
260
+ this.shortMessage = void 0;
261
+ this.pos = void 0;
262
+ this.shortMessage = message;
263
+ this.pos = pos;
264
+ this.stack = undefined;
265
+ }
266
+ }
267
+ exports.AriaKeyError = AriaKeyError;