patchright-bun-core 1.58.0 → 1.58.2

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 (358) hide show
  1. package/README.md +2 -2
  2. package/ThirdPartyNotices.txt +4075 -4075
  3. package/bin/install_media_pack.ps1 +5 -5
  4. package/bin/install_webkit_wsl.ps1 +32 -32
  5. package/bin/reinstall_chrome_beta_linux.sh +42 -42
  6. package/bin/reinstall_chrome_beta_mac.sh +13 -13
  7. package/bin/reinstall_chrome_beta_win.ps1 +24 -24
  8. package/bin/reinstall_chrome_stable_linux.sh +42 -42
  9. package/bin/reinstall_chrome_stable_mac.sh +12 -12
  10. package/bin/reinstall_chrome_stable_win.ps1 +24 -24
  11. package/bin/reinstall_msedge_beta_linux.sh +48 -48
  12. package/bin/reinstall_msedge_beta_mac.sh +11 -11
  13. package/bin/reinstall_msedge_beta_win.ps1 +23 -23
  14. package/bin/reinstall_msedge_dev_linux.sh +48 -48
  15. package/bin/reinstall_msedge_dev_mac.sh +11 -11
  16. package/bin/reinstall_msedge_dev_win.ps1 +23 -23
  17. package/bin/reinstall_msedge_stable_linux.sh +48 -48
  18. package/bin/reinstall_msedge_stable_mac.sh +11 -11
  19. package/bin/reinstall_msedge_stable_win.ps1 +23 -23
  20. package/browsers.json +79 -79
  21. package/cli.js +18 -18
  22. package/index.d.ts +17 -17
  23. package/index.js +32 -32
  24. package/index.mjs +28 -28
  25. package/lib/androidServerImpl.js +65 -65
  26. package/lib/browserServerImpl.js +120 -120
  27. package/lib/cli/driver.js +97 -97
  28. package/lib/cli/program.js +589 -589
  29. package/lib/cli/programWithTestStub.js +74 -74
  30. package/lib/client/android.js +361 -361
  31. package/lib/client/api.js +137 -137
  32. package/lib/client/artifact.js +79 -79
  33. package/lib/client/browser.js +161 -161
  34. package/lib/client/browserContext.js +582 -582
  35. package/lib/client/browserType.js +185 -185
  36. package/lib/client/cdpSession.js +51 -51
  37. package/lib/client/channelOwner.js +194 -194
  38. package/lib/client/clientHelper.js +64 -64
  39. package/lib/client/clientInstrumentation.js +55 -55
  40. package/lib/client/clientStackTrace.js +69 -69
  41. package/lib/client/clock.js +68 -68
  42. package/lib/client/connection.js +318 -318
  43. package/lib/client/consoleMessage.js +58 -58
  44. package/lib/client/coverage.js +44 -44
  45. package/lib/client/dialog.js +56 -56
  46. package/lib/client/download.js +62 -62
  47. package/lib/client/electron.js +138 -138
  48. package/lib/client/elementHandle.js +284 -284
  49. package/lib/client/errors.js +77 -77
  50. package/lib/client/eventEmitter.js +314 -314
  51. package/lib/client/events.js +103 -103
  52. package/lib/client/fetch.js +368 -368
  53. package/lib/client/fileChooser.js +46 -46
  54. package/lib/client/fileUtils.js +34 -34
  55. package/lib/client/frame.js +409 -409
  56. package/lib/client/harRouter.js +87 -87
  57. package/lib/client/input.js +84 -84
  58. package/lib/client/jsHandle.js +109 -109
  59. package/lib/client/jsonPipe.js +39 -39
  60. package/lib/client/localUtils.js +60 -60
  61. package/lib/client/locator.js +369 -369
  62. package/lib/client/network.js +747 -747
  63. package/lib/client/page.js +745 -745
  64. package/lib/client/pageAgent.js +64 -64
  65. package/lib/client/platform.js +77 -77
  66. package/lib/client/playwright.js +71 -71
  67. package/lib/client/selectors.js +55 -55
  68. package/lib/client/stream.js +39 -39
  69. package/lib/client/timeoutSettings.js +79 -79
  70. package/lib/client/tracing.js +119 -119
  71. package/lib/client/types.js +28 -28
  72. package/lib/client/video.js +59 -59
  73. package/lib/client/waiter.js +142 -142
  74. package/lib/client/webError.js +39 -39
  75. package/lib/client/webSocket.js +93 -93
  76. package/lib/client/worker.js +85 -85
  77. package/lib/client/writableStream.js +39 -39
  78. package/lib/generated/bindingsControllerSource.js +28 -28
  79. package/lib/generated/clockSource.js +28 -28
  80. package/lib/generated/injectedScriptSource.js +28 -28
  81. package/lib/generated/pollingRecorderSource.js +28 -28
  82. package/lib/generated/storageScriptSource.js +28 -28
  83. package/lib/generated/utilityScriptSource.js +28 -28
  84. package/lib/generated/webSocketMockSource.js +336 -336
  85. package/lib/inProcessFactory.js +60 -60
  86. package/lib/inprocess.js +3 -3
  87. package/lib/mcpBundle.js +84 -84
  88. package/lib/mcpBundleImpl/index.js +147 -147
  89. package/lib/outofprocess.js +76 -76
  90. package/lib/protocol/serializers.js +197 -197
  91. package/lib/protocol/validator.js +2969 -2969
  92. package/lib/protocol/validatorPrimitives.js +193 -193
  93. package/lib/remote/playwrightConnection.js +129 -129
  94. package/lib/remote/playwrightServer.js +334 -334
  95. package/lib/server/agent/actionRunner.js +335 -335
  96. package/lib/server/agent/actions.js +128 -128
  97. package/lib/server/agent/codegen.js +111 -111
  98. package/lib/server/agent/context.js +150 -150
  99. package/lib/server/agent/expectTools.js +156 -156
  100. package/lib/server/agent/pageAgent.js +204 -204
  101. package/lib/server/agent/performTools.js +262 -262
  102. package/lib/server/agent/tool.js +109 -109
  103. package/lib/server/android/android.js +465 -465
  104. package/lib/server/android/backendAdb.js +177 -177
  105. package/lib/server/artifact.js +127 -127
  106. package/lib/server/bidi/bidiBrowser.js +549 -549
  107. package/lib/server/bidi/bidiChromium.js +149 -148
  108. package/lib/server/bidi/bidiConnection.js +213 -213
  109. package/lib/server/bidi/bidiDeserializer.js +116 -116
  110. package/lib/server/bidi/bidiExecutionContext.js +267 -267
  111. package/lib/server/bidi/bidiFirefox.js +128 -128
  112. package/lib/server/bidi/bidiInput.js +146 -146
  113. package/lib/server/bidi/bidiNetworkManager.js +383 -383
  114. package/lib/server/bidi/bidiOverCdp.js +102 -102
  115. package/lib/server/bidi/bidiPage.js +583 -583
  116. package/lib/server/bidi/bidiPdf.js +106 -106
  117. package/lib/server/bidi/third_party/bidiCommands.d.js +22 -22
  118. package/lib/server/bidi/third_party/bidiKeyboard.js +256 -256
  119. package/lib/server/bidi/third_party/bidiProtocol.js +24 -24
  120. package/lib/server/bidi/third_party/bidiProtocolCore.js +180 -180
  121. package/lib/server/bidi/third_party/bidiProtocolPermissions.js +42 -42
  122. package/lib/server/bidi/third_party/bidiSerializer.js +148 -148
  123. package/lib/server/bidi/third_party/firefoxPrefs.js +259 -259
  124. package/lib/server/browser.js +149 -149
  125. package/lib/server/browserContext.js +702 -702
  126. package/lib/server/browserType.js +336 -336
  127. package/lib/server/callLog.js +82 -82
  128. package/lib/server/chromium/chromium.js +397 -395
  129. package/lib/server/chromium/chromiumSwitches.js +104 -104
  130. package/lib/server/chromium/crBrowser.js +520 -511
  131. package/lib/server/chromium/crConnection.js +197 -197
  132. package/lib/server/chromium/crCoverage.js +235 -235
  133. package/lib/server/chromium/crDevTools.js +111 -111
  134. package/lib/server/chromium/crDragDrop.js +131 -131
  135. package/lib/server/chromium/crExecutionContext.js +146 -146
  136. package/lib/server/chromium/crInput.js +187 -187
  137. package/lib/server/chromium/crNetworkManager.js +707 -707
  138. package/lib/server/chromium/crPage.js +1001 -1001
  139. package/lib/server/chromium/crPdf.js +121 -121
  140. package/lib/server/chromium/crProtocolHelper.js +145 -145
  141. package/lib/server/chromium/crServiceWorker.js +136 -136
  142. package/lib/server/chromium/defaultFontFamilies.js +162 -162
  143. package/lib/server/chromium/protocol.d.js +16 -16
  144. package/lib/server/clock.js +149 -149
  145. package/lib/server/codegen/csharp.js +327 -327
  146. package/lib/server/codegen/java.js +274 -274
  147. package/lib/server/codegen/javascript.js +247 -247
  148. package/lib/server/codegen/jsonl.js +52 -52
  149. package/lib/server/codegen/language.js +132 -132
  150. package/lib/server/codegen/languages.js +68 -68
  151. package/lib/server/codegen/python.js +279 -279
  152. package/lib/server/codegen/types.js +16 -16
  153. package/lib/server/console.js +57 -57
  154. package/lib/server/cookieStore.js +206 -206
  155. package/lib/server/debugController.js +191 -191
  156. package/lib/server/debugger.js +119 -119
  157. package/lib/server/deviceDescriptors.js +39 -39
  158. package/lib/server/deviceDescriptorsSource.json +1778 -1778
  159. package/lib/server/dialog.js +116 -116
  160. package/lib/server/dispatchers/androidDispatcher.js +325 -325
  161. package/lib/server/dispatchers/artifactDispatcher.js +118 -118
  162. package/lib/server/dispatchers/browserContextDispatcher.js +384 -384
  163. package/lib/server/dispatchers/browserDispatcher.js +118 -118
  164. package/lib/server/dispatchers/browserTypeDispatcher.js +64 -64
  165. package/lib/server/dispatchers/cdpSessionDispatcher.js +44 -44
  166. package/lib/server/dispatchers/debugControllerDispatcher.js +78 -78
  167. package/lib/server/dispatchers/dialogDispatcher.js +47 -47
  168. package/lib/server/dispatchers/dispatcher.js +364 -364
  169. package/lib/server/dispatchers/electronDispatcher.js +89 -89
  170. package/lib/server/dispatchers/elementHandlerDispatcher.js +181 -181
  171. package/lib/server/dispatchers/frameDispatcher.js +227 -227
  172. package/lib/server/dispatchers/jsHandleDispatcher.js +85 -85
  173. package/lib/server/dispatchers/jsonPipeDispatcher.js +58 -58
  174. package/lib/server/dispatchers/localUtilsDispatcher.js +149 -149
  175. package/lib/server/dispatchers/networkDispatchers.js +213 -213
  176. package/lib/server/dispatchers/pageAgentDispatcher.js +96 -96
  177. package/lib/server/dispatchers/pageDispatcher.js +393 -393
  178. package/lib/server/dispatchers/playwrightDispatcher.js +108 -108
  179. package/lib/server/dispatchers/streamDispatcher.js +67 -67
  180. package/lib/server/dispatchers/tracingDispatcher.js +68 -68
  181. package/lib/server/dispatchers/webSocketRouteDispatcher.js +165 -165
  182. package/lib/server/dispatchers/writableStreamDispatcher.js +79 -79
  183. package/lib/server/dom.js +815 -815
  184. package/lib/server/download.js +70 -70
  185. package/lib/server/electron/electron.js +273 -273
  186. package/lib/server/electron/loader.js +29 -29
  187. package/lib/server/errors.js +69 -69
  188. package/lib/server/fetch.js +621 -621
  189. package/lib/server/fileChooser.js +43 -43
  190. package/lib/server/fileUploadUtils.js +84 -84
  191. package/lib/server/firefox/ffBrowser.js +418 -418
  192. package/lib/server/firefox/ffConnection.js +142 -142
  193. package/lib/server/firefox/ffExecutionContext.js +150 -150
  194. package/lib/server/firefox/ffInput.js +159 -159
  195. package/lib/server/firefox/ffNetworkManager.js +256 -256
  196. package/lib/server/firefox/ffPage.js +497 -497
  197. package/lib/server/firefox/firefox.js +114 -114
  198. package/lib/server/firefox/protocol.d.js +16 -16
  199. package/lib/server/formData.js +147 -147
  200. package/lib/server/frameSelectors.js +160 -160
  201. package/lib/server/frames.js +1471 -1471
  202. package/lib/server/har/harRecorder.js +147 -147
  203. package/lib/server/har/harTracer.js +607 -607
  204. package/lib/server/harBackend.js +157 -157
  205. package/lib/server/helper.js +96 -96
  206. package/lib/server/index.js +58 -58
  207. package/lib/server/input.js +277 -277
  208. package/lib/server/instrumentation.js +72 -72
  209. package/lib/server/javascript.js +291 -291
  210. package/lib/server/launchApp.js +128 -128
  211. package/lib/server/localUtils.js +214 -214
  212. package/lib/server/macEditingCommands.js +143 -143
  213. package/lib/server/network.js +667 -667
  214. package/lib/server/page.js +830 -830
  215. package/lib/server/pipeTransport.js +89 -89
  216. package/lib/server/playwright.js +69 -69
  217. package/lib/server/progress.js +132 -132
  218. package/lib/server/protocolError.js +52 -52
  219. package/lib/server/recorder/chat.js +161 -161
  220. package/lib/server/recorder/recorderApp.js +366 -366
  221. package/lib/server/recorder/recorderRunner.js +138 -138
  222. package/lib/server/recorder/recorderSignalProcessor.js +83 -83
  223. package/lib/server/recorder/recorderUtils.js +157 -157
  224. package/lib/server/recorder/throttledFile.js +57 -57
  225. package/lib/server/recorder.js +499 -499
  226. package/lib/server/registry/browserFetcher.js +177 -177
  227. package/lib/server/registry/dependencies.js +371 -371
  228. package/lib/server/registry/index.js +1422 -1422
  229. package/lib/server/registry/nativeDeps.js +1280 -1280
  230. package/lib/server/registry/oopDownloadBrowserMain.js +127 -127
  231. package/lib/server/screencast.js +190 -190
  232. package/lib/server/screenshotter.js +333 -333
  233. package/lib/server/selectors.js +112 -112
  234. package/lib/server/socksClientCertificatesInterceptor.js +383 -383
  235. package/lib/server/socksInterceptor.js +95 -95
  236. package/lib/server/trace/recorder/snapshotter.js +147 -147
  237. package/lib/server/trace/recorder/snapshotterInjected.js +561 -561
  238. package/lib/server/trace/recorder/tracing.js +604 -604
  239. package/lib/server/trace/viewer/traceParser.js +72 -72
  240. package/lib/server/trace/viewer/traceViewer.js +245 -245
  241. package/lib/server/transport.js +254 -254
  242. package/lib/server/types.js +28 -28
  243. package/lib/server/usKeyboardLayout.js +145 -145
  244. package/lib/server/utils/ascii.js +44 -44
  245. package/lib/server/utils/comparators.js +139 -139
  246. package/lib/server/utils/crypto.js +216 -216
  247. package/lib/server/utils/debug.js +42 -42
  248. package/lib/server/utils/debugLogger.js +122 -122
  249. package/lib/server/utils/env.js +73 -73
  250. package/lib/server/utils/eventsHelper.js +39 -39
  251. package/lib/server/utils/expectUtils.js +123 -123
  252. package/lib/server/utils/fileUtils.js +191 -191
  253. package/lib/server/utils/happyEyeballs.js +207 -207
  254. package/lib/server/utils/hostPlatform.js +138 -123
  255. package/lib/server/utils/httpServer.js +203 -203
  256. package/lib/server/utils/imageUtils.js +141 -141
  257. package/lib/server/utils/image_tools/colorUtils.js +89 -89
  258. package/lib/server/utils/image_tools/compare.js +109 -109
  259. package/lib/server/utils/image_tools/imageChannel.js +78 -78
  260. package/lib/server/utils/image_tools/stats.js +102 -102
  261. package/lib/server/utils/linuxUtils.js +71 -71
  262. package/lib/server/utils/network.js +242 -242
  263. package/lib/server/utils/nodePlatform.js +154 -154
  264. package/lib/server/utils/pipeTransport.js +84 -84
  265. package/lib/server/utils/processLauncher.js +241 -241
  266. package/lib/server/utils/profiler.js +65 -65
  267. package/lib/server/utils/socksProxy.js +511 -511
  268. package/lib/server/utils/spawnAsync.js +41 -41
  269. package/lib/server/utils/task.js +51 -51
  270. package/lib/server/utils/userAgent.js +98 -98
  271. package/lib/server/utils/wsServer.js +121 -121
  272. package/lib/server/utils/zipFile.js +74 -74
  273. package/lib/server/utils/zones.js +57 -57
  274. package/lib/server/videoRecorder.js +124 -124
  275. package/lib/server/webkit/protocol.d.js +16 -16
  276. package/lib/server/webkit/webkit.js +108 -108
  277. package/lib/server/webkit/wkBrowser.js +335 -335
  278. package/lib/server/webkit/wkConnection.js +144 -144
  279. package/lib/server/webkit/wkExecutionContext.js +154 -154
  280. package/lib/server/webkit/wkInput.js +181 -181
  281. package/lib/server/webkit/wkInterceptableRequest.js +197 -197
  282. package/lib/server/webkit/wkPage.js +1159 -1158
  283. package/lib/server/webkit/wkProvisionalPage.js +83 -83
  284. package/lib/server/webkit/wkWorkers.js +105 -105
  285. package/lib/third_party/pixelmatch.js +255 -255
  286. package/lib/utils/isomorphic/ariaSnapshot.js +455 -455
  287. package/lib/utils/isomorphic/assert.js +31 -31
  288. package/lib/utils/isomorphic/colors.js +72 -72
  289. package/lib/utils/isomorphic/cssParser.js +245 -245
  290. package/lib/utils/isomorphic/cssTokenizer.js +1051 -1051
  291. package/lib/utils/isomorphic/headers.js +53 -53
  292. package/lib/utils/isomorphic/locatorGenerators.js +689 -689
  293. package/lib/utils/isomorphic/locatorParser.js +176 -176
  294. package/lib/utils/isomorphic/locatorUtils.js +81 -81
  295. package/lib/utils/isomorphic/lruCache.js +51 -51
  296. package/lib/utils/isomorphic/manualPromise.js +114 -114
  297. package/lib/utils/isomorphic/mimeType.js +459 -459
  298. package/lib/utils/isomorphic/multimap.js +80 -80
  299. package/lib/utils/isomorphic/protocolFormatter.js +81 -81
  300. package/lib/utils/isomorphic/protocolMetainfo.js +330 -330
  301. package/lib/utils/isomorphic/rtti.js +43 -43
  302. package/lib/utils/isomorphic/selectorParser.js +386 -386
  303. package/lib/utils/isomorphic/semaphore.js +54 -54
  304. package/lib/utils/isomorphic/stackTrace.js +158 -158
  305. package/lib/utils/isomorphic/stringUtils.js +204 -204
  306. package/lib/utils/isomorphic/time.js +49 -49
  307. package/lib/utils/isomorphic/timeoutRunner.js +66 -66
  308. package/lib/utils/isomorphic/trace/entries.js +16 -16
  309. package/lib/utils/isomorphic/trace/snapshotRenderer.js +499 -499
  310. package/lib/utils/isomorphic/trace/snapshotServer.js +120 -120
  311. package/lib/utils/isomorphic/trace/snapshotStorage.js +89 -89
  312. package/lib/utils/isomorphic/trace/traceLoader.js +131 -131
  313. package/lib/utils/isomorphic/trace/traceModel.js +365 -365
  314. package/lib/utils/isomorphic/trace/traceModernizer.js +400 -400
  315. package/lib/utils/isomorphic/trace/versions/traceV3.js +16 -16
  316. package/lib/utils/isomorphic/trace/versions/traceV4.js +16 -16
  317. package/lib/utils/isomorphic/trace/versions/traceV5.js +16 -16
  318. package/lib/utils/isomorphic/trace/versions/traceV6.js +16 -16
  319. package/lib/utils/isomorphic/trace/versions/traceV7.js +16 -16
  320. package/lib/utils/isomorphic/trace/versions/traceV8.js +16 -16
  321. package/lib/utils/isomorphic/traceUtils.js +58 -58
  322. package/lib/utils/isomorphic/types.js +16 -16
  323. package/lib/utils/isomorphic/urlMatch.js +190 -190
  324. package/lib/utils/isomorphic/utilityScriptSerializers.js +251 -251
  325. package/lib/utils/isomorphic/yaml.js +84 -84
  326. package/lib/utils.js +111 -111
  327. package/lib/utilsBundle.js +109 -109
  328. package/lib/utilsBundleImpl/index.js +218 -218
  329. package/lib/utilsBundleImpl/xdg-open +1066 -1066
  330. package/lib/vite/htmlReport/index.html +84 -84
  331. package/lib/vite/recorder/assets/codeMirrorModule-DYBRYzYX.css +1 -1
  332. package/lib/vite/recorder/assets/codeMirrorModule-DadYNm1I.js +32 -32
  333. package/lib/vite/recorder/assets/index-BSjZa4pk.css +1 -1
  334. package/lib/vite/recorder/assets/index-BhTWtUlo.js +193 -193
  335. package/lib/vite/recorder/index.html +29 -29
  336. package/lib/vite/recorder/playwright-logo.svg +9 -9
  337. package/lib/vite/traceViewer/assets/codeMirrorModule-a5XoALAZ.js +32 -32
  338. package/lib/vite/traceViewer/assets/defaultSettingsView-CJSZINFr.js +266 -266
  339. package/lib/vite/traceViewer/assets/xtermModule-CsJ4vdCR.js +9 -9
  340. package/lib/vite/traceViewer/codeMirrorModule.DYBRYzYX.css +1 -1
  341. package/lib/vite/traceViewer/defaultSettingsView.7ch9cixO.css +1 -1
  342. package/lib/vite/traceViewer/{index.Bk2uYQRV.js → index.BDwrLSGN.js} +2 -2
  343. package/lib/vite/traceViewer/index.BVu7tZDe.css +1 -1
  344. package/lib/vite/traceViewer/index.html +43 -43
  345. package/lib/vite/traceViewer/manifest.webmanifest +16 -16
  346. package/lib/vite/traceViewer/playwright-logo.svg +9 -9
  347. package/lib/vite/traceViewer/snapshot.html +21 -21
  348. package/lib/vite/traceViewer/sw.bundle.js +5 -5
  349. package/lib/vite/traceViewer/uiMode.Btcz36p_.css +1 -1
  350. package/lib/vite/traceViewer/uiMode.CQJ9SCIQ.js +5 -5
  351. package/lib/vite/traceViewer/uiMode.html +17 -17
  352. package/lib/vite/traceViewer/xtermModule.DYP7pi_n.css +32 -32
  353. package/lib/zipBundle.js +34 -34
  354. package/lib/zipBundleImpl.js +5 -5
  355. package/package.json +1 -1
  356. package/types/protocol.d.ts +23824 -23824
  357. package/types/structs.d.ts +45 -45
  358. package/types/types.d.ts +22843 -22843
@@ -1,395 +1,397 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chromium_exports = {};
30
- __export(chromium_exports, {
31
- Chromium: () => Chromium,
32
- waitForReadyState: () => waitForReadyState
33
- });
34
- module.exports = __toCommonJS(chromium_exports);
35
- var import_fs = __toESM(require("fs"));
36
- var import_os = __toESM(require("os"));
37
- var import_path = __toESM(require("path"));
38
- var import_chromiumSwitches = require("./chromiumSwitches");
39
- var import_crBrowser = require("./crBrowser");
40
- var import_crConnection = require("./crConnection");
41
- var import_utils = require("../../utils");
42
- var import_ascii = require("../utils/ascii");
43
- var import_debugLogger = require("../utils/debugLogger");
44
- var import_manualPromise = require("../../utils/isomorphic/manualPromise");
45
- var import_network = require("../utils/network");
46
- var import_userAgent = require("../utils/userAgent");
47
- var import_browserContext = require("../browserContext");
48
- var import_browserType = require("../browserType");
49
- var import_helper = require("../helper");
50
- var import_registry = require("../registry");
51
- var import_transport = require("../transport");
52
- var import_crDevTools = require("./crDevTools");
53
- var import_browser = require("../browser");
54
- var import_fileUtils = require("../utils/fileUtils");
55
- var import_processLauncher = require("../utils/processLauncher");
56
- const ARTIFACTS_FOLDER = import_path.default.join(import_os.default.tmpdir(), "playwright-artifacts-");
57
- class Chromium extends import_browserType.BrowserType {
58
- constructor(parent, bidiChromium) {
59
- super(parent, "chromium");
60
- this._bidiChromium = bidiChromium;
61
- if ((0, import_utils.debugMode)() === "inspector")
62
- this._devtools = this._createDevTools();
63
- }
64
- launch(progress, options, protocolLogger) {
65
- if (options.channel?.startsWith("bidi-"))
66
- return this._bidiChromium.launch(progress, options, protocolLogger);
67
- return super.launch(progress, options, protocolLogger);
68
- }
69
- async launchPersistentContext(progress, userDataDir, options) {
70
- if (options.channel?.startsWith("bidi-"))
71
- return this._bidiChromium.launchPersistentContext(progress, userDataDir, options);
72
- return super.launchPersistentContext(progress, userDataDir, options);
73
- }
74
- async connectOverCDP(progress, endpointURL, options) {
75
- return await this._connectOverCDPInternal(progress, endpointURL, options);
76
- }
77
- async _connectOverCDPInternal(progress, endpointURL, options, onClose) {
78
- let headersMap;
79
- if (options.headers)
80
- headersMap = (0, import_utils.headersArrayToObject)(options.headers, false);
81
- if (!headersMap)
82
- headersMap = { "User-Agent": (0, import_userAgent.getUserAgent)() };
83
- else if (headersMap && !Object.keys(headersMap).some((key) => key.toLowerCase() === "user-agent"))
84
- headersMap["User-Agent"] = (0, import_userAgent.getUserAgent)();
85
- const artifactsDir = await progress.race(import_fs.default.promises.mkdtemp(ARTIFACTS_FOLDER));
86
- const doCleanup = async () => {
87
- await (0, import_fileUtils.removeFolders)([artifactsDir]);
88
- const cb = onClose;
89
- onClose = void 0;
90
- await cb?.();
91
- };
92
- let chromeTransport;
93
- const doClose = async () => {
94
- await chromeTransport?.closeAndWait();
95
- await doCleanup();
96
- };
97
- try {
98
- const wsEndpoint = await urlToWSEndpoint(progress, endpointURL, headersMap);
99
- chromeTransport = await import_transport.WebSocketTransport.connect(progress, wsEndpoint, { headers: headersMap });
100
- const browserProcess = { close: doClose, kill: doClose };
101
- const persistent = { noDefaultViewport: true };
102
- const browserOptions = {
103
- slowMo: options.slowMo,
104
- name: "chromium",
105
- isChromium: true,
106
- persistent,
107
- browserProcess,
108
- protocolLogger: import_helper.helper.debugProtocolLogger(),
109
- browserLogsCollector: new import_debugLogger.RecentLogsCollector(),
110
- artifactsDir,
111
- downloadsPath: options.downloadsPath || artifactsDir,
112
- tracesDir: options.tracesDir || artifactsDir,
113
- originalLaunchOptions: {}
114
- };
115
- (0, import_browserContext.validateBrowserContextOptions)(persistent, browserOptions);
116
- const browser = await progress.race(import_crBrowser.CRBrowser.connect(this.attribution.playwright, chromeTransport, browserOptions));
117
- if (!options.isLocal)
118
- browser._isCollocatedWithServer = false;
119
- browser.on(import_browser.Browser.Events.Disconnected, doCleanup);
120
- return browser;
121
- } catch (error) {
122
- await doClose().catch(() => {
123
- });
124
- throw error;
125
- }
126
- }
127
- _createDevTools() {
128
- const directory = import_registry.registry.findExecutable("chromium").directory;
129
- return directory ? new import_crDevTools.CRDevTools(import_path.default.join(directory, "devtools-preferences.json")) : void 0;
130
- }
131
- async connectToTransport(transport, options, browserLogsCollector) {
132
- try {
133
- return await import_crBrowser.CRBrowser.connect(this.attribution.playwright, transport, options, this._devtools);
134
- } catch (e) {
135
- if (browserLogsCollector.recentLogs().some((log) => log.includes("Failed to create a ProcessSingleton for your profile directory."))) {
136
- throw new Error(
137
- "Failed to create a ProcessSingleton for your profile directory. This usually means that the profile is already in use by another instance of Chromium."
138
- );
139
- }
140
- throw e;
141
- }
142
- }
143
- doRewriteStartupLog(logs) {
144
- if (logs.includes("Missing X server"))
145
- logs = "\n" + (0, import_ascii.wrapInASCIIBox)(import_browserType.kNoXServerRunningError, 1);
146
- if (!logs.includes("crbug.com/357670") && !logs.includes("No usable sandbox!") && !logs.includes("crbug.com/638180"))
147
- return logs;
148
- return [
149
- `Chromium sandboxing failed!`,
150
- `================================`,
151
- `To avoid the sandboxing issue, do either of the following:`,
152
- ` - (preferred): Configure your environment to support sandboxing`,
153
- ` - (alternative): Launch Chromium without sandbox using 'chromiumSandbox: false' option`,
154
- `================================`,
155
- ``
156
- ].join("\n");
157
- }
158
- amendEnvironment(env) {
159
- return env;
160
- }
161
- attemptToGracefullyCloseBrowser(transport) {
162
- const message = { method: "Browser.close", id: import_crConnection.kBrowserCloseMessageId, params: {} };
163
- transport.send(message);
164
- }
165
- async _launchWithSeleniumHub(progress, hubUrl, options) {
166
- await progress.race(this._createArtifactDirs(options));
167
- if (!hubUrl.endsWith("/"))
168
- hubUrl = hubUrl + "/";
169
- const args = this._innerDefaultArgs(options);
170
- args.push("--remote-debugging-port=0");
171
- const isEdge = options.channel && options.channel.startsWith("msedge");
172
- let desiredCapabilities = {
173
- "browserName": isEdge ? "MicrosoftEdge" : "chrome",
174
- [isEdge ? "ms:edgeOptions" : "goog:chromeOptions"]: { args }
175
- };
176
- if (process.env.SELENIUM_REMOTE_CAPABILITIES) {
177
- const remoteCapabilities = parseSeleniumRemoteParams({ name: "capabilities", value: process.env.SELENIUM_REMOTE_CAPABILITIES }, progress);
178
- if (remoteCapabilities)
179
- desiredCapabilities = { ...desiredCapabilities, ...remoteCapabilities };
180
- }
181
- let headers = {};
182
- if (process.env.SELENIUM_REMOTE_HEADERS) {
183
- const remoteHeaders = parseSeleniumRemoteParams({ name: "headers", value: process.env.SELENIUM_REMOTE_HEADERS }, progress);
184
- if (remoteHeaders)
185
- headers = remoteHeaders;
186
- }
187
- progress.log(`<selenium> connecting to ${hubUrl}`);
188
- const response = await (0, import_network.fetchData)(progress, {
189
- url: hubUrl + "session",
190
- method: "POST",
191
- headers: {
192
- "Content-Type": "application/json; charset=utf-8",
193
- ...headers
194
- },
195
- data: JSON.stringify({
196
- capabilities: { alwaysMatch: desiredCapabilities }
197
- })
198
- }, seleniumErrorHandler);
199
- const value = JSON.parse(response).value;
200
- const sessionId = value.sessionId;
201
- progress.log(`<selenium> connected to sessionId=${sessionId}`);
202
- const disconnectFromSelenium = async () => {
203
- progress.log(`<selenium> disconnecting from sessionId=${sessionId}`);
204
- await (0, import_network.fetchData)(void 0, {
205
- url: hubUrl + "session/" + sessionId,
206
- method: "DELETE",
207
- headers
208
- }).catch((error) => progress.log(`<error disconnecting from selenium>: ${error}`));
209
- progress.log(`<selenium> disconnected from sessionId=${sessionId}`);
210
- import_processLauncher.gracefullyCloseSet.delete(disconnectFromSelenium);
211
- };
212
- import_processLauncher.gracefullyCloseSet.add(disconnectFromSelenium);
213
- try {
214
- const capabilities = value.capabilities;
215
- let endpointURL;
216
- if (capabilities["se:cdp"]) {
217
- progress.log(`<selenium> using selenium v4`);
218
- const endpointURLString = addProtocol(capabilities["se:cdp"]);
219
- endpointURL = new URL(endpointURLString);
220
- if (endpointURL.hostname === "localhost" || endpointURL.hostname === "127.0.0.1")
221
- endpointURL.hostname = new URL(hubUrl).hostname;
222
- progress.log(`<selenium> retrieved endpoint ${endpointURL.toString()} for sessionId=${sessionId}`);
223
- } else {
224
- progress.log(`<selenium> using selenium v3`);
225
- const maybeChromeOptions = capabilities["goog:chromeOptions"];
226
- const chromeOptions = maybeChromeOptions && typeof maybeChromeOptions === "object" ? maybeChromeOptions : void 0;
227
- const debuggerAddress = chromeOptions && typeof chromeOptions.debuggerAddress === "string" ? chromeOptions.debuggerAddress : void 0;
228
- const chromeOptionsURL = typeof maybeChromeOptions === "string" ? maybeChromeOptions : void 0;
229
- const endpointURLString = addProtocol(debuggerAddress || chromeOptionsURL).replace("localhost", "127.0.0.1");
230
- progress.log(`<selenium> retrieved endpoint ${endpointURLString} for sessionId=${sessionId}`);
231
- endpointURL = new URL(endpointURLString);
232
- if (endpointURL.hostname === "localhost" || endpointURL.hostname === "127.0.0.1") {
233
- const sessionInfoUrl = new URL(hubUrl).origin + "/grid/api/testsession?session=" + sessionId;
234
- try {
235
- const sessionResponse = await (0, import_network.fetchData)(progress, {
236
- url: sessionInfoUrl,
237
- method: "GET",
238
- headers
239
- }, seleniumErrorHandler);
240
- const proxyId = JSON.parse(sessionResponse).proxyId;
241
- endpointURL.hostname = new URL(proxyId).hostname;
242
- progress.log(`<selenium> resolved endpoint ip ${endpointURL.toString()} for sessionId=${sessionId}`);
243
- } catch (e) {
244
- progress.log(`<selenium> unable to resolve endpoint ip for sessionId=${sessionId}, running in standalone?`);
245
- }
246
- }
247
- }
248
- return await this._connectOverCDPInternal(progress, endpointURL.toString(), {
249
- ...options,
250
- headers: (0, import_utils.headersObjectToArray)(headers)
251
- }, disconnectFromSelenium);
252
- } catch (e) {
253
- await disconnectFromSelenium();
254
- throw e;
255
- }
256
- }
257
- async defaultArgs(options, isPersistent, userDataDir) {
258
- const chromeArguments = this._innerDefaultArgs(options);
259
- chromeArguments.push(`--user-data-dir=${userDataDir}`);
260
- if (options.cdpPort !== void 0)
261
- chromeArguments.push(`--remote-debugging-port=${options.cdpPort}`);
262
- else
263
- chromeArguments.push("--remote-debugging-pipe");
264
- if (isPersistent)
265
- chromeArguments.push("about:blank");
266
- else
267
- chromeArguments.push("--no-startup-window");
268
- return chromeArguments;
269
- }
270
- _innerDefaultArgs(options) {
271
- const { args = [] } = options;
272
- const userDataDirArg = args.find((arg) => arg.startsWith("--user-data-dir"));
273
- if (userDataDirArg)
274
- throw this._createUserDataDirArgMisuseError("--user-data-dir");
275
- if (args.find((arg) => arg.startsWith("--remote-debugging-pipe")))
276
- throw new Error("Playwright manages remote debugging connection itself.");
277
- if (args.find((arg) => !arg.startsWith("-")))
278
- throw new Error("Arguments can not specify page to be opened");
279
- const chromeArguments = [...(0, import_chromiumSwitches.chromiumSwitches)(options.assistantMode, options.channel)];
280
- chromeArguments.push("--enable-unsafe-swiftshader");
281
- if (options.headless) {
282
- chromeArguments.push("--headless");
283
- chromeArguments.push(
284
- "--hide-scrollbars",
285
- "--mute-audio",
286
- "--blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4"
287
- );
288
- }
289
- if (options.chromiumSandbox !== true)
290
- chromeArguments.push("--no-sandbox");
291
- const proxy = options.proxyOverride || options.proxy;
292
- if (proxy) {
293
- const proxyURL = new URL(proxy.server);
294
- const isSocks = proxyURL.protocol === "socks5:";
295
- if (isSocks && !options.socksProxyPort) {
296
- chromeArguments.push(`--host-resolver-rules="MAP * ~NOTFOUND , EXCLUDE ${proxyURL.hostname}"`);
297
- }
298
- chromeArguments.push(`--proxy-server=${proxy.server}`);
299
- const proxyBypassRules = [];
300
- if (options.socksProxyPort)
301
- proxyBypassRules.push("<-loopback>");
302
- if (proxy.bypass)
303
- proxyBypassRules.push(...proxy.bypass.split(",").map((t) => t.trim()).map((t) => t.startsWith(".") ? "*" + t : t));
304
- if (!process.env.PLAYWRIGHT_DISABLE_FORCED_CHROMIUM_PROXIED_LOOPBACK && !proxyBypassRules.includes("<-loopback>"))
305
- proxyBypassRules.push("<-loopback>");
306
- if (proxyBypassRules.length > 0)
307
- chromeArguments.push(`--proxy-bypass-list=${proxyBypassRules.join(";")}`);
308
- }
309
- chromeArguments.push(...args);
310
- return chromeArguments;
311
- }
312
- async waitForReadyState(options, browserLogsCollector) {
313
- return waitForReadyState(options, browserLogsCollector);
314
- }
315
- getExecutableName(options) {
316
- if (options.channel && import_registry.registry.isChromiumAlias(options.channel))
317
- return "chromium";
318
- if (options.channel === "chromium-tip-of-tree")
319
- return options.headless ? "chromium-tip-of-tree-headless-shell" : "chromium-tip-of-tree";
320
- if (options.channel)
321
- return options.channel;
322
- return options.headless ? "chromium-headless-shell" : "chromium";
323
- }
324
- }
325
- async function waitForReadyState(options, browserLogsCollector) {
326
- if (options.cdpPort === void 0 && !options.args?.some((a) => a.startsWith("--remote-debugging-port")))
327
- return {};
328
- const result = new import_manualPromise.ManualPromise();
329
- browserLogsCollector.onMessage((message) => {
330
- if (message.includes("Failed to create a ProcessSingleton for your profile directory.")) {
331
- result.reject(new Error("Failed to create a ProcessSingleton for your profile directory. This usually means that the profile is already in use by another instance of Chromium."));
332
- }
333
- const match = message.match(/DevTools listening on (.*)/);
334
- if (match)
335
- result.resolve({ wsEndpoint: match[1] });
336
- });
337
- return result;
338
- }
339
- async function urlToWSEndpoint(progress, endpointURL, headers) {
340
- if (endpointURL.startsWith("ws"))
341
- return endpointURL;
342
- progress.log(`<ws preparing> retrieving websocket url from ${endpointURL}`);
343
- const url = new URL(endpointURL);
344
- if (!url.pathname.endsWith("/"))
345
- url.pathname += "/";
346
- url.pathname += "json/version/";
347
- const httpURL = url.toString();
348
- const json = await (0, import_network.fetchData)(
349
- progress,
350
- {
351
- url: httpURL,
352
- headers
353
- },
354
- async (_, resp) => new Error(`Unexpected status ${resp.statusCode} when connecting to ${httpURL}.
355
- This does not look like a DevTools server, try connecting via ws://.`)
356
- );
357
- return JSON.parse(json).webSocketDebuggerUrl;
358
- }
359
- async function seleniumErrorHandler(params, response) {
360
- const body = await streamToString(response);
361
- let message = body;
362
- try {
363
- const json = JSON.parse(body);
364
- message = json.value.localizedMessage || json.value.message;
365
- } catch (e) {
366
- }
367
- return new Error(`Error connecting to Selenium at ${params.url}: ${message}`);
368
- }
369
- function addProtocol(url) {
370
- if (!["ws://", "wss://", "http://", "https://"].some((protocol) => url.startsWith(protocol)))
371
- return "http://" + url;
372
- return url;
373
- }
374
- function streamToString(stream) {
375
- return new Promise((resolve, reject) => {
376
- const chunks = [];
377
- stream.on("data", (chunk) => chunks.push(Buffer.from(chunk)));
378
- stream.on("error", reject);
379
- stream.on("end", () => resolve(Buffer.concat(chunks).toString("utf8")));
380
- });
381
- }
382
- function parseSeleniumRemoteParams(env, progress) {
383
- try {
384
- const parsed = JSON.parse(env.value);
385
- progress.log(`<selenium> using additional ${env.name} "${env.value}"`);
386
- return parsed;
387
- } catch (e) {
388
- progress.log(`<selenium> ignoring additional ${env.name} "${env.value}": ${e}`);
389
- }
390
- }
391
- // Annotate the CommonJS export names for ESM import in node:
392
- 0 && (module.exports = {
393
- Chromium,
394
- waitForReadyState
395
- });
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var chromium_exports = {};
30
+ __export(chromium_exports, {
31
+ Chromium: () => Chromium,
32
+ waitForReadyState: () => waitForReadyState
33
+ });
34
+ module.exports = __toCommonJS(chromium_exports);
35
+ var import_fs = __toESM(require("fs"));
36
+ var import_os = __toESM(require("os"));
37
+ var import_path = __toESM(require("path"));
38
+ var import_chromiumSwitches = require("./chromiumSwitches");
39
+ var import_crBrowser = require("./crBrowser");
40
+ var import_crConnection = require("./crConnection");
41
+ var import_utils = require("../../utils");
42
+ var import_ascii = require("../utils/ascii");
43
+ var import_debugLogger = require("../utils/debugLogger");
44
+ var import_manualPromise = require("../../utils/isomorphic/manualPromise");
45
+ var import_network = require("../utils/network");
46
+ var import_userAgent = require("../utils/userAgent");
47
+ var import_browserContext = require("../browserContext");
48
+ var import_browserType = require("../browserType");
49
+ var import_helper = require("../helper");
50
+ var import_registry = require("../registry");
51
+ var import_transport = require("../transport");
52
+ var import_crDevTools = require("./crDevTools");
53
+ var import_browser = require("../browser");
54
+ var import_fileUtils = require("../utils/fileUtils");
55
+ var import_processLauncher = require("../utils/processLauncher");
56
+ const ARTIFACTS_FOLDER = import_path.default.join(import_os.default.tmpdir(), "playwright-artifacts-");
57
+ class Chromium extends import_browserType.BrowserType {
58
+ constructor(parent, bidiChromium) {
59
+ super(parent, "chromium");
60
+ this._bidiChromium = bidiChromium;
61
+ if ((0, import_utils.debugMode)() === "inspector")
62
+ this._devtools = this._createDevTools();
63
+ }
64
+ launch(progress, options, protocolLogger) {
65
+ if (options.channel?.startsWith("bidi-"))
66
+ return this._bidiChromium.launch(progress, options, protocolLogger);
67
+ return super.launch(progress, options, protocolLogger);
68
+ }
69
+ async launchPersistentContext(progress, userDataDir, options) {
70
+ if (options.channel?.startsWith("bidi-"))
71
+ return this._bidiChromium.launchPersistentContext(progress, userDataDir, options);
72
+ return super.launchPersistentContext(progress, userDataDir, options);
73
+ }
74
+ async connectOverCDP(progress, endpointURL, options) {
75
+ return await this._connectOverCDPInternal(progress, endpointURL, options);
76
+ }
77
+ async _connectOverCDPInternal(progress, endpointURL, options, onClose) {
78
+ let headersMap;
79
+ if (options.headers)
80
+ headersMap = (0, import_utils.headersArrayToObject)(options.headers, false);
81
+ if (!headersMap)
82
+ headersMap = { "User-Agent": (0, import_userAgent.getUserAgent)() };
83
+ else if (headersMap && !Object.keys(headersMap).some((key) => key.toLowerCase() === "user-agent"))
84
+ headersMap["User-Agent"] = (0, import_userAgent.getUserAgent)();
85
+ const artifactsDir = await progress.race(import_fs.default.promises.mkdtemp(ARTIFACTS_FOLDER));
86
+ const doCleanup = async () => {
87
+ await (0, import_fileUtils.removeFolders)([artifactsDir]);
88
+ const cb = onClose;
89
+ onClose = void 0;
90
+ await cb?.();
91
+ };
92
+ let chromeTransport;
93
+ const doClose = async () => {
94
+ await chromeTransport?.closeAndWait();
95
+ await doCleanup();
96
+ };
97
+ try {
98
+ const wsEndpoint = await urlToWSEndpoint(progress, endpointURL, headersMap);
99
+ chromeTransport = await import_transport.WebSocketTransport.connect(progress, wsEndpoint, { headers: headersMap });
100
+ const browserProcess = { close: doClose, kill: doClose };
101
+ const persistent = { noDefaultViewport: true };
102
+ const browserOptions = {
103
+ slowMo: options.slowMo,
104
+ name: "chromium",
105
+ isChromium: true,
106
+ persistent,
107
+ browserProcess,
108
+ protocolLogger: import_helper.helper.debugProtocolLogger(),
109
+ browserLogsCollector: new import_debugLogger.RecentLogsCollector(),
110
+ artifactsDir,
111
+ downloadsPath: options.downloadsPath || artifactsDir,
112
+ tracesDir: options.tracesDir || artifactsDir,
113
+ originalLaunchOptions: {}
114
+ };
115
+ (0, import_browserContext.validateBrowserContextOptions)(persistent, browserOptions);
116
+ const browser = await progress.race(import_crBrowser.CRBrowser.connect(this.attribution.playwright, chromeTransport, browserOptions));
117
+ if (!options.isLocal)
118
+ browser._isCollocatedWithServer = false;
119
+ browser.on(import_browser.Browser.Events.Disconnected, doCleanup);
120
+ return browser;
121
+ } catch (error) {
122
+ await doClose().catch(() => {
123
+ });
124
+ throw error;
125
+ }
126
+ }
127
+ _createDevTools() {
128
+ const directory = import_registry.registry.findExecutable("chromium").directory;
129
+ return directory ? new import_crDevTools.CRDevTools(import_path.default.join(directory, "devtools-preferences.json")) : void 0;
130
+ }
131
+ async connectToTransport(transport, options, browserLogsCollector) {
132
+ try {
133
+ return await import_crBrowser.CRBrowser.connect(this.attribution.playwright, transport, options, this._devtools);
134
+ } catch (e) {
135
+ if (browserLogsCollector.recentLogs().some((log) => log.includes("Failed to create a ProcessSingleton for your profile directory."))) {
136
+ throw new Error(
137
+ "Failed to create a ProcessSingleton for your profile directory. This usually means that the profile is already in use by another instance of Chromium."
138
+ );
139
+ }
140
+ throw e;
141
+ }
142
+ }
143
+ doRewriteStartupLog(logs) {
144
+ if (logs.includes("Missing X server"))
145
+ logs = "\n" + (0, import_ascii.wrapInASCIIBox)(import_browserType.kNoXServerRunningError, 1);
146
+ if (!logs.includes("crbug.com/357670") && !logs.includes("No usable sandbox!") && !logs.includes("crbug.com/638180"))
147
+ return logs;
148
+ return [
149
+ `Chromium sandboxing failed!`,
150
+ `================================`,
151
+ `To avoid the sandboxing issue, do either of the following:`,
152
+ ` - (preferred): Configure your environment to support sandboxing`,
153
+ ` - (alternative): Launch Chromium without sandbox using 'chromiumSandbox: false' option`,
154
+ `================================`,
155
+ ``
156
+ ].join("\n");
157
+ }
158
+ amendEnvironment(env) {
159
+ return env;
160
+ }
161
+ attemptToGracefullyCloseBrowser(transport) {
162
+ const message = { method: "Browser.close", id: import_crConnection.kBrowserCloseMessageId, params: {} };
163
+ transport.send(message);
164
+ }
165
+ async _launchWithSeleniumHub(progress, hubUrl, options) {
166
+ await progress.race(this._createArtifactDirs(options));
167
+ if (!hubUrl.endsWith("/"))
168
+ hubUrl = hubUrl + "/";
169
+ const args = this._innerDefaultArgs(options);
170
+ args.push("--remote-debugging-port=0");
171
+ const isEdge = options.channel && options.channel.startsWith("msedge");
172
+ let desiredCapabilities = {
173
+ "browserName": isEdge ? "MicrosoftEdge" : "chrome",
174
+ [isEdge ? "ms:edgeOptions" : "goog:chromeOptions"]: { args }
175
+ };
176
+ if (process.env.SELENIUM_REMOTE_CAPABILITIES) {
177
+ const remoteCapabilities = parseSeleniumRemoteParams({ name: "capabilities", value: process.env.SELENIUM_REMOTE_CAPABILITIES }, progress);
178
+ if (remoteCapabilities)
179
+ desiredCapabilities = { ...desiredCapabilities, ...remoteCapabilities };
180
+ }
181
+ let headers = {};
182
+ if (process.env.SELENIUM_REMOTE_HEADERS) {
183
+ const remoteHeaders = parseSeleniumRemoteParams({ name: "headers", value: process.env.SELENIUM_REMOTE_HEADERS }, progress);
184
+ if (remoteHeaders)
185
+ headers = remoteHeaders;
186
+ }
187
+ progress.log(`<selenium> connecting to ${hubUrl}`);
188
+ const response = await (0, import_network.fetchData)(progress, {
189
+ url: hubUrl + "session",
190
+ method: "POST",
191
+ headers: {
192
+ "Content-Type": "application/json; charset=utf-8",
193
+ ...headers
194
+ },
195
+ data: JSON.stringify({
196
+ capabilities: { alwaysMatch: desiredCapabilities }
197
+ })
198
+ }, seleniumErrorHandler);
199
+ const value = JSON.parse(response).value;
200
+ const sessionId = value.sessionId;
201
+ progress.log(`<selenium> connected to sessionId=${sessionId}`);
202
+ const disconnectFromSelenium = async () => {
203
+ progress.log(`<selenium> disconnecting from sessionId=${sessionId}`);
204
+ await (0, import_network.fetchData)(void 0, {
205
+ url: hubUrl + "session/" + sessionId,
206
+ method: "DELETE",
207
+ headers
208
+ }).catch((error) => progress.log(`<error disconnecting from selenium>: ${error}`));
209
+ progress.log(`<selenium> disconnected from sessionId=${sessionId}`);
210
+ import_processLauncher.gracefullyCloseSet.delete(disconnectFromSelenium);
211
+ };
212
+ import_processLauncher.gracefullyCloseSet.add(disconnectFromSelenium);
213
+ try {
214
+ const capabilities = value.capabilities;
215
+ let endpointURL;
216
+ if (capabilities["se:cdp"]) {
217
+ progress.log(`<selenium> using selenium v4`);
218
+ const endpointURLString = addProtocol(capabilities["se:cdp"]);
219
+ endpointURL = new URL(endpointURLString);
220
+ if (endpointURL.hostname === "localhost" || endpointURL.hostname === "127.0.0.1")
221
+ endpointURL.hostname = new URL(hubUrl).hostname;
222
+ progress.log(`<selenium> retrieved endpoint ${endpointURL.toString()} for sessionId=${sessionId}`);
223
+ } else {
224
+ progress.log(`<selenium> using selenium v3`);
225
+ const maybeChromeOptions = capabilities["goog:chromeOptions"];
226
+ const chromeOptions = maybeChromeOptions && typeof maybeChromeOptions === "object" ? maybeChromeOptions : void 0;
227
+ const debuggerAddress = chromeOptions && typeof chromeOptions.debuggerAddress === "string" ? chromeOptions.debuggerAddress : void 0;
228
+ const chromeOptionsURL = typeof maybeChromeOptions === "string" ? maybeChromeOptions : void 0;
229
+ const endpointURLString = addProtocol(debuggerAddress || chromeOptionsURL).replace("localhost", "127.0.0.1");
230
+ progress.log(`<selenium> retrieved endpoint ${endpointURLString} for sessionId=${sessionId}`);
231
+ endpointURL = new URL(endpointURLString);
232
+ if (endpointURL.hostname === "localhost" || endpointURL.hostname === "127.0.0.1") {
233
+ const sessionInfoUrl = new URL(hubUrl).origin + "/grid/api/testsession?session=" + sessionId;
234
+ try {
235
+ const sessionResponse = await (0, import_network.fetchData)(progress, {
236
+ url: sessionInfoUrl,
237
+ method: "GET",
238
+ headers
239
+ }, seleniumErrorHandler);
240
+ const proxyId = JSON.parse(sessionResponse).proxyId;
241
+ endpointURL.hostname = new URL(proxyId).hostname;
242
+ progress.log(`<selenium> resolved endpoint ip ${endpointURL.toString()} for sessionId=${sessionId}`);
243
+ } catch (e) {
244
+ progress.log(`<selenium> unable to resolve endpoint ip for sessionId=${sessionId}, running in standalone?`);
245
+ }
246
+ }
247
+ }
248
+ return await this._connectOverCDPInternal(progress, endpointURL.toString(), {
249
+ ...options,
250
+ headers: (0, import_utils.headersObjectToArray)(headers)
251
+ }, disconnectFromSelenium);
252
+ } catch (e) {
253
+ await disconnectFromSelenium();
254
+ throw e;
255
+ }
256
+ }
257
+ async defaultArgs(options, isPersistent, userDataDir) {
258
+ const chromeArguments = this._innerDefaultArgs(options);
259
+ chromeArguments.push(`--user-data-dir=${userDataDir}`);
260
+ if (options.cdpPort !== void 0)
261
+ chromeArguments.push(`--remote-debugging-port=${options.cdpPort}`);
262
+ else
263
+ chromeArguments.push("--remote-debugging-pipe");
264
+ if (isPersistent)
265
+ chromeArguments.push("about:blank");
266
+ else
267
+ chromeArguments.push("--no-startup-window");
268
+ return chromeArguments;
269
+ }
270
+ _innerDefaultArgs(options) {
271
+ const { args = [] } = options;
272
+ const userDataDirArg = args.find((arg) => arg.startsWith("--user-data-dir"));
273
+ if (userDataDirArg)
274
+ throw this._createUserDataDirArgMisuseError("--user-data-dir");
275
+ if (args.find((arg) => arg.startsWith("--remote-debugging-pipe")))
276
+ throw new Error("Playwright manages remote debugging connection itself.");
277
+ if (args.find((arg) => !arg.startsWith("-")))
278
+ throw new Error("Arguments can not specify page to be opened");
279
+ const chromeArguments = [...(0, import_chromiumSwitches.chromiumSwitches)(options.assistantMode, options.channel)];
280
+ if (import_os.default.platform() !== "darwin" || !(0, import_utils.hasGpuMac)()) {
281
+ chromeArguments.push("--enable-unsafe-swiftshader");
282
+ }
283
+ if (options.headless) {
284
+ chromeArguments.push("--headless");
285
+ chromeArguments.push(
286
+ "--hide-scrollbars",
287
+ "--mute-audio",
288
+ "--blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4"
289
+ );
290
+ }
291
+ if (options.chromiumSandbox !== true)
292
+ chromeArguments.push("--no-sandbox");
293
+ const proxy = options.proxyOverride || options.proxy;
294
+ if (proxy) {
295
+ const proxyURL = new URL(proxy.server);
296
+ const isSocks = proxyURL.protocol === "socks5:";
297
+ if (isSocks && !options.socksProxyPort) {
298
+ chromeArguments.push(`--host-resolver-rules="MAP * ~NOTFOUND , EXCLUDE ${proxyURL.hostname}"`);
299
+ }
300
+ chromeArguments.push(`--proxy-server=${proxy.server}`);
301
+ const proxyBypassRules = [];
302
+ if (options.socksProxyPort)
303
+ proxyBypassRules.push("<-loopback>");
304
+ if (proxy.bypass)
305
+ proxyBypassRules.push(...proxy.bypass.split(",").map((t) => t.trim()).map((t) => t.startsWith(".") ? "*" + t : t));
306
+ if (!process.env.PLAYWRIGHT_DISABLE_FORCED_CHROMIUM_PROXIED_LOOPBACK && !proxyBypassRules.includes("<-loopback>"))
307
+ proxyBypassRules.push("<-loopback>");
308
+ if (proxyBypassRules.length > 0)
309
+ chromeArguments.push(`--proxy-bypass-list=${proxyBypassRules.join(";")}`);
310
+ }
311
+ chromeArguments.push(...args);
312
+ return chromeArguments;
313
+ }
314
+ async waitForReadyState(options, browserLogsCollector) {
315
+ return waitForReadyState(options, browserLogsCollector);
316
+ }
317
+ getExecutableName(options) {
318
+ if (options.channel && import_registry.registry.isChromiumAlias(options.channel))
319
+ return "chromium";
320
+ if (options.channel === "chromium-tip-of-tree")
321
+ return options.headless ? "chromium-tip-of-tree-headless-shell" : "chromium-tip-of-tree";
322
+ if (options.channel)
323
+ return options.channel;
324
+ return options.headless ? "chromium-headless-shell" : "chromium";
325
+ }
326
+ }
327
+ async function waitForReadyState(options, browserLogsCollector) {
328
+ if (options.cdpPort === void 0 && !options.args?.some((a) => a.startsWith("--remote-debugging-port")))
329
+ return {};
330
+ const result = new import_manualPromise.ManualPromise();
331
+ browserLogsCollector.onMessage((message) => {
332
+ if (message.includes("Failed to create a ProcessSingleton for your profile directory.")) {
333
+ result.reject(new Error("Failed to create a ProcessSingleton for your profile directory. This usually means that the profile is already in use by another instance of Chromium."));
334
+ }
335
+ const match = message.match(/DevTools listening on (.*)/);
336
+ if (match)
337
+ result.resolve({ wsEndpoint: match[1] });
338
+ });
339
+ return result;
340
+ }
341
+ async function urlToWSEndpoint(progress, endpointURL, headers) {
342
+ if (endpointURL.startsWith("ws"))
343
+ return endpointURL;
344
+ progress.log(`<ws preparing> retrieving websocket url from ${endpointURL}`);
345
+ const url = new URL(endpointURL);
346
+ if (!url.pathname.endsWith("/"))
347
+ url.pathname += "/";
348
+ url.pathname += "json/version/";
349
+ const httpURL = url.toString();
350
+ const json = await (0, import_network.fetchData)(
351
+ progress,
352
+ {
353
+ url: httpURL,
354
+ headers
355
+ },
356
+ async (_, resp) => new Error(`Unexpected status ${resp.statusCode} when connecting to ${httpURL}.
357
+ This does not look like a DevTools server, try connecting via ws://.`)
358
+ );
359
+ return JSON.parse(json).webSocketDebuggerUrl;
360
+ }
361
+ async function seleniumErrorHandler(params, response) {
362
+ const body = await streamToString(response);
363
+ let message = body;
364
+ try {
365
+ const json = JSON.parse(body);
366
+ message = json.value.localizedMessage || json.value.message;
367
+ } catch (e) {
368
+ }
369
+ return new Error(`Error connecting to Selenium at ${params.url}: ${message}`);
370
+ }
371
+ function addProtocol(url) {
372
+ if (!["ws://", "wss://", "http://", "https://"].some((protocol) => url.startsWith(protocol)))
373
+ return "http://" + url;
374
+ return url;
375
+ }
376
+ function streamToString(stream) {
377
+ return new Promise((resolve, reject) => {
378
+ const chunks = [];
379
+ stream.on("data", (chunk) => chunks.push(Buffer.from(chunk)));
380
+ stream.on("error", reject);
381
+ stream.on("end", () => resolve(Buffer.concat(chunks).toString("utf8")));
382
+ });
383
+ }
384
+ function parseSeleniumRemoteParams(env, progress) {
385
+ try {
386
+ const parsed = JSON.parse(env.value);
387
+ progress.log(`<selenium> using additional ${env.name} "${env.value}"`);
388
+ return parsed;
389
+ } catch (e) {
390
+ progress.log(`<selenium> ignoring additional ${env.name} "${env.value}": ${e}`);
391
+ }
392
+ }
393
+ // Annotate the CommonJS export names for ESM import in node:
394
+ 0 && (module.exports = {
395
+ Chromium,
396
+ waitForReadyState
397
+ });