@smoothdeploy/playwright-core 1.58.3 → 1.60.0-beta-1780662356000

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