@checkly/playwright-core 1.41.21 → 1.41.23

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 (126) hide show
  1. package/lib/browserServerImpl.js +1 -1
  2. package/lib/cli/driver.js +11 -3
  3. package/lib/cli/program.js +13 -5
  4. package/lib/client/android.js +1 -1
  5. package/lib/client/artifact.js +2 -2
  6. package/lib/client/browserContext.js +5 -5
  7. package/lib/client/browserType.js +1 -1
  8. package/lib/client/channelOwner.js +3 -3
  9. package/lib/client/clientHelper.js +5 -1
  10. package/lib/client/connection.js +2 -2
  11. package/lib/client/consoleMessage.js +3 -3
  12. package/lib/client/electron.js +3 -0
  13. package/lib/client/events.js +1 -0
  14. package/lib/client/fetch.js +3 -3
  15. package/lib/client/frame.js +4 -3
  16. package/lib/client/harRouter.js +7 -1
  17. package/lib/client/locator.js +2 -2
  18. package/lib/client/page.js +26 -7
  19. package/lib/common/socksProxy.js +12 -17
  20. package/lib/generated/consoleApiSource.js +1 -1
  21. package/lib/generated/injectedScriptSource.js +1 -1
  22. package/lib/generated/recorderSource.js +1 -1
  23. package/lib/outofprocess.js +3 -3
  24. package/lib/protocol/validator.js +46 -29
  25. package/lib/remote/playwrightConnection.js +2 -2
  26. package/lib/remote/playwrightServer.js +72 -166
  27. package/lib/server/android/android.js +2 -2
  28. package/lib/server/android/backendAdb.js +2 -2
  29. package/lib/server/browser.js +2 -2
  30. package/lib/server/browserContext.js +8 -9
  31. package/lib/server/browserType.js +5 -5
  32. package/lib/server/chromium/chromium.js +5 -4
  33. package/lib/server/chromium/crBrowser.js +2 -3
  34. package/lib/server/chromium/crConnection.js +2 -2
  35. package/lib/server/chromium/crExecutionContext.js +2 -2
  36. package/lib/server/chromium/crInput.js +2 -2
  37. package/lib/server/chromium/crNetworkManager.js +10 -11
  38. package/lib/server/chromium/crPage.js +48 -7
  39. package/lib/server/chromium/crServiceWorker.js +2 -3
  40. package/lib/server/console.js +1 -3
  41. package/lib/server/debugController.js +0 -3
  42. package/lib/server/deviceDescriptorsSource.json +50 -50
  43. package/lib/server/dispatchers/browserContextDispatcher.js +7 -6
  44. package/lib/server/dispatchers/dispatcher.js +19 -20
  45. package/lib/server/dispatchers/electronDispatcher.js +13 -0
  46. package/lib/server/dispatchers/frameDispatcher.js +0 -6
  47. package/lib/server/dispatchers/localUtilsDispatcher.js +4 -4
  48. package/lib/server/dispatchers/pageDispatcher.js +14 -10
  49. package/lib/server/dispatchers/playwrightDispatcher.js +5 -5
  50. package/lib/server/dispatchers/writableStreamDispatcher.js +2 -2
  51. package/lib/server/dom.js +133 -170
  52. package/lib/server/electron/electron.js +40 -14
  53. package/lib/server/electron/loader.js +4 -2
  54. package/lib/server/fetch.js +4 -4
  55. package/lib/server/firefox/ffAccessibility.js +2 -1
  56. package/lib/server/firefox/ffBrowser.js +3 -3
  57. package/lib/server/firefox/ffConnection.js +1 -1
  58. package/lib/server/firefox/ffExecutionContext.js +2 -2
  59. package/lib/server/firefox/ffNetworkManager.js +7 -7
  60. package/lib/server/firefox/ffPage.js +3 -5
  61. package/lib/server/firefox/firefox.js +2 -2
  62. package/lib/server/frames.js +42 -23
  63. package/lib/server/har/harTracer.js +6 -6
  64. package/lib/server/helper.js +1 -1
  65. package/lib/server/input.js +2 -2
  66. package/lib/server/isomorphic/utilityScriptSerializers.js +0 -1
  67. package/lib/server/javascript.js +2 -2
  68. package/lib/server/page.js +51 -7
  69. package/lib/server/pipeTransport.js +1 -1
  70. package/lib/server/playwright.js +1 -1
  71. package/lib/server/progress.js +5 -14
  72. package/lib/server/recorder/csharp.js +1 -1
  73. package/lib/server/recorder/recorderUtils.js +2 -2
  74. package/lib/server/recorder.js +14 -14
  75. package/lib/server/registry/browserFetcher.js +1 -2
  76. package/lib/server/registry/dependencies.js +7 -6
  77. package/lib/server/registry/index.js +50 -33
  78. package/lib/server/registry/nativeDeps.js +0 -94
  79. package/lib/server/registry/oopDownloadBrowserMain.js +2 -2
  80. package/lib/server/screenshotter.js +0 -1
  81. package/lib/server/socksInterceptor.js +2 -2
  82. package/lib/server/trace/recorder/snapshotter.js +2 -2
  83. package/lib/server/trace/recorder/tracing.js +12 -11
  84. package/lib/server/trace/test/inMemorySnapshotter.js +1 -1
  85. package/lib/server/trace/viewer/traceViewer.js +2 -2
  86. package/lib/server/transport.js +15 -13
  87. package/lib/server/webkit/wkBrowser.js +3 -3
  88. package/lib/server/webkit/wkConnection.js +1 -1
  89. package/lib/server/webkit/wkExecutionContext.js +2 -2
  90. package/lib/server/webkit/wkInput.js +2 -2
  91. package/lib/server/webkit/wkInterceptableRequest.js +2 -2
  92. package/lib/server/webkit/wkPage.js +10 -12
  93. package/lib/utils/comparators.js +4 -4
  94. package/lib/utils/fileUtils.js +4 -0
  95. package/lib/utils/happy-eyeballs.js +5 -4
  96. package/lib/utils/hostPlatform.js +1 -1
  97. package/lib/utils/index.js +11 -0
  98. package/lib/utils/isomorphic/cssParser.js +2 -2
  99. package/lib/utils/isomorphic/locatorParser.js +6 -4
  100. package/lib/utils/isomorphic/selectorParser.js +0 -1
  101. package/lib/utils/network.js +33 -0
  102. package/lib/utils/processLauncher.js +9 -2
  103. package/lib/utils/profiler.js +2 -2
  104. package/lib/utils/zipFile.js +1 -1
  105. package/lib/vite/htmlReport/index.html +12 -13
  106. package/lib/vite/recorder/assets/codeMirrorModule-Hs9-1ZG4.css +1 -0
  107. package/lib/vite/recorder/assets/codeMirrorModule-I9ks4y7D.js +24 -0
  108. package/lib/vite/recorder/assets/{index-64ce22d5.css → index-ljsTwXtJ.css} +1 -1
  109. package/lib/vite/recorder/assets/index-yg8ypzl6.js +47 -0
  110. package/lib/vite/recorder/index.html +2 -3
  111. package/lib/vite/traceViewer/assets/codeMirrorModule-A2_PGeGB.js +24 -0
  112. package/lib/vite/{recorder/assets/codeMirrorModule-85487eb6.js → traceViewer/assets/codeMirrorModule-aUzO-LID.js} +1 -1
  113. package/lib/vite/traceViewer/assets/wsPort-L8WBvZfK.js +69 -0
  114. package/lib/vite/traceViewer/assets/wsPort-uVqol1LI.js +69 -0
  115. package/lib/vite/traceViewer/index.4xhUWj1f.js +2 -0
  116. package/lib/vite/traceViewer/index.html +4 -5
  117. package/lib/vite/traceViewer/index.o6j3Cv4u.js +2 -0
  118. package/lib/vite/traceViewer/sw.bundle.js +4 -4
  119. package/lib/vite/traceViewer/uiMode.PlLkrJDI.js +10 -0
  120. package/lib/vite/traceViewer/uiMode.html +4 -5
  121. package/lib/vite/traceViewer/uiMode.qpn6w4df.js +10 -0
  122. package/lib/vite/traceViewer/wsPort.zR1WIy9-.css +1 -0
  123. package/package.json +1 -1
  124. package/lib/vite/recorder/assets/codeMirrorModule-5d0f417c.css +0 -1
  125. package/lib/vite/recorder/assets/index-b14c63fe.js +0 -41
  126. /package/lib/vite/recorder/assets/{codicon-79f233d0.ttf → codicon-zGuYmc9o.ttf} +0 -0
@@ -9,8 +9,8 @@ var _transport = require("./protocol/transport");
9
9
  var childProcess = _interopRequireWildcard(require("child_process"));
10
10
  var path = _interopRequireWildcard(require("path"));
11
11
  var _manualPromise = require("./utils/manualPromise");
12
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
12
+ 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); }
13
+ 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; }
14
14
  /**
15
15
  * Copyright (c) Microsoft Corporation.
16
16
  *
@@ -41,7 +41,7 @@ class PlaywrightClient {
41
41
  this._playwright = void 0;
42
42
  this._driverProcess = void 0;
43
43
  this._closePromise = new _manualPromise.ManualPromise();
44
- this._driverProcess = childProcess.fork(path.join(__dirname, 'cli', 'cli.js'), ['run-driver'], {
44
+ this._driverProcess = childProcess.fork(path.join(__dirname, '..', 'cli.js'), ['run-driver'], {
45
45
  stdio: 'pipe',
46
46
  detached: true,
47
47
  env: {
@@ -429,13 +429,6 @@ _validatorPrimitives.scheme.DebugControllerSourceChangedEvent = (0, _validatorPr
429
429
  _validatorPrimitives.scheme.DebugControllerPausedEvent = (0, _validatorPrimitives.tObject)({
430
430
  paused: _validatorPrimitives.tBoolean
431
431
  });
432
- _validatorPrimitives.scheme.DebugControllerBrowsersChangedEvent = (0, _validatorPrimitives.tObject)({
433
- browsers: (0, _validatorPrimitives.tArray)((0, _validatorPrimitives.tObject)({
434
- contexts: (0, _validatorPrimitives.tArray)((0, _validatorPrimitives.tObject)({
435
- pages: (0, _validatorPrimitives.tArray)(_validatorPrimitives.tString)
436
- }))
437
- }))
438
- });
439
432
  _validatorPrimitives.scheme.DebugControllerInitializeParams = (0, _validatorPrimitives.tObject)({
440
433
  codegenId: _validatorPrimitives.tString,
441
434
  sdkLanguage: (0, _validatorPrimitives.tEnum)(['javascript', 'python', 'java', 'csharp'])
@@ -819,7 +812,6 @@ _validatorPrimitives.scheme.BrowserContextBindingCallEvent = (0, _validatorPrimi
819
812
  binding: (0, _validatorPrimitives.tChannel)(['BindingCall'])
820
813
  });
821
814
  _validatorPrimitives.scheme.BrowserContextConsoleEvent = (0, _validatorPrimitives.tObject)({
822
- page: (0, _validatorPrimitives.tChannel)(['Page']),
823
815
  type: _validatorPrimitives.tString,
824
816
  text: _validatorPrimitives.tString,
825
817
  args: (0, _validatorPrimitives.tArray)((0, _validatorPrimitives.tChannel)(['ElementHandle', 'JSHandle'])),
@@ -827,7 +819,8 @@ _validatorPrimitives.scheme.BrowserContextConsoleEvent = (0, _validatorPrimitive
827
819
  url: _validatorPrimitives.tString,
828
820
  lineNumber: _validatorPrimitives.tNumber,
829
821
  columnNumber: _validatorPrimitives.tNumber
830
- })
822
+ }),
823
+ page: (0, _validatorPrimitives.tChannel)(['Page'])
831
824
  });
832
825
  _validatorPrimitives.scheme.BrowserContextCloseEvent = (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tObject)({}));
833
826
  _validatorPrimitives.scheme.BrowserContextDialogEvent = (0, _validatorPrimitives.tObject)({
@@ -1030,6 +1023,9 @@ _validatorPrimitives.scheme.PageFrameAttachedEvent = (0, _validatorPrimitives.tO
1030
1023
  _validatorPrimitives.scheme.PageFrameDetachedEvent = (0, _validatorPrimitives.tObject)({
1031
1024
  frame: (0, _validatorPrimitives.tChannel)(['Frame'])
1032
1025
  });
1026
+ _validatorPrimitives.scheme.PageLocatorHandlerTriggeredEvent = (0, _validatorPrimitives.tObject)({
1027
+ uid: _validatorPrimitives.tNumber
1028
+ });
1033
1029
  _validatorPrimitives.scheme.PageRouteEvent = (0, _validatorPrimitives.tObject)({
1034
1030
  route: (0, _validatorPrimitives.tChannel)(['Route'])
1035
1031
  });
@@ -1085,6 +1081,16 @@ _validatorPrimitives.scheme.PageGoForwardParams = (0, _validatorPrimitives.tObje
1085
1081
  _validatorPrimitives.scheme.PageGoForwardResult = (0, _validatorPrimitives.tObject)({
1086
1082
  response: (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tChannel)(['Response']))
1087
1083
  });
1084
+ _validatorPrimitives.scheme.PageRegisterLocatorHandlerParams = (0, _validatorPrimitives.tObject)({
1085
+ selector: _validatorPrimitives.tString
1086
+ });
1087
+ _validatorPrimitives.scheme.PageRegisterLocatorHandlerResult = (0, _validatorPrimitives.tObject)({
1088
+ uid: _validatorPrimitives.tNumber
1089
+ });
1090
+ _validatorPrimitives.scheme.PageResolveLocatorHandlerNoReplyParams = (0, _validatorPrimitives.tObject)({
1091
+ uid: _validatorPrimitives.tNumber
1092
+ });
1093
+ _validatorPrimitives.scheme.PageResolveLocatorHandlerNoReplyResult = (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tObject)({}));
1088
1094
  _validatorPrimitives.scheme.PageReloadParams = (0, _validatorPrimitives.tObject)({
1089
1095
  timeout: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tNumber),
1090
1096
  waitUntil: (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tType)('LifecycleEvent'))
@@ -1100,26 +1106,22 @@ _validatorPrimitives.scheme.PageExpectScreenshotParams = (0, _validatorPrimitive
1100
1106
  frame: (0, _validatorPrimitives.tChannel)(['Frame']),
1101
1107
  selector: _validatorPrimitives.tString
1102
1108
  })),
1103
- comparatorOptions: (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tObject)({
1104
- comparator: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tString),
1105
- maxDiffPixels: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tNumber),
1106
- maxDiffPixelRatio: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tNumber),
1107
- threshold: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tNumber)
1108
- })),
1109
- screenshotOptions: (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tObject)({
1110
- fullPage: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tBoolean),
1111
- clip: (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tType)('Rect')),
1112
- omitBackground: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tBoolean),
1113
- caret: (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tEnum)(['hide', 'initial'])),
1114
- animations: (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tEnum)(['disabled', 'allow'])),
1115
- scale: (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tEnum)(['css', 'device'])),
1116
- mask: (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tArray)((0, _validatorPrimitives.tObject)({
1117
- frame: (0, _validatorPrimitives.tChannel)(['Frame']),
1118
- selector: _validatorPrimitives.tString
1119
- }))),
1120
- maskColor: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tString),
1121
- style: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tString)
1122
- }))
1109
+ comparator: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tString),
1110
+ maxDiffPixels: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tNumber),
1111
+ maxDiffPixelRatio: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tNumber),
1112
+ threshold: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tNumber),
1113
+ fullPage: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tBoolean),
1114
+ clip: (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tType)('Rect')),
1115
+ omitBackground: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tBoolean),
1116
+ caret: (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tEnum)(['hide', 'initial'])),
1117
+ animations: (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tEnum)(['disabled', 'allow'])),
1118
+ scale: (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tEnum)(['css', 'device'])),
1119
+ mask: (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tArray)((0, _validatorPrimitives.tObject)({
1120
+ frame: (0, _validatorPrimitives.tChannel)(['Frame']),
1121
+ selector: _validatorPrimitives.tString
1122
+ }))),
1123
+ maskColor: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tString),
1124
+ style: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tString)
1123
1125
  });
1124
1126
  _validatorPrimitives.scheme.PageExpectScreenshotResult = (0, _validatorPrimitives.tObject)({
1125
1127
  diff: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tBinary),
@@ -2299,6 +2301,16 @@ _validatorPrimitives.scheme.ElectronApplicationInitializer = (0, _validatorPrimi
2299
2301
  context: (0, _validatorPrimitives.tChannel)(['BrowserContext'])
2300
2302
  });
2301
2303
  _validatorPrimitives.scheme.ElectronApplicationCloseEvent = (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tObject)({}));
2304
+ _validatorPrimitives.scheme.ElectronApplicationConsoleEvent = (0, _validatorPrimitives.tObject)({
2305
+ type: _validatorPrimitives.tString,
2306
+ text: _validatorPrimitives.tString,
2307
+ args: (0, _validatorPrimitives.tArray)((0, _validatorPrimitives.tChannel)(['ElementHandle', 'JSHandle'])),
2308
+ location: (0, _validatorPrimitives.tObject)({
2309
+ url: _validatorPrimitives.tString,
2310
+ lineNumber: _validatorPrimitives.tNumber,
2311
+ columnNumber: _validatorPrimitives.tNumber
2312
+ })
2313
+ });
2302
2314
  _validatorPrimitives.scheme.ElectronApplicationBrowserWindowParams = (0, _validatorPrimitives.tObject)({
2303
2315
  page: (0, _validatorPrimitives.tChannel)(['Page'])
2304
2316
  });
@@ -2321,6 +2333,11 @@ _validatorPrimitives.scheme.ElectronApplicationEvaluateExpressionHandleParams =
2321
2333
  _validatorPrimitives.scheme.ElectronApplicationEvaluateExpressionHandleResult = (0, _validatorPrimitives.tObject)({
2322
2334
  handle: (0, _validatorPrimitives.tChannel)(['ElementHandle', 'JSHandle'])
2323
2335
  });
2336
+ _validatorPrimitives.scheme.ElectronApplicationUpdateSubscriptionParams = (0, _validatorPrimitives.tObject)({
2337
+ event: (0, _validatorPrimitives.tEnum)(['console']),
2338
+ enabled: _validatorPrimitives.tBoolean
2339
+ });
2340
+ _validatorPrimitives.scheme.ElectronApplicationUpdateSubscriptionResult = (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tObject)({}));
2324
2341
  _validatorPrimitives.scheme.ElectronApplicationCloseParams = (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tObject)({}));
2325
2342
  _validatorPrimitives.scheme.ElectronApplicationCloseResult = (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tObject)({}));
2326
2343
  _validatorPrimitives.scheme.AndroidInitializer = (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tObject)({}));
@@ -11,7 +11,7 @@ var _socksProxy = require("../common/socksProxy");
11
11
  var _utils = require("../utils");
12
12
  var _android = require("../server/android/android");
13
13
  var _debugControllerDispatcher = require("../server/dispatchers/debugControllerDispatcher");
14
- var _debugLogger = require("../common/debugLogger");
14
+ var _debugLogger = require("../utils/debugLogger");
15
15
  /**
16
16
  * Copyright (c) Microsoft Corporation.
17
17
  *
@@ -109,7 +109,7 @@ class PlaywrightConnection {
109
109
  const playwright = this._preLaunched.playwright;
110
110
 
111
111
  // Note: connected client owns the socks proxy and configures the pattern.
112
- (_this$_preLaunched$so = this._preLaunched.socksProxy) === null || _this$_preLaunched$so === void 0 ? void 0 : _this$_preLaunched$so.setPattern(this._options.socksProxyPattern);
112
+ (_this$_preLaunched$so = this._preLaunched.socksProxy) === null || _this$_preLaunched$so === void 0 || _this$_preLaunched$so.setPattern(this._options.socksProxyPattern);
113
113
  const browser = this._preLaunched.browser;
114
114
  browser.on(_browser.Browser.Events.Disconnected, () => {
115
115
  // Underlying browser did close for some reason - force disconnect the client.
@@ -3,14 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Semaphore = exports.PlaywrightServer = void 0;
7
- var _utilsBundle = require("../utilsBundle");
6
+ exports.PlaywrightServer = void 0;
8
7
  var _playwright = require("../server/playwright");
9
8
  var _playwrightConnection = require("./playwrightConnection");
10
- var _manualPromise = require("../utils/manualPromise");
11
- var _debugLogger = require("../common/debugLogger");
9
+ var _semaphore = require("../utils/semaphore");
10
+ var _debugLogger = require("../utils/debugLogger");
12
11
  var _utils = require("../utils");
13
- var _transport = require("../server/transport");
12
+ var _wsServer = require("../utils/wsServer");
14
13
  /**
15
14
  * Copyright (c) Microsoft Corporation.
16
15
  *
@@ -27,178 +26,85 @@ var _transport = require("../server/transport");
27
26
  * limitations under the License.
28
27
  */
29
28
 
30
- let lastConnectionId = 0;
31
- const kConnectionSymbol = Symbol('kConnection');
32
29
  class PlaywrightServer {
33
30
  constructor(options) {
34
31
  this._preLaunchedPlaywright = void 0;
35
- this._wsServer = void 0;
36
- this._server = void 0;
37
32
  this._options = void 0;
33
+ this._wsServer = void 0;
38
34
  this._options = options;
39
35
  if (options.preLaunchedBrowser) this._preLaunchedPlaywright = options.preLaunchedBrowser.attribution.playwright;
40
36
  if (options.preLaunchedAndroidDevice) this._preLaunchedPlaywright = options.preLaunchedAndroidDevice._android.attribution.playwright;
41
- }
42
- async listen(port = 0, hostname) {
43
- _debugLogger.debugLogger.log('server', `Server started at ${new Date()}`);
44
- const server = (0, _utils.createHttpServer)((request, response) => {
45
- if (request.method === 'GET' && request.url === '/json') {
46
- response.setHeader('Content-Type', 'application/json');
47
- response.end(JSON.stringify({
48
- wsEndpointPath: this._options.path
49
- }));
50
- return;
51
- }
52
- response.end('Running');
53
- });
54
- server.on('error', error => _debugLogger.debugLogger.log('server', String(error)));
55
- this._server = server;
56
- const wsEndpoint = await new Promise((resolve, reject) => {
57
- server.listen(port, hostname, () => {
58
- const address = server.address();
59
- if (!address) {
60
- reject(new Error('Could not bind server socket'));
61
- return;
62
- }
63
- const wsEndpoint = typeof address === 'string' ? `${address}${this._options.path}` : `ws://${hostname || 'localhost'}:${address.port}${this._options.path}`;
64
- resolve(wsEndpoint);
65
- }).on('error', reject);
66
- });
67
- _debugLogger.debugLogger.log('server', 'Listening at ' + wsEndpoint);
68
- this._wsServer = new _utilsBundle.wsServer({
69
- noServer: true,
70
- perMessageDeflate: _transport.perMessageDeflate
71
- });
72
- const browserSemaphore = new Semaphore(this._options.maxConnections);
73
- const controllerSemaphore = new Semaphore(1);
74
- const reuseBrowserSemaphore = new Semaphore(1);
75
- if (process.env.PWTEST_SERVER_WS_HEADERS) {
76
- this._wsServer.on('headers', (headers, request) => {
77
- headers.push(process.env.PWTEST_SERVER_WS_HEADERS);
78
- });
79
- }
80
- server.on('upgrade', (request, socket, head) => {
81
- var _this$_wsServer;
82
- const pathname = new URL('http://localhost' + request.url).pathname;
83
- if (pathname !== this._options.path) {
84
- socket.write(`HTTP/${request.httpVersion} 400 Bad Request\r\n\r\n`);
85
- socket.destroy();
86
- return;
87
- }
88
- const uaError = (0, _utils.userAgentVersionMatchesErrorMessage)(request.headers['user-agent'] || '');
89
- if (uaError) {
90
- socket.write(`HTTP/${request.httpVersion} 428 Precondition Required\r\n\r\n${uaError}`);
91
- socket.destroy();
92
- return;
93
- }
94
- (_this$_wsServer = this._wsServer) === null || _this$_wsServer === void 0 ? void 0 : _this$_wsServer.handleUpgrade(request, socket, head, ws => {
95
- var _this$_wsServer2;
96
- return (_this$_wsServer2 = this._wsServer) === null || _this$_wsServer2 === void 0 ? void 0 : _this$_wsServer2.emit('connection', ws, request);
97
- });
98
- });
99
- this._wsServer.on('connection', (ws, request) => {
100
- _debugLogger.debugLogger.log('server', 'Connected client ws.extension=' + ws.extensions);
101
- const url = new URL('http://localhost' + (request.url || ''));
102
- const browserHeader = request.headers['x-playwright-browser'];
103
- const browserName = url.searchParams.get('browser') || (Array.isArray(browserHeader) ? browserHeader[0] : browserHeader) || null;
104
- const proxyHeader = request.headers['x-playwright-proxy'];
105
- const proxyValue = url.searchParams.get('proxy') || (Array.isArray(proxyHeader) ? proxyHeader[0] : proxyHeader);
106
- const launchOptionsHeader = request.headers['x-playwright-launch-options'] || '';
107
- const launchOptionsHeaderValue = Array.isArray(launchOptionsHeader) ? launchOptionsHeader[0] : launchOptionsHeader;
108
- const launchOptionsParam = url.searchParams.get('launch-options');
109
- let launchOptions = {};
110
- try {
111
- launchOptions = JSON.parse(launchOptionsParam || launchOptionsHeaderValue);
112
- } catch (e) {}
113
- const id = String(++lastConnectionId);
114
- _debugLogger.debugLogger.log('server', `[${id}] serving connection: ${request.url}`);
37
+ const browserSemaphore = new _semaphore.Semaphore(this._options.maxConnections);
38
+ const controllerSemaphore = new _semaphore.Semaphore(1);
39
+ const reuseBrowserSemaphore = new _semaphore.Semaphore(1);
40
+ this._wsServer = new _wsServer.WSServer({
41
+ onUpgrade: (request, socket) => {
42
+ const uaError = (0, _utils.userAgentVersionMatchesErrorMessage)(request.headers['user-agent'] || '');
43
+ if (uaError) return {
44
+ error: `HTTP/${request.httpVersion} 428 Precondition Required\r\n\r\n${uaError}`
45
+ };
46
+ },
47
+ onHeaders: headers => {
48
+ if (process.env.PWTEST_SERVER_WS_HEADERS) headers.push(process.env.PWTEST_SERVER_WS_HEADERS);
49
+ },
50
+ onConnection: (request, url, ws, id) => {
51
+ const browserHeader = request.headers['x-playwright-browser'];
52
+ const browserName = url.searchParams.get('browser') || (Array.isArray(browserHeader) ? browserHeader[0] : browserHeader) || null;
53
+ const proxyHeader = request.headers['x-playwright-proxy'];
54
+ const proxyValue = url.searchParams.get('proxy') || (Array.isArray(proxyHeader) ? proxyHeader[0] : proxyHeader);
55
+ const launchOptionsHeader = request.headers['x-playwright-launch-options'] || '';
56
+ const launchOptionsHeaderValue = Array.isArray(launchOptionsHeader) ? launchOptionsHeader[0] : launchOptionsHeader;
57
+ const launchOptionsParam = url.searchParams.get('launch-options');
58
+ let launchOptions = {};
59
+ try {
60
+ launchOptions = JSON.parse(launchOptionsParam || launchOptionsHeaderValue);
61
+ } catch (e) {}
115
62
 
116
- // Instantiate playwright for the extension modes.
117
- const isExtension = this._options.mode === 'extension';
118
- if (isExtension) {
119
- if (!this._preLaunchedPlaywright) this._preLaunchedPlaywright = (0, _playwright.createPlaywright)({
120
- sdkLanguage: 'javascript',
121
- isServer: true
122
- });
123
- }
124
- let clientType = 'launch-browser';
125
- let semaphore = browserSemaphore;
126
- if (isExtension && url.searchParams.has('debug-controller')) {
127
- clientType = 'controller';
128
- semaphore = controllerSemaphore;
129
- } else if (isExtension) {
130
- clientType = 'reuse-browser';
131
- semaphore = reuseBrowserSemaphore;
132
- } else if (this._options.mode === 'launchServer') {
133
- clientType = 'pre-launched-browser-or-android';
134
- semaphore = browserSemaphore;
63
+ // Instantiate playwright for the extension modes.
64
+ const isExtension = this._options.mode === 'extension';
65
+ if (isExtension) {
66
+ if (!this._preLaunchedPlaywright) this._preLaunchedPlaywright = (0, _playwright.createPlaywright)({
67
+ sdkLanguage: 'javascript',
68
+ isServer: true
69
+ });
70
+ }
71
+ let clientType = 'launch-browser';
72
+ let semaphore = browserSemaphore;
73
+ if (isExtension && url.searchParams.has('debug-controller')) {
74
+ clientType = 'controller';
75
+ semaphore = controllerSemaphore;
76
+ } else if (isExtension) {
77
+ clientType = 'reuse-browser';
78
+ semaphore = reuseBrowserSemaphore;
79
+ } else if (this._options.mode === 'launchServer') {
80
+ clientType = 'pre-launched-browser-or-android';
81
+ semaphore = browserSemaphore;
82
+ }
83
+ return new _playwrightConnection.PlaywrightConnection(semaphore.acquire(), clientType, ws, {
84
+ socksProxyPattern: proxyValue,
85
+ browserName,
86
+ launchOptions
87
+ }, {
88
+ playwright: this._preLaunchedPlaywright,
89
+ browser: this._options.preLaunchedBrowser,
90
+ androidDevice: this._options.preLaunchedAndroidDevice,
91
+ socksProxy: this._options.preLaunchedSocksProxy
92
+ }, id, () => semaphore.release());
93
+ },
94
+ onClose: async () => {
95
+ _debugLogger.debugLogger.log('server', 'closing browsers');
96
+ if (this._preLaunchedPlaywright) await Promise.all(this._preLaunchedPlaywright.allBrowsers().map(browser => browser.close({
97
+ reason: 'Playwright Server stopped'
98
+ })));
99
+ _debugLogger.debugLogger.log('server', 'closed browsers');
135
100
  }
136
- const connection = new _playwrightConnection.PlaywrightConnection(semaphore.acquire(), clientType, ws, {
137
- socksProxyPattern: proxyValue,
138
- browserName,
139
- launchOptions
140
- }, {
141
- playwright: this._preLaunchedPlaywright,
142
- browser: this._options.preLaunchedBrowser,
143
- androidDevice: this._options.preLaunchedAndroidDevice,
144
- socksProxy: this._options.preLaunchedSocksProxy
145
- }, id, () => semaphore.release());
146
- ws[kConnectionSymbol] = connection;
147
101
  });
148
- return wsEndpoint;
149
102
  }
150
- async close() {
151
- const server = this._wsServer;
152
- if (!server) return;
153
- _debugLogger.debugLogger.log('server', 'closing websocket server');
154
- const waitForClose = new Promise(f => server.close(f));
155
- // First disconnect all remaining clients.
156
- await Promise.all(Array.from(server.clients).map(async ws => {
157
- const connection = ws[kConnectionSymbol];
158
- if (connection) await connection.close();
159
- try {
160
- ws.terminate();
161
- } catch (e) {}
162
- }));
163
- await waitForClose;
164
- _debugLogger.debugLogger.log('server', 'closing http server');
165
- if (this._server) await new Promise(f => this._server.close(f));
166
- this._wsServer = undefined;
167
- this._server = undefined;
168
- _debugLogger.debugLogger.log('server', 'closed server');
169
- _debugLogger.debugLogger.log('server', 'closing browsers');
170
- if (this._preLaunchedPlaywright) await Promise.all(this._preLaunchedPlaywright.allBrowsers().map(browser => browser.close({
171
- reason: 'Playwright Server stopped'
172
- })));
173
- _debugLogger.debugLogger.log('server', 'closed browsers');
174
- }
175
- }
176
- exports.PlaywrightServer = PlaywrightServer;
177
- class Semaphore {
178
- constructor(max) {
179
- this._max = void 0;
180
- this._acquired = 0;
181
- this._queue = [];
182
- this._max = max;
183
- }
184
- setMax(max) {
185
- this._max = max;
186
- }
187
- acquire() {
188
- const lock = new _manualPromise.ManualPromise();
189
- this._queue.push(lock);
190
- this._flush();
191
- return lock;
192
- }
193
- release() {
194
- --this._acquired;
195
- this._flush();
103
+ async listen(port = 0, hostname) {
104
+ return this._wsServer.listen(port, hostname, this._options.path);
196
105
  }
197
- _flush() {
198
- while (this._acquired < this._max && this._queue.length) {
199
- ++this._acquired;
200
- this._queue.shift().resolve();
201
- }
106
+ async close() {
107
+ await this._wsServer.close();
202
108
  }
203
109
  }
204
- exports.Semaphore = Semaphore;
110
+ exports.PlaywrightServer = PlaywrightServer;
@@ -16,7 +16,7 @@ var _progress = require("../progress");
16
16
  var _crBrowser = require("../chromium/crBrowser");
17
17
  var _helper = require("../helper");
18
18
  var _transport = require("../../protocol/transport");
19
- var _debugLogger = require("../../common/debugLogger");
19
+ var _debugLogger = require("../../utils/debugLogger");
20
20
  var _processLauncher = require("../../utils/processLauncher");
21
21
  var _timeoutSettings = require("../../common/timeoutSettings");
22
22
  var _instrumentation = require("../instrumentation");
@@ -204,7 +204,7 @@ class AndroidDevice extends _instrumentation.SdkObject {
204
204
  for (const connection of this._browserConnections) await connection.close();
205
205
  if (this._driverPromise) {
206
206
  const driver = await this._driver();
207
- driver === null || driver === void 0 ? void 0 : driver.close();
207
+ driver === null || driver === void 0 || driver.close();
208
208
  }
209
209
  await this._backend.close();
210
210
  this._android._deviceClosed(this);
@@ -8,8 +8,8 @@ var _utilsBundle = require("../../utilsBundle");
8
8
  var net = _interopRequireWildcard(require("net"));
9
9
  var _events = require("events");
10
10
  var _utils = require("../../utils");
11
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
11
+ 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); }
12
+ 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; }
13
13
  /**
14
14
  * Copyright Microsoft Corporation. All rights reserved.
15
15
  *
@@ -68,8 +68,8 @@ class Browser extends _instrumentation.SdkObject {
68
68
  };
69
69
  }
70
70
  async stopPendingOperations(reason) {
71
- var _this$_contextForReus, _this$_contextForReus2;
72
- await ((_this$_contextForReus = this._contextForReuse) === null || _this$_contextForReus === void 0 ? void 0 : (_this$_contextForReus2 = _this$_contextForReus.context) === null || _this$_contextForReus2 === void 0 ? void 0 : _this$_contextForReus2.stopPendingOperations(reason));
71
+ var _this$_contextForReus;
72
+ await ((_this$_contextForReus = this._contextForReuse) === null || _this$_contextForReus === void 0 || (_this$_contextForReus = _this$_contextForReus.context) === null || _this$_contextForReus === void 0 ? void 0 : _this$_contextForReus.stopPendingOperations(reason));
73
73
  }
74
74
  _downloadCreated(page, uuid, url, suggestedFilename) {
75
75
  const download = new _download.Download(page, this.options.downloadsPath || '', uuid, url, suggestedFilename);
@@ -25,8 +25,8 @@ var _recorder = require("./recorder");
25
25
  var consoleApiSource = _interopRequireWildcard(require("../generated/consoleApiSource"));
26
26
  var _fetch = require("./fetch");
27
27
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
29
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
28
+ 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); }
29
+ 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; }
30
30
  /**
31
31
  * Copyright 2017 Google Inc. All rights reserved.
32
32
  * Modifications copyright (c) Microsoft Corporation.
@@ -158,13 +158,13 @@ class BrowserContext extends _instrumentation.SdkObject {
158
158
  }
159
159
 
160
160
  // Unless dialogs are dismissed, setting extra http headers below does not respond.
161
- (_page = page) === null || _page === void 0 ? void 0 : _page._frameManager.setCloseAllOpeningDialogs(true);
161
+ (_page = page) === null || _page === void 0 || _page._frameManager.setCloseAllOpeningDialogs(true);
162
162
  await ((_page2 = page) === null || _page2 === void 0 ? void 0 : _page2._frameManager.closeOpenDialogs());
163
163
  // Navigate to about:blank first to ensure no page scripts are running after this point.
164
164
  await ((_page3 = page) === null || _page3 === void 0 ? void 0 : _page3.mainFrame().goto(metadata, 'about:blank', {
165
165
  timeout: 0
166
166
  }));
167
- (_page4 = page) === null || _page4 === void 0 ? void 0 : _page4._frameManager.setCloseAllOpeningDialogs(false);
167
+ (_page4 = page) === null || _page4 === void 0 || _page4._frameManager.setCloseAllOpeningDialogs(false);
168
168
  await this._resetStorage();
169
169
  await this._removeExposedBindings();
170
170
  await this._removeInitScripts();
@@ -401,9 +401,9 @@ class BrowserContext extends _instrumentation.SdkObject {
401
401
  return result;
402
402
  }
403
403
  async _resetStorage() {
404
- var _this$_options$storag, _this$_options$storag2;
404
+ var _this$_options$storag;
405
405
  const oldOrigins = this._origins;
406
- const newOrigins = new Map(((_this$_options$storag = this._options.storageState) === null || _this$_options$storag === void 0 ? void 0 : (_this$_options$storag2 = _this$_options$storag.origins) === null || _this$_options$storag2 === void 0 ? void 0 : _this$_options$storag2.map(p => [p.origin, p])) || []);
406
+ const newOrigins = new Map(((_this$_options$storag = this._options.storageState) === null || _this$_options$storag === void 0 || (_this$_options$storag = _this$_options$storag.origins) === null || _this$_options$storag === void 0 ? void 0 : _this$_options$storag.map(p => [p.origin, p])) || []);
407
407
  if (!oldOrigins.size && !newOrigins.size) return;
408
408
  let page = this.pages()[0];
409
409
  const internalMetadata = (0, _instrumentation.serverSideCallMetadata)();
@@ -429,11 +429,10 @@ class BrowserContext extends _instrumentation.SdkObject {
429
429
  this._origins = new Set([...newOrigins.keys()]);
430
430
  // It is safe to not restore the URL to about:blank since we are doing it in Page::resetForReuse.
431
431
  }
432
-
433
432
  async _resetCookies() {
434
- var _this$_options$storag3, _this$_options$storag4;
433
+ var _this$_options$storag2, _this$_options$storag3;
435
434
  await this.clearCookies();
436
- if ((_this$_options$storag3 = this._options.storageState) !== null && _this$_options$storag3 !== void 0 && _this$_options$storag3.cookies) await this.addCookies((_this$_options$storag4 = this._options.storageState) === null || _this$_options$storag4 === void 0 ? void 0 : _this$_options$storag4.cookies);
435
+ if ((_this$_options$storag2 = this._options.storageState) !== null && _this$_options$storag2 !== void 0 && _this$_options$storag2.cookies) await this.addCookies((_this$_options$storag3 = this._options.storageState) === null || _this$_options$storag3 === void 0 ? void 0 : _this$_options$storag3.cookies);
437
436
  }
438
437
  isSettingStorageState() {
439
438
  return this._settingStorageState;
@@ -17,12 +17,12 @@ var _timeoutSettings = require("../common/timeoutSettings");
17
17
  var _utils = require("../utils");
18
18
  var _fileUtils = require("../utils/fileUtils");
19
19
  var _helper = require("./helper");
20
- var _debugLogger = require("../common/debugLogger");
20
+ var _debugLogger = require("../utils/debugLogger");
21
21
  var _instrumentation = require("./instrumentation");
22
22
  var _manualPromise = require("../utils/manualPromise");
23
23
  var _protocolError = require("./protocolError");
24
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
25
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
24
+ 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); }
25
+ 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; }
26
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
27
  /**
28
28
  * Copyright (c) Microsoft Corporation.
@@ -164,7 +164,7 @@ class BrowserType extends _instrumentation.SdkObject {
164
164
  const registryExecutable = _registry.registry.findExecutable(options.channel || this._name);
165
165
  if (!registryExecutable || registryExecutable.browserName !== this._name) throw new Error(`Unsupported ${this._name} channel "${options.channel}"`);
166
166
  executable = registryExecutable.executablePathOrDie(this.attribution.playwright.options.sdkLanguage);
167
- await registryExecutable.validateHostRequirements(this.attribution.playwright.options.sdkLanguage);
167
+ await _registry.registry.validateHostRequirementsForExecutablesIfNeeded([registryExecutable], this.attribution.playwright.options.sdkLanguage);
168
168
  }
169
169
  const waitForWSEndpoint = options.useWebSocket || (_options$args = options.args) !== null && _options$args !== void 0 && _options$args.some(a => a.startsWith('--remote-debugging-port')) ? new _manualPromise.ManualPromise() : undefined;
170
170
  const waitForJuggler = this._name === 'firefox' ? new _manualPromise.ManualPromise() : undefined;
@@ -203,7 +203,7 @@ class BrowserType extends _instrumentation.SdkObject {
203
203
  },
204
204
  onExit: (exitCode, signal) => {
205
205
  // Unblock launch when browser prematurely exits.
206
- waitForJuggler === null || waitForJuggler === void 0 ? void 0 : waitForJuggler.resolve();
206
+ waitForJuggler === null || waitForJuggler === void 0 || waitForJuggler.resolve();
207
207
  if (browserProcess && browserProcess.onclose) browserProcess.onclose(exitCode, signal);
208
208
  }
209
209
  });
@@ -19,7 +19,7 @@ var _userAgent = require("../../utils/userAgent");
19
19
  var _ascii = require("../../utils/ascii");
20
20
  var _utils = require("../../utils");
21
21
  var _fileUtils = require("../../utils/fileUtils");
22
- var _debugLogger = require("../../common/debugLogger");
22
+ var _debugLogger = require("../../utils/debugLogger");
23
23
  var _progress = require("../progress");
24
24
  var _timeoutSettings = require("../../common/timeoutSettings");
25
25
  var _helper = require("../helper");
@@ -68,7 +68,7 @@ class Chromium extends _browserType.BrowserType {
68
68
  'User-Agent': (0, _userAgent.getUserAgent)()
69
69
  };else if (headersMap && !Object.keys(headersMap).some(key => key.toLowerCase() === 'user-agent')) headersMap['User-Agent'] = (0, _userAgent.getUserAgent)();
70
70
  const artifactsDir = await _fs.default.promises.mkdtemp(ARTIFACTS_FOLDER);
71
- const wsEndpoint = await urlToWSEndpoint(progress, endpointURL);
71
+ const wsEndpoint = await urlToWSEndpoint(progress, endpointURL, headersMap);
72
72
  progress.throwIfAborted();
73
73
  const chromeTransport = await _transport.WebSocketTransport.connect(progress, wsEndpoint, headersMap);
74
74
  const cleanedUp = new _manualPromise.ManualPromise();
@@ -305,12 +305,13 @@ class Chromium extends _browserType.BrowserType {
305
305
  }
306
306
  }
307
307
  exports.Chromium = Chromium;
308
- async function urlToWSEndpoint(progress, endpointURL) {
308
+ async function urlToWSEndpoint(progress, endpointURL, headers) {
309
309
  if (endpointURL.startsWith('ws')) return endpointURL;
310
310
  progress.log(`<ws preparing> retrieving websocket url from ${endpointURL}`);
311
311
  const httpURL = endpointURL.endsWith('/') ? `${endpointURL}json/version/` : `${endpointURL}/json/version/`;
312
312
  const json = await (0, _network.fetchData)({
313
- url: httpURL
313
+ url: httpURL,
314
+ headers
314
315
  }, async (_, resp) => new Error(`Unexpected status ${resp.statusCode} when connecting to ${httpURL}.\n` + `This does not look like a DevTools server, try connecting via ws://.`));
315
316
  return JSON.parse(json).webSocketDebuggerUrl;
316
317
  }