rebrowser-playwright-core 1.52.0 → 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 (395) hide show
  1. package/ThirdPartyNotices.txt +7 -1554
  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 +1 -1
  8. package/bin/reinstall_msedge_beta_mac.sh +1 -1
  9. package/bin/reinstall_msedge_dev_linux.sh +1 -1
  10. package/bin/reinstall_msedge_dev_mac.sh +1 -1
  11. package/bin/reinstall_msedge_stable_linux.sh +1 -1
  12. package/bin/reinstall_msedge_stable_mac.sh +1 -1
  13. package/browsers.json +16 -44
  14. package/cli.js +5 -1
  15. package/index.js +2 -17
  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/{server/deviceDescriptors.js → package.js} +18 -7
  23. package/lib/server/electron/loader.js +108 -14
  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 +86038 -66
  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 +2 -61
  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 -8
  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 -5
  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 +10495 -8030
  98. package/types/structs.d.ts +8 -1
  99. package/types/types.d.ts +9256 -4825
  100. package/lib/androidServerImpl.js +0 -63
  101. package/lib/browserServerImpl.js +0 -88
  102. package/lib/cli/driver.js +0 -97
  103. package/lib/cli/program.js +0 -567
  104. package/lib/cli/programWithTestStub.js +0 -74
  105. package/lib/client/accessibility.js +0 -49
  106. package/lib/client/android.js +0 -365
  107. package/lib/client/api.js +0 -137
  108. package/lib/client/artifact.js +0 -79
  109. package/lib/client/browser.js +0 -136
  110. package/lib/client/browserContext.js +0 -539
  111. package/lib/client/browserType.js +0 -193
  112. package/lib/client/cdpSession.js +0 -51
  113. package/lib/client/channelOwner.js +0 -205
  114. package/lib/client/clientHelper.js +0 -64
  115. package/lib/client/clientInstrumentation.js +0 -55
  116. package/lib/client/clientStackTrace.js +0 -69
  117. package/lib/client/clock.js +0 -68
  118. package/lib/client/connection.js +0 -318
  119. package/lib/client/consoleMessage.js +0 -55
  120. package/lib/client/coverage.js +0 -44
  121. package/lib/client/dialog.js +0 -56
  122. package/lib/client/download.js +0 -62
  123. package/lib/client/electron.js +0 -133
  124. package/lib/client/elementHandle.js +0 -284
  125. package/lib/client/errors.js +0 -77
  126. package/lib/client/eventEmitter.js +0 -314
  127. package/lib/client/events.js +0 -98
  128. package/lib/client/fetch.js +0 -367
  129. package/lib/client/fileChooser.js +0 -46
  130. package/lib/client/fileUtils.js +0 -34
  131. package/lib/client/frame.js +0 -386
  132. package/lib/client/harRouter.js +0 -87
  133. package/lib/client/input.js +0 -82
  134. package/lib/client/jsHandle.js +0 -105
  135. package/lib/client/jsonPipe.js +0 -39
  136. package/lib/client/localUtils.js +0 -61
  137. package/lib/client/locator.js +0 -362
  138. package/lib/client/network.js +0 -751
  139. package/lib/client/page.js +0 -709
  140. package/lib/client/platform.js +0 -74
  141. package/lib/client/playwright.js +0 -85
  142. package/lib/client/selectors.js +0 -75
  143. package/lib/client/stream.js +0 -39
  144. package/lib/client/timeoutSettings.js +0 -75
  145. package/lib/client/tracing.js +0 -114
  146. package/lib/client/types.js +0 -28
  147. package/lib/client/video.js +0 -59
  148. package/lib/client/waiter.js +0 -142
  149. package/lib/client/webError.js +0 -39
  150. package/lib/client/webSocket.js +0 -111
  151. package/lib/client/worker.js +0 -63
  152. package/lib/client/writableStream.js +0 -39
  153. package/lib/generated/clockSource.js +0 -28
  154. package/lib/generated/consoleApiSource.js +0 -28
  155. package/lib/generated/injectedScriptSource.js +0 -28
  156. package/lib/generated/pollingRecorderSource.js +0 -28
  157. package/lib/generated/utilityScriptSource.js +0 -28
  158. package/lib/generated/webSocketMockSource.js +0 -378
  159. package/lib/inProcessFactory.js +0 -59
  160. package/lib/inprocess.js +0 -3
  161. package/lib/outofprocess.js +0 -78
  162. package/lib/protocol/debug.js +0 -211
  163. package/lib/protocol/serializers.js +0 -192
  164. package/lib/protocol/validator.js +0 -2825
  165. package/lib/protocol/validatorPrimitives.js +0 -179
  166. package/lib/remote/playwrightConnection.js +0 -266
  167. package/lib/remote/playwrightServer.js +0 -139
  168. package/lib/server/accessibility.js +0 -69
  169. package/lib/server/android/android.js +0 -451
  170. package/lib/server/android/backendAdb.js +0 -179
  171. package/lib/server/artifact.js +0 -127
  172. package/lib/server/bidi/bidiBrowser.js +0 -380
  173. package/lib/server/bidi/bidiChromium.js +0 -152
  174. package/lib/server/bidi/bidiConnection.js +0 -187
  175. package/lib/server/bidi/bidiExecutionContext.js +0 -220
  176. package/lib/server/bidi/bidiFirefox.js +0 -112
  177. package/lib/server/bidi/bidiInput.js +0 -146
  178. package/lib/server/bidi/bidiNetworkManager.js +0 -320
  179. package/lib/server/bidi/bidiOverCdp.js +0 -102
  180. package/lib/server/bidi/bidiPage.js +0 -530
  181. package/lib/server/bidi/bidiPdf.js +0 -106
  182. package/lib/server/bidi/third_party/bidiCommands.d.js +0 -22
  183. package/lib/server/bidi/third_party/bidiDeserializer.js +0 -98
  184. package/lib/server/bidi/third_party/bidiKeyboard.js +0 -256
  185. package/lib/server/bidi/third_party/bidiProtocol.js +0 -152
  186. package/lib/server/bidi/third_party/bidiSerializer.js +0 -148
  187. package/lib/server/bidi/third_party/firefoxPrefs.js +0 -259
  188. package/lib/server/browser.js +0 -140
  189. package/lib/server/browserContext.js +0 -650
  190. package/lib/server/browserType.js +0 -326
  191. package/lib/server/callLog.js +0 -82
  192. package/lib/server/chromium/chromium.js +0 -376
  193. package/lib/server/chromium/chromiumSwitches.js +0 -101
  194. package/lib/server/chromium/crAccessibility.js +0 -263
  195. package/lib/server/chromium/crBrowser.js +0 -498
  196. package/lib/server/chromium/crConnection.js +0 -324
  197. package/lib/server/chromium/crCoverage.js +0 -232
  198. package/lib/server/chromium/crDevTools.js +0 -117
  199. package/lib/server/chromium/crDragDrop.js +0 -126
  200. package/lib/server/chromium/crExecutionContext.js +0 -145
  201. package/lib/server/chromium/crInput.js +0 -184
  202. package/lib/server/chromium/crNetworkManager.js +0 -666
  203. package/lib/server/chromium/crPage.js +0 -1055
  204. package/lib/server/chromium/crPdf.js +0 -121
  205. package/lib/server/chromium/crProtocolHelper.js +0 -145
  206. package/lib/server/chromium/crServiceWorker.js +0 -130
  207. package/lib/server/chromium/defaultFontFamilies.js +0 -162
  208. package/lib/server/chromium/protocol.d.js +0 -16
  209. package/lib/server/chromium/videoRecorder.js +0 -121
  210. package/lib/server/clock.js +0 -137
  211. package/lib/server/codegen/csharp.js +0 -329
  212. package/lib/server/codegen/java.js +0 -270
  213. package/lib/server/codegen/javascript.js +0 -268
  214. package/lib/server/codegen/jsonl.js +0 -51
  215. package/lib/server/codegen/language.js +0 -111
  216. package/lib/server/codegen/languages.js +0 -68
  217. package/lib/server/codegen/python.js +0 -277
  218. package/lib/server/codegen/types.js +0 -16
  219. package/lib/server/console.js +0 -53
  220. package/lib/server/cookieStore.js +0 -204
  221. package/lib/server/debugController.js +0 -185
  222. package/lib/server/debugger.js +0 -136
  223. package/lib/server/deviceDescriptorsSource.json +0 -1669
  224. package/lib/server/dialog.js +0 -72
  225. package/lib/server/dispatchers/androidDispatcher.js +0 -293
  226. package/lib/server/dispatchers/artifactDispatcher.js +0 -118
  227. package/lib/server/dispatchers/browserContextDispatcher.js +0 -328
  228. package/lib/server/dispatchers/browserDispatcher.js +0 -151
  229. package/lib/server/dispatchers/browserTypeDispatcher.js +0 -55
  230. package/lib/server/dispatchers/cdpSessionDispatcher.js +0 -44
  231. package/lib/server/dispatchers/debugControllerDispatcher.js +0 -87
  232. package/lib/server/dispatchers/dialogDispatcher.js +0 -47
  233. package/lib/server/dispatchers/dispatcher.js +0 -346
  234. package/lib/server/dispatchers/electronDispatcher.js +0 -90
  235. package/lib/server/dispatchers/elementHandlerDispatcher.js +0 -191
  236. package/lib/server/dispatchers/frameDispatcher.js +0 -224
  237. package/lib/server/dispatchers/jsHandleDispatcher.js +0 -80
  238. package/lib/server/dispatchers/jsonPipeDispatcher.js +0 -58
  239. package/lib/server/dispatchers/localUtilsDispatcher.js +0 -155
  240. package/lib/server/dispatchers/networkDispatchers.js +0 -204
  241. package/lib/server/dispatchers/pageDispatcher.js +0 -328
  242. package/lib/server/dispatchers/playwrightDispatcher.js +0 -100
  243. package/lib/server/dispatchers/selectorsDispatcher.js +0 -40
  244. package/lib/server/dispatchers/streamDispatcher.js +0 -60
  245. package/lib/server/dispatchers/tracingDispatcher.js +0 -59
  246. package/lib/server/dispatchers/webSocketRouteDispatcher.js +0 -154
  247. package/lib/server/dispatchers/writableStreamDispatcher.js +0 -73
  248. package/lib/server/dom.js +0 -869
  249. package/lib/server/download.js +0 -70
  250. package/lib/server/electron/electron.js +0 -277
  251. package/lib/server/errors.js +0 -69
  252. package/lib/server/fetch.js +0 -640
  253. package/lib/server/fileChooser.js +0 -43
  254. package/lib/server/fileUploadUtils.js +0 -84
  255. package/lib/server/firefox/ffAccessibility.js +0 -238
  256. package/lib/server/firefox/ffBrowser.js +0 -404
  257. package/lib/server/firefox/ffConnection.js +0 -147
  258. package/lib/server/firefox/ffExecutionContext.js +0 -149
  259. package/lib/server/firefox/ffInput.js +0 -159
  260. package/lib/server/firefox/ffNetworkManager.js +0 -254
  261. package/lib/server/firefox/ffPage.js +0 -501
  262. package/lib/server/firefox/firefox.js +0 -106
  263. package/lib/server/firefox/protocol.d.js +0 -16
  264. package/lib/server/formData.js +0 -147
  265. package/lib/server/frameSelectors.js +0 -137
  266. package/lib/server/frames.js +0 -1555
  267. package/lib/server/har/harRecorder.js +0 -147
  268. package/lib/server/har/harTracer.js +0 -606
  269. package/lib/server/harBackend.js +0 -157
  270. package/lib/server/helper.js +0 -100
  271. package/lib/server/index.js +0 -61
  272. package/lib/server/input.js +0 -280
  273. package/lib/server/instrumentation.js +0 -75
  274. package/lib/server/javascript.js +0 -299
  275. package/lib/server/launchApp.js +0 -110
  276. package/lib/server/localUtils.js +0 -211
  277. package/lib/server/macEditingCommands.js +0 -143
  278. package/lib/server/network.js +0 -583
  279. package/lib/server/page.js +0 -790
  280. package/lib/server/pageBinding.js +0 -88
  281. package/lib/server/pipeTransport.js +0 -89
  282. package/lib/server/playwright.js +0 -81
  283. package/lib/server/progress.js +0 -104
  284. package/lib/server/protocolError.js +0 -52
  285. package/lib/server/recorder/chat.js +0 -161
  286. package/lib/server/recorder/contextRecorder.js +0 -286
  287. package/lib/server/recorder/recorderApp.js +0 -184
  288. package/lib/server/recorder/recorderCollection.js +0 -116
  289. package/lib/server/recorder/recorderFrontend.js +0 -16
  290. package/lib/server/recorder/recorderRunner.js +0 -135
  291. package/lib/server/recorder/recorderUtils.js +0 -100
  292. package/lib/server/recorder/throttledFile.js +0 -57
  293. package/lib/server/recorder.js +0 -360
  294. package/lib/server/registry/browserFetcher.js +0 -175
  295. package/lib/server/registry/dependencies.js +0 -371
  296. package/lib/server/registry/index.js +0 -1271
  297. package/lib/server/registry/nativeDeps.js +0 -1105
  298. package/lib/server/registry/oopDownloadBrowserMain.js +0 -120
  299. package/lib/server/screenshotter.js +0 -332
  300. package/lib/server/selectors.js +0 -112
  301. package/lib/server/socksClientCertificatesInterceptor.js +0 -321
  302. package/lib/server/socksInterceptor.js +0 -95
  303. package/lib/server/storageScript.js +0 -154
  304. package/lib/server/timeoutSettings.js +0 -89
  305. package/lib/server/trace/recorder/snapshotter.js +0 -143
  306. package/lib/server/trace/recorder/snapshotterInjected.js +0 -539
  307. package/lib/server/trace/recorder/tracing.js +0 -593
  308. package/lib/server/trace/test/inMemorySnapshotter.js +0 -87
  309. package/lib/server/trace/viewer/traceViewer.js +0 -249
  310. package/lib/server/transport.js +0 -183
  311. package/lib/server/types.js +0 -28
  312. package/lib/server/usKeyboardLayout.js +0 -145
  313. package/lib/server/utils/ascii.js +0 -44
  314. package/lib/server/utils/comparators.js +0 -161
  315. package/lib/server/utils/crypto.js +0 -216
  316. package/lib/server/utils/debug.js +0 -47
  317. package/lib/server/utils/debugLogger.js +0 -114
  318. package/lib/server/utils/env.js +0 -68
  319. package/lib/server/utils/eventsHelper.js +0 -39
  320. package/lib/server/utils/expectUtils.js +0 -38
  321. package/lib/server/utils/fileUtils.js +0 -191
  322. package/lib/server/utils/happyEyeballs.js +0 -207
  323. package/lib/server/utils/hostPlatform.js +0 -109
  324. package/lib/server/utils/httpServer.js +0 -218
  325. package/lib/server/utils/image_tools/colorUtils.js +0 -89
  326. package/lib/server/utils/image_tools/compare.js +0 -109
  327. package/lib/server/utils/image_tools/imageChannel.js +0 -78
  328. package/lib/server/utils/image_tools/stats.js +0 -102
  329. package/lib/server/utils/linuxUtils.js +0 -71
  330. package/lib/server/utils/network.js +0 -217
  331. package/lib/server/utils/nodePlatform.js +0 -148
  332. package/lib/server/utils/pipeTransport.js +0 -84
  333. package/lib/server/utils/processLauncher.js +0 -238
  334. package/lib/server/utils/profiler.js +0 -65
  335. package/lib/server/utils/socksProxy.js +0 -511
  336. package/lib/server/utils/spawnAsync.js +0 -41
  337. package/lib/server/utils/task.js +0 -51
  338. package/lib/server/utils/userAgent.js +0 -98
  339. package/lib/server/utils/wsServer.js +0 -132
  340. package/lib/server/utils/zipFile.js +0 -74
  341. package/lib/server/utils/zones.js +0 -57
  342. package/lib/server/webkit/protocol.d.js +0 -16
  343. package/lib/server/webkit/webkit.js +0 -100
  344. package/lib/server/webkit/wkAccessibility.js +0 -237
  345. package/lib/server/webkit/wkBrowser.js +0 -312
  346. package/lib/server/webkit/wkConnection.js +0 -149
  347. package/lib/server/webkit/wkExecutionContext.js +0 -153
  348. package/lib/server/webkit/wkInput.js +0 -181
  349. package/lib/server/webkit/wkInterceptableRequest.js +0 -169
  350. package/lib/server/webkit/wkPage.js +0 -1114
  351. package/lib/server/webkit/wkProvisionalPage.js +0 -83
  352. package/lib/server/webkit/wkWorkers.js +0 -104
  353. package/lib/third_party/pixelmatch.js +0 -255
  354. package/lib/utils/isomorphic/ariaSnapshot.js +0 -384
  355. package/lib/utils/isomorphic/assert.js +0 -31
  356. package/lib/utils/isomorphic/builtins.js +0 -90
  357. package/lib/utils/isomorphic/colors.js +0 -72
  358. package/lib/utils/isomorphic/cssParser.js +0 -246
  359. package/lib/utils/isomorphic/cssTokenizer.js +0 -1051
  360. package/lib/utils/isomorphic/headers.js +0 -53
  361. package/lib/utils/isomorphic/locatorGenerators.js +0 -655
  362. package/lib/utils/isomorphic/locatorParser.js +0 -176
  363. package/lib/utils/isomorphic/locatorUtils.js +0 -81
  364. package/lib/utils/isomorphic/manualPromise.js +0 -115
  365. package/lib/utils/isomorphic/mimeType.js +0 -460
  366. package/lib/utils/isomorphic/multimap.js +0 -81
  367. package/lib/utils/isomorphic/rtti.js +0 -43
  368. package/lib/utils/isomorphic/selectorParser.js +0 -387
  369. package/lib/utils/isomorphic/semaphore.js +0 -54
  370. package/lib/utils/isomorphic/stackTrace.js +0 -158
  371. package/lib/utils/isomorphic/stringUtils.js +0 -176
  372. package/lib/utils/isomorphic/time.js +0 -44
  373. package/lib/utils/isomorphic/timeoutRunner.js +0 -67
  374. package/lib/utils/isomorphic/traceUtils.js +0 -59
  375. package/lib/utils/isomorphic/types.js +0 -16
  376. package/lib/utils/isomorphic/urlMatch.js +0 -167
  377. package/lib/utils/isomorphic/utilityScriptSerializers.js +0 -248
  378. package/lib/utils.js +0 -101
  379. package/lib/utilsBundleImpl/index.js +0 -208
  380. package/lib/vite/recorder/assets/codeMirrorModule-C3UTv-Ge.css +0 -1
  381. package/lib/vite/recorder/assets/codeMirrorModule-DVQi6prl.js +0 -24
  382. package/lib/vite/recorder/assets/index-97EUAAbk.js +0 -184
  383. package/lib/vite/recorder/assets/index-eHBmevrY.css +0 -1
  384. package/lib/vite/traceViewer/assets/codeMirrorModule-DwAiTpyC.js +0 -24
  385. package/lib/vite/traceViewer/assets/defaultSettingsView-DkkRvn5X.js +0 -265
  386. package/lib/vite/traceViewer/assets/xtermModule-BoAIEibi.js +0 -9
  387. package/lib/vite/traceViewer/codeMirrorModule.C3UTv-Ge.css +0 -1
  388. package/lib/vite/traceViewer/defaultSettingsView.QdHITyLI.css +0 -1
  389. package/lib/vite/traceViewer/index.CFOW-Ezb.css +0 -1
  390. package/lib/vite/traceViewer/index.DvtSwn6E.js +0 -2
  391. package/lib/vite/traceViewer/uiMode.BatfzHMG.css +0 -1
  392. package/lib/vite/traceViewer/uiMode.Sdytl9wc.js +0 -5
  393. package/lib/vite/traceViewer/xtermModule.Beg8tuEN.css +0 -32
  394. package/lib/zipBundle.js +0 -34
  395. package/lib/zipBundleImpl.js +0 -5
@@ -1,1555 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var frames_exports = {};
30
- __export(frames_exports, {
31
- Frame: () => Frame,
32
- FrameManager: () => FrameManager,
33
- NavigationAbortedError: () => NavigationAbortedError
34
- });
35
- module.exports = __toCommonJS(frames_exports);
36
- var import_browserContext = require("./browserContext");
37
- var dom = __toESM(require("./dom"));
38
- var import_errors = require("./errors");
39
- var import_fileUploadUtils = require("./fileUploadUtils");
40
- var import_frameSelectors = require("./frameSelectors");
41
- var import_helper = require("./helper");
42
- var import_instrumentation = require("./instrumentation");
43
- var js = __toESM(require("./javascript"));
44
- var network = __toESM(require("./network"));
45
- var import_page = require("./page");
46
- var import_progress = require("./progress");
47
- var types = __toESM(require("./types"));
48
- var import_utils = require("../utils");
49
- var import_protocolError = require("./protocolError");
50
- var import_debugLogger = require("./utils/debugLogger");
51
- var import_eventsHelper = require("./utils/eventsHelper");
52
- var import_selectorParser = require("../utils/isomorphic/selectorParser");
53
- var import_manualPromise = require("../utils/isomorphic/manualPromise");
54
- var import_callLog = require("./callLog");
55
- class NavigationAbortedError extends Error {
56
- constructor(documentId, message) {
57
- super(message);
58
- this.documentId = documentId;
59
- }
60
- }
61
- const kDummyFrameId = "<dummy>";
62
- class FrameManager {
63
- constructor(page) {
64
- this._frames = /* @__PURE__ */ new Map();
65
- this._consoleMessageTags = /* @__PURE__ */ new Map();
66
- this._signalBarriers = /* @__PURE__ */ new Set();
67
- this._webSockets = /* @__PURE__ */ new Map();
68
- this._openedDialogs = /* @__PURE__ */ new Set();
69
- this._closeAllOpeningDialogs = false;
70
- this._page = page;
71
- this._mainFrame = void 0;
72
- }
73
- createDummyMainFrameIfNeeded() {
74
- if (!this._mainFrame)
75
- this.frameAttached(kDummyFrameId, null);
76
- }
77
- dispose() {
78
- for (const frame of this._frames.values()) {
79
- frame._stopNetworkIdleTimer();
80
- frame._invalidateNonStallingEvaluations("Target crashed");
81
- }
82
- }
83
- mainFrame() {
84
- return this._mainFrame;
85
- }
86
- frames() {
87
- const frames = [];
88
- collect(this._mainFrame);
89
- return frames;
90
- function collect(frame) {
91
- frames.push(frame);
92
- for (const subframe of frame.childFrames())
93
- collect(subframe);
94
- }
95
- }
96
- frame(frameId) {
97
- return this._frames.get(frameId) || null;
98
- }
99
- frameAttached(frameId, parentFrameId) {
100
- const parentFrame = parentFrameId ? this._frames.get(parentFrameId) : null;
101
- if (!parentFrame) {
102
- if (this._mainFrame) {
103
- this._frames.delete(this._mainFrame._id);
104
- this._mainFrame._id = frameId;
105
- } else {
106
- (0, import_utils.assert)(!this._frames.has(frameId));
107
- this._mainFrame = new Frame(this._page, frameId, parentFrame);
108
- }
109
- this._frames.set(frameId, this._mainFrame);
110
- return this._mainFrame;
111
- } else {
112
- (0, import_utils.assert)(!this._frames.has(frameId));
113
- const frame = new Frame(this._page, frameId, parentFrame);
114
- this._frames.set(frameId, frame);
115
- this._page.emit(import_page.Page.Events.FrameAttached, frame);
116
- return frame;
117
- }
118
- }
119
- async waitForSignalsCreatedBy(progress, waitAfter, action) {
120
- if (!waitAfter)
121
- return action();
122
- const barrier = new SignalBarrier(progress);
123
- this._signalBarriers.add(barrier);
124
- if (progress)
125
- progress.cleanupWhenAborted(() => this._signalBarriers.delete(barrier));
126
- const result = await action();
127
- await this._page._delegate.inputActionEpilogue();
128
- await barrier.waitFor();
129
- this._signalBarriers.delete(barrier);
130
- await new Promise((0, import_utils.makeWaitForNextTask)());
131
- return result;
132
- }
133
- frameWillPotentiallyRequestNavigation() {
134
- for (const barrier of this._signalBarriers)
135
- barrier.retain();
136
- }
137
- frameDidPotentiallyRequestNavigation() {
138
- for (const barrier of this._signalBarriers)
139
- barrier.release();
140
- }
141
- frameRequestedNavigation(frameId, documentId) {
142
- const frame = this._frames.get(frameId);
143
- if (!frame)
144
- return;
145
- for (const barrier of this._signalBarriers)
146
- barrier.addFrameNavigation(frame);
147
- if (frame.pendingDocument() && frame.pendingDocument().documentId === documentId) {
148
- return;
149
- }
150
- const request = documentId ? Array.from(frame._inflightRequests).find((request2) => request2._documentId === documentId) : void 0;
151
- frame.setPendingDocument({ documentId, request });
152
- }
153
- frameCommittedNewDocumentNavigation(frameId, url, name, documentId, initial) {
154
- const frame = this._frames.get(frameId);
155
- this.removeChildFramesRecursively(frame);
156
- this.clearWebSockets(frame);
157
- frame._url = url;
158
- frame._name = name;
159
- let keepPending;
160
- const pendingDocument = frame.pendingDocument();
161
- if (pendingDocument) {
162
- if (pendingDocument.documentId === void 0) {
163
- pendingDocument.documentId = documentId;
164
- }
165
- if (pendingDocument.documentId === documentId) {
166
- frame._currentDocument = pendingDocument;
167
- } else {
168
- keepPending = pendingDocument;
169
- frame._currentDocument = { documentId, request: void 0 };
170
- }
171
- frame.setPendingDocument(void 0);
172
- } else {
173
- frame._currentDocument = { documentId, request: void 0 };
174
- }
175
- frame._onClearLifecycle();
176
- const navigationEvent = { url, name, newDocument: frame._currentDocument, isPublic: true };
177
- this._fireInternalFrameNavigation(frame, navigationEvent);
178
- if (!initial) {
179
- import_debugLogger.debugLogger.log("api", ` navigated to "${url}"`);
180
- this._page.frameNavigatedToNewDocument(frame);
181
- }
182
- frame.setPendingDocument(keepPending);
183
- }
184
- frameCommittedSameDocumentNavigation(frameId, url) {
185
- const frame = this._frames.get(frameId);
186
- if (!frame)
187
- return;
188
- const pending = frame.pendingDocument();
189
- if (pending && pending.documentId === void 0 && pending.request === void 0) {
190
- frame.setPendingDocument(void 0);
191
- }
192
- frame._url = url;
193
- const navigationEvent = { url, name: frame._name, isPublic: true };
194
- this._fireInternalFrameNavigation(frame, navigationEvent);
195
- import_debugLogger.debugLogger.log("api", ` navigated to "${url}"`);
196
- }
197
- frameAbortedNavigation(frameId, errorText, documentId) {
198
- const frame = this._frames.get(frameId);
199
- if (!frame || !frame.pendingDocument())
200
- return;
201
- if (documentId !== void 0 && frame.pendingDocument().documentId !== documentId)
202
- return;
203
- const navigationEvent = {
204
- url: frame._url,
205
- name: frame._name,
206
- newDocument: frame.pendingDocument(),
207
- error: new NavigationAbortedError(documentId, errorText),
208
- isPublic: !(documentId && frame._redirectedNavigations.has(documentId))
209
- };
210
- frame.setPendingDocument(void 0);
211
- this._fireInternalFrameNavigation(frame, navigationEvent);
212
- }
213
- frameDetached(frameId) {
214
- const frame = this._frames.get(frameId);
215
- if (frame) {
216
- this._removeFramesRecursively(frame);
217
- this._page.mainFrame()._recalculateNetworkIdle();
218
- }
219
- }
220
- frameLifecycleEvent(frameId, event) {
221
- const frame = this._frames.get(frameId);
222
- if (frame)
223
- frame._onLifecycleEvent(event);
224
- }
225
- requestStarted(request, route) {
226
- const frame = request.frame();
227
- this._inflightRequestStarted(request);
228
- if (request._documentId)
229
- frame.setPendingDocument({ documentId: request._documentId, request });
230
- if (request._isFavicon) {
231
- route?.abort("aborted").catch(() => {
232
- });
233
- return;
234
- }
235
- this._page.emitOnContext(import_browserContext.BrowserContext.Events.Request, request);
236
- if (route) {
237
- const r = new network.Route(request, route);
238
- if (this._page._serverRequestInterceptor?.(r, request))
239
- return;
240
- if (this._page._clientRequestInterceptor?.(r, request))
241
- return;
242
- if (this._page._browserContext._requestInterceptor?.(r, request))
243
- return;
244
- r.continue({ isFallback: true }).catch(() => {
245
- });
246
- }
247
- }
248
- requestReceivedResponse(response) {
249
- if (response.request()._isFavicon)
250
- return;
251
- this._page.emitOnContext(import_browserContext.BrowserContext.Events.Response, response);
252
- }
253
- reportRequestFinished(request, response) {
254
- this._inflightRequestFinished(request);
255
- if (request._isFavicon)
256
- return;
257
- this._page.emitOnContext(import_browserContext.BrowserContext.Events.RequestFinished, { request, response });
258
- }
259
- requestFailed(request, canceled) {
260
- const frame = request.frame();
261
- this._inflightRequestFinished(request);
262
- if (frame.pendingDocument() && frame.pendingDocument().request === request) {
263
- let errorText = request.failure().errorText;
264
- if (canceled)
265
- errorText += "; maybe frame was detached?";
266
- this.frameAbortedNavigation(frame._id, errorText, frame.pendingDocument().documentId);
267
- }
268
- if (request._isFavicon)
269
- return;
270
- this._page.emitOnContext(import_browserContext.BrowserContext.Events.RequestFailed, request);
271
- }
272
- dialogDidOpen(dialog) {
273
- for (const frame of this._frames.values())
274
- frame._invalidateNonStallingEvaluations("JavaScript dialog interrupted evaluation");
275
- if (this._closeAllOpeningDialogs)
276
- dialog.close().then(() => {
277
- });
278
- else
279
- this._openedDialogs.add(dialog);
280
- }
281
- dialogWillClose(dialog) {
282
- this._openedDialogs.delete(dialog);
283
- }
284
- async closeOpenDialogs() {
285
- await Promise.all([...this._openedDialogs].map((dialog) => dialog.close())).catch(() => {
286
- });
287
- this._openedDialogs.clear();
288
- }
289
- setCloseAllOpeningDialogs(closeDialogs) {
290
- this._closeAllOpeningDialogs = closeDialogs;
291
- }
292
- removeChildFramesRecursively(frame) {
293
- for (const child of frame.childFrames())
294
- this._removeFramesRecursively(child);
295
- }
296
- _removeFramesRecursively(frame) {
297
- this.removeChildFramesRecursively(frame);
298
- frame._onDetached();
299
- this._frames.delete(frame._id);
300
- if (!this._page.isClosed())
301
- this._page.emit(import_page.Page.Events.FrameDetached, frame);
302
- }
303
- _inflightRequestFinished(request) {
304
- const frame = request.frame();
305
- if (request._isFavicon)
306
- return;
307
- if (!frame._inflightRequests.has(request))
308
- return;
309
- frame._inflightRequests.delete(request);
310
- if (frame._inflightRequests.size === 0)
311
- frame._startNetworkIdleTimer();
312
- }
313
- _inflightRequestStarted(request) {
314
- const frame = request.frame();
315
- if (request._isFavicon)
316
- return;
317
- frame._inflightRequests.add(request);
318
- if (frame._inflightRequests.size === 1)
319
- frame._stopNetworkIdleTimer();
320
- }
321
- interceptConsoleMessage(message) {
322
- if (message.type() !== "debug")
323
- return false;
324
- const tag = message.text();
325
- const handler = this._consoleMessageTags.get(tag);
326
- if (!handler)
327
- return false;
328
- this._consoleMessageTags.delete(tag);
329
- handler();
330
- return true;
331
- }
332
- clearWebSockets(frame) {
333
- if (frame.parentFrame())
334
- return;
335
- this._webSockets.clear();
336
- }
337
- onWebSocketCreated(requestId, url) {
338
- const ws = new network.WebSocket(this._page, url);
339
- this._webSockets.set(requestId, ws);
340
- }
341
- onWebSocketRequest(requestId) {
342
- const ws = this._webSockets.get(requestId);
343
- if (ws && ws.markAsNotified())
344
- this._page.emit(import_page.Page.Events.WebSocket, ws);
345
- }
346
- onWebSocketResponse(requestId, status, statusText) {
347
- const ws = this._webSockets.get(requestId);
348
- if (status < 400)
349
- return;
350
- if (ws)
351
- ws.error(`${statusText}: ${status}`);
352
- }
353
- onWebSocketFrameSent(requestId, opcode, data) {
354
- const ws = this._webSockets.get(requestId);
355
- if (ws)
356
- ws.frameSent(opcode, data);
357
- }
358
- webSocketFrameReceived(requestId, opcode, data) {
359
- const ws = this._webSockets.get(requestId);
360
- if (ws)
361
- ws.frameReceived(opcode, data);
362
- }
363
- webSocketClosed(requestId) {
364
- const ws = this._webSockets.get(requestId);
365
- if (ws)
366
- ws.closed();
367
- this._webSockets.delete(requestId);
368
- }
369
- webSocketError(requestId, errorMessage) {
370
- const ws = this._webSockets.get(requestId);
371
- if (ws)
372
- ws.error(errorMessage);
373
- }
374
- _fireInternalFrameNavigation(frame, event) {
375
- frame.emit(Frame.Events.InternalNavigation, event);
376
- }
377
- }
378
- class Frame extends import_instrumentation.SdkObject {
379
- constructor(page, id, parentFrame) {
380
- super(page, "frame");
381
- this._firedLifecycleEvents = /* @__PURE__ */ new Set();
382
- this._firedNetworkIdleSelf = false;
383
- this._url = "";
384
- this._contextData = /* @__PURE__ */ new Map();
385
- this._childFrames = /* @__PURE__ */ new Set();
386
- this._name = "";
387
- this._inflightRequests = /* @__PURE__ */ new Set();
388
- this._setContentCounter = 0;
389
- this._detachedScope = new import_utils.LongStandingScope();
390
- this._raceAgainstEvaluationStallingEventsPromises = /* @__PURE__ */ new Set();
391
- this._redirectedNavigations = /* @__PURE__ */ new Map();
392
- this.attribution.frame = this;
393
- this._id = id;
394
- this._page = page;
395
- this._parentFrame = parentFrame;
396
- this._currentDocument = { documentId: void 0, request: void 0 };
397
- this.selectors = new import_frameSelectors.FrameSelectors(this);
398
- this._contextData.set("main", { contextPromise: new import_manualPromise.ManualPromise(), context: null });
399
- this._contextData.set("utility", { contextPromise: new import_manualPromise.ManualPromise(), context: null });
400
- this._setContext("main", null);
401
- this._setContext("utility", null);
402
- if (this._parentFrame)
403
- this._parentFrame._childFrames.add(this);
404
- this._firedLifecycleEvents.add("commit");
405
- if (id !== kDummyFrameId)
406
- this._startNetworkIdleTimer();
407
- }
408
- static {
409
- this.Events = {
410
- InternalNavigation: "internalnavigation",
411
- AddLifecycle: "addlifecycle",
412
- RemoveLifecycle: "removelifecycle"
413
- };
414
- }
415
- isDetached() {
416
- return this._detachedScope.isClosed();
417
- }
418
- _onLifecycleEvent(event) {
419
- if (this._firedLifecycleEvents.has(event))
420
- return;
421
- this._firedLifecycleEvents.add(event);
422
- this.emit(Frame.Events.AddLifecycle, event);
423
- if (this === this._page.mainFrame() && this._url !== "about:blank")
424
- import_debugLogger.debugLogger.log("api", ` "${event}" event fired`);
425
- this._page.mainFrame()._recalculateNetworkIdle();
426
- }
427
- _onClearLifecycle() {
428
- for (const event of this._firedLifecycleEvents)
429
- this.emit(Frame.Events.RemoveLifecycle, event);
430
- this._firedLifecycleEvents.clear();
431
- this._inflightRequests = new Set(Array.from(this._inflightRequests).filter((request) => request === this._currentDocument.request));
432
- this._stopNetworkIdleTimer();
433
- if (this._inflightRequests.size === 0)
434
- this._startNetworkIdleTimer();
435
- this._page.mainFrame()._recalculateNetworkIdle(this);
436
- this._onLifecycleEvent("commit");
437
- const crSession = (this._page._delegate._sessions.get(this._id) || this._page._delegate._mainFrameSession)._client;
438
- crSession.emit("Runtime.executionContextsCleared");
439
- }
440
- setPendingDocument(documentInfo) {
441
- this._pendingDocument = documentInfo;
442
- if (documentInfo)
443
- this._invalidateNonStallingEvaluations("Navigation interrupted the evaluation");
444
- }
445
- pendingDocument() {
446
- return this._pendingDocument;
447
- }
448
- _invalidateNonStallingEvaluations(message) {
449
- if (!this._raceAgainstEvaluationStallingEventsPromises.size)
450
- return;
451
- const error = new Error(message);
452
- for (const promise of this._raceAgainstEvaluationStallingEventsPromises)
453
- promise.reject(error);
454
- }
455
- async raceAgainstEvaluationStallingEvents(cb) {
456
- if (this._pendingDocument)
457
- throw new Error("Frame is currently attempting a navigation");
458
- if (this._page._frameManager._openedDialogs.size)
459
- throw new Error("Open JavaScript dialog prevents evaluation");
460
- const promise = new import_manualPromise.ManualPromise();
461
- this._raceAgainstEvaluationStallingEventsPromises.add(promise);
462
- try {
463
- return await Promise.race([
464
- cb(),
465
- promise
466
- ]);
467
- } finally {
468
- this._raceAgainstEvaluationStallingEventsPromises.delete(promise);
469
- }
470
- }
471
- nonStallingRawEvaluateInExistingMainContext(expression) {
472
- return this.raceAgainstEvaluationStallingEvents(() => {
473
- const context = this._existingMainContext();
474
- if (!context)
475
- throw new Error("Frame does not yet have a main execution context");
476
- return context.rawEvaluateJSON(expression);
477
- });
478
- }
479
- nonStallingEvaluateInExistingContext(expression, world) {
480
- return this.raceAgainstEvaluationStallingEvents(() => {
481
- const context = this._contextData.get(world)?.context;
482
- if (!context)
483
- throw new Error("Frame does not yet have the execution context");
484
- return context.evaluateExpression(expression, { isFunction: false });
485
- });
486
- }
487
- _recalculateNetworkIdle(frameThatAllowsRemovingNetworkIdle) {
488
- let isNetworkIdle = this._firedNetworkIdleSelf;
489
- for (const child of this._childFrames) {
490
- child._recalculateNetworkIdle(frameThatAllowsRemovingNetworkIdle);
491
- if (!child._firedLifecycleEvents.has("networkidle"))
492
- isNetworkIdle = false;
493
- }
494
- if (isNetworkIdle && !this._firedLifecycleEvents.has("networkidle")) {
495
- this._firedLifecycleEvents.add("networkidle");
496
- this.emit(Frame.Events.AddLifecycle, "networkidle");
497
- if (this === this._page.mainFrame() && this._url !== "about:blank")
498
- import_debugLogger.debugLogger.log("api", ` "networkidle" event fired`);
499
- }
500
- if (frameThatAllowsRemovingNetworkIdle !== this && this._firedLifecycleEvents.has("networkidle") && !isNetworkIdle) {
501
- this._firedLifecycleEvents.delete("networkidle");
502
- this.emit(Frame.Events.RemoveLifecycle, "networkidle");
503
- }
504
- }
505
- async raceNavigationAction(progress, options, action) {
506
- return import_utils.LongStandingScope.raceMultiple([
507
- this._detachedScope,
508
- this._page.openScope
509
- ], action().catch((e) => {
510
- if (e instanceof NavigationAbortedError && e.documentId) {
511
- const data = this._redirectedNavigations.get(e.documentId);
512
- if (data) {
513
- progress.log(`waiting for redirected navigation to "${data.url}"`);
514
- return data.gotoPromise;
515
- }
516
- }
517
- throw e;
518
- }));
519
- }
520
- redirectNavigation(url, documentId, referer) {
521
- const controller = new import_progress.ProgressController((0, import_instrumentation.serverSideCallMetadata)(), this);
522
- const data = {
523
- url,
524
- gotoPromise: controller.run((progress) => this._gotoAction(progress, url, { referer }), 0)
525
- };
526
- this._redirectedNavigations.set(documentId, data);
527
- data.gotoPromise.finally(() => this._redirectedNavigations.delete(documentId));
528
- }
529
- async goto(metadata, url, options = {}) {
530
- const constructedNavigationURL = (0, import_utils.constructURLBasedOnBaseURL)(this._page._browserContext._options.baseURL, url);
531
- const controller = new import_progress.ProgressController(metadata, this);
532
- return controller.run((progress) => this._goto(progress, constructedNavigationURL, options), this._page._timeoutSettings.navigationTimeout(options));
533
- }
534
- async _goto(progress, url, options) {
535
- return this.raceNavigationAction(progress, options, async () => this._gotoAction(progress, url, options));
536
- }
537
- async _gotoAction(progress, url, options) {
538
- const waitUntil = verifyLifecycle("waitUntil", options.waitUntil === void 0 ? "load" : options.waitUntil);
539
- progress.log(`navigating to "${url}", waiting until "${waitUntil}"`);
540
- const headers = this._page.extraHTTPHeaders() || [];
541
- const refererHeader = headers.find((h) => h.name.toLowerCase() === "referer");
542
- let referer = refererHeader ? refererHeader.value : void 0;
543
- if (options.referer !== void 0) {
544
- if (referer !== void 0 && referer !== options.referer)
545
- throw new Error('"referer" is already specified as extra HTTP header');
546
- referer = options.referer;
547
- }
548
- url = import_helper.helper.completeUserURL(url);
549
- const navigationEvents = [];
550
- const collectNavigations = (arg) => navigationEvents.push(arg);
551
- this.on(Frame.Events.InternalNavigation, collectNavigations);
552
- const navigateResult = await this._page._delegate.navigateFrame(this, url, referer).finally(
553
- () => this.off(Frame.Events.InternalNavigation, collectNavigations)
554
- );
555
- let event;
556
- if (navigateResult.newDocumentId) {
557
- const predicate = (event2) => {
558
- return event2.newDocument && (event2.newDocument.documentId === navigateResult.newDocumentId || !event2.error);
559
- };
560
- const events = navigationEvents.filter(predicate);
561
- if (events.length)
562
- event = events[0];
563
- else
564
- event = await import_helper.helper.waitForEvent(progress, this, Frame.Events.InternalNavigation, predicate).promise;
565
- if (event.newDocument.documentId !== navigateResult.newDocumentId) {
566
- throw new NavigationAbortedError(navigateResult.newDocumentId, `Navigation to "${url}" is interrupted by another navigation to "${event.url}"`);
567
- }
568
- if (event.error)
569
- throw event.error;
570
- } else {
571
- const predicate = (e) => !e.newDocument;
572
- const events = navigationEvents.filter(predicate);
573
- if (events.length)
574
- event = events[0];
575
- else
576
- event = await import_helper.helper.waitForEvent(progress, this, Frame.Events.InternalNavigation, predicate).promise;
577
- }
578
- if (!this._firedLifecycleEvents.has(waitUntil))
579
- await import_helper.helper.waitForEvent(progress, this, Frame.Events.AddLifecycle, (e) => e === waitUntil).promise;
580
- const request = event.newDocument ? event.newDocument.request : void 0;
581
- const response = request ? request._finalRequest().response() : null;
582
- return response;
583
- }
584
- async _waitForNavigation(progress, requiresNewDocument, options) {
585
- const waitUntil = verifyLifecycle("waitUntil", options.waitUntil === void 0 ? "load" : options.waitUntil);
586
- progress.log(`waiting for navigation until "${waitUntil}"`);
587
- const navigationEvent = await import_helper.helper.waitForEvent(progress, this, Frame.Events.InternalNavigation, (event) => {
588
- if (event.error)
589
- return true;
590
- if (requiresNewDocument && !event.newDocument)
591
- return false;
592
- progress.log(` navigated to "${this._url}"`);
593
- return true;
594
- }).promise;
595
- if (navigationEvent.error)
596
- throw navigationEvent.error;
597
- if (!this._firedLifecycleEvents.has(waitUntil))
598
- await import_helper.helper.waitForEvent(progress, this, Frame.Events.AddLifecycle, (e) => e === waitUntil).promise;
599
- const request = navigationEvent.newDocument ? navigationEvent.newDocument.request : void 0;
600
- return request ? request._finalRequest().response() : null;
601
- }
602
- async _waitForLoadState(progress, state) {
603
- const waitUntil = verifyLifecycle("state", state);
604
- if (!this._firedLifecycleEvents.has(waitUntil))
605
- await import_helper.helper.waitForEvent(progress, this, Frame.Events.AddLifecycle, (e) => e === waitUntil).promise;
606
- }
607
- async frameElement() {
608
- return this._page._delegate.getFrameElement(this);
609
- }
610
- _context(world, useContextPromise = false) {
611
- if (process.env["REBROWSER_PATCHES_RUNTIME_FIX_MODE"] === "0" || this._contextData.get(world).context || useContextPromise) {
612
- return this._contextData.get(world).contextPromise.then((contextOrDestroyedReason) => {
613
- if (contextOrDestroyedReason instanceof js.ExecutionContext)
614
- return contextOrDestroyedReason;
615
- throw new Error(contextOrDestroyedReason.destroyedReason);
616
- });
617
- }
618
- const crSession = (this._page._delegate._sessions.get(this._id) || this._page._delegate._mainFrameSession)._client;
619
- return crSession.__re__emitExecutionContext({
620
- world,
621
- targetId: this._id,
622
- frame: this
623
- }).then(() => {
624
- return this._context(world, true);
625
- }).catch((error) => {
626
- if (error.message.includes("No frame for given id found")) {
627
- return {
628
- destroyedReason: "Frame was detached"
629
- };
630
- }
631
- import_debugLogger.debugLogger.log("error", error);
632
- console.error("[rebrowser-patches][frames._context] cannot get world, error:", error);
633
- });
634
- }
635
- _mainContext() {
636
- return this._context("main");
637
- }
638
- _existingMainContext() {
639
- return this._contextData.get("main")?.context || null;
640
- }
641
- _utilityContext() {
642
- return this._context("utility");
643
- }
644
- async evaluateExpression(expression, options = {}, arg) {
645
- const context = await this._context(options.world ?? "main");
646
- const value = await context.evaluateExpression(expression, options, arg);
647
- return value;
648
- }
649
- async evaluateExpressionHandle(expression, options = {}, arg) {
650
- const context = await this._context(options.world ?? "main");
651
- const value = await context.evaluateExpressionHandle(expression, options, arg);
652
- return value;
653
- }
654
- async querySelector(selector, options) {
655
- import_debugLogger.debugLogger.log("api", ` finding element using the selector "${selector}"`);
656
- return this.selectors.query(selector, options);
657
- }
658
- async waitForSelector(metadata, selector, options, scope) {
659
- const controller = new import_progress.ProgressController(metadata, this);
660
- if (options.visibility)
661
- throw new Error("options.visibility is not supported, did you mean options.state?");
662
- if (options.waitFor && options.waitFor !== "visible")
663
- throw new Error("options.waitFor is not supported, did you mean options.state?");
664
- const { state = "visible" } = options;
665
- if (!["attached", "detached", "visible", "hidden"].includes(state))
666
- throw new Error(`state: expected one of (attached|detached|visible|hidden)`);
667
- return controller.run(async (progress) => {
668
- progress.log(`waiting for ${this._asLocator(selector)}${state === "attached" ? "" : " to be " + state}`);
669
- return await this.waitForSelectorInternal(progress, selector, true, options, scope);
670
- }, this._page._timeoutSettings.timeout(options));
671
- }
672
- async waitForSelectorInternal(progress, selector, performActionPreChecks, options, scope) {
673
- const { state = "visible" } = options;
674
- const promise = this.retryWithProgressAndTimeouts(progress, [0, 20, 50, 100, 100, 500], async (continuePolling) => {
675
- if (performActionPreChecks)
676
- await this._page.performActionPreChecks(progress);
677
- const resolved = await this.selectors.resolveInjectedForSelector(selector, options, scope);
678
- progress.throwIfAborted();
679
- if (!resolved) {
680
- if (state === "hidden" || state === "detached")
681
- return null;
682
- return continuePolling;
683
- }
684
- const result = await resolved.injected.evaluateHandle((injected, { info, root }) => {
685
- if (root && !root.isConnected)
686
- throw injected.createStacklessError("Element is not attached to the DOM");
687
- const elements = injected.querySelectorAll(info.parsed, root || document);
688
- const element2 = elements[0];
689
- const visible2 = element2 ? injected.utils.isElementVisible(element2) : false;
690
- let log2 = "";
691
- if (elements.length > 1) {
692
- if (info.strict)
693
- throw injected.strictModeViolationError(info.parsed, elements);
694
- log2 = ` locator resolved to ${elements.length} elements. Proceeding with the first one: ${injected.previewNode(elements[0])}`;
695
- } else if (element2) {
696
- log2 = ` locator resolved to ${visible2 ? "visible" : "hidden"} ${injected.previewNode(element2)}`;
697
- }
698
- return { log: log2, element: element2, visible: visible2, attached: !!element2 };
699
- }, { info: resolved.info, root: resolved.frame === this ? scope : void 0 });
700
- const { log, visible, attached } = await result.evaluate((r) => ({ log: r.log, visible: r.visible, attached: r.attached }));
701
- if (log)
702
- progress.log(log);
703
- const success = { attached, detached: !attached, visible, hidden: !visible }[state];
704
- if (!success) {
705
- result.dispose();
706
- return continuePolling;
707
- }
708
- if (options.omitReturnValue) {
709
- result.dispose();
710
- return null;
711
- }
712
- const element = state === "attached" || state === "visible" ? await result.evaluateHandle((r) => r.element) : null;
713
- result.dispose();
714
- if (!element)
715
- return null;
716
- if (options.__testHookBeforeAdoptNode)
717
- await options.__testHookBeforeAdoptNode();
718
- try {
719
- return await element._adoptTo(await resolved.frame._mainContext());
720
- } catch (e) {
721
- return continuePolling;
722
- }
723
- });
724
- return scope ? scope._context._raceAgainstContextDestroyed(promise) : promise;
725
- }
726
- async dispatchEvent(metadata, selector, type, eventInit = {}, options = {}, scope) {
727
- await this._callOnElementOnceMatches(metadata, selector, (injectedScript, element, data) => {
728
- injectedScript.dispatchEvent(element, data.type, data.eventInit);
729
- }, { type, eventInit }, { mainWorld: true, ...options }, scope);
730
- }
731
- async evalOnSelector(selector, strict, expression, isFunction, arg, scope) {
732
- const handle = await this.selectors.query(selector, { strict }, scope);
733
- if (!handle)
734
- throw new Error(`Failed to find element matching selector "${selector}"`);
735
- const result = await handle.evaluateExpression(expression, { isFunction }, arg);
736
- handle.dispose();
737
- return result;
738
- }
739
- async evalOnSelectorAll(selector, expression, isFunction, arg, scope) {
740
- const arrayHandle = await this.selectors.queryArrayInMainWorld(selector, scope);
741
- const result = await arrayHandle.evaluateExpression(expression, { isFunction }, arg);
742
- arrayHandle.dispose();
743
- return result;
744
- }
745
- async maskSelectors(selectors, color) {
746
- const context = await this._utilityContext();
747
- const injectedScript = await context.injectedScript();
748
- await injectedScript.evaluate((injected, { parsed, color: color2 }) => {
749
- injected.maskSelectors(parsed, color2);
750
- }, { parsed: selectors, color });
751
- }
752
- async querySelectorAll(selector) {
753
- return this.selectors.queryAll(selector);
754
- }
755
- async queryCount(selector) {
756
- return await this.selectors.queryCount(selector);
757
- }
758
- async content() {
759
- try {
760
- const context = await this._utilityContext();
761
- return await context.evaluate(() => {
762
- let retVal = "";
763
- if (document.doctype)
764
- retVal = new XMLSerializer().serializeToString(document.doctype);
765
- if (document.documentElement)
766
- retVal += document.documentElement.outerHTML;
767
- return retVal;
768
- });
769
- } catch (e) {
770
- if (js.isJavaScriptErrorInEvaluate(e) || (0, import_protocolError.isSessionClosedError)(e))
771
- throw e;
772
- throw new Error(`Unable to retrieve content because the page is navigating and changing the content.`);
773
- }
774
- }
775
- async setContent(metadata, html, options = {}) {
776
- const controller = new import_progress.ProgressController(metadata, this);
777
- return controller.run(async (progress) => {
778
- await this.raceNavigationAction(progress, options, async () => {
779
- const waitUntil = options.waitUntil === void 0 ? "load" : options.waitUntil;
780
- progress.log(`setting frame content, waiting until "${waitUntil}"`);
781
- const tag = `--playwright--set--content--${this._id}--${++this._setContentCounter}--`;
782
- const context = await this._utilityContext();
783
- const lifecyclePromise = new Promise((resolve, reject) => {
784
- this._page._frameManager._consoleMessageTags.set(tag, () => {
785
- this._onClearLifecycle();
786
- this._waitForLoadState(progress, waitUntil).then(resolve).catch(reject);
787
- });
788
- });
789
- const contentPromise = context.evaluate(({ html: html2, tag: tag2 }) => {
790
- document.open();
791
- console.debug(tag2);
792
- document.write(html2);
793
- document.close();
794
- }, { html, tag });
795
- await Promise.all([contentPromise, lifecyclePromise]);
796
- return null;
797
- });
798
- }, this._page._timeoutSettings.navigationTimeout(options));
799
- }
800
- name() {
801
- return this._name || "";
802
- }
803
- url() {
804
- return this._url;
805
- }
806
- origin() {
807
- if (!this._url.startsWith("http"))
808
- return;
809
- return network.parseURL(this._url)?.origin;
810
- }
811
- parentFrame() {
812
- return this._parentFrame;
813
- }
814
- childFrames() {
815
- return Array.from(this._childFrames);
816
- }
817
- async addScriptTag(params) {
818
- const {
819
- url = null,
820
- content = null,
821
- type = ""
822
- } = params;
823
- if (!url && !content)
824
- throw new Error("Provide an object with a `url`, `path` or `content` property");
825
- const context = await this._mainContext();
826
- return this._raceWithCSPError(async () => {
827
- if (url !== null)
828
- return (await context.evaluateHandle(addScriptUrl, { url, type })).asElement();
829
- const result = (await context.evaluateHandle(addScriptContent, { content, type })).asElement();
830
- if (this._page._delegate.cspErrorsAsynchronousForInlineScripts)
831
- await context.evaluate(() => true);
832
- return result;
833
- });
834
- async function addScriptUrl(params2) {
835
- const script = document.createElement("script");
836
- script.src = params2.url;
837
- if (params2.type)
838
- script.type = params2.type;
839
- const promise = new Promise((res, rej) => {
840
- script.onload = res;
841
- script.onerror = (e) => rej(typeof e === "string" ? new Error(e) : new Error(`Failed to load script at ${script.src}`));
842
- });
843
- document.head.appendChild(script);
844
- await promise;
845
- return script;
846
- }
847
- function addScriptContent(params2) {
848
- const script = document.createElement("script");
849
- script.type = params2.type || "text/javascript";
850
- script.text = params2.content;
851
- let error = null;
852
- script.onerror = (e) => error = e;
853
- document.head.appendChild(script);
854
- if (error)
855
- throw error;
856
- return script;
857
- }
858
- }
859
- async addStyleTag(params) {
860
- const {
861
- url = null,
862
- content = null
863
- } = params;
864
- if (!url && !content)
865
- throw new Error("Provide an object with a `url`, `path` or `content` property");
866
- const context = await this._mainContext();
867
- return this._raceWithCSPError(async () => {
868
- if (url !== null)
869
- return (await context.evaluateHandle(addStyleUrl, url)).asElement();
870
- return (await context.evaluateHandle(addStyleContent, content)).asElement();
871
- });
872
- async function addStyleUrl(url2) {
873
- const link = document.createElement("link");
874
- link.rel = "stylesheet";
875
- link.href = url2;
876
- const promise = new Promise((res, rej) => {
877
- link.onload = res;
878
- link.onerror = rej;
879
- });
880
- document.head.appendChild(link);
881
- await promise;
882
- return link;
883
- }
884
- async function addStyleContent(content2) {
885
- const style = document.createElement("style");
886
- style.type = "text/css";
887
- style.appendChild(document.createTextNode(content2));
888
- const promise = new Promise((res, rej) => {
889
- style.onload = res;
890
- style.onerror = rej;
891
- });
892
- document.head.appendChild(style);
893
- await promise;
894
- return style;
895
- }
896
- }
897
- async _raceWithCSPError(func) {
898
- const listeners = [];
899
- let result;
900
- let error;
901
- let cspMessage;
902
- const actionPromise = func().then((r) => result = r).catch((e) => error = e);
903
- const errorPromise = new Promise((resolve) => {
904
- listeners.push(import_eventsHelper.eventsHelper.addEventListener(this._page._browserContext, import_browserContext.BrowserContext.Events.Console, (message) => {
905
- if (message.page() !== this._page || message.type() !== "error")
906
- return;
907
- if (message.text().includes("Content-Security-Policy") || message.text().includes("Content Security Policy")) {
908
- cspMessage = message;
909
- resolve();
910
- }
911
- }));
912
- });
913
- await Promise.race([actionPromise, errorPromise]);
914
- import_eventsHelper.eventsHelper.removeEventListeners(listeners);
915
- if (cspMessage)
916
- throw new Error(cspMessage.text());
917
- if (error)
918
- throw error;
919
- return result;
920
- }
921
- async retryWithProgressAndTimeouts(progress, timeouts, action) {
922
- const continuePolling = Symbol("continuePolling");
923
- timeouts = [0, ...timeouts];
924
- let timeoutIndex = 0;
925
- while (progress.isRunning()) {
926
- const timeout = timeouts[Math.min(timeoutIndex++, timeouts.length - 1)];
927
- if (timeout) {
928
- const actionPromise = new Promise((f) => setTimeout(f, timeout));
929
- await import_utils.LongStandingScope.raceMultiple([
930
- this._page.openScope,
931
- this._detachedScope
932
- ], actionPromise);
933
- }
934
- progress.throwIfAborted();
935
- try {
936
- const result = await action(continuePolling);
937
- if (result === continuePolling)
938
- continue;
939
- return result;
940
- } catch (e) {
941
- if (this._isErrorThatCannotBeRetried(e))
942
- throw e;
943
- continue;
944
- }
945
- }
946
- progress.throwIfAborted();
947
- return void 0;
948
- }
949
- _isErrorThatCannotBeRetried(e) {
950
- if (js.isJavaScriptErrorInEvaluate(e) || (0, import_protocolError.isSessionClosedError)(e))
951
- return true;
952
- if (dom.isNonRecoverableDOMError(e) || (0, import_selectorParser.isInvalidSelectorError)(e))
953
- return true;
954
- if (this.isDetached())
955
- return true;
956
- return false;
957
- }
958
- async _retryWithProgressIfNotConnected(progress, selector, strict, performActionPreChecks, action) {
959
- progress.log(`waiting for ${this._asLocator(selector)}`);
960
- return this.retryWithProgressAndTimeouts(progress, [0, 20, 50, 100, 100, 500], async (continuePolling) => {
961
- if (performActionPreChecks)
962
- await this._page.performActionPreChecks(progress);
963
- const resolved = await this.selectors.resolveInjectedForSelector(selector, { strict });
964
- progress.throwIfAborted();
965
- if (!resolved)
966
- return continuePolling;
967
- const result = await resolved.injected.evaluateHandle((injected, { info, callId }) => {
968
- const elements = injected.querySelectorAll(info.parsed, document);
969
- if (callId)
970
- injected.markTargetElements(new Set(elements), callId);
971
- const element2 = elements[0];
972
- let log2 = "";
973
- if (elements.length > 1) {
974
- if (info.strict)
975
- throw injected.strictModeViolationError(info.parsed, elements);
976
- log2 = ` locator resolved to ${elements.length} elements. Proceeding with the first one: ${injected.previewNode(elements[0])}`;
977
- } else if (element2) {
978
- log2 = ` locator resolved to ${injected.previewNode(element2)}`;
979
- }
980
- return { log: log2, success: !!element2, element: element2 };
981
- }, { info: resolved.info, callId: progress.metadata.id });
982
- const { log, success } = await result.evaluate((r) => ({ log: r.log, success: r.success }));
983
- if (log)
984
- progress.log(log);
985
- if (!success) {
986
- result.dispose();
987
- return continuePolling;
988
- }
989
- const element = await result.evaluateHandle((r) => r.element);
990
- result.dispose();
991
- try {
992
- const result2 = await action(element);
993
- if (result2 === "error:notconnected") {
994
- progress.log("element was detached from the DOM, retrying");
995
- return continuePolling;
996
- }
997
- return result2;
998
- } finally {
999
- element?.dispose();
1000
- }
1001
- });
1002
- }
1003
- async rafrafTimeoutScreenshotElementWithProgress(progress, selector, timeout, options) {
1004
- return await this._retryWithProgressIfNotConnected(progress, selector, true, true, async (handle) => {
1005
- await handle._frame.rafrafTimeout(timeout);
1006
- return await this._page._screenshotter.screenshotElement(progress, handle, options);
1007
- });
1008
- }
1009
- async click(metadata, selector, options) {
1010
- const controller = new import_progress.ProgressController(metadata, this);
1011
- return controller.run(async (progress) => {
1012
- return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._click(progress, { ...options, waitAfter: !options.noWaitAfter })));
1013
- }, this._page._timeoutSettings.timeout(options));
1014
- }
1015
- async dblclick(metadata, selector, options = {}) {
1016
- const controller = new import_progress.ProgressController(metadata, this);
1017
- return controller.run(async (progress) => {
1018
- return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._dblclick(progress, options)));
1019
- }, this._page._timeoutSettings.timeout(options));
1020
- }
1021
- async dragAndDrop(metadata, source, target, options = {}) {
1022
- const controller = new import_progress.ProgressController(metadata, this);
1023
- await controller.run(async (progress) => {
1024
- dom.assertDone(await this._retryWithProgressIfNotConnected(progress, source, options.strict, !options.force, async (handle) => {
1025
- return handle._retryPointerAction(progress, "move and down", false, async (point) => {
1026
- await this._page.mouse.move(point.x, point.y);
1027
- await this._page.mouse.down();
1028
- }, {
1029
- ...options,
1030
- waitAfter: "disabled",
1031
- position: options.sourcePosition,
1032
- timeout: progress.timeUntilDeadline()
1033
- });
1034
- }));
1035
- dom.assertDone(await this._retryWithProgressIfNotConnected(progress, target, options.strict, false, async (handle) => {
1036
- return handle._retryPointerAction(progress, "move and up", false, async (point) => {
1037
- await this._page.mouse.move(point.x, point.y);
1038
- await this._page.mouse.up();
1039
- }, {
1040
- ...options,
1041
- waitAfter: "disabled",
1042
- position: options.targetPosition,
1043
- timeout: progress.timeUntilDeadline()
1044
- });
1045
- }));
1046
- }, this._page._timeoutSettings.timeout(options));
1047
- }
1048
- async tap(metadata, selector, options) {
1049
- if (!this._page._browserContext._options.hasTouch)
1050
- throw new Error("The page does not support tap. Use hasTouch context option to enable touch support.");
1051
- const controller = new import_progress.ProgressController(metadata, this);
1052
- return controller.run(async (progress) => {
1053
- return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._tap(progress, options)));
1054
- }, this._page._timeoutSettings.timeout(options));
1055
- }
1056
- async fill(metadata, selector, value, options) {
1057
- const controller = new import_progress.ProgressController(metadata, this);
1058
- return controller.run(async (progress) => {
1059
- return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._fill(progress, value, options)));
1060
- }, this._page._timeoutSettings.timeout(options));
1061
- }
1062
- async focus(metadata, selector, options = {}) {
1063
- const controller = new import_progress.ProgressController(metadata, this);
1064
- await controller.run(async (progress) => {
1065
- dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true, (handle) => handle._focus(progress)));
1066
- }, this._page._timeoutSettings.timeout(options));
1067
- }
1068
- async blur(metadata, selector, options = {}) {
1069
- const controller = new import_progress.ProgressController(metadata, this);
1070
- await controller.run(async (progress) => {
1071
- dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true, (handle) => handle._blur(progress)));
1072
- }, this._page._timeoutSettings.timeout(options));
1073
- }
1074
- async textContent(metadata, selector, options = {}, scope) {
1075
- return this._callOnElementOnceMatches(metadata, selector, (injected, element) => element.textContent, void 0, options, scope);
1076
- }
1077
- async innerText(metadata, selector, options = {}, scope) {
1078
- return this._callOnElementOnceMatches(metadata, selector, (injectedScript, element) => {
1079
- if (element.namespaceURI !== "http://www.w3.org/1999/xhtml")
1080
- throw injectedScript.createStacklessError("Node is not an HTMLElement");
1081
- return element.innerText;
1082
- }, void 0, options, scope);
1083
- }
1084
- async innerHTML(metadata, selector, options = {}, scope) {
1085
- return this._callOnElementOnceMatches(metadata, selector, (injected, element) => element.innerHTML, void 0, options, scope);
1086
- }
1087
- async getAttribute(metadata, selector, name, options = {}, scope) {
1088
- return this._callOnElementOnceMatches(metadata, selector, (injected, element, data) => element.getAttribute(data.name), { name }, options, scope);
1089
- }
1090
- async inputValue(metadata, selector, options = {}, scope) {
1091
- return this._callOnElementOnceMatches(metadata, selector, (injectedScript, node) => {
1092
- const element = injectedScript.retarget(node, "follow-label");
1093
- if (!element || element.nodeName !== "INPUT" && element.nodeName !== "TEXTAREA" && element.nodeName !== "SELECT")
1094
- throw injectedScript.createStacklessError("Node is not an <input>, <textarea> or <select> element");
1095
- return element.value;
1096
- }, void 0, options, scope);
1097
- }
1098
- async highlight(selector) {
1099
- const resolved = await this.selectors.resolveInjectedForSelector(selector);
1100
- if (!resolved)
1101
- return;
1102
- return await resolved.injected.evaluate((injected, { info }) => {
1103
- return injected.highlight(info.parsed);
1104
- }, { info: resolved.info });
1105
- }
1106
- async hideHighlight() {
1107
- return this.raceAgainstEvaluationStallingEvents(async () => {
1108
- const context = await this._utilityContext();
1109
- const injectedScript = await context.injectedScript();
1110
- return await injectedScript.evaluate((injected) => {
1111
- return injected.hideHighlight();
1112
- });
1113
- });
1114
- }
1115
- async _elementState(metadata, selector, state, options = {}, scope) {
1116
- const result = await this._callOnElementOnceMatches(metadata, selector, (injected, element, data) => {
1117
- return injected.elementState(element, data.state);
1118
- }, { state }, options, scope);
1119
- if (result.received === "error:notconnected")
1120
- dom.throwElementIsNotAttached();
1121
- return result.matches;
1122
- }
1123
- async isVisible(metadata, selector, options = {}, scope) {
1124
- const controller = new import_progress.ProgressController(metadata, this);
1125
- return controller.run(async (progress) => {
1126
- progress.log(` checking visibility of ${this._asLocator(selector)}`);
1127
- return await this.isVisibleInternal(selector, options, scope);
1128
- }, this._page._timeoutSettings.timeout({}));
1129
- }
1130
- async isVisibleInternal(selector, options = {}, scope) {
1131
- try {
1132
- const resolved = await this.selectors.resolveInjectedForSelector(selector, options, scope);
1133
- if (!resolved)
1134
- return false;
1135
- return await resolved.injected.evaluate((injected, { info, root }) => {
1136
- const element = injected.querySelector(info.parsed, root || document, info.strict);
1137
- const state = element ? injected.elementState(element, "visible") : { matches: false, received: "error:notconnected" };
1138
- return state.matches;
1139
- }, { info: resolved.info, root: resolved.frame === this ? scope : void 0 });
1140
- } catch (e) {
1141
- if (js.isJavaScriptErrorInEvaluate(e) || (0, import_selectorParser.isInvalidSelectorError)(e) || (0, import_protocolError.isSessionClosedError)(e))
1142
- throw e;
1143
- return false;
1144
- }
1145
- }
1146
- async isHidden(metadata, selector, options = {}, scope) {
1147
- return !await this.isVisible(metadata, selector, options, scope);
1148
- }
1149
- async isDisabled(metadata, selector, options = {}, scope) {
1150
- return this._elementState(metadata, selector, "disabled", options, scope);
1151
- }
1152
- async isEnabled(metadata, selector, options = {}, scope) {
1153
- return this._elementState(metadata, selector, "enabled", options, scope);
1154
- }
1155
- async isEditable(metadata, selector, options = {}, scope) {
1156
- return this._elementState(metadata, selector, "editable", options, scope);
1157
- }
1158
- async isChecked(metadata, selector, options = {}, scope) {
1159
- return this._elementState(metadata, selector, "checked", options, scope);
1160
- }
1161
- async hover(metadata, selector, options = {}) {
1162
- const controller = new import_progress.ProgressController(metadata, this);
1163
- return controller.run(async (progress) => {
1164
- return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._hover(progress, options)));
1165
- }, this._page._timeoutSettings.timeout(options));
1166
- }
1167
- async selectOption(metadata, selector, elements, values, options = {}) {
1168
- const controller = new import_progress.ProgressController(metadata, this);
1169
- return controller.run(async (progress) => {
1170
- return await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._selectOption(progress, elements, values, options));
1171
- }, this._page._timeoutSettings.timeout(options));
1172
- }
1173
- async setInputFiles(metadata, selector, params) {
1174
- const inputFileItems = await (0, import_fileUploadUtils.prepareFilesForUpload)(this, params);
1175
- const controller = new import_progress.ProgressController(metadata, this);
1176
- return controller.run(async (progress) => {
1177
- return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, params.strict, true, (handle) => handle._setInputFiles(progress, inputFileItems)));
1178
- }, this._page._timeoutSettings.timeout(params));
1179
- }
1180
- async type(metadata, selector, text, options = {}) {
1181
- const controller = new import_progress.ProgressController(metadata, this);
1182
- return controller.run(async (progress) => {
1183
- return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true, (handle) => handle._type(progress, text, options)));
1184
- }, this._page._timeoutSettings.timeout(options));
1185
- }
1186
- async press(metadata, selector, key, options = {}) {
1187
- const controller = new import_progress.ProgressController(metadata, this);
1188
- return controller.run(async (progress) => {
1189
- return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true, (handle) => handle._press(progress, key, options)));
1190
- }, this._page._timeoutSettings.timeout(options));
1191
- }
1192
- async check(metadata, selector, options = {}) {
1193
- const controller = new import_progress.ProgressController(metadata, this);
1194
- return controller.run(async (progress) => {
1195
- return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._setChecked(progress, true, options)));
1196
- }, this._page._timeoutSettings.timeout(options));
1197
- }
1198
- async uncheck(metadata, selector, options = {}) {
1199
- const controller = new import_progress.ProgressController(metadata, this);
1200
- return controller.run(async (progress) => {
1201
- return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._setChecked(progress, false, options)));
1202
- }, this._page._timeoutSettings.timeout(options));
1203
- }
1204
- async waitForTimeout(metadata, timeout) {
1205
- const controller = new import_progress.ProgressController(metadata, this);
1206
- return controller.run(async () => {
1207
- await new Promise((resolve) => setTimeout(resolve, timeout));
1208
- });
1209
- }
1210
- async ariaSnapshot(metadata, selector, options = {}) {
1211
- const controller = new import_progress.ProgressController(metadata, this);
1212
- return controller.run(async (progress) => {
1213
- return await this._retryWithProgressIfNotConnected(progress, selector, true, true, (handle) => handle.ariaSnapshot(options));
1214
- }, this._page._timeoutSettings.timeout(options));
1215
- }
1216
- async expect(metadata, selector, options) {
1217
- const result = await this._expectImpl(metadata, selector, options);
1218
- if (result.matches === options.isNot)
1219
- metadata.error = { error: { name: "Expect", message: "Expect failed" } };
1220
- return result;
1221
- }
1222
- async _expectImpl(metadata, selector, options) {
1223
- const lastIntermediateResult = { isSet: false };
1224
- try {
1225
- let timeout = this._page._timeoutSettings.timeout(options);
1226
- const start = timeout > 0 ? (0, import_utils.monotonicTime)() : 0;
1227
- await new import_progress.ProgressController(metadata, this).run(async (progress) => {
1228
- progress.log(`${metadata.apiName}${timeout ? ` with timeout ${timeout}ms` : ""}`);
1229
- progress.log(`waiting for ${this._asLocator(selector)}`);
1230
- await this._page.performActionPreChecks(progress);
1231
- }, timeout);
1232
- try {
1233
- const resultOneShot = await new import_progress.ProgressController(metadata, this).run(async (progress) => {
1234
- return await this._expectInternal(progress, selector, options, lastIntermediateResult);
1235
- });
1236
- if (resultOneShot.matches !== options.isNot)
1237
- return resultOneShot;
1238
- } catch (e) {
1239
- if (js.isJavaScriptErrorInEvaluate(e) || (0, import_selectorParser.isInvalidSelectorError)(e))
1240
- throw e;
1241
- }
1242
- if (timeout > 0) {
1243
- const elapsed = (0, import_utils.monotonicTime)() - start;
1244
- timeout -= elapsed;
1245
- }
1246
- if (timeout < 0)
1247
- return { matches: options.isNot, log: (0, import_callLog.compressCallLog)(metadata.log), timedOut: true, received: lastIntermediateResult.received };
1248
- return await new import_progress.ProgressController(metadata, this).run(async (progress) => {
1249
- return await this.retryWithProgressAndTimeouts(progress, [100, 250, 500, 1e3], async (continuePolling) => {
1250
- await this._page.performActionPreChecks(progress);
1251
- const { matches, received } = await this._expectInternal(progress, selector, options, lastIntermediateResult);
1252
- if (matches === options.isNot) {
1253
- return continuePolling;
1254
- }
1255
- return { matches, received };
1256
- });
1257
- }, timeout);
1258
- } catch (e) {
1259
- if (js.isJavaScriptErrorInEvaluate(e) || (0, import_selectorParser.isInvalidSelectorError)(e))
1260
- throw e;
1261
- const result = { matches: options.isNot, log: (0, import_callLog.compressCallLog)(metadata.log) };
1262
- if (lastIntermediateResult.isSet)
1263
- result.received = lastIntermediateResult.received;
1264
- if (e instanceof import_errors.TimeoutError)
1265
- result.timedOut = true;
1266
- return result;
1267
- }
1268
- }
1269
- async _expectInternal(progress, selector, options, lastIntermediateResult) {
1270
- const selectorInFrame = await this.selectors.resolveFrameForSelector(selector, { strict: true });
1271
- progress.throwIfAborted();
1272
- const { frame, info } = selectorInFrame || { frame: this, info: void 0 };
1273
- const world = options.expression === "to.have.property" ? "main" : info?.world ?? "utility";
1274
- const context = await frame._context(world);
1275
- const injected = await context.injectedScript();
1276
- progress.throwIfAborted();
1277
- const { log, matches, received, missingReceived } = await injected.evaluate(async (injected2, { info: info2, options: options2, callId }) => {
1278
- const elements = info2 ? injected2.querySelectorAll(info2.parsed, document) : [];
1279
- if (callId)
1280
- injected2.markTargetElements(new Set(elements), callId);
1281
- const isArray = options2.expression === "to.have.count" || options2.expression.endsWith(".array");
1282
- let log2 = "";
1283
- if (isArray)
1284
- log2 = ` locator resolved to ${elements.length} element${elements.length === 1 ? "" : "s"}`;
1285
- else if (elements.length > 1)
1286
- throw injected2.strictModeViolationError(info2.parsed, elements);
1287
- else if (elements.length)
1288
- log2 = ` locator resolved to ${injected2.previewNode(elements[0])}`;
1289
- return { log: log2, ...await injected2.expect(elements[0], options2, elements) };
1290
- }, { info, options, callId: progress.metadata.id });
1291
- if (log)
1292
- progress.log(log);
1293
- if (matches === options.isNot) {
1294
- lastIntermediateResult.received = missingReceived ? "<element(s) not found>" : received;
1295
- lastIntermediateResult.isSet = true;
1296
- if (!missingReceived && !Array.isArray(received))
1297
- progress.log(` unexpected value "${renderUnexpectedValue(options.expression, received)}"`);
1298
- }
1299
- return { matches, received };
1300
- }
1301
- async _waitForFunctionExpression(metadata, expression, isFunction, arg, options, world = "main") {
1302
- const controller = new import_progress.ProgressController(metadata, this);
1303
- if (typeof options.pollingInterval === "number")
1304
- (0, import_utils.assert)(options.pollingInterval > 0, "Cannot poll with non-positive interval: " + options.pollingInterval);
1305
- expression = js.normalizeEvaluationExpression(expression, isFunction);
1306
- return controller.run(async (progress) => {
1307
- return this.retryWithProgressAndTimeouts(progress, [100], async () => {
1308
- const context = world === "main" ? await this._mainContext() : await this._utilityContext();
1309
- const injectedScript = await context.injectedScript();
1310
- const handle = await injectedScript.evaluateHandle((injected, { expression: expression2, isFunction: isFunction2, polling, arg: arg2 }) => {
1311
- const predicate = () => {
1312
- let result2 = globalThis.eval(expression2);
1313
- if (isFunction2 === true) {
1314
- result2 = result2(arg2);
1315
- } else if (isFunction2 === false) {
1316
- result2 = result2;
1317
- } else {
1318
- if (typeof result2 === "function")
1319
- result2 = result2(arg2);
1320
- }
1321
- return result2;
1322
- };
1323
- let fulfill;
1324
- let reject;
1325
- let aborted = false;
1326
- const result = new Promise((f, r) => {
1327
- fulfill = f;
1328
- reject = r;
1329
- });
1330
- const next = () => {
1331
- if (aborted)
1332
- return;
1333
- try {
1334
- const success = predicate();
1335
- if (success) {
1336
- fulfill(success);
1337
- return;
1338
- }
1339
- if (typeof polling !== "number")
1340
- injected.utils.builtins.requestAnimationFrame(next);
1341
- else
1342
- injected.utils.builtins.setTimeout(next, polling);
1343
- } catch (e) {
1344
- reject(e);
1345
- }
1346
- };
1347
- next();
1348
- return { result, abort: () => aborted = true };
1349
- }, { expression, isFunction, polling: options.pollingInterval, arg });
1350
- progress.cleanupWhenAborted(() => handle.evaluate((h) => h.abort()).catch(() => {
1351
- }));
1352
- return handle.evaluateHandle((h) => h.result);
1353
- });
1354
- }, this._page._timeoutSettings.timeout(options));
1355
- }
1356
- async waitForFunctionValueInUtility(progress, pageFunction) {
1357
- const expression = `() => {
1358
- const result = (${pageFunction})();
1359
- if (!result)
1360
- return result;
1361
- return JSON.stringify(result);
1362
- }`;
1363
- const handle = await this._waitForFunctionExpression((0, import_instrumentation.serverSideCallMetadata)(), expression, true, void 0, { timeout: progress.timeUntilDeadline() }, "utility");
1364
- return JSON.parse(handle.rawValue());
1365
- }
1366
- async title() {
1367
- const context = await this._utilityContext();
1368
- return context.evaluate(() => document.title);
1369
- }
1370
- async rafrafTimeout(timeout) {
1371
- if (timeout === 0)
1372
- return;
1373
- const context = await this._utilityContext();
1374
- await Promise.all([
1375
- // wait for double raf
1376
- context.evaluate(() => new Promise((x) => {
1377
- requestAnimationFrame(() => {
1378
- requestAnimationFrame(x);
1379
- });
1380
- })),
1381
- new Promise((fulfill) => setTimeout(fulfill, timeout))
1382
- ]);
1383
- }
1384
- _onDetached() {
1385
- this._stopNetworkIdleTimer();
1386
- this._detachedScope.close(new Error("Frame was detached"));
1387
- for (const data of this._contextData.values()) {
1388
- if (data.context)
1389
- data.context.contextDestroyed("Frame was detached");
1390
- data.contextPromise.resolve({ destroyedReason: "Frame was detached" });
1391
- }
1392
- if (this._parentFrame)
1393
- this._parentFrame._childFrames.delete(this);
1394
- this._parentFrame = null;
1395
- }
1396
- async _callOnElementOnceMatches(metadata, selector, body, taskData, options = {}, scope) {
1397
- const callbackText = body.toString();
1398
- const controller = new import_progress.ProgressController(metadata, this);
1399
- return controller.run(async (progress) => {
1400
- progress.log(`waiting for ${this._asLocator(selector)}`);
1401
- const promise = this.retryWithProgressAndTimeouts(progress, [0, 20, 50, 100, 100, 500], async (continuePolling) => {
1402
- const resolved = await this.selectors.resolveInjectedForSelector(selector, options, scope);
1403
- progress.throwIfAborted();
1404
- if (!resolved)
1405
- return continuePolling;
1406
- const { log, success, value } = await resolved.injected.evaluate((injected, { info, callbackText: callbackText2, taskData: taskData2, callId, root }) => {
1407
- const callback = injected.eval(callbackText2);
1408
- const element = injected.querySelector(info.parsed, root || document, info.strict);
1409
- if (!element)
1410
- return { success: false };
1411
- const log2 = ` locator resolved to ${injected.previewNode(element)}`;
1412
- if (callId)
1413
- injected.markTargetElements(/* @__PURE__ */ new Set([element]), callId);
1414
- return { log: log2, success: true, value: callback(injected, element, taskData2) };
1415
- }, { info: resolved.info, callbackText, taskData, callId: progress.metadata.id, root: resolved.frame === this ? scope : void 0 });
1416
- if (log)
1417
- progress.log(log);
1418
- if (!success)
1419
- return continuePolling;
1420
- return value;
1421
- });
1422
- return scope ? scope._context._raceAgainstContextDestroyed(promise) : promise;
1423
- }, this._page._timeoutSettings.timeout(options));
1424
- }
1425
- _setContext(world, context) {
1426
- const data = this._contextData.get(world);
1427
- data.context = context;
1428
- if (context)
1429
- data.contextPromise.resolve(context);
1430
- else
1431
- data.contextPromise = new import_manualPromise.ManualPromise();
1432
- }
1433
- _contextCreated(world, context) {
1434
- const data = this._contextData.get(world);
1435
- if (data.context) {
1436
- data.context.contextDestroyed("Execution context was destroyed, most likely because of a navigation");
1437
- this._setContext(world, null);
1438
- }
1439
- this._setContext(world, context);
1440
- }
1441
- _contextDestroyed(context) {
1442
- if (this._detachedScope.isClosed())
1443
- return;
1444
- context.contextDestroyed("Execution context was destroyed, most likely because of a navigation");
1445
- for (const [world, data] of this._contextData) {
1446
- if (data.context === context)
1447
- this._setContext(world, null);
1448
- }
1449
- }
1450
- _startNetworkIdleTimer() {
1451
- (0, import_utils.assert)(!this._networkIdleTimer);
1452
- if (this._firedLifecycleEvents.has("networkidle") || this._detachedScope.isClosed())
1453
- return;
1454
- this._networkIdleTimer = setTimeout(() => {
1455
- this._firedNetworkIdleSelf = true;
1456
- this._page.mainFrame()._recalculateNetworkIdle();
1457
- }, 500);
1458
- }
1459
- _stopNetworkIdleTimer() {
1460
- if (this._networkIdleTimer)
1461
- clearTimeout(this._networkIdleTimer);
1462
- this._networkIdleTimer = void 0;
1463
- this._firedNetworkIdleSelf = false;
1464
- }
1465
- async extendInjectedScript(source, arg) {
1466
- const context = await this._context("main");
1467
- const injectedScriptHandle = await context.injectedScript();
1468
- return injectedScriptHandle.evaluateHandle((injectedScript, { source: source2, arg: arg2 }) => {
1469
- return injectedScript.extend(source2, arg2);
1470
- }, { source, arg });
1471
- }
1472
- async resetStorageForCurrentOriginBestEffort(newStorage) {
1473
- const context = await this._utilityContext();
1474
- await context.evaluate(async ({ ls }) => {
1475
- sessionStorage.clear();
1476
- localStorage.clear();
1477
- for (const entry of ls || [])
1478
- localStorage[entry.name] = entry.value;
1479
- const registrations = navigator.serviceWorker ? await navigator.serviceWorker.getRegistrations() : [];
1480
- await Promise.all(registrations.map(async (r) => {
1481
- if (!r.installing && !r.waiting && !r.active)
1482
- r.unregister().catch(() => {
1483
- });
1484
- else
1485
- await r.unregister().catch(() => {
1486
- });
1487
- }));
1488
- for (const db of await indexedDB.databases?.() || []) {
1489
- if (db.name)
1490
- indexedDB.deleteDatabase(db.name);
1491
- }
1492
- }, { ls: newStorage?.localStorage }).catch(() => {
1493
- });
1494
- }
1495
- _asLocator(selector) {
1496
- return (0, import_utils.asLocator)(this._page.attribution.playwright.options.sdkLanguage, selector);
1497
- }
1498
- }
1499
- class SignalBarrier {
1500
- constructor(progress) {
1501
- this._protectCount = 0;
1502
- this._promise = new import_manualPromise.ManualPromise();
1503
- this._progress = progress;
1504
- this.retain();
1505
- }
1506
- waitFor() {
1507
- this.release();
1508
- return this._promise;
1509
- }
1510
- async addFrameNavigation(frame) {
1511
- if (frame.parentFrame())
1512
- return;
1513
- this.retain();
1514
- const waiter = import_helper.helper.waitForEvent(null, frame, Frame.Events.InternalNavigation, (e) => {
1515
- if (!e.isPublic)
1516
- return false;
1517
- if (!e.error && this._progress)
1518
- this._progress.log(` navigated to "${frame._url}"`);
1519
- return true;
1520
- });
1521
- await import_utils.LongStandingScope.raceMultiple([
1522
- frame._page.openScope,
1523
- frame._detachedScope
1524
- ], waiter.promise).catch(() => {
1525
- });
1526
- waiter.dispose();
1527
- this.release();
1528
- }
1529
- retain() {
1530
- ++this._protectCount;
1531
- }
1532
- release() {
1533
- --this._protectCount;
1534
- if (!this._protectCount)
1535
- this._promise.resolve();
1536
- }
1537
- }
1538
- function verifyLifecycle(name, waitUntil) {
1539
- if (waitUntil === "networkidle0")
1540
- waitUntil = "networkidle";
1541
- if (!types.kLifecycleEvents.has(waitUntil))
1542
- throw new Error(`${name}: expected one of (load|domcontentloaded|networkidle|commit)`);
1543
- return waitUntil;
1544
- }
1545
- function renderUnexpectedValue(expression, received) {
1546
- if (expression === "to.match.aria")
1547
- return received ? received.raw : received;
1548
- return received;
1549
- }
1550
- // Annotate the CommonJS export names for ESM import in node:
1551
- 0 && (module.exports = {
1552
- Frame,
1553
- FrameManager,
1554
- NavigationAbortedError
1555
- });