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,873 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Worker = exports.PageBinding = exports.Page = exports.InitScript = void 0;
7
- var frames = _interopRequireWildcard(require("./frames"));
8
- var input = _interopRequireWildcard(require("./input"));
9
- var js = _interopRequireWildcard(require("./javascript"));
10
- var _screenshotter = require("./screenshotter");
11
- var _timeoutSettings = require("../common/timeoutSettings");
12
- var _browserContext = require("./browserContext");
13
- var _console = require("./console");
14
- var accessibility = _interopRequireWildcard(require("./accessibility"));
15
- var _fileChooser = require("./fileChooser");
16
- var _progress = require("./progress");
17
- var _utils = require("../utils");
18
- var _manualPromise = require("../utils/manualPromise");
19
- var _debugLogger = require("../utils/debugLogger");
20
- var _comparators = require("../utils/comparators");
21
- var _instrumentation = require("./instrumentation");
22
- var _selectorParser = require("../utils/isomorphic/selectorParser");
23
- var _utilityScriptSerializers = require("./isomorphic/utilityScriptSerializers");
24
- var _errors = require("./errors");
25
- var _helper = require("./helper");
26
- 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); }
27
- 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; }
28
- /**
29
- * Copyright 2017 Google Inc. All rights reserved.
30
- * Modifications copyright (c) Microsoft Corporation.
31
- *
32
- * Licensed under the Apache License, Version 2.0 (the "License");
33
- * you may not use this file except in compliance with the License.
34
- * You may obtain a copy of the License at
35
- *
36
- * http://www.apache.org/licenses/LICENSE-2.0
37
- *
38
- * Unless required by applicable law or agreed to in writing, software
39
- * distributed under the License is distributed on an "AS IS" BASIS,
40
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
41
- * See the License for the specific language governing permissions and
42
- * limitations under the License.
43
- */
44
-
45
- class Page extends _instrumentation.SdkObject {
46
- constructor(delegate, browserContext) {
47
- super(browserContext, 'page');
48
- this._closedState = 'open';
49
- this._closedPromise = new _manualPromise.ManualPromise();
50
- this._initialized = false;
51
- this._eventsToEmitAfterInitialized = [];
52
- this._crashed = false;
53
- this.openScope = new _utils.LongStandingScope();
54
- this._browserContext = void 0;
55
- this.keyboard = void 0;
56
- this.mouse = void 0;
57
- this.touchscreen = void 0;
58
- this._timeoutSettings = void 0;
59
- this._delegate = void 0;
60
- this._emulatedSize = void 0;
61
- this._extraHTTPHeaders = void 0;
62
- this._emulatedMedia = {};
63
- this._interceptFileChooser = false;
64
- this._pageBindings = new Map();
65
- this.initScripts = [];
66
- this._screenshotter = void 0;
67
- this._frameManager = void 0;
68
- this.accessibility = void 0;
69
- this._workers = new Map();
70
- this.pdf = void 0;
71
- this.coverage = void 0;
72
- this._clientRequestInterceptor = void 0;
73
- this._serverRequestInterceptor = void 0;
74
- this._ownedContext = void 0;
75
- this._pageIsError = void 0;
76
- this._video = null;
77
- this._opener = void 0;
78
- this._isServerSideOnly = false;
79
- this._locatorHandlers = new Map();
80
- this._lastLocatorHandlerUid = 0;
81
- this._locatorHandlerRunningCounter = 0;
82
- // Aiming at 25 fps by default - each frame is 40ms, but we give some slack with 35ms.
83
- // When throttling for tracing, 200ms between frames, except for 10 frames around the action.
84
- this._frameThrottler = new FrameThrottler(10, 35, 200);
85
- this._closeReason = void 0;
86
- this.attribution.page = this;
87
- this._delegate = delegate;
88
- this._browserContext = browserContext;
89
- this.accessibility = new accessibility.Accessibility(delegate.getAccessibilityTree.bind(delegate));
90
- this.keyboard = new input.Keyboard(delegate.rawKeyboard);
91
- this.mouse = new input.Mouse(delegate.rawMouse, this);
92
- this.touchscreen = new input.Touchscreen(delegate.rawTouchscreen, this);
93
- this._timeoutSettings = new _timeoutSettings.TimeoutSettings(browserContext._timeoutSettings);
94
- this._screenshotter = new _screenshotter.Screenshotter(this);
95
- this._frameManager = new frames.FrameManager(this);
96
- if (delegate.pdf) this.pdf = delegate.pdf.bind(delegate);
97
- this.coverage = delegate.coverage ? delegate.coverage() : null;
98
- }
99
- async initOpener(opener) {
100
- if (!opener) return;
101
- const openerPage = await opener.pageOrError();
102
- if (openerPage instanceof Page && !openerPage.isClosed()) this._opener = openerPage;
103
- }
104
- reportAsNew(error = undefined, contextEvent = _browserContext.BrowserContext.Events.Page) {
105
- if (error) {
106
- // Initialization error could have happened because of
107
- // context/browser closure. Just ignore the page.
108
- if (this._browserContext.isClosingOrClosed()) return;
109
- this._setIsError(error);
110
- }
111
- this._initialized = true;
112
- this.emitOnContext(contextEvent, this);
113
- for (const {
114
- event,
115
- args
116
- } of this._eventsToEmitAfterInitialized) this._browserContext.emit(event, ...args);
117
- this._eventsToEmitAfterInitialized = [];
118
-
119
- // It may happen that page initialization finishes after Close event has already been sent,
120
- // in that case we fire another Close event to ensure that each reported Page will have
121
- // corresponding Close event after it is reported on the context.
122
- if (this.isClosed()) this.emit(Page.Events.Close);else this.instrumentation.onPageOpen(this);
123
- }
124
- initializedOrUndefined() {
125
- return this._initialized ? this : undefined;
126
- }
127
- emitOnContext(event, ...args) {
128
- if (this._isServerSideOnly) return;
129
- this._browserContext.emit(event, ...args);
130
- }
131
- emitOnContextOnceInitialized(event, ...args) {
132
- if (this._isServerSideOnly) return;
133
- // Some events, like console messages, may come before page is ready.
134
- // In this case, postpone the event until page is initialized,
135
- // and dispatch it to the client later, either on the live Page,
136
- // or on the "errored" Page.
137
- if (this._initialized) this._browserContext.emit(event, ...args);else this._eventsToEmitAfterInitialized.push({
138
- event,
139
- args
140
- });
141
- }
142
- async resetForReuse(metadata) {
143
- this.setDefaultNavigationTimeout(undefined);
144
- this.setDefaultTimeout(undefined);
145
- this._locatorHandlers.clear();
146
- await this._removeExposedBindings();
147
- await this._removeInitScripts();
148
- await this.setClientRequestInterceptor(undefined);
149
- await this._setServerRequestInterceptor(undefined);
150
- await this.setFileChooserIntercepted(false);
151
- // Re-navigate once init scripts are gone.
152
- await this.mainFrame().goto(metadata, 'about:blank');
153
- this._emulatedSize = undefined;
154
- this._emulatedMedia = {};
155
- this._extraHTTPHeaders = undefined;
156
- this._interceptFileChooser = false;
157
- await Promise.all([this._delegate.updateEmulatedViewportSize(), this._delegate.updateEmulateMedia(), this._delegate.updateFileChooserInterception()]);
158
- await this._delegate.resetForReuse();
159
- }
160
- _didClose() {
161
- this._frameManager.dispose();
162
- this._frameThrottler.dispose();
163
- (0, _utils.assert)(this._closedState !== 'closed', 'Page closed twice');
164
- this._closedState = 'closed';
165
- this.emit(Page.Events.Close);
166
- this._closedPromise.resolve();
167
- this.instrumentation.onPageClose(this);
168
- this.openScope.close(new _errors.TargetClosedError());
169
- }
170
- _didCrash() {
171
- this._frameManager.dispose();
172
- this._frameThrottler.dispose();
173
- this.emit(Page.Events.Crash);
174
- this._crashed = true;
175
- this.instrumentation.onPageClose(this);
176
- this.openScope.close(new Error('Page crashed'));
177
- }
178
- async _onFileChooserOpened(handle) {
179
- let multiple;
180
- try {
181
- multiple = await handle.evaluate(element => !!element.multiple);
182
- } catch (e) {
183
- // Frame/context may be gone during async processing. Do not throw.
184
- return;
185
- }
186
- if (!this.listenerCount(Page.Events.FileChooser)) {
187
- handle.dispose();
188
- return;
189
- }
190
- const fileChooser = new _fileChooser.FileChooser(this, handle, multiple);
191
- this.emit(Page.Events.FileChooser, fileChooser);
192
- }
193
- context() {
194
- return this._browserContext;
195
- }
196
- opener() {
197
- return this._opener;
198
- }
199
- mainFrame() {
200
- return this._frameManager.mainFrame();
201
- }
202
- frames() {
203
- return this._frameManager.frames();
204
- }
205
- setDefaultNavigationTimeout(timeout) {
206
- this._timeoutSettings.setDefaultNavigationTimeout(timeout);
207
- }
208
- setDefaultTimeout(timeout) {
209
- this._timeoutSettings.setDefaultTimeout(timeout);
210
- }
211
- async exposeBinding(name, needsHandle, playwrightBinding) {
212
- if (this._pageBindings.has(name)) throw new Error(`Function "${name}" has been already registered`);
213
- if (this._browserContext._pageBindings.has(name)) throw new Error(`Function "${name}" has been already registered in the browser context`);
214
- const binding = new PageBinding(name, playwrightBinding, needsHandle);
215
- this._pageBindings.set(name, binding);
216
- await this._delegate.addInitScript(binding.initScript);
217
- await Promise.all(this.frames().map(frame => frame.evaluateExpression(binding.initScript.source).catch(e => {})));
218
- }
219
- async _removeExposedBindings() {
220
- for (const [key, binding] of this._pageBindings) {
221
- if (!binding.internal) this._pageBindings.delete(key);
222
- }
223
- }
224
- setExtraHTTPHeaders(headers) {
225
- this._extraHTTPHeaders = headers;
226
- return this._delegate.updateExtraHTTPHeaders();
227
- }
228
- extraHTTPHeaders() {
229
- return this._extraHTTPHeaders;
230
- }
231
- async _onBindingCalled(payload, context) {
232
- if (this._closedState === 'closed') return;
233
- await PageBinding.dispatch(this, payload, context);
234
- }
235
- _addConsoleMessage(type, args, location, text) {
236
- const message = new _console.ConsoleMessage(this, type, text, args, location);
237
- const intercepted = this._frameManager.interceptConsoleMessage(message);
238
- if (intercepted) {
239
- args.forEach(arg => arg.dispose());
240
- return;
241
- }
242
- this.emitOnContextOnceInitialized(_browserContext.BrowserContext.Events.Console, message);
243
- }
244
- async reload(metadata, options) {
245
- const controller = new _progress.ProgressController(metadata, this);
246
- return controller.run(progress => this.mainFrame().raceNavigationAction(progress, options, async () => {
247
- // Note: waitForNavigation may fail before we get response to reload(),
248
- // so we should await it immediately.
249
- const [response] = await Promise.all([
250
- // Reload must be a new document, and should not be confused with a stray pushState.
251
- this.mainFrame()._waitForNavigation(progress, true /* requiresNewDocument */, options), this._delegate.reload()]);
252
- return response;
253
- }), this._timeoutSettings.navigationTimeout(options));
254
- }
255
- async goBack(metadata, options) {
256
- const controller = new _progress.ProgressController(metadata, this);
257
- return controller.run(progress => this.mainFrame().raceNavigationAction(progress, options, async () => {
258
- // Note: waitForNavigation may fail before we get response to goBack,
259
- // so we should catch it immediately.
260
- let error;
261
- const waitPromise = this.mainFrame()._waitForNavigation(progress, false /* requiresNewDocument */, options).catch(e => {
262
- error = e;
263
- return null;
264
- });
265
- const result = await this._delegate.goBack();
266
- if (!result) return null;
267
- const response = await waitPromise;
268
- if (error) throw error;
269
- return response;
270
- }), this._timeoutSettings.navigationTimeout(options));
271
- }
272
- async goForward(metadata, options) {
273
- const controller = new _progress.ProgressController(metadata, this);
274
- return controller.run(progress => this.mainFrame().raceNavigationAction(progress, options, async () => {
275
- // Note: waitForNavigation may fail before we get response to goForward,
276
- // so we should catch it immediately.
277
- let error;
278
- const waitPromise = this.mainFrame()._waitForNavigation(progress, false /* requiresNewDocument */, options).catch(e => {
279
- error = e;
280
- return null;
281
- });
282
- const result = await this._delegate.goForward();
283
- if (!result) return null;
284
- const response = await waitPromise;
285
- if (error) throw error;
286
- return response;
287
- }), this._timeoutSettings.navigationTimeout(options));
288
- }
289
- requestGC() {
290
- return this._delegate.requestGC();
291
- }
292
- registerLocatorHandler(selector, noWaitAfter) {
293
- const uid = ++this._lastLocatorHandlerUid;
294
- this._locatorHandlers.set(uid, {
295
- selector,
296
- noWaitAfter
297
- });
298
- return uid;
299
- }
300
- resolveLocatorHandler(uid, remove) {
301
- const handler = this._locatorHandlers.get(uid);
302
- if (remove) this._locatorHandlers.delete(uid);
303
- if (handler) {
304
- var _handler$resolved;
305
- (_handler$resolved = handler.resolved) === null || _handler$resolved === void 0 || _handler$resolved.resolve();
306
- handler.resolved = undefined;
307
- }
308
- }
309
- unregisterLocatorHandler(uid) {
310
- this._locatorHandlers.delete(uid);
311
- }
312
- async performActionPreChecks(progress) {
313
- await this._performWaitForNavigationCheck(progress);
314
- progress.throwIfAborted();
315
- await this._performLocatorHandlersCheckpoint(progress);
316
- progress.throwIfAborted();
317
- // Wait once again, just in case a locator handler caused a navigation.
318
- await this._performWaitForNavigationCheck(progress);
319
- }
320
- async _performWaitForNavigationCheck(progress) {
321
- var _mainFrame$pendingDoc;
322
- if (process.env.PLAYWRIGHT_SKIP_NAVIGATION_CHECK) return;
323
- const mainFrame = this._frameManager.mainFrame();
324
- if (!mainFrame || !mainFrame.pendingDocument()) return;
325
- const url = (_mainFrame$pendingDoc = mainFrame.pendingDocument()) === null || _mainFrame$pendingDoc === void 0 || (_mainFrame$pendingDoc = _mainFrame$pendingDoc.request) === null || _mainFrame$pendingDoc === void 0 ? void 0 : _mainFrame$pendingDoc.url();
326
- const toUrl = url ? `" ${(0, _utils.trimStringWithEllipsis)(url, 200)}"` : '';
327
- progress.log(` waiting for${toUrl} navigation to finish...`);
328
- await _helper.helper.waitForEvent(progress, mainFrame, frames.Frame.Events.InternalNavigation, e => {
329
- if (!e.isPublic) return false;
330
- if (!e.error) progress.log(` navigated to "${(0, _utils.trimStringWithEllipsis)(mainFrame.url(), 200)}"`);
331
- return true;
332
- }).promise;
333
- }
334
- async _performLocatorHandlersCheckpoint(progress) {
335
- // Do not run locator handlers from inside locator handler callbacks to avoid deadlocks.
336
- if (this._locatorHandlerRunningCounter) return;
337
- for (const [uid, handler] of this._locatorHandlers) {
338
- if (!handler.resolved) {
339
- if (await this.mainFrame().isVisibleInternal(handler.selector, {
340
- strict: true
341
- })) {
342
- handler.resolved = new _manualPromise.ManualPromise();
343
- this.emit(Page.Events.LocatorHandlerTriggered, uid);
344
- }
345
- }
346
- if (handler.resolved) {
347
- ++this._locatorHandlerRunningCounter;
348
- progress.log(` found ${(0, _utils.asLocator)(this.attribution.playwright.options.sdkLanguage, handler.selector)}, intercepting action to run the handler`);
349
- const promise = handler.resolved.then(async () => {
350
- progress.throwIfAborted();
351
- if (!handler.noWaitAfter) {
352
- progress.log(` locator handler has finished, waiting for ${(0, _utils.asLocator)(this.attribution.playwright.options.sdkLanguage, handler.selector)} to be hidden`);
353
- await this.mainFrame().waitForSelectorInternal(progress, handler.selector, false, {
354
- state: 'hidden'
355
- });
356
- } else {
357
- progress.log(` locator handler has finished`);
358
- }
359
- });
360
- await this.openScope.race(promise).finally(() => --this._locatorHandlerRunningCounter);
361
- // Avoid side-effects after long-running operation.
362
- progress.throwIfAborted();
363
- progress.log(` interception handler has finished, continuing`);
364
- }
365
- }
366
- }
367
- async emulateMedia(options) {
368
- if (options.media !== undefined) this._emulatedMedia.media = options.media;
369
- if (options.colorScheme !== undefined) this._emulatedMedia.colorScheme = options.colorScheme;
370
- if (options.reducedMotion !== undefined) this._emulatedMedia.reducedMotion = options.reducedMotion;
371
- if (options.forcedColors !== undefined) this._emulatedMedia.forcedColors = options.forcedColors;
372
- await this._delegate.updateEmulateMedia();
373
- }
374
- emulatedMedia() {
375
- var _contextOptions$color, _contextOptions$reduc, _contextOptions$force;
376
- const contextOptions = this._browserContext._options;
377
- return {
378
- media: this._emulatedMedia.media || 'no-override',
379
- colorScheme: this._emulatedMedia.colorScheme !== undefined ? this._emulatedMedia.colorScheme : (_contextOptions$color = contextOptions.colorScheme) !== null && _contextOptions$color !== void 0 ? _contextOptions$color : 'light',
380
- reducedMotion: this._emulatedMedia.reducedMotion !== undefined ? this._emulatedMedia.reducedMotion : (_contextOptions$reduc = contextOptions.reducedMotion) !== null && _contextOptions$reduc !== void 0 ? _contextOptions$reduc : 'no-preference',
381
- forcedColors: this._emulatedMedia.forcedColors !== undefined ? this._emulatedMedia.forcedColors : (_contextOptions$force = contextOptions.forcedColors) !== null && _contextOptions$force !== void 0 ? _contextOptions$force : 'none'
382
- };
383
- }
384
- async setViewportSize(viewportSize) {
385
- this._emulatedSize = {
386
- viewport: {
387
- ...viewportSize
388
- },
389
- screen: {
390
- ...viewportSize
391
- }
392
- };
393
- await this._delegate.updateEmulatedViewportSize();
394
- }
395
- viewportSize() {
396
- var _this$emulatedSize;
397
- return ((_this$emulatedSize = this.emulatedSize()) === null || _this$emulatedSize === void 0 ? void 0 : _this$emulatedSize.viewport) || null;
398
- }
399
- emulatedSize() {
400
- if (this._emulatedSize) return this._emulatedSize;
401
- const contextOptions = this._browserContext._options;
402
- return contextOptions.viewport ? {
403
- viewport: contextOptions.viewport,
404
- screen: contextOptions.screen || contextOptions.viewport
405
- } : null;
406
- }
407
- async bringToFront() {
408
- await this._delegate.bringToFront();
409
- }
410
- async addInitScript(source) {
411
- const initScript = new InitScript(source);
412
- this.initScripts.push(initScript);
413
- await this._delegate.addInitScript(initScript);
414
- }
415
- async _removeInitScripts() {
416
- this.initScripts = this.initScripts.filter(script => script.internal);
417
- await this._delegate.removeNonInternalInitScripts();
418
- }
419
- needsRequestInterception() {
420
- return !!this._clientRequestInterceptor || !!this._serverRequestInterceptor || !!this._browserContext._requestInterceptor;
421
- }
422
- async setClientRequestInterceptor(handler) {
423
- this._clientRequestInterceptor = handler;
424
- await this._delegate.updateRequestInterception();
425
- }
426
- async _setServerRequestInterceptor(handler) {
427
- this._serverRequestInterceptor = handler;
428
- await this._delegate.updateRequestInterception();
429
- }
430
- async expectScreenshot(metadata, options = {}) {
431
- const locator = options.locator;
432
- const rafrafScreenshot = locator ? async (progress, timeout) => {
433
- return await locator.frame.rafrafTimeoutScreenshotElementWithProgress(progress, locator.selector, timeout, options || {});
434
- } : async (progress, timeout) => {
435
- await this.performActionPreChecks(progress);
436
- await this.mainFrame().rafrafTimeout(timeout);
437
- return await this._screenshotter.screenshotPage(progress, options || {});
438
- };
439
- const comparator = (0, _comparators.getComparator)('image/png');
440
- const controller = new _progress.ProgressController(metadata, this);
441
- if (!options.expected && options.isNot) return {
442
- errorMessage: '"not" matcher requires expected result'
443
- };
444
- try {
445
- const format = (0, _screenshotter.validateScreenshotOptions)(options || {});
446
- if (format !== 'png') throw new Error('Only PNG screenshots are supported');
447
- } catch (error) {
448
- return {
449
- errorMessage: error.message
450
- };
451
- }
452
- let intermediateResult = undefined;
453
- const areEqualScreenshots = (actual, expected, previous) => {
454
- const comparatorResult = actual && expected ? comparator(actual, expected, options) : undefined;
455
- if (comparatorResult !== undefined && !!comparatorResult === !!options.isNot) return true;
456
- if (comparatorResult) intermediateResult = {
457
- errorMessage: comparatorResult.errorMessage,
458
- diff: comparatorResult.diff,
459
- actual,
460
- previous
461
- };
462
- return false;
463
- };
464
- const callTimeout = this._timeoutSettings.timeout(options);
465
- return controller.run(async progress => {
466
- let actual;
467
- let previous;
468
- const pollIntervals = [0, 100, 250, 500];
469
- progress.log(`${metadata.apiName}${callTimeout ? ` with timeout ${callTimeout}ms` : ''}`);
470
- if (options.expected) progress.log(` verifying given screenshot expectation`);else progress.log(` generating new stable screenshot expectation`);
471
- let isFirstIteration = true;
472
- while (true) {
473
- var _pollIntervals$shift;
474
- progress.throwIfAborted();
475
- if (this.isClosed()) throw new Error('The page has closed');
476
- const screenshotTimeout = (_pollIntervals$shift = pollIntervals.shift()) !== null && _pollIntervals$shift !== void 0 ? _pollIntervals$shift : 1000;
477
- if (screenshotTimeout) progress.log(`waiting ${screenshotTimeout}ms before taking screenshot`);
478
- previous = actual;
479
- actual = await rafrafScreenshot(progress, screenshotTimeout).catch(e => {
480
- progress.log(`failed to take screenshot - ` + e.message);
481
- return undefined;
482
- });
483
- if (!actual) continue;
484
- // Compare against expectation for the first iteration.
485
- const expectation = options.expected && isFirstIteration ? options.expected : previous;
486
- if (areEqualScreenshots(actual, expectation, previous)) break;
487
- if (intermediateResult) progress.log(intermediateResult.errorMessage);
488
- isFirstIteration = false;
489
- }
490
- if (!isFirstIteration) progress.log(`captured a stable screenshot`);
491
- if (!options.expected) return {
492
- actual
493
- };
494
- if (isFirstIteration) {
495
- progress.log(`screenshot matched expectation`);
496
- return {};
497
- }
498
- if (areEqualScreenshots(actual, options.expected, undefined)) {
499
- progress.log(`screenshot matched expectation`);
500
- return {};
501
- }
502
- throw new Error(intermediateResult.errorMessage);
503
- }, callTimeout).catch(e => {
504
- var _intermediateResult;
505
- // Q: Why not throw upon isSessionClosedError(e) as in other places?
506
- // A: We want user to receive a friendly diff between actual and expected/previous.
507
- if (js.isJavaScriptErrorInEvaluate(e) || (0, _selectorParser.isInvalidSelectorError)(e)) throw e;
508
- let errorMessage = e.message;
509
- if (e instanceof _errors.TimeoutError && (_intermediateResult = intermediateResult) !== null && _intermediateResult !== void 0 && _intermediateResult.previous) errorMessage = `Failed to take two consecutive stable screenshots.`;
510
- return {
511
- log: (0, _utils.compressCallLog)(e.message ? [...metadata.log, e.message] : metadata.log),
512
- ...intermediateResult,
513
- errorMessage,
514
- timedOut: e instanceof _errors.TimeoutError
515
- };
516
- });
517
- }
518
- async screenshot(metadata, options = {}) {
519
- const controller = new _progress.ProgressController(metadata, this);
520
- return controller.run(progress => this._screenshotter.screenshotPage(progress, options), this._timeoutSettings.timeout(options));
521
- }
522
- async close(metadata, options = {}) {
523
- if (this._closedState === 'closed') return;
524
- if (options.reason) this._closeReason = options.reason;
525
- const runBeforeUnload = !!options.runBeforeUnload;
526
- if (this._closedState !== 'closing') {
527
- this._closedState = 'closing';
528
- // This might throw if the browser context containing the page closes
529
- // while we are trying to close the page.
530
- await this._delegate.closePage(runBeforeUnload).catch(e => _debugLogger.debugLogger.log('error', e));
531
- }
532
- if (!runBeforeUnload) await this._closedPromise;
533
- if (this._ownedContext) await this._ownedContext.close(options);
534
- }
535
- _setIsError(error) {
536
- this._pageIsError = error;
537
- this._frameManager.createDummyMainFrameIfNeeded();
538
- }
539
- isClosed() {
540
- return this._closedState === 'closed';
541
- }
542
- hasCrashed() {
543
- return this._crashed;
544
- }
545
- isClosedOrClosingOrCrashed() {
546
- return this._closedState !== 'open' || this._crashed;
547
- }
548
- _addWorker(workerId, worker) {
549
- this._workers.set(workerId, worker);
550
- this.emit(Page.Events.Worker, worker);
551
- }
552
- _removeWorker(workerId) {
553
- const worker = this._workers.get(workerId);
554
- if (!worker) return;
555
- worker.didClose();
556
- this._workers.delete(workerId);
557
- }
558
- _clearWorkers() {
559
- for (const [workerId, worker] of this._workers) {
560
- worker.didClose();
561
- this._workers.delete(workerId);
562
- }
563
- }
564
- async setFileChooserIntercepted(enabled) {
565
- this._interceptFileChooser = enabled;
566
- await this._delegate.updateFileChooserInterception();
567
- }
568
- fileChooserIntercepted() {
569
- return this._interceptFileChooser;
570
- }
571
- frameNavigatedToNewDocument(frame) {
572
- this.emit(Page.Events.InternalFrameNavigatedToNewDocument, frame);
573
- const origin = frame.origin();
574
- if (origin) this._browserContext.addVisitedOrigin(origin);
575
- }
576
- allInitScripts() {
577
- const bindings = [...this._browserContext._pageBindings.values(), ...this._pageBindings.values()];
578
- return [...bindings.map(binding => binding.initScript), ...this._browserContext.initScripts, ...this.initScripts];
579
- }
580
- getBinding(name) {
581
- return this._pageBindings.get(name) || this._browserContext._pageBindings.get(name);
582
- }
583
- setScreencastOptions(options) {
584
- this._delegate.setScreencastOptions(options).catch(e => _debugLogger.debugLogger.log('error', e));
585
- this._frameThrottler.setThrottlingEnabled(!!options);
586
- }
587
- throttleScreencastFrameAck(ack) {
588
- // Don't ack immediately, tracing has smart throttling logic that is implemented here.
589
- this._frameThrottler.ack(ack);
590
- }
591
- temporarilyDisableTracingScreencastThrottling() {
592
- this._frameThrottler.recharge();
593
- }
594
- async safeNonStallingEvaluateInAllFrames(expression, world, options = {}) {
595
- await Promise.all(this.frames().map(async frame => {
596
- try {
597
- await frame.nonStallingEvaluateInExistingContext(expression, world);
598
- } catch (e) {
599
- if (options.throwOnJSErrors && js.isJavaScriptErrorInEvaluate(e)) throw e;
600
- }
601
- }));
602
- }
603
- async hideHighlight() {
604
- await Promise.all(this.frames().map(frame => frame.hideHighlight().catch(() => {})));
605
- }
606
- markAsServerSideOnly() {
607
- this._isServerSideOnly = true;
608
- }
609
- }
610
- exports.Page = Page;
611
- Page.Events = {
612
- Close: 'close',
613
- Crash: 'crash',
614
- Download: 'download',
615
- FileChooser: 'filechooser',
616
- FrameAttached: 'frameattached',
617
- FrameDetached: 'framedetached',
618
- InternalFrameNavigatedToNewDocument: 'internalframenavigatedtonewdocument',
619
- LocatorHandlerTriggered: 'locatorhandlertriggered',
620
- ScreencastFrame: 'screencastframe',
621
- Video: 'video',
622
- WebSocket: 'websocket',
623
- Worker: 'worker'
624
- };
625
- class Worker extends _instrumentation.SdkObject {
626
- constructor(parent, url, targetId, session) {
627
- super(parent, 'worker');
628
- this._url = void 0;
629
- this._executionContextPromise = void 0;
630
- this._executionContextCallback = void 0;
631
- this._existingExecutionContext = null;
632
- this.openScope = new _utils.LongStandingScope();
633
- this._targetId = void 0;
634
- this._session = void 0;
635
- this._url = url;
636
- this._executionContextCallback = () => {};
637
- this._executionContextPromise = new Promise(x => this._executionContextCallback = x);
638
- this._targetId = targetId;
639
- this._session = session;
640
- }
641
- _createExecutionContext(delegate) {
642
- this._existingExecutionContext = new js.ExecutionContext(this, delegate, 'worker');
643
- this._executionContextCallback(this._existingExecutionContext);
644
- }
645
- url() {
646
- return this._url;
647
- }
648
- didClose() {
649
- if (this._existingExecutionContext) this._existingExecutionContext.contextDestroyed('Worker was closed');
650
- this.emit(Worker.Events.Close, this);
651
- this.openScope.close(new Error('Worker closed'));
652
- }
653
- async getExecutionContext() {
654
- if (process.env['REBROWSER_PATCHES_RUNTIME_FIX_MODE'] !== '0' && !this._existingExecutionContext) {
655
- await this._session.__re__emitExecutionContext({
656
- world: 'main',
657
- targetId: this._targetId
658
- });
659
- }
660
- return this._executionContextPromise;
661
- }
662
- async evaluateExpression(expression, isFunction, arg) {
663
- return js.evaluateExpression(await this.getExecutionContext(), expression, {
664
- returnByValue: true,
665
- isFunction
666
- }, arg);
667
- }
668
- async evaluateExpressionHandle(expression, isFunction, arg) {
669
- return js.evaluateExpression(await this.getExecutionContext(), expression, {
670
- returnByValue: false,
671
- isFunction
672
- }, arg);
673
- }
674
- }
675
- exports.Worker = Worker;
676
- Worker.Events = {
677
- Close: 'close'
678
- };
679
- class PageBinding {
680
- constructor(name, playwrightFunction, needsHandle) {
681
- this.name = void 0;
682
- this.playwrightFunction = void 0;
683
- this.initScript = void 0;
684
- this.needsHandle = void 0;
685
- this.internal = void 0;
686
- this.name = name;
687
- this.playwrightFunction = playwrightFunction;
688
- this.initScript = new InitScript(`(${addPageBinding.toString()})(${JSON.stringify(PageBinding.kPlaywrightBinding)}, ${JSON.stringify(name)}, ${needsHandle}, (${_utilityScriptSerializers.source})())`, true /* internal */);
689
- this.needsHandle = needsHandle;
690
- this.internal = name.startsWith('__pw');
691
- }
692
- static async dispatch(page, payload, context) {
693
- if (process.env['REBROWSER_PATCHES_RUNTIME_FIX_MODE'] !== '0' && !payload.includes('{')) {
694
- // ignore as it's not a JSON but a string from addBinding method
695
- return;
696
- }
697
- const {
698
- name,
699
- seq,
700
- serializedArgs
701
- } = JSON.parse(payload);
702
- try {
703
- (0, _utils.assert)(context.world);
704
- const binding = page.getBinding(name);
705
- if (!binding) throw new Error(`Function "${name}" is not exposed`);
706
- let result;
707
- if (binding.needsHandle) {
708
- const handle = await context.evaluateHandle(takeHandle, {
709
- name,
710
- seq
711
- }).catch(e => null);
712
- result = await binding.playwrightFunction({
713
- frame: context.frame,
714
- page,
715
- context: page._browserContext
716
- }, handle);
717
- } else {
718
- if (!Array.isArray(serializedArgs)) throw new Error(`serializedArgs is not an array. This can happen when Array.prototype.toJSON is defined incorrectly`);
719
- const args = serializedArgs.map(a => (0, _utilityScriptSerializers.parseEvaluationResultValue)(a));
720
- result = await binding.playwrightFunction({
721
- frame: context.frame,
722
- page,
723
- context: page._browserContext
724
- }, ...args);
725
- }
726
- context.evaluate(deliverResult, {
727
- name,
728
- seq,
729
- result
730
- }).catch(e => _debugLogger.debugLogger.log('error', e));
731
- } catch (error) {
732
- context.evaluate(deliverResult, {
733
- name,
734
- seq,
735
- error
736
- }).catch(e => _debugLogger.debugLogger.log('error', e));
737
- }
738
- function takeHandle(arg) {
739
- const handle = globalThis[arg.name]['handles'].get(arg.seq);
740
- globalThis[arg.name]['handles'].delete(arg.seq);
741
- return handle;
742
- }
743
- function deliverResult(arg) {
744
- const callbacks = globalThis[arg.name]['callbacks'];
745
- if ('error' in arg) callbacks.get(arg.seq).reject(arg.error);else callbacks.get(arg.seq).resolve(arg.result);
746
- callbacks.delete(arg.seq);
747
- }
748
- }
749
- }
750
- exports.PageBinding = PageBinding;
751
- PageBinding.kPlaywrightBinding = '__playwright__binding__';
752
- function addPageBinding(playwrightBinding, bindingName, needsHandle, utilityScriptSerializers) {
753
- const binding = globalThis[playwrightBinding];
754
- globalThis[bindingName] = (...args) => {
755
- const me = globalThis[bindingName];
756
- if (needsHandle && args.slice(1).some(arg => arg !== undefined)) throw new Error(`exposeBindingHandle supports a single argument, ${args.length} received`);
757
- let callbacks = me['callbacks'];
758
- if (!callbacks) {
759
- callbacks = new Map();
760
- me['callbacks'] = callbacks;
761
- }
762
- const seq = (me['lastSeq'] || 0) + 1;
763
- me['lastSeq'] = seq;
764
- let handles = me['handles'];
765
- if (!handles) {
766
- handles = new Map();
767
- me['handles'] = handles;
768
- }
769
- const promise = new Promise((resolve, reject) => callbacks.set(seq, {
770
- resolve,
771
- reject
772
- }));
773
- let payload;
774
- if (needsHandle) {
775
- handles.set(seq, args[0]);
776
- payload = {
777
- name: bindingName,
778
- seq
779
- };
780
- } else {
781
- const serializedArgs = [];
782
- for (let i = 0; i < args.length; i++) {
783
- serializedArgs[i] = utilityScriptSerializers.serializeAsCallArgument(args[i], v => {
784
- return {
785
- fallThrough: v
786
- };
787
- });
788
- }
789
- payload = {
790
- name: bindingName,
791
- seq,
792
- serializedArgs
793
- };
794
- }
795
- binding(JSON.stringify(payload));
796
- return promise;
797
- };
798
- globalThis[bindingName].__installed = true;
799
- }
800
- class InitScript {
801
- constructor(source, internal) {
802
- this.source = void 0;
803
- this.internal = void 0;
804
- const guid = (0, _utils.createGuid)();
805
- this.source = `(() => {
806
- globalThis.__pwInitScripts = globalThis.__pwInitScripts || {};
807
- const hasInitScript = globalThis.__pwInitScripts[${JSON.stringify(guid)}];
808
- if (hasInitScript)
809
- return;
810
- globalThis.__pwInitScripts[${JSON.stringify(guid)}] = true;
811
- ${source}
812
- })();`;
813
- this.internal = !!internal;
814
- }
815
- }
816
- exports.InitScript = InitScript;
817
- class FrameThrottler {
818
- constructor(nonThrottledFrames, defaultInterval, throttlingInterval) {
819
- this._acks = [];
820
- this._defaultInterval = void 0;
821
- this._throttlingInterval = void 0;
822
- this._nonThrottledFrames = void 0;
823
- this._budget = void 0;
824
- this._throttlingEnabled = false;
825
- this._timeoutId = void 0;
826
- this._nonThrottledFrames = nonThrottledFrames;
827
- this._budget = nonThrottledFrames;
828
- this._defaultInterval = defaultInterval;
829
- this._throttlingInterval = throttlingInterval;
830
- this._tick();
831
- }
832
- dispose() {
833
- if (this._timeoutId) {
834
- clearTimeout(this._timeoutId);
835
- this._timeoutId = undefined;
836
- }
837
- }
838
- setThrottlingEnabled(enabled) {
839
- this._throttlingEnabled = enabled;
840
- }
841
- recharge() {
842
- // Send all acks, reset budget.
843
- for (const ack of this._acks) ack();
844
- this._acks = [];
845
- this._budget = this._nonThrottledFrames;
846
- if (this._timeoutId) {
847
- clearTimeout(this._timeoutId);
848
- this._tick();
849
- }
850
- }
851
- ack(ack) {
852
- if (!this._timeoutId) {
853
- // Already disposed.
854
- ack();
855
- return;
856
- }
857
- this._acks.push(ack);
858
- }
859
- _tick() {
860
- const ack = this._acks.shift();
861
- if (ack) {
862
- --this._budget;
863
- ack();
864
- }
865
- if (this._throttlingEnabled && this._budget <= 0) {
866
- // Non-throttled frame budget is exceeded. Next ack will be throttled.
867
- this._timeoutId = setTimeout(() => this._tick(), this._throttlingInterval);
868
- } else {
869
- // Either not throttling, or still under budget. Next ack will be after the default timeout.
870
- this._timeoutId = setTimeout(() => this._tick(), this._defaultInterval);
871
- }
872
- }
873
- }