rebrowser-playwright-core 1.49.1 → 1.64.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (393) hide show
  1. package/ThirdPartyNotices.txt +7 -1228
  2. package/bin/install_webkit_wsl.ps1 +33 -0
  3. package/bin/reinstall_chrome_beta_linux.sh +1 -1
  4. package/bin/reinstall_chrome_beta_mac.sh +1 -1
  5. package/bin/reinstall_chrome_stable_linux.sh +1 -1
  6. package/bin/reinstall_chrome_stable_mac.sh +1 -1
  7. package/bin/reinstall_msedge_beta_linux.sh +7 -1
  8. package/bin/reinstall_msedge_beta_mac.sh +1 -1
  9. package/bin/reinstall_msedge_dev_linux.sh +7 -1
  10. package/bin/reinstall_msedge_dev_mac.sh +1 -1
  11. package/bin/reinstall_msedge_stable_linux.sh +7 -1
  12. package/bin/reinstall_msedge_stable_mac.sh +1 -1
  13. package/browsers.json +21 -34
  14. package/cli.js +5 -1
  15. package/index.js +2 -18
  16. package/lib/bootstrap.js +149 -0
  17. package/lib/coreBundle.js +78218 -0
  18. package/lib/entry/cliDaemon.js +5 -0
  19. package/lib/entry/dashboardApp.js +3 -0
  20. package/lib/entry/mcp.js +10 -0
  21. package/lib/entry/oopBrowserDownload.js +3 -0
  22. package/lib/package.js +50 -0
  23. package/lib/server/electron/loader.js +109 -43
  24. package/lib/serverRegistry.js +1939 -0
  25. package/lib/serverRegistry.js.LICENSE +65 -0
  26. package/lib/tools/cli-client/channelSessions.js +141 -0
  27. package/lib/tools/cli-client/cli.js +7 -0
  28. package/lib/tools/cli-client/help.json +808 -0
  29. package/lib/tools/cli-client/minimist.js +128 -0
  30. package/lib/tools/cli-client/output.js +352 -0
  31. package/lib/tools/cli-client/program.js +422 -0
  32. package/lib/tools/cli-client/registry.js +180 -0
  33. package/lib/tools/cli-client/session.js +261 -0
  34. package/lib/tools/dashboard/appIcon.png +0 -0
  35. package/lib/tools/skills/playwright-cli/SKILL.md +493 -0
  36. package/lib/tools/skills/playwright-cli/references/element-attributes.md +23 -0
  37. package/lib/tools/skills/playwright-cli/references/playwright-tests.md +39 -0
  38. package/lib/tools/skills/playwright-cli/references/pr-attachments.md +60 -0
  39. package/lib/tools/skills/playwright-cli/references/request-mocking.md +87 -0
  40. package/lib/tools/skills/playwright-cli/references/running-code.md +245 -0
  41. package/lib/tools/skills/playwright-cli/references/session-management.md +227 -0
  42. package/lib/tools/skills/playwright-cli/references/storage-state.md +275 -0
  43. package/lib/tools/skills/playwright-cli/references/test-generation.md +433 -0
  44. package/lib/tools/skills/playwright-cli/references/tracing.md +139 -0
  45. package/lib/tools/skills/playwright-cli/references/video-recording.md +216 -0
  46. package/lib/tools/skills/playwright-component-testing/SKILL.md +136 -0
  47. package/lib/tools/skills/playwright-component-testing/references/gallery-spec.md +144 -0
  48. package/lib/tools/skills/playwright-component-testing/references/migration.md +89 -0
  49. package/lib/tools/skills/playwright-component-testing/references/react.md +69 -0
  50. package/lib/tools/skills/playwright-component-testing/references/typing.md +173 -0
  51. package/lib/tools/skills/playwright-component-testing/references/vue.md +77 -0
  52. package/lib/tools/skills/playwright-trace/SKILL.md +174 -0
  53. package/lib/tools/utils/extension.js +112 -0
  54. package/lib/tools/utils/socketConnection.js +108 -0
  55. package/lib/utilsBundle.js +86076 -79
  56. package/lib/utilsBundle.js.LICENSE +1890 -0
  57. package/lib/vite/dashboard/assets/codeMirrorModule--QdMvsKi.css +1 -0
  58. package/lib/vite/dashboard/assets/codeMirrorModule-CQ8RZGBm.js +32 -0
  59. package/lib/vite/dashboard/assets/codicon-DCmgc-ay.ttf +0 -0
  60. package/lib/vite/dashboard/assets/firefox-1bWoP6pv.svg +1 -0
  61. package/lib/vite/dashboard/assets/firefox-beta-k3eOH_eK.svg +1 -0
  62. package/lib/vite/dashboard/assets/firefox-nightly-Cp5nfeDT.svg +1 -0
  63. package/lib/vite/dashboard/assets/index-AwgwcYie.css +1 -0
  64. package/lib/vite/dashboard/assets/index-hRvO4yU2.js +12 -0
  65. package/lib/vite/dashboard/assets/safari-na3_-uQk.svg +1 -0
  66. package/lib/vite/dashboard/index.html +29 -0
  67. package/lib/vite/dashboard/playwright-logo.svg +24 -0
  68. package/lib/vite/htmlReport/index.html +3 -56
  69. package/lib/vite/htmlReport/report.css +2 -0
  70. package/lib/vite/htmlReport/report.js +32 -0
  71. package/lib/vite/recorder/assets/codeMirrorModule--QdMvsKi.css +1 -0
  72. package/lib/vite/recorder/assets/codeMirrorModule-DK72OMRi.js +32 -0
  73. package/lib/vite/recorder/assets/index-BZpYJZ-P.css +1 -0
  74. package/lib/vite/recorder/assets/index-Cn0mmDuv.js +129 -0
  75. package/lib/vite/recorder/index.html +3 -3
  76. package/lib/vite/traceViewer/assets/codeMirrorModule-BEB2e8M3.js +32 -0
  77. package/lib/vite/traceViewer/assets/defaultSettingsView-D-g2vrvf.js +184 -0
  78. package/lib/vite/traceViewer/assets/urlMatch-L3liM589.js +1 -0
  79. package/lib/vite/traceViewer/assets/xtermModule-B794rD2Z.js +7 -0
  80. package/lib/vite/traceViewer/codeMirrorModule.-QdMvsKi.css +1 -0
  81. package/lib/vite/traceViewer/defaultSettingsView.C8BeHuxd.css +1 -0
  82. package/lib/vite/traceViewer/index.B_TqY17P.css +1 -0
  83. package/lib/vite/traceViewer/index.html +9 -11
  84. package/lib/vite/traceViewer/index.oNry3Hjv.js +1 -0
  85. package/lib/vite/traceViewer/manifest.webmanifest +16 -0
  86. package/lib/vite/traceViewer/snapshot.B_Jk1wbt.js +1 -0
  87. package/lib/vite/traceViewer/snapshot.html +4 -15
  88. package/lib/vite/traceViewer/sw.bundle.js +4 -3
  89. package/lib/vite/traceViewer/uiMode.CYwC_gH1.js +5 -0
  90. package/lib/vite/traceViewer/uiMode.CyMfwkXJ.css +1 -0
  91. package/lib/vite/traceViewer/uiMode.html +6 -8
  92. package/lib/vite/traceViewer/xtermModule.kHJ-D0s7.css +1 -0
  93. package/lib/webp_codec.LICENSE +173 -0
  94. package/lib/webp_codec.wasm +0 -0
  95. package/lib/{utilsBundleImpl/xdg-open → xdg-open} +338 -137
  96. package/package.json +6 -16
  97. package/types/protocol.d.ts +9357 -6200
  98. package/types/structs.d.ts +8 -1
  99. package/types/types.d.ts +9490 -4947
  100. package/bin/PrintDeps.exe +0 -0
  101. package/bin/README.md +0 -2
  102. package/lib/androidServerImpl.js +0 -69
  103. package/lib/browserServerImpl.js +0 -92
  104. package/lib/cli/driver.js +0 -95
  105. package/lib/cli/program.js +0 -607
  106. package/lib/cli/programWithTestStub.js +0 -67
  107. package/lib/client/accessibility.js +0 -50
  108. package/lib/client/android.js +0 -473
  109. package/lib/client/api.js +0 -285
  110. package/lib/client/artifact.js +0 -79
  111. package/lib/client/browser.js +0 -145
  112. package/lib/client/browserContext.js +0 -559
  113. package/lib/client/browserType.js +0 -241
  114. package/lib/client/cdpSession.js +0 -53
  115. package/lib/client/channelOwner.js +0 -235
  116. package/lib/client/clientHelper.js +0 -57
  117. package/lib/client/clientInstrumentation.js +0 -50
  118. package/lib/client/clock.js +0 -68
  119. package/lib/client/connection.js +0 -333
  120. package/lib/client/consoleMessage.js +0 -55
  121. package/lib/client/coverage.js +0 -41
  122. package/lib/client/dialog.js +0 -57
  123. package/lib/client/download.js +0 -62
  124. package/lib/client/electron.js +0 -135
  125. package/lib/client/elementHandle.js +0 -321
  126. package/lib/client/errors.js +0 -77
  127. package/lib/client/eventEmitter.js +0 -314
  128. package/lib/client/events.js +0 -94
  129. package/lib/client/fetch.js +0 -391
  130. package/lib/client/fileChooser.js +0 -45
  131. package/lib/client/frame.js +0 -504
  132. package/lib/client/harRouter.js +0 -99
  133. package/lib/client/input.js +0 -111
  134. package/lib/client/jsHandle.js +0 -121
  135. package/lib/client/jsonPipe.js +0 -35
  136. package/lib/client/localUtils.js +0 -36
  137. package/lib/client/locator.js +0 -448
  138. package/lib/client/network.js +0 -767
  139. package/lib/client/page.js +0 -748
  140. package/lib/client/playwright.js +0 -80
  141. package/lib/client/selectors.js +0 -67
  142. package/lib/client/stream.js +0 -54
  143. package/lib/client/tracing.js +0 -147
  144. package/lib/client/types.js +0 -24
  145. package/lib/client/video.js +0 -51
  146. package/lib/client/waiter.js +0 -162
  147. package/lib/client/webError.js +0 -37
  148. package/lib/client/worker.js +0 -71
  149. package/lib/client/writableStream.js +0 -54
  150. package/lib/common/socksProxy.js +0 -569
  151. package/lib/common/timeoutSettings.js +0 -73
  152. package/lib/common/types.js +0 -5
  153. package/lib/generated/clockSource.js +0 -7
  154. package/lib/generated/consoleApiSource.js +0 -7
  155. package/lib/generated/injectedScriptSource.js +0 -7
  156. package/lib/generated/pollingRecorderSource.js +0 -7
  157. package/lib/generated/utilityScriptSource.js +0 -7
  158. package/lib/generated/webSocketMockSource.js +0 -7
  159. package/lib/image_tools/colorUtils.js +0 -98
  160. package/lib/image_tools/compare.js +0 -108
  161. package/lib/image_tools/imageChannel.js +0 -70
  162. package/lib/image_tools/stats.js +0 -102
  163. package/lib/inProcessFactory.js +0 -54
  164. package/lib/inprocess.js +0 -20
  165. package/lib/outofprocess.js +0 -67
  166. package/lib/protocol/debug.js +0 -27
  167. package/lib/protocol/serializers.js +0 -173
  168. package/lib/protocol/transport.js +0 -82
  169. package/lib/protocol/validator.js +0 -2780
  170. package/lib/protocol/validatorPrimitives.js +0 -139
  171. package/lib/remote/playwrightConnection.js +0 -274
  172. package/lib/remote/playwrightServer.js +0 -110
  173. package/lib/server/accessibility.js +0 -62
  174. package/lib/server/android/android.js +0 -441
  175. package/lib/server/android/backendAdb.js +0 -172
  176. package/lib/server/ariaSnapshot.js +0 -33
  177. package/lib/server/artifact.js +0 -104
  178. package/lib/server/bidi/bidiBrowser.js +0 -311
  179. package/lib/server/bidi/bidiChromium.js +0 -124
  180. package/lib/server/bidi/bidiConnection.js +0 -204
  181. package/lib/server/bidi/bidiExecutionContext.js +0 -156
  182. package/lib/server/bidi/bidiFirefox.js +0 -104
  183. package/lib/server/bidi/bidiInput.js +0 -158
  184. package/lib/server/bidi/bidiNetworkManager.js +0 -338
  185. package/lib/server/bidi/bidiOverCdp.js +0 -103
  186. package/lib/server/bidi/bidiPage.js +0 -529
  187. package/lib/server/bidi/bidiPdf.js +0 -140
  188. package/lib/server/bidi/third_party/bidiDeserializer.js +0 -93
  189. package/lib/server/bidi/third_party/bidiKeyboard.js +0 -238
  190. package/lib/server/bidi/third_party/bidiProtocol.js +0 -139
  191. package/lib/server/bidi/third_party/bidiSerializer.js +0 -144
  192. package/lib/server/bidi/third_party/firefoxPrefs.js +0 -221
  193. package/lib/server/browser.js +0 -148
  194. package/lib/server/browserContext.js +0 -667
  195. package/lib/server/browserType.js +0 -338
  196. package/lib/server/chromium/chromium.js +0 -354
  197. package/lib/server/chromium/chromiumSwitches.js +0 -46
  198. package/lib/server/chromium/crAccessibility.js +0 -237
  199. package/lib/server/chromium/crBrowser.js +0 -516
  200. package/lib/server/chromium/crConnection.js +0 -381
  201. package/lib/server/chromium/crCoverage.js +0 -246
  202. package/lib/server/chromium/crDevTools.js +0 -108
  203. package/lib/server/chromium/crDragDrop.js +0 -143
  204. package/lib/server/chromium/crExecutionContext.js +0 -136
  205. package/lib/server/chromium/crInput.js +0 -171
  206. package/lib/server/chromium/crNetworkManager.js +0 -767
  207. package/lib/server/chromium/crPage.js +0 -1143
  208. package/lib/server/chromium/crPdf.js +0 -153
  209. package/lib/server/chromium/crProtocolHelper.js +0 -133
  210. package/lib/server/chromium/crServiceWorker.js +0 -114
  211. package/lib/server/chromium/defaultFontFamilies.js +0 -145
  212. package/lib/server/chromium/videoRecorder.js +0 -155
  213. package/lib/server/clock.js +0 -125
  214. package/lib/server/codegen/csharp.js +0 -294
  215. package/lib/server/codegen/java.js +0 -232
  216. package/lib/server/codegen/javascript.js +0 -245
  217. package/lib/server/codegen/jsonl.js +0 -47
  218. package/lib/server/codegen/language.js +0 -88
  219. package/lib/server/codegen/languages.js +0 -30
  220. package/lib/server/codegen/python.js +0 -261
  221. package/lib/server/codegen/types.js +0 -5
  222. package/lib/server/console.js +0 -57
  223. package/lib/server/cookieStore.js +0 -185
  224. package/lib/server/debugController.js +0 -237
  225. package/lib/server/debugger.js +0 -132
  226. package/lib/server/deviceDescriptors.js +0 -26
  227. package/lib/server/deviceDescriptorsSource.json +0 -1669
  228. package/lib/server/dialog.js +0 -71
  229. package/lib/server/dispatchers/androidDispatcher.js +0 -204
  230. package/lib/server/dispatchers/artifactDispatcher.js +0 -118
  231. package/lib/server/dispatchers/browserContextDispatcher.js +0 -368
  232. package/lib/server/dispatchers/browserDispatcher.js +0 -170
  233. package/lib/server/dispatchers/browserTypeDispatcher.js +0 -55
  234. package/lib/server/dispatchers/cdpSessionDispatcher.js +0 -48
  235. package/lib/server/dispatchers/debugControllerDispatcher.js +0 -103
  236. package/lib/server/dispatchers/dialogDispatcher.js +0 -44
  237. package/lib/server/dispatchers/dispatcher.js +0 -395
  238. package/lib/server/dispatchers/electronDispatcher.js +0 -93
  239. package/lib/server/dispatchers/elementHandlerDispatcher.js +0 -228
  240. package/lib/server/dispatchers/frameDispatcher.js +0 -293
  241. package/lib/server/dispatchers/jsHandleDispatcher.js +0 -97
  242. package/lib/server/dispatchers/jsonPipeDispatcher.js +0 -59
  243. package/lib/server/dispatchers/localUtilsDispatcher.js +0 -413
  244. package/lib/server/dispatchers/networkDispatchers.js +0 -221
  245. package/lib/server/dispatchers/pageDispatcher.js +0 -367
  246. package/lib/server/dispatchers/playwrightDispatcher.js +0 -107
  247. package/lib/server/dispatchers/selectorsDispatcher.js +0 -36
  248. package/lib/server/dispatchers/streamDispatcher.js +0 -62
  249. package/lib/server/dispatchers/tracingDispatcher.js +0 -64
  250. package/lib/server/dispatchers/webSocketRouteDispatcher.js +0 -189
  251. package/lib/server/dispatchers/writableStreamDispatcher.js +0 -58
  252. package/lib/server/dom.js +0 -888
  253. package/lib/server/download.js +0 -60
  254. package/lib/server/electron/electron.js +0 -296
  255. package/lib/server/errors.js +0 -68
  256. package/lib/server/fetch.js +0 -669
  257. package/lib/server/fileChooser.js +0 -42
  258. package/lib/server/fileUploadUtils.js +0 -75
  259. package/lib/server/firefox/ffAccessibility.js +0 -216
  260. package/lib/server/firefox/ffBrowser.js +0 -460
  261. package/lib/server/firefox/ffConnection.js +0 -168
  262. package/lib/server/firefox/ffExecutionContext.js +0 -123
  263. package/lib/server/firefox/ffInput.js +0 -150
  264. package/lib/server/firefox/ffNetworkManager.js +0 -233
  265. package/lib/server/firefox/ffPage.js +0 -559
  266. package/lib/server/firefox/firefox.js +0 -99
  267. package/lib/server/formData.js +0 -75
  268. package/lib/server/frameSelectors.js +0 -171
  269. package/lib/server/frames.js +0 -1691
  270. package/lib/server/har/harRecorder.js +0 -139
  271. package/lib/server/har/harTracer.js +0 -542
  272. package/lib/server/helper.js +0 -103
  273. package/lib/server/index.js +0 -108
  274. package/lib/server/input.js +0 -310
  275. package/lib/server/instrumentation.js +0 -70
  276. package/lib/server/isomorphic/utilityScriptSerializers.js +0 -226
  277. package/lib/server/javascript.js +0 -293
  278. package/lib/server/launchApp.js +0 -91
  279. package/lib/server/macEditingCommands.js +0 -139
  280. package/lib/server/network.js +0 -617
  281. package/lib/server/page.js +0 -873
  282. package/lib/server/pipeTransport.js +0 -85
  283. package/lib/server/playwright.js +0 -88
  284. package/lib/server/progress.js +0 -99
  285. package/lib/server/protocolError.js +0 -49
  286. package/lib/server/recorder/contextRecorder.js +0 -299
  287. package/lib/server/recorder/recorderApp.js +0 -187
  288. package/lib/server/recorder/recorderCollection.js +0 -116
  289. package/lib/server/recorder/recorderFrontend.js +0 -5
  290. package/lib/server/recorder/recorderInTraceViewer.js +0 -144
  291. package/lib/server/recorder/recorderRunner.js +0 -155
  292. package/lib/server/recorder/recorderUtils.js +0 -113
  293. package/lib/server/recorder/throttledFile.js +0 -46
  294. package/lib/server/recorder.js +0 -364
  295. package/lib/server/registry/browserFetcher.js +0 -168
  296. package/lib/server/registry/dependencies.js +0 -322
  297. package/lib/server/registry/index.js +0 -1052
  298. package/lib/server/registry/nativeDeps.js +0 -493
  299. package/lib/server/registry/oopDownloadBrowserMain.js +0 -138
  300. package/lib/server/screenshotter.js +0 -348
  301. package/lib/server/selectors.js +0 -73
  302. package/lib/server/socksClientCertificatesInterceptor.js +0 -340
  303. package/lib/server/socksInterceptor.js +0 -100
  304. package/lib/server/trace/recorder/snapshotter.js +0 -161
  305. package/lib/server/trace/recorder/snapshotterInjected.js +0 -511
  306. package/lib/server/trace/recorder/tracing.js +0 -596
  307. package/lib/server/trace/test/inMemorySnapshotter.js +0 -93
  308. package/lib/server/trace/viewer/traceViewer.js +0 -214
  309. package/lib/server/transport.js +0 -191
  310. package/lib/server/types.js +0 -24
  311. package/lib/server/usKeyboardLayout.js +0 -555
  312. package/lib/server/webkit/webkit.js +0 -87
  313. package/lib/server/webkit/wkAccessibility.js +0 -194
  314. package/lib/server/webkit/wkBrowser.js +0 -329
  315. package/lib/server/webkit/wkConnection.js +0 -173
  316. package/lib/server/webkit/wkExecutionContext.js +0 -130
  317. package/lib/server/webkit/wkInput.js +0 -169
  318. package/lib/server/webkit/wkInterceptableRequest.js +0 -162
  319. package/lib/server/webkit/wkPage.js +0 -1225
  320. package/lib/server/webkit/wkProvisionalPage.js +0 -94
  321. package/lib/server/webkit/wkWorkers.js +0 -104
  322. package/lib/third_party/pixelmatch.js +0 -255
  323. package/lib/utils/ascii.js +0 -31
  324. package/lib/utils/comparators.js +0 -153
  325. package/lib/utils/crypto.js +0 -171
  326. package/lib/utils/debug.js +0 -46
  327. package/lib/utils/debugLogger.js +0 -91
  328. package/lib/utils/env.js +0 -49
  329. package/lib/utils/eventsHelper.js +0 -38
  330. package/lib/utils/expectUtils.js +0 -33
  331. package/lib/utils/fileUtils.js +0 -205
  332. package/lib/utils/happy-eyeballs.js +0 -194
  333. package/lib/utils/headers.js +0 -52
  334. package/lib/utils/hostPlatform.js +0 -139
  335. package/lib/utils/httpServer.js +0 -237
  336. package/lib/utils/index.js +0 -368
  337. package/lib/utils/isomorphic/ariaSnapshot.js +0 -267
  338. package/lib/utils/isomorphic/cssParser.js +0 -250
  339. package/lib/utils/isomorphic/cssTokenizer.js +0 -979
  340. package/lib/utils/isomorphic/locatorGenerators.js +0 -660
  341. package/lib/utils/isomorphic/locatorParser.js +0 -179
  342. package/lib/utils/isomorphic/locatorUtils.js +0 -62
  343. package/lib/utils/isomorphic/mimeType.js +0 -29
  344. package/lib/utils/isomorphic/recorderUtils.js +0 -227
  345. package/lib/utils/isomorphic/selectorParser.js +0 -397
  346. package/lib/utils/isomorphic/stringUtils.js +0 -169
  347. package/lib/utils/isomorphic/traceUtils.js +0 -39
  348. package/lib/utils/isomorphic/urlMatch.js +0 -124
  349. package/lib/utils/linuxUtils.js +0 -78
  350. package/lib/utils/manualPromise.js +0 -109
  351. package/lib/utils/multimap.js +0 -75
  352. package/lib/utils/network.js +0 -160
  353. package/lib/utils/processLauncher.js +0 -248
  354. package/lib/utils/profiler.js +0 -53
  355. package/lib/utils/rtti.js +0 -44
  356. package/lib/utils/semaphore.js +0 -51
  357. package/lib/utils/sequence.js +0 -64
  358. package/lib/utils/spawnAsync.js +0 -45
  359. package/lib/utils/stackTrace.js +0 -134
  360. package/lib/utils/task.js +0 -58
  361. package/lib/utils/time.js +0 -37
  362. package/lib/utils/timeoutRunner.js +0 -66
  363. package/lib/utils/traceUtils.js +0 -44
  364. package/lib/utils/userAgent.js +0 -105
  365. package/lib/utils/wsServer.js +0 -127
  366. package/lib/utils/zipFile.js +0 -75
  367. package/lib/utils/zones.js +0 -71
  368. package/lib/utilsBundleImpl/index.js +0 -210
  369. package/lib/vite/recorder/assets/codeMirrorModule-C5j27SYZ.js +0 -24
  370. package/lib/vite/recorder/assets/codeMirrorModule-ez37Vkbh.css +0 -1
  371. package/lib/vite/recorder/assets/index-iA1aAGZg.css +0 -1
  372. package/lib/vite/recorder/assets/index-m0XdVJHe.js +0 -184
  373. package/lib/vite/traceViewer/assets/codeMirrorModule-BBCX0spr.js +0 -24
  374. package/lib/vite/traceViewer/assets/inspectorTab-B4Iw34Ow.js +0 -68
  375. package/lib/vite/traceViewer/assets/testServerConnection-DeE2kSzz.js +0 -1
  376. package/lib/vite/traceViewer/assets/workbench-DFlGYqou.js +0 -9
  377. package/lib/vite/traceViewer/assets/xtermModule-BeNbaIVa.js +0 -9
  378. package/lib/vite/traceViewer/codeMirrorModule.ez37Vkbh.css +0 -1
  379. package/lib/vite/traceViewer/embedded.CmarehFk.js +0 -2
  380. package/lib/vite/traceViewer/embedded.html +0 -18
  381. package/lib/vite/traceViewer/embedded.w7WN2u1R.css +0 -1
  382. package/lib/vite/traceViewer/index.CrbWWHbf.css +0 -1
  383. package/lib/vite/traceViewer/index.FBucu_gE.js +0 -2
  384. package/lib/vite/traceViewer/inspectorTab.DEOUW62d.css +0 -1
  385. package/lib/vite/traceViewer/recorder.B_SY1GJM.css +0 -0
  386. package/lib/vite/traceViewer/recorder.CW_rzcEp.js +0 -2
  387. package/lib/vite/traceViewer/recorder.html +0 -17
  388. package/lib/vite/traceViewer/uiMode.CDUVjusr.js +0 -5
  389. package/lib/vite/traceViewer/uiMode.voC1ZiOQ.css +0 -1
  390. package/lib/vite/traceViewer/workbench.C-zR9ysA.css +0 -1
  391. package/lib/vite/traceViewer/xtermModule.DSXBckUd.css +0 -32
  392. package/lib/zipBundle.js +0 -25
  393. package/lib/zipBundleImpl.js +0 -5
@@ -1,340 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ClientCertificatesProxy = void 0;
7
- exports.getMatchingTLSOptionsForOrigin = getMatchingTLSOptionsForOrigin;
8
- exports.rewriteOpenSSLErrorIfNeeded = rewriteOpenSSLErrorIfNeeded;
9
- var _net = _interopRequireDefault(require("net"));
10
- var _http = _interopRequireDefault(require("http2"));
11
- var _tls = _interopRequireDefault(require("tls"));
12
- var _stream = _interopRequireDefault(require("stream"));
13
- var _happyEyeballs = require("../utils/happy-eyeballs");
14
- var _utils = require("../utils");
15
- var _socksProxy = require("../common/socksProxy");
16
- var _debugLogger = require("../utils/debugLogger");
17
- var _fetch = require("./fetch");
18
- var _events = require("events");
19
- var _browserContext = require("./browserContext");
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
- /**
22
- * Copyright (c) Microsoft Corporation.
23
- *
24
- * Licensed under the Apache License, Version 2.0 (the 'License");
25
- * you may not use this file except in compliance with the License.
26
- * You may obtain a copy of the License at
27
- *
28
- * http://www.apache.org/licenses/LICENSE-2.0
29
- *
30
- * Unless required by applicable law or agreed to in writing, software
31
- * distributed under the License is distributed on an "AS IS" BASIS,
32
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33
- * See the License for the specific language governing permissions and
34
- * limitations under the License.
35
- */
36
-
37
- let dummyServerTlsOptions = undefined;
38
- function loadDummyServerCertsIfNeeded() {
39
- if (dummyServerTlsOptions) return;
40
- const {
41
- cert,
42
- key
43
- } = (0, _utils.generateSelfSignedCertificate)();
44
- dummyServerTlsOptions = {
45
- key,
46
- cert
47
- };
48
- }
49
- class ALPNCache {
50
- constructor() {
51
- this._cache = new Map();
52
- }
53
- get(host, port, success) {
54
- const cacheKey = `${host}:${port}`;
55
- {
56
- const result = this._cache.get(cacheKey);
57
- if (result) {
58
- result.then(success);
59
- return;
60
- }
61
- }
62
- const result = new _utils.ManualPromise();
63
- this._cache.set(cacheKey, result);
64
- result.then(success);
65
- (0, _happyEyeballs.createTLSSocket)({
66
- host,
67
- port,
68
- servername: _net.default.isIP(host) ? undefined : host,
69
- ALPNProtocols: ['h2', 'http/1.1'],
70
- rejectUnauthorized: false
71
- }).then(socket => {
72
- // The server may not respond with ALPN, in which case we default to http/1.1.
73
- result.resolve(socket.alpnProtocol || 'http/1.1');
74
- socket.end();
75
- }).catch(error => {
76
- _debugLogger.debugLogger.log('client-certificates', `ALPN error: ${error.message}`);
77
- result.resolve('http/1.1');
78
- });
79
- }
80
- }
81
- class SocksProxyConnection {
82
- constructor(socksProxy, uid, host, port) {
83
- this.socksProxy = void 0;
84
- this.uid = void 0;
85
- this.host = void 0;
86
- this.port = void 0;
87
- this.firstPackageReceived = false;
88
- this.target = void 0;
89
- // In case of http, we just pipe data to the target socket and they are |undefined|.
90
- this.internal = void 0;
91
- this.internalTLS = void 0;
92
- this._targetCloseEventListener = void 0;
93
- this._dummyServer = void 0;
94
- this._closed = false;
95
- this.socksProxy = socksProxy;
96
- this.uid = uid;
97
- this.host = host;
98
- this.port = port;
99
- this._targetCloseEventListener = () => {
100
- var _this$internalTLS, _this$_dummyServer;
101
- // Close the other end and cleanup TLS resources.
102
- this.socksProxy._socksProxy.sendSocketEnd({
103
- uid: this.uid
104
- });
105
- (_this$internalTLS = this.internalTLS) === null || _this$internalTLS === void 0 || _this$internalTLS.destroy();
106
- (_this$_dummyServer = this._dummyServer) === null || _this$_dummyServer === void 0 || _this$_dummyServer.close();
107
- };
108
- }
109
- async connect() {
110
- if (this.socksProxy.proxyAgentFromOptions) this.target = await this.socksProxy.proxyAgentFromOptions.connect(new _events.EventEmitter(), {
111
- host: rewriteToLocalhostIfNeeded(this.host),
112
- port: this.port,
113
- secureEndpoint: false
114
- });else this.target = await (0, _happyEyeballs.createSocket)(rewriteToLocalhostIfNeeded(this.host), this.port);
115
- this.target.once('close', this._targetCloseEventListener);
116
- this.target.once('error', error => this.socksProxy._socksProxy.sendSocketError({
117
- uid: this.uid,
118
- error: error.message
119
- }));
120
- if (this._closed) {
121
- this.target.destroy();
122
- return;
123
- }
124
- this.socksProxy._socksProxy.socketConnected({
125
- uid: this.uid,
126
- host: this.target.localAddress,
127
- port: this.target.localPort
128
- });
129
- }
130
- onClose() {
131
- var _this$internalTLS2, _this$_dummyServer2;
132
- // Close the other end and cleanup TLS resources.
133
- this.target.destroy();
134
- (_this$internalTLS2 = this.internalTLS) === null || _this$internalTLS2 === void 0 || _this$internalTLS2.destroy();
135
- (_this$_dummyServer2 = this._dummyServer) === null || _this$_dummyServer2 === void 0 || _this$_dummyServer2.close();
136
- this._closed = true;
137
- }
138
- onData(data) {
139
- // HTTP / TLS are client-hello based protocols. This allows us to detect
140
- // the protocol on the first package and attach appropriate listeners.
141
- if (!this.firstPackageReceived) {
142
- this.firstPackageReceived = true;
143
- // 0x16 is SSLv3/TLS "handshake" content type: https://en.wikipedia.org/wiki/Transport_Layer_Security#TLS_record
144
- if (data[0] === 0x16) this._attachTLSListeners();else this.target.on('data', data => this.socksProxy._socksProxy.sendSocketData({
145
- uid: this.uid,
146
- data
147
- }));
148
- }
149
- if (this.internal) this.internal.push(data);else this.target.write(data);
150
- }
151
- _attachTLSListeners() {
152
- this.internal = new _stream.default.Duplex({
153
- read: () => {},
154
- write: (data, encoding, callback) => {
155
- this.socksProxy._socksProxy.sendSocketData({
156
- uid: this.uid,
157
- data
158
- });
159
- callback();
160
- }
161
- });
162
- this.socksProxy.alpnCache.get(rewriteToLocalhostIfNeeded(this.host), this.port, alpnProtocolChosenByServer => {
163
- _debugLogger.debugLogger.log('client-certificates', `Proxy->Target ${this.host}:${this.port} chooses ALPN ${alpnProtocolChosenByServer}`);
164
- if (this._closed) return;
165
- this._dummyServer = _tls.default.createServer({
166
- ...dummyServerTlsOptions,
167
- ALPNProtocols: alpnProtocolChosenByServer === 'h2' ? ['h2', 'http/1.1'] : ['http/1.1']
168
- });
169
- this._dummyServer.emit('connection', this.internal);
170
- this._dummyServer.once('secureConnection', internalTLS => {
171
- this.internalTLS = internalTLS;
172
- _debugLogger.debugLogger.log('client-certificates', `Browser->Proxy ${this.host}:${this.port} chooses ALPN ${internalTLS.alpnProtocol}`);
173
- let targetTLS = undefined;
174
- const handleError = error => {
175
- _debugLogger.debugLogger.log('client-certificates', `error when connecting to target: ${error.message.replaceAll('\n', ' ')}`);
176
- const responseBody = (0, _utils.escapeHTML)('Playwright client-certificate error: ' + error.message).replaceAll('\n', ' <br>');
177
- if ((internalTLS === null || internalTLS === void 0 ? void 0 : internalTLS.alpnProtocol) === 'h2') {
178
- // This method is available only in Node.js 20+
179
- if ('performServerHandshake' in _http.default) {
180
- // In case of an 'error' event on the target connection, we still need to perform the http2 handshake on the browser side.
181
- // This is an async operation, so we need to remove the listener to prevent the socket from being closed too early.
182
- // This means we call this._targetCloseEventListener manually.
183
- this.target.removeListener('close', this._targetCloseEventListener);
184
- // @ts-expect-error
185
- const session = _http.default.performServerHandshake(internalTLS);
186
- session.on('error', () => {
187
- this.target.destroy();
188
- this._targetCloseEventListener();
189
- });
190
- session.once('stream', stream => {
191
- stream.respond({
192
- 'content-type': 'text/html',
193
- [_http.default.constants.HTTP2_HEADER_STATUS]: 503
194
- });
195
- const cleanup = () => {
196
- session.close();
197
- this.target.destroy();
198
- this._targetCloseEventListener();
199
- };
200
- stream.end(responseBody, cleanup);
201
- stream.once('error', cleanup);
202
- });
203
- } else {
204
- this.target.destroy();
205
- }
206
- } else {
207
- internalTLS.end(['HTTP/1.1 503 Internal Server Error', 'Content-Type: text/html; charset=utf-8', 'Content-Length: ' + Buffer.byteLength(responseBody), '', responseBody].join('\r\n'));
208
- this.target.destroy();
209
- }
210
- };
211
- if (this._closed) {
212
- internalTLS.destroy();
213
- return;
214
- }
215
- targetTLS = _tls.default.connect({
216
- socket: this.target,
217
- host: this.host,
218
- port: this.port,
219
- rejectUnauthorized: !this.socksProxy.ignoreHTTPSErrors,
220
- ALPNProtocols: [internalTLS.alpnProtocol || 'http/1.1'],
221
- servername: !_net.default.isIP(this.host) ? this.host : undefined,
222
- secureContext: this.socksProxy.secureContextMap.get(new URL(`https://${this.host}:${this.port}`).origin)
223
- });
224
- targetTLS.once('secureConnect', () => {
225
- internalTLS.pipe(targetTLS);
226
- targetTLS.pipe(internalTLS);
227
- });
228
- internalTLS.once('error', () => this.target.destroy());
229
- targetTLS.once('error', handleError);
230
- });
231
- });
232
- }
233
- }
234
- class ClientCertificatesProxy {
235
- constructor(contextOptions) {
236
- this._socksProxy = void 0;
237
- this._connections = new Map();
238
- this.ignoreHTTPSErrors = void 0;
239
- this.secureContextMap = new Map();
240
- this.alpnCache = void 0;
241
- this.proxyAgentFromOptions = void 0;
242
- (0, _browserContext.verifyClientCertificates)(contextOptions.clientCertificates);
243
- this.alpnCache = new ALPNCache();
244
- this.ignoreHTTPSErrors = contextOptions.ignoreHTTPSErrors;
245
- this.proxyAgentFromOptions = contextOptions.proxy ? (0, _fetch.createProxyAgent)(contextOptions.proxy) : undefined;
246
- this._initSecureContexts(contextOptions.clientCertificates);
247
- this._socksProxy = new _socksProxy.SocksProxy();
248
- this._socksProxy.setPattern('*');
249
- this._socksProxy.addListener(_socksProxy.SocksProxy.Events.SocksRequested, async payload => {
250
- try {
251
- const connection = new SocksProxyConnection(this, payload.uid, payload.host, payload.port);
252
- await connection.connect();
253
- this._connections.set(payload.uid, connection);
254
- } catch (error) {
255
- this._socksProxy.socketFailed({
256
- uid: payload.uid,
257
- errorCode: error.code
258
- });
259
- }
260
- });
261
- this._socksProxy.addListener(_socksProxy.SocksProxy.Events.SocksData, async payload => {
262
- var _this$_connections$ge;
263
- (_this$_connections$ge = this._connections.get(payload.uid)) === null || _this$_connections$ge === void 0 || _this$_connections$ge.onData(payload.data);
264
- });
265
- this._socksProxy.addListener(_socksProxy.SocksProxy.Events.SocksClosed, payload => {
266
- var _this$_connections$ge2;
267
- (_this$_connections$ge2 = this._connections.get(payload.uid)) === null || _this$_connections$ge2 === void 0 || _this$_connections$ge2.onClose();
268
- this._connections.delete(payload.uid);
269
- });
270
- loadDummyServerCertsIfNeeded();
271
- }
272
- _initSecureContexts(clientCertificates) {
273
- // Step 1. Group certificates by origin.
274
- const origin2certs = new Map();
275
- for (const cert of clientCertificates || []) {
276
- const origin = normalizeOrigin(cert.origin);
277
- const certs = origin2certs.get(origin) || [];
278
- certs.push(cert);
279
- origin2certs.set(origin, certs);
280
- }
281
-
282
- // Step 2. Create secure contexts for each origin.
283
- for (const [origin, certs] of origin2certs) {
284
- try {
285
- this.secureContextMap.set(origin, _tls.default.createSecureContext(convertClientCertificatesToTLSOptions(certs)));
286
- } catch (error) {
287
- error = rewriteOpenSSLErrorIfNeeded(error);
288
- throw (0, _utils.rewriteErrorMessage)(error, `Failed to load client certificate: ${error.message}`);
289
- }
290
- }
291
- }
292
- async listen() {
293
- const port = await this._socksProxy.listen(0, '127.0.0.1');
294
- return {
295
- server: `socks5://127.0.0.1:${port}`
296
- };
297
- }
298
- async close() {
299
- await this._socksProxy.close();
300
- }
301
- }
302
- exports.ClientCertificatesProxy = ClientCertificatesProxy;
303
- function normalizeOrigin(origin) {
304
- try {
305
- return new URL(origin).origin;
306
- } catch (error) {
307
- return origin;
308
- }
309
- }
310
- function convertClientCertificatesToTLSOptions(clientCertificates) {
311
- if (!clientCertificates || !clientCertificates.length) return;
312
- const tlsOptions = {
313
- pfx: [],
314
- key: [],
315
- cert: []
316
- };
317
- for (const cert of clientCertificates) {
318
- if (cert.cert) tlsOptions.cert.push(cert.cert);
319
- if (cert.key) tlsOptions.key.push({
320
- pem: cert.key,
321
- passphrase: cert.passphrase
322
- });
323
- if (cert.pfx) tlsOptions.pfx.push({
324
- buf: cert.pfx,
325
- passphrase: cert.passphrase
326
- });
327
- }
328
- return tlsOptions;
329
- }
330
- function getMatchingTLSOptionsForOrigin(clientCertificates, origin) {
331
- const matchingCerts = clientCertificates === null || clientCertificates === void 0 ? void 0 : clientCertificates.filter(c => normalizeOrigin(c.origin) === origin);
332
- return convertClientCertificatesToTLSOptions(matchingCerts);
333
- }
334
- function rewriteToLocalhostIfNeeded(host) {
335
- return host === 'local.playwright' ? 'localhost' : host;
336
- }
337
- function rewriteOpenSSLErrorIfNeeded(error) {
338
- if (error.message !== 'unsupported' && error.code !== 'ERR_CRYPTO_UNSUPPORTED_OPERATION') return error;
339
- return (0, _utils.rewriteErrorMessage)(error, ['Unsupported TLS certificate.', 'Most likely, the security algorithm of the given certificate was deprecated by OpenSSL.', 'For more details, see https://github.com/openssl/openssl/blob/master/README-PROVIDERS.md#the-legacy-provider', 'You could probably modernize the certificate by following the steps at https://github.com/nodejs/node/issues/40672#issuecomment-1243648223'].join('\n'));
340
- }
@@ -1,100 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.SocksInterceptor = void 0;
7
- var socks = _interopRequireWildcard(require("../common/socksProxy"));
8
- var _events = _interopRequireDefault(require("events"));
9
- var _validator = require("../protocol/validator");
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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
- /**
14
- * Copyright (c) Microsoft Corporation.
15
- *
16
- * Licensed under the Apache License, Version 2.0 (the 'License");
17
- * you may not use this file except in compliance with the License.
18
- * You may obtain a copy of the License at
19
- *
20
- * http://www.apache.org/licenses/LICENSE-2.0
21
- *
22
- * Unless required by applicable law or agreed to in writing, software
23
- * distributed under the License is distributed on an "AS IS" BASIS,
24
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25
- * See the License for the specific language governing permissions and
26
- * limitations under the License.
27
- */
28
-
29
- class SocksInterceptor {
30
- constructor(transport, pattern, redirectPortForTest) {
31
- this._handler = void 0;
32
- this._channel = void 0;
33
- this._socksSupportObjectGuid = void 0;
34
- this._ids = new Set();
35
- this._handler = new socks.SocksProxyHandler(pattern, redirectPortForTest);
36
- let lastId = -1;
37
- this._channel = new Proxy(new _events.default(), {
38
- get: (obj, prop) => {
39
- if (prop in obj || obj[prop] !== undefined || typeof prop !== 'string') return obj[prop];
40
- return params => {
41
- try {
42
- const id = --lastId;
43
- this._ids.add(id);
44
- const validator = (0, _validator.findValidator)('SocksSupport', prop, 'Params');
45
- params = validator(params, '', {
46
- tChannelImpl: tChannelForSocks,
47
- binary: 'toBase64'
48
- });
49
- transport.send({
50
- id,
51
- guid: this._socksSupportObjectGuid,
52
- method: prop,
53
- params,
54
- metadata: {
55
- stack: [],
56
- apiName: '',
57
- internal: true
58
- }
59
- });
60
- } catch (e) {}
61
- };
62
- }
63
- });
64
- this._handler.on(socks.SocksProxyHandler.Events.SocksConnected, payload => this._channel.socksConnected(payload));
65
- this._handler.on(socks.SocksProxyHandler.Events.SocksData, payload => this._channel.socksData(payload));
66
- this._handler.on(socks.SocksProxyHandler.Events.SocksError, payload => this._channel.socksError(payload));
67
- this._handler.on(socks.SocksProxyHandler.Events.SocksFailed, payload => this._channel.socksFailed(payload));
68
- this._handler.on(socks.SocksProxyHandler.Events.SocksEnd, payload => this._channel.socksEnd(payload));
69
- this._channel.on('socksRequested', payload => this._handler.socketRequested(payload));
70
- this._channel.on('socksClosed', payload => this._handler.socketClosed(payload));
71
- this._channel.on('socksData', payload => this._handler.sendSocketData(payload));
72
- }
73
- cleanup() {
74
- this._handler.cleanup();
75
- }
76
- interceptMessage(message) {
77
- if (this._ids.has(message.id)) {
78
- this._ids.delete(message.id);
79
- return true;
80
- }
81
- if (message.method === '__create__' && message.params.type === 'SocksSupport') {
82
- this._socksSupportObjectGuid = message.params.guid;
83
- return false;
84
- }
85
- if (this._socksSupportObjectGuid && message.guid === this._socksSupportObjectGuid) {
86
- const validator = (0, _validator.findValidator)('SocksSupport', message.method, 'Event');
87
- const params = validator(message.params, '', {
88
- tChannelImpl: tChannelForSocks,
89
- binary: 'fromBase64'
90
- });
91
- this._channel.emit(message.method, params);
92
- return true;
93
- }
94
- return false;
95
- }
96
- }
97
- exports.SocksInterceptor = SocksInterceptor;
98
- function tChannelForSocks(names, arg, path, context) {
99
- throw new _validator.ValidationError(`${path}: channels are not expected in SocksSupport`);
100
- }
@@ -1,161 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Snapshotter = void 0;
7
- var _browserContext = require("../../browserContext");
8
- var _page = require("../../page");
9
- var _eventsHelper = require("../../../utils/eventsHelper");
10
- var _debugLogger = require("../../../utils/debugLogger");
11
- var _snapshotterInjected = require("./snapshotterInjected");
12
- var _utils = require("../../../utils");
13
- var _utilsBundle = require("../../../utilsBundle");
14
- /**
15
- * Copyright (c) Microsoft Corporation.
16
- *
17
- * Licensed under the Apache License, Version 2.0 (the "License");
18
- * you may not use this file except in compliance with the License.
19
- * You may obtain a copy of the License at
20
- *
21
- * http://www.apache.org/licenses/LICENSE-2.0
22
- *
23
- * Unless required by applicable law or agreed to in writing, software
24
- * distributed under the License is distributed on an "AS IS" BASIS,
25
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26
- * See the License for the specific language governing permissions and
27
- * limitations under the License.
28
- */
29
-
30
- class Snapshotter {
31
- constructor(context, delegate) {
32
- this._context = void 0;
33
- this._delegate = void 0;
34
- this._eventListeners = [];
35
- this._snapshotStreamer = void 0;
36
- this._initialized = false;
37
- this._started = false;
38
- this._context = context;
39
- this._delegate = delegate;
40
- const guid = (0, _utils.createGuid)();
41
- this._snapshotStreamer = '__playwright_snapshot_streamer_' + guid;
42
- }
43
- started() {
44
- return this._started;
45
- }
46
- async start() {
47
- this._started = true;
48
- if (!this._initialized) {
49
- this._initialized = true;
50
- await this._initialize();
51
- }
52
- await this.reset();
53
- }
54
- async reset() {
55
- if (this._started) await this._runInAllFrames(`window["${this._snapshotStreamer}"].reset()`);
56
- }
57
- async stop() {
58
- this._started = false;
59
- }
60
- resetForReuse() {
61
- // Next time we start recording, we will call addInitScript again.
62
- this._initialized = false;
63
- }
64
- async _initialize() {
65
- for (const page of this._context.pages()) this._onPage(page);
66
- this._eventListeners = [_eventsHelper.eventsHelper.addEventListener(this._context, _browserContext.BrowserContext.Events.Page, this._onPage.bind(this))];
67
- const {
68
- javaScriptEnabled
69
- } = this._context._options;
70
- const initScript = `(${_snapshotterInjected.frameSnapshotStreamer})("${this._snapshotStreamer}", ${javaScriptEnabled || javaScriptEnabled === undefined})`;
71
- await this._context.addInitScript(initScript);
72
- await this._runInAllFrames(initScript);
73
- }
74
- async _runInAllFrames(expression) {
75
- const frames = [];
76
- for (const page of this._context.pages()) frames.push(...page.frames());
77
- await Promise.all(frames.map(frame => {
78
- return frame.nonStallingRawEvaluateInExistingMainContext(expression).catch(e => _debugLogger.debugLogger.log('error', e));
79
- }));
80
- }
81
- dispose() {
82
- _eventsHelper.eventsHelper.removeEventListeners(this._eventListeners);
83
- }
84
- async captureSnapshot(page, callId, snapshotName) {
85
- // Prepare expression synchronously.
86
- const expression = `window["${this._snapshotStreamer}"].captureSnapshot(${JSON.stringify(snapshotName)})`;
87
-
88
- // In each frame, in a non-stalling manner, capture the snapshots.
89
- const snapshots = page.frames().map(async frame => {
90
- const data = await frame.nonStallingRawEvaluateInExistingMainContext(expression).catch(e => _debugLogger.debugLogger.log('error', e));
91
- // Something went wrong -> bail out, our snapshots are best-efforty.
92
- if (!data || !this._started) return;
93
- const snapshot = {
94
- callId,
95
- snapshotName,
96
- pageId: page.guid,
97
- frameId: frame.guid,
98
- frameUrl: data.url,
99
- doctype: data.doctype,
100
- html: data.html,
101
- viewport: data.viewport,
102
- timestamp: (0, _utils.monotonicTime)(),
103
- wallTime: data.wallTime,
104
- collectionTime: data.collectionTime,
105
- resourceOverrides: [],
106
- isMainFrame: page.mainFrame() === frame
107
- };
108
- for (const {
109
- url,
110
- content,
111
- contentType
112
- } of data.resourceOverrides) {
113
- if (typeof content === 'string') {
114
- const buffer = Buffer.from(content);
115
- const sha1 = (0, _utils.calculateSha1)(buffer) + '.' + (_utilsBundle.mime.getExtension(contentType) || 'dat');
116
- this._delegate.onSnapshotterBlob({
117
- sha1,
118
- buffer
119
- });
120
- snapshot.resourceOverrides.push({
121
- url,
122
- sha1
123
- });
124
- } else {
125
- snapshot.resourceOverrides.push({
126
- url,
127
- ref: content
128
- });
129
- }
130
- }
131
- this._delegate.onFrameSnapshot(snapshot);
132
- });
133
- await Promise.all(snapshots);
134
- }
135
- _onPage(page) {
136
- // Annotate frame hierarchy so that snapshots could include frame ids.
137
- for (const frame of page.frames()) this._annotateFrameHierarchy(frame);
138
- this._eventListeners.push(_eventsHelper.eventsHelper.addEventListener(page, _page.Page.Events.FrameAttached, frame => this._annotateFrameHierarchy(frame)));
139
- }
140
- async _annotateFrameHierarchy(frame) {
141
- try {
142
- const frameElement = await frame.frameElement();
143
- const parent = frame.parentFrame();
144
- if (!parent) return;
145
- const context = await parent._mainContext();
146
- await (context === null || context === void 0 ? void 0 : context.evaluate(({
147
- snapshotStreamer,
148
- frameElement,
149
- frameId
150
- }) => {
151
- window[snapshotStreamer].markIframe(frameElement, frameId);
152
- }, {
153
- snapshotStreamer: this._snapshotStreamer,
154
- frameElement,
155
- frameId: frame.guid
156
- }));
157
- frameElement.dispose();
158
- } catch (e) {}
159
- }
160
- }
161
- exports.Snapshotter = Snapshotter;