rebrowser-playwright-core 1.49.1 → 1.52.0

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 (372) hide show
  1. package/ThirdPartyNotices.txt +381 -55
  2. package/bin/reinstall_msedge_beta_linux.sh +6 -0
  3. package/bin/reinstall_msedge_dev_linux.sh +6 -0
  4. package/bin/reinstall_msedge_stable_linux.sh +6 -0
  5. package/browsers.json +28 -13
  6. package/index.js +0 -1
  7. package/lib/androidServerImpl.js +42 -48
  8. package/lib/browserServerImpl.js +60 -64
  9. package/lib/cli/driver.js +71 -69
  10. package/lib/cli/program.js +314 -354
  11. package/lib/cli/programWithTestStub.js +51 -44
  12. package/lib/client/accessibility.js +31 -32
  13. package/lib/client/android.js +146 -254
  14. package/lib/client/api.js +135 -283
  15. package/lib/client/artifact.js +39 -39
  16. package/lib/client/browser.js +59 -68
  17. package/lib/client/browserContext.js +302 -322
  18. package/lib/client/browserType.js +95 -143
  19. package/lib/client/cdpSession.js +29 -31
  20. package/lib/client/channelOwner.js +109 -139
  21. package/lib/client/clientHelper.js +49 -42
  22. package/lib/client/clientInstrumentation.js +40 -35
  23. package/lib/client/clientStackTrace.js +69 -0
  24. package/lib/client/clock.js +36 -36
  25. package/lib/client/connection.js +203 -218
  26. package/lib/client/consoleMessage.js +33 -33
  27. package/lib/client/coverage.js +25 -22
  28. package/lib/client/dialog.js +30 -31
  29. package/lib/client/download.js +25 -25
  30. package/lib/client/electron.js +74 -76
  31. package/lib/client/elementHandle.js +126 -163
  32. package/lib/client/errors.js +53 -53
  33. package/lib/client/eventEmitter.js +127 -127
  34. package/lib/client/events.js +72 -68
  35. package/lib/client/fetch.js +154 -178
  36. package/lib/client/fileChooser.js +25 -24
  37. package/lib/client/fileUtils.js +34 -0
  38. package/lib/client/frame.js +189 -307
  39. package/lib/client/harRouter.js +44 -56
  40. package/lib/client/input.js +40 -69
  41. package/lib/client/jsHandle.js +55 -71
  42. package/lib/client/jsonPipe.js +27 -23
  43. package/lib/client/localUtils.js +53 -28
  44. package/lib/client/locator.js +144 -230
  45. package/lib/client/network.js +285 -301
  46. package/lib/client/page.js +273 -312
  47. package/lib/client/platform.js +74 -0
  48. package/lib/client/playwright.js +62 -57
  49. package/lib/client/selectors.js +51 -43
  50. package/lib/client/stream.js +30 -45
  51. package/lib/client/timeoutSettings.js +75 -0
  52. package/lib/client/tracing.js +49 -82
  53. package/lib/client/types.js +26 -22
  54. package/lib/client/video.js +35 -27
  55. package/lib/client/waiter.js +71 -91
  56. package/lib/client/webError.js +25 -23
  57. package/lib/client/webSocket.js +111 -0
  58. package/lib/client/worker.js +48 -56
  59. package/lib/client/writableStream.js +28 -43
  60. package/lib/generated/clockSource.js +26 -5
  61. package/lib/generated/consoleApiSource.js +26 -5
  62. package/lib/generated/injectedScriptSource.js +26 -5
  63. package/lib/generated/pollingRecorderSource.js +26 -5
  64. package/lib/generated/utilityScriptSource.js +26 -5
  65. package/lib/generated/webSocketMockSource.js +375 -4
  66. package/lib/inProcessFactory.js +53 -48
  67. package/lib/inprocess.js +2 -19
  68. package/lib/outofprocess.js +53 -42
  69. package/lib/protocol/debug.js +209 -25
  70. package/lib/protocol/serializers.js +153 -134
  71. package/lib/protocol/validator.js +2712 -2667
  72. package/lib/protocol/validatorPrimitives.js +115 -75
  73. package/lib/remote/playwrightConnection.js +144 -152
  74. package/lib/remote/playwrightServer.js +106 -77
  75. package/lib/server/accessibility.js +44 -37
  76. package/lib/server/android/android.js +216 -206
  77. package/lib/server/android/backendAdb.js +89 -82
  78. package/lib/server/artifact.js +78 -55
  79. package/lib/server/bidi/bidiBrowser.js +227 -158
  80. package/lib/server/bidi/bidiChromium.js +106 -78
  81. package/lib/server/bidi/bidiConnection.js +66 -83
  82. package/lib/server/bidi/bidiExecutionContext.js +161 -97
  83. package/lib/server/bidi/bidiFirefox.js +76 -68
  84. package/lib/server/bidi/bidiInput.js +90 -102
  85. package/lib/server/bidi/bidiNetworkManager.js +141 -159
  86. package/lib/server/bidi/bidiOverCdp.js +57 -58
  87. package/lib/server/bidi/bidiPage.js +262 -261
  88. package/lib/server/bidi/bidiPdf.js +52 -86
  89. package/lib/server/bidi/third_party/bidiCommands.d.js +22 -0
  90. package/lib/server/bidi/third_party/bidiDeserializer.js +55 -50
  91. package/lib/server/bidi/third_party/bidiKeyboard.js +241 -223
  92. package/lib/server/bidi/third_party/bidiProtocol.js +144 -131
  93. package/lib/server/bidi/third_party/bidiSerializer.js +67 -63
  94. package/lib/server/bidi/third_party/firefoxPrefs.js +149 -111
  95. package/lib/server/browser.js +76 -84
  96. package/lib/server/browserContext.js +343 -360
  97. package/lib/server/browserType.js +169 -181
  98. package/lib/server/callLog.js +82 -0
  99. package/lib/server/chromium/chromium.js +212 -190
  100. package/lib/server/chromium/chromiumSwitches.js +99 -44
  101. package/lib/server/chromium/crAccessibility.js +157 -131
  102. package/lib/server/chromium/crBrowser.js +262 -280
  103. package/lib/server/chromium/crConnection.js +121 -178
  104. package/lib/server/chromium/crCoverage.js +113 -127
  105. package/lib/server/chromium/crDevTools.js +64 -55
  106. package/lib/server/chromium/crDragDrop.js +62 -79
  107. package/lib/server/chromium/crExecutionContext.js +100 -91
  108. package/lib/server/chromium/crInput.js +101 -88
  109. package/lib/server/chromium/crNetworkManager.js +269 -370
  110. package/lib/server/chromium/crPage.js +509 -597
  111. package/lib/server/chromium/crPdf.js +54 -86
  112. package/lib/server/chromium/crProtocolHelper.js +92 -80
  113. package/lib/server/chromium/crServiceWorker.js +85 -69
  114. package/lib/server/chromium/defaultFontFamilies.js +152 -135
  115. package/lib/server/chromium/protocol.d.js +16 -0
  116. package/lib/server/chromium/videoRecorder.js +65 -99
  117. package/lib/server/clock.js +58 -46
  118. package/lib/server/codegen/csharp.js +191 -156
  119. package/lib/server/codegen/java.js +163 -125
  120. package/lib/server/codegen/javascript.js +166 -143
  121. package/lib/server/codegen/jsonl.js +33 -29
  122. package/lib/server/codegen/language.js +75 -52
  123. package/lib/server/codegen/languages.js +65 -27
  124. package/lib/server/codegen/python.js +141 -125
  125. package/lib/server/codegen/types.js +15 -4
  126. package/lib/server/console.js +28 -32
  127. package/lib/server/cookieStore.js +105 -86
  128. package/lib/server/debugController.js +102 -154
  129. package/lib/server/debugger.js +82 -78
  130. package/lib/server/deviceDescriptors.js +37 -24
  131. package/lib/server/deviceDescriptorsSource.json +131 -131
  132. package/lib/server/dialog.js +36 -35
  133. package/lib/server/dispatchers/androidDispatcher.js +196 -107
  134. package/lib/server/dispatchers/artifactDispatcher.js +62 -62
  135. package/lib/server/dispatchers/browserContextDispatcher.js +177 -217
  136. package/lib/server/dispatchers/browserDispatcher.js +78 -97
  137. package/lib/server/dispatchers/browserTypeDispatcher.js +35 -35
  138. package/lib/server/dispatchers/cdpSessionDispatcher.js +32 -36
  139. package/lib/server/dispatchers/debugControllerDispatcher.js +48 -64
  140. package/lib/server/dispatchers/dialogDispatcher.js +30 -27
  141. package/lib/server/dispatchers/dispatcher.js +180 -229
  142. package/lib/server/dispatchers/electronDispatcher.js +54 -57
  143. package/lib/server/dispatchers/elementHandlerDispatcher.js +79 -116
  144. package/lib/server/dispatchers/frameDispatcher.js +93 -162
  145. package/lib/server/dispatchers/jsHandleDispatcher.js +49 -66
  146. package/lib/server/dispatchers/jsonPipeDispatcher.js +35 -36
  147. package/lib/server/dispatchers/localUtilsDispatcher.js +107 -365
  148. package/lib/server/dispatchers/networkDispatchers.js +92 -109
  149. package/lib/server/dispatchers/pageDispatcher.js +130 -169
  150. package/lib/server/dispatchers/playwrightDispatcher.js +69 -76
  151. package/lib/server/dispatchers/selectorsDispatcher.js +28 -24
  152. package/lib/server/dispatchers/streamDispatcher.js +42 -44
  153. package/lib/server/dispatchers/tracingDispatcher.js +36 -41
  154. package/lib/server/dispatchers/webSocketRouteDispatcher.js +100 -135
  155. package/lib/server/dispatchers/writableStreamDispatcher.js +54 -39
  156. package/lib/server/dom.js +424 -443
  157. package/lib/server/download.js +45 -35
  158. package/lib/server/electron/electron.js +156 -175
  159. package/lib/server/electron/loader.js +8 -36
  160. package/lib/server/errors.js +47 -46
  161. package/lib/server/fetch.js +302 -331
  162. package/lib/server/fileChooser.js +25 -24
  163. package/lib/server/fileUploadUtils.js +66 -57
  164. package/lib/server/firefox/ffAccessibility.js +153 -131
  165. package/lib/server/firefox/ffBrowser.js +218 -274
  166. package/lib/server/firefox/ffConnection.js +63 -84
  167. package/lib/server/firefox/ffExecutionContext.js +103 -77
  168. package/lib/server/firefox/ffInput.js +72 -63
  169. package/lib/server/firefox/ffNetworkManager.js +131 -110
  170. package/lib/server/firefox/ffPage.js +244 -302
  171. package/lib/server/firefox/firefox.js +76 -69
  172. package/lib/server/firefox/protocol.d.js +16 -0
  173. package/lib/server/formData.js +107 -35
  174. package/lib/server/frameSelectors.js +77 -111
  175. package/lib/server/frames.js +719 -855
  176. package/lib/server/har/harRecorder.js +85 -77
  177. package/lib/server/har/harTracer.js +288 -224
  178. package/lib/server/harBackend.js +157 -0
  179. package/lib/server/helper.js +56 -59
  180. package/lib/server/index.js +59 -106
  181. package/lib/server/input.js +136 -166
  182. package/lib/server/instrumentation.js +49 -44
  183. package/lib/server/javascript.js +157 -151
  184. package/lib/server/launchApp.js +92 -73
  185. package/lib/server/localUtils.js +211 -0
  186. package/lib/server/macEditingCommands.js +141 -137
  187. package/lib/server/network.js +263 -297
  188. package/lib/server/page.js +351 -434
  189. package/lib/server/pageBinding.js +88 -0
  190. package/lib/server/pipeTransport.js +49 -45
  191. package/lib/server/playwright.js +60 -67
  192. package/lib/server/progress.js +56 -51
  193. package/lib/server/protocolError.js +34 -31
  194. package/lib/server/recorder/chat.js +161 -0
  195. package/lib/server/recorder/contextRecorder.js +135 -148
  196. package/lib/server/recorder/recorderApp.js +129 -132
  197. package/lib/server/recorder/recorderCollection.js +57 -57
  198. package/lib/server/recorder/recorderFrontend.js +15 -4
  199. package/lib/server/recorder/recorderRunner.js +80 -100
  200. package/lib/server/recorder/recorderUtils.js +59 -72
  201. package/lib/server/recorder/throttledFile.js +42 -31
  202. package/lib/server/recorder.js +186 -190
  203. package/lib/server/registry/browserFetcher.js +107 -100
  204. package/lib/server/registry/dependencies.js +247 -198
  205. package/lib/server/registry/index.js +928 -709
  206. package/lib/server/registry/nativeDeps.js +1073 -461
  207. package/lib/server/registry/oopDownloadBrowserMain.js +57 -75
  208. package/lib/server/screenshotter.js +166 -182
  209. package/lib/server/selectors.js +85 -46
  210. package/lib/server/socksClientCertificatesInterceptor.js +166 -185
  211. package/lib/server/socksInterceptor.js +62 -67
  212. package/lib/server/storageScript.js +154 -0
  213. package/lib/server/timeoutSettings.js +89 -0
  214. package/lib/server/trace/recorder/snapshotter.js +70 -88
  215. package/lib/server/trace/recorder/snapshotterInjected.js +246 -218
  216. package/lib/server/trace/recorder/tracing.js +324 -327
  217. package/lib/server/trace/test/inMemorySnapshotter.js +46 -52
  218. package/lib/server/trace/viewer/traceViewer.js +172 -137
  219. package/lib/server/transport.js +125 -133
  220. package/lib/server/types.js +26 -22
  221. package/lib/server/usKeyboardLayout.js +135 -545
  222. package/lib/server/utils/ascii.js +44 -0
  223. package/lib/server/utils/comparators.js +161 -0
  224. package/lib/server/utils/crypto.js +216 -0
  225. package/lib/server/utils/debug.js +47 -0
  226. package/lib/server/utils/debugLogger.js +114 -0
  227. package/lib/server/utils/env.js +68 -0
  228. package/lib/server/utils/eventsHelper.js +39 -0
  229. package/lib/server/utils/expectUtils.js +38 -0
  230. package/lib/server/utils/fileUtils.js +191 -0
  231. package/lib/server/utils/happyEyeballs.js +207 -0
  232. package/lib/server/utils/hostPlatform.js +109 -0
  233. package/lib/server/utils/httpServer.js +218 -0
  234. package/lib/server/utils/image_tools/colorUtils.js +89 -0
  235. package/lib/{image_tools → server/utils/image_tools}/compare.js +44 -43
  236. package/lib/server/utils/image_tools/imageChannel.js +78 -0
  237. package/lib/{image_tools → server/utils/image_tools}/stats.js +40 -40
  238. package/lib/server/utils/linuxUtils.js +71 -0
  239. package/lib/server/utils/network.js +217 -0
  240. package/lib/server/utils/nodePlatform.js +148 -0
  241. package/lib/server/utils/pipeTransport.js +84 -0
  242. package/lib/server/utils/processLauncher.js +238 -0
  243. package/lib/server/utils/profiler.js +65 -0
  244. package/lib/server/utils/socksProxy.js +511 -0
  245. package/lib/server/utils/spawnAsync.js +41 -0
  246. package/lib/server/utils/task.js +51 -0
  247. package/lib/server/utils/userAgent.js +98 -0
  248. package/lib/server/utils/wsServer.js +132 -0
  249. package/lib/server/utils/zipFile.js +74 -0
  250. package/lib/server/utils/zones.js +57 -0
  251. package/lib/server/webkit/protocol.d.js +16 -0
  252. package/lib/server/webkit/webkit.js +76 -63
  253. package/lib/server/webkit/wkAccessibility.js +161 -118
  254. package/lib/server/webkit/wkBrowser.js +163 -180
  255. package/lib/server/webkit/wkConnection.js +59 -83
  256. package/lib/server/webkit/wkExecutionContext.js +96 -73
  257. package/lib/server/webkit/wkInput.js +87 -75
  258. package/lib/server/webkit/wkInterceptableRequest.js +102 -95
  259. package/lib/server/webkit/wkPage.js +536 -647
  260. package/lib/server/webkit/wkProvisionalPage.js +45 -56
  261. package/lib/server/webkit/wkWorkers.js +77 -77
  262. package/lib/utils/isomorphic/ariaSnapshot.js +245 -128
  263. package/lib/utils/isomorphic/assert.js +31 -0
  264. package/lib/utils/isomorphic/builtins.js +90 -0
  265. package/lib/utils/isomorphic/colors.js +72 -0
  266. package/lib/utils/isomorphic/cssParser.js +123 -127
  267. package/lib/utils/isomorphic/cssTokenizer.js +436 -364
  268. package/lib/utils/isomorphic/headers.js +53 -0
  269. package/lib/utils/isomorphic/locatorGenerators.js +344 -349
  270. package/lib/utils/isomorphic/locatorParser.js +103 -106
  271. package/lib/utils/isomorphic/locatorUtils.js +63 -44
  272. package/lib/utils/isomorphic/manualPromise.js +115 -0
  273. package/lib/utils/isomorphic/mimeType.js +453 -22
  274. package/lib/utils/isomorphic/multimap.js +81 -0
  275. package/lib/utils/isomorphic/rtti.js +43 -0
  276. package/lib/utils/isomorphic/selectorParser.js +183 -193
  277. package/lib/utils/isomorphic/semaphore.js +54 -0
  278. package/lib/utils/isomorphic/stackTrace.js +158 -0
  279. package/lib/utils/isomorphic/stringUtils.js +113 -106
  280. package/lib/utils/isomorphic/time.js +44 -0
  281. package/lib/utils/isomorphic/timeoutRunner.js +67 -0
  282. package/lib/utils/isomorphic/traceUtils.js +52 -32
  283. package/lib/utils/isomorphic/types.js +16 -0
  284. package/lib/utils/isomorphic/urlMatch.js +114 -71
  285. package/lib/utils/isomorphic/utilityScriptSerializers.js +248 -0
  286. package/lib/utils.js +101 -0
  287. package/lib/utilsBundle.js +101 -76
  288. package/lib/utilsBundleImpl/index.js +114 -116
  289. package/lib/vite/htmlReport/index.html +26 -20
  290. package/lib/vite/recorder/assets/{codeMirrorModule-C5j27SYZ.js → codeMirrorModule-DVQi6prl.js} +13 -13
  291. package/lib/vite/recorder/assets/index-97EUAAbk.js +184 -0
  292. package/lib/vite/recorder/assets/{index-iA1aAGZg.css → index-eHBmevrY.css} +1 -1
  293. package/lib/vite/recorder/index.html +2 -2
  294. package/lib/vite/traceViewer/assets/codeMirrorModule-DwAiTpyC.js +24 -0
  295. package/lib/vite/traceViewer/assets/defaultSettingsView-DkkRvn5X.js +265 -0
  296. package/lib/vite/traceViewer/assets/{xtermModule-BeNbaIVa.js → xtermModule-BoAIEibi.js} +7 -7
  297. package/lib/vite/traceViewer/defaultSettingsView.QdHITyLI.css +1 -0
  298. package/lib/vite/traceViewer/index.DvtSwn6E.js +2 -0
  299. package/lib/vite/traceViewer/index.html +4 -7
  300. package/lib/vite/traceViewer/sw.bundle.js +3 -3
  301. package/lib/vite/traceViewer/{uiMode.voC1ZiOQ.css → uiMode.BatfzHMG.css} +1 -1
  302. package/lib/vite/traceViewer/uiMode.Sdytl9wc.js +5 -0
  303. package/lib/vite/traceViewer/uiMode.html +4 -7
  304. package/lib/zipBundle.js +32 -23
  305. package/lib/zipBundleImpl.js +4 -4
  306. package/package.json +7 -7
  307. package/types/protocol.d.ts +819 -127
  308. package/types/types.d.ts +181 -69
  309. package/bin/PrintDeps.exe +0 -0
  310. package/bin/README.md +0 -2
  311. package/lib/common/socksProxy.js +0 -569
  312. package/lib/common/timeoutSettings.js +0 -73
  313. package/lib/common/types.js +0 -5
  314. package/lib/image_tools/colorUtils.js +0 -98
  315. package/lib/image_tools/imageChannel.js +0 -70
  316. package/lib/protocol/transport.js +0 -82
  317. package/lib/server/ariaSnapshot.js +0 -33
  318. package/lib/server/isomorphic/utilityScriptSerializers.js +0 -226
  319. package/lib/server/recorder/recorderInTraceViewer.js +0 -144
  320. package/lib/utils/ascii.js +0 -31
  321. package/lib/utils/comparators.js +0 -153
  322. package/lib/utils/crypto.js +0 -171
  323. package/lib/utils/debug.js +0 -46
  324. package/lib/utils/debugLogger.js +0 -91
  325. package/lib/utils/env.js +0 -49
  326. package/lib/utils/eventsHelper.js +0 -38
  327. package/lib/utils/expectUtils.js +0 -33
  328. package/lib/utils/fileUtils.js +0 -205
  329. package/lib/utils/happy-eyeballs.js +0 -194
  330. package/lib/utils/headers.js +0 -52
  331. package/lib/utils/hostPlatform.js +0 -139
  332. package/lib/utils/httpServer.js +0 -237
  333. package/lib/utils/index.js +0 -368
  334. package/lib/utils/isomorphic/recorderUtils.js +0 -227
  335. package/lib/utils/linuxUtils.js +0 -78
  336. package/lib/utils/manualPromise.js +0 -109
  337. package/lib/utils/multimap.js +0 -75
  338. package/lib/utils/network.js +0 -160
  339. package/lib/utils/processLauncher.js +0 -248
  340. package/lib/utils/profiler.js +0 -53
  341. package/lib/utils/rtti.js +0 -44
  342. package/lib/utils/semaphore.js +0 -51
  343. package/lib/utils/sequence.js +0 -64
  344. package/lib/utils/spawnAsync.js +0 -45
  345. package/lib/utils/stackTrace.js +0 -134
  346. package/lib/utils/task.js +0 -58
  347. package/lib/utils/time.js +0 -37
  348. package/lib/utils/timeoutRunner.js +0 -66
  349. package/lib/utils/traceUtils.js +0 -44
  350. package/lib/utils/userAgent.js +0 -105
  351. package/lib/utils/wsServer.js +0 -127
  352. package/lib/utils/zipFile.js +0 -75
  353. package/lib/utils/zones.js +0 -71
  354. package/lib/vite/recorder/assets/index-m0XdVJHe.js +0 -184
  355. package/lib/vite/traceViewer/assets/codeMirrorModule-BBCX0spr.js +0 -24
  356. package/lib/vite/traceViewer/assets/inspectorTab-B4Iw34Ow.js +0 -68
  357. package/lib/vite/traceViewer/assets/testServerConnection-DeE2kSzz.js +0 -1
  358. package/lib/vite/traceViewer/assets/workbench-DFlGYqou.js +0 -9
  359. package/lib/vite/traceViewer/embedded.CmarehFk.js +0 -2
  360. package/lib/vite/traceViewer/embedded.html +0 -18
  361. package/lib/vite/traceViewer/embedded.w7WN2u1R.css +0 -1
  362. package/lib/vite/traceViewer/index.FBucu_gE.js +0 -2
  363. package/lib/vite/traceViewer/inspectorTab.DEOUW62d.css +0 -1
  364. package/lib/vite/traceViewer/recorder.B_SY1GJM.css +0 -0
  365. package/lib/vite/traceViewer/recorder.CW_rzcEp.js +0 -2
  366. package/lib/vite/traceViewer/recorder.html +0 -17
  367. package/lib/vite/traceViewer/uiMode.CDUVjusr.js +0 -5
  368. package/lib/vite/traceViewer/workbench.C-zR9ysA.css +0 -1
  369. /package/lib/vite/recorder/assets/{codeMirrorModule-ez37Vkbh.css → codeMirrorModule-C3UTv-Ge.css} +0 -0
  370. /package/lib/vite/traceViewer/{codeMirrorModule.ez37Vkbh.css → codeMirrorModule.C3UTv-Ge.css} +0 -0
  371. /package/lib/vite/traceViewer/{index.CrbWWHbf.css → index.CFOW-Ezb.css} +0 -0
  372. /package/lib/vite/traceViewer/{xtermModule.DSXBckUd.css → xtermModule.Beg8tuEN.css} +0 -0
package/lib/server/dom.js CHANGED
@@ -1,86 +1,84 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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 dom_exports = {};
30
+ __export(dom_exports, {
31
+ ElementHandle: () => ElementHandle,
32
+ FrameExecutionContext: () => FrameExecutionContext,
33
+ NonRecoverableDOMError: () => NonRecoverableDOMError,
34
+ assertDone: () => assertDone,
35
+ isNonRecoverableDOMError: () => isNonRecoverableDOMError,
36
+ kUnableToAdoptErrorMessage: () => kUnableToAdoptErrorMessage,
37
+ throwElementIsNotAttached: () => throwElementIsNotAttached,
38
+ throwRetargetableDOMError: () => throwRetargetableDOMError
5
39
  });
6
- exports.NonRecoverableDOMError = exports.FrameExecutionContext = exports.ElementHandle = void 0;
7
- exports.assertDone = assertDone;
8
- exports.isNonRecoverableDOMError = isNonRecoverableDOMError;
9
- exports.kUnableToAdoptErrorMessage = void 0;
10
- exports.throwRetargetableDOMError = throwRetargetableDOMError;
11
- var _fs = _interopRequireDefault(require("fs"));
12
- var injectedScriptSource = _interopRequireWildcard(require("../generated/injectedScriptSource"));
13
- var _protocolError = require("./protocolError");
14
- var js = _interopRequireWildcard(require("./javascript"));
15
- var _progress = require("./progress");
16
- var _utils = require("../utils");
17
- var _fileUploadUtils = require("./fileUploadUtils");
18
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
19
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
- /**
22
- * Copyright (c) Microsoft Corporation.
23
- *
24
- * Licensed under the Apache License, Version 2.0 (the "License");
25
- * you may not use this file except in compliance with the License.
26
- * You may obtain a copy of the License at
27
- *
28
- * http://www.apache.org/licenses/LICENSE-2.0
29
- *
30
- * Unless required by applicable law or agreed to in writing, software
31
- * distributed under the License is distributed on an "AS IS" BASIS,
32
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33
- * See the License for the specific language governing permissions and
34
- * limitations under the License.
35
- */
36
-
37
- class NonRecoverableDOMError extends Error {}
38
- exports.NonRecoverableDOMError = NonRecoverableDOMError;
40
+ module.exports = __toCommonJS(dom_exports);
41
+ var import_fs = __toESM(require("fs"));
42
+ var js = __toESM(require("./javascript"));
43
+ var import_progress = require("./progress");
44
+ var import_utils = require("../utils");
45
+ var import_fileUploadUtils = require("./fileUploadUtils");
46
+ var import_protocolError = require("./protocolError");
47
+ var injectedScriptSource = __toESM(require("../generated/injectedScriptSource"));
48
+ class NonRecoverableDOMError extends Error {
49
+ }
39
50
  function isNonRecoverableDOMError(error) {
40
51
  return error instanceof NonRecoverableDOMError;
41
52
  }
42
53
  class FrameExecutionContext extends js.ExecutionContext {
43
54
  constructor(delegate, frame, world) {
44
- super(frame, delegate, world || 'content-script');
45
- this.frame = void 0;
46
- this._injectedScriptPromise = void 0;
47
- this.world = void 0;
55
+ super(frame, delegate, world || "content-script");
48
56
  this.frame = frame;
49
57
  this.world = world;
50
58
  }
51
59
  adoptIfNeeded(handle) {
52
- if (handle instanceof ElementHandle && handle._context !== this) return this.frame._page._delegate.adoptElementHandle(handle, this);
60
+ if (handle instanceof ElementHandle && handle._context !== this)
61
+ return this.frame._page._delegate.adoptElementHandle(handle, this);
53
62
  return null;
54
63
  }
55
64
  async evaluate(pageFunction, arg) {
56
- return js.evaluate(this, true /* returnByValue */, pageFunction, arg);
65
+ return js.evaluate(this, true, pageFunction, arg);
57
66
  }
58
67
  async evaluateHandle(pageFunction, arg) {
59
- return js.evaluate(this, false /* returnByValue */, pageFunction, arg);
68
+ return js.evaluate(this, false, pageFunction, arg);
60
69
  }
61
70
  async evaluateExpression(expression, options, arg) {
62
- return js.evaluateExpression(this, expression, {
63
- ...options,
64
- returnByValue: true
65
- }, arg);
71
+ return js.evaluateExpression(this, expression, { ...options, returnByValue: true }, arg);
66
72
  }
67
73
  async evaluateExpressionHandle(expression, options, arg) {
68
- return js.evaluateExpression(this, expression, {
69
- ...options,
70
- returnByValue: false
71
- }, arg);
72
- }
73
- createHandle(remoteObject) {
74
- if (this.frame._page._delegate.isElementHandle(remoteObject)) return new ElementHandle(this, remoteObject.objectId);
75
- return super.createHandle(remoteObject);
74
+ return js.evaluateExpression(this, expression, { ...options, returnByValue: false }, arg);
76
75
  }
77
76
  injectedScript() {
78
77
  if (!this._injectedScriptPromise) {
79
78
  const custom = [];
80
79
  const selectorsRegistry = this.frame._page.context().selectors();
81
- for (const [name, {
82
- source
83
- }] of selectorsRegistry._engines) custom.push(`{ name: '${name}', engine: (${source}) }`);
80
+ for (const [name, { source: source2 }] of selectorsRegistry._engines)
81
+ custom.push(`{ name: '${name}', engine: (${source2}) }`);
84
82
  const sdkLanguage = this.frame.attribution.playwright.options.sdkLanguage;
85
83
  const source = `
86
84
  (() => {
@@ -88,34 +86,36 @@ class FrameExecutionContext extends js.ExecutionContext {
88
86
  ${injectedScriptSource.source}
89
87
  return new (module.exports.InjectedScript())(
90
88
  globalThis,
91
- ${(0, _utils.isUnderTest)()},
89
+ ${(0, import_utils.isUnderTest)()},
92
90
  "${sdkLanguage}",
93
91
  ${JSON.stringify(selectorsRegistry.testIdAttributeName())},
94
92
  ${this.frame._page._delegate.rafCountForStablePosition()},
95
93
  "${this.frame._page._browserContext._browser.options.name}",
96
- [${custom.join(',\n')}]
94
+ ${process.env.PLAYWRIGHT_INPUT_FILE_TEXTBOX ? "true" : "false"},
95
+ [${custom.join(",\n")}]
97
96
  );
98
97
  })();
99
98
  `;
100
- this._injectedScriptPromise = this.rawEvaluateHandle(source).then(objectId => new js.JSHandle(this, 'object', 'InjectedScript', objectId));
99
+ this._injectedScriptPromise = this.rawEvaluateHandle(source).then((handle) => {
100
+ handle._setPreview("InjectedScript");
101
+ return handle;
102
+ });
101
103
  }
102
104
  return this._injectedScriptPromise;
103
105
  }
104
106
  }
105
- exports.FrameExecutionContext = FrameExecutionContext;
106
107
  class ElementHandle extends js.JSHandle {
107
108
  constructor(context, objectId) {
108
- super(context, 'node', undefined, objectId);
109
+ super(context, "node", void 0, objectId);
109
110
  this.__elementhandle = true;
110
- this._page = void 0;
111
- this._frame = void 0;
112
111
  this._page = context.frame._page;
113
112
  this._frame = context.frame;
114
- this._initializePreview().catch(e => {});
113
+ this._initializePreview().catch((e) => {
114
+ });
115
115
  }
116
116
  async _initializePreview() {
117
117
  const utility = await this._context.injectedScript();
118
- this._setPreview(await utility.evaluate((injected, e) => 'JSHandle@' + injected.previewNode(e), this));
118
+ this._setPreview(await utility.evaluate((injected, e) => "JSHandle@" + injected.previewNode(e), this));
119
119
  }
120
120
  asElement() {
121
121
  return this;
@@ -125,8 +125,9 @@ class ElementHandle extends js.JSHandle {
125
125
  const utility = await this._frame._utilityContext();
126
126
  return await utility.evaluate(pageFunction, [await utility.injectedScript(), this, arg]);
127
127
  } catch (e) {
128
- if (js.isJavaScriptErrorInEvaluate(e) || (0, _protocolError.isSessionClosedError)(e)) throw e;
129
- return 'error:notconnected';
128
+ if (js.isJavaScriptErrorInEvaluate(e) || (0, import_protocolError.isSessionClosedError)(e))
129
+ throw e;
130
+ return "error:notconnected";
130
131
  }
131
132
  }
132
133
  async evaluateHandleInUtility(pageFunction, arg) {
@@ -134,79 +135,94 @@ class ElementHandle extends js.JSHandle {
134
135
  const utility = await this._frame._utilityContext();
135
136
  return await utility.evaluateHandle(pageFunction, [await utility.injectedScript(), this, arg]);
136
137
  } catch (e) {
137
- if (js.isJavaScriptErrorInEvaluate(e) || (0, _protocolError.isSessionClosedError)(e)) throw e;
138
- return 'error:notconnected';
138
+ if (js.isJavaScriptErrorInEvaluate(e) || (0, import_protocolError.isSessionClosedError)(e))
139
+ throw e;
140
+ return "error:notconnected";
139
141
  }
140
142
  }
141
143
  async ownerFrame() {
142
144
  const frameId = await this._page._delegate.getOwnerFrame(this);
143
- if (!frameId) return null;
145
+ if (!frameId)
146
+ return null;
144
147
  const frame = this._page._frameManager.frame(frameId);
145
- if (frame) return frame;
148
+ if (frame)
149
+ return frame;
146
150
  for (const page of this._page._browserContext.pages()) {
147
- const frame = page._frameManager.frame(frameId);
148
- if (frame) return frame;
151
+ const frame2 = page._frameManager.frame(frameId);
152
+ if (frame2)
153
+ return frame2;
149
154
  }
150
155
  return null;
151
156
  }
152
157
  async isIframeElement() {
153
- return this.evaluateInUtility(([injected, node]) => node && (node.nodeName === 'IFRAME' || node.nodeName === 'FRAME'), {});
158
+ return this.evaluateInUtility(([injected, node]) => node && (node.nodeName === "IFRAME" || node.nodeName === "FRAME"), {});
154
159
  }
155
160
  async contentFrame() {
156
161
  const isFrameElement = throwRetargetableDOMError(await this.isIframeElement());
157
- if (!isFrameElement) return null;
162
+ if (!isFrameElement)
163
+ return null;
158
164
  return this._page._delegate.getContentFrame(this);
159
165
  }
166
+ async generateLocatorString() {
167
+ const selector = await this.evaluateInUtility(async ([injected, node]) => {
168
+ return injected.generateSelectorSimple(node);
169
+ }, {});
170
+ if (selector === "error:notconnected")
171
+ return;
172
+ return (0, import_utils.asLocator)("javascript", selector);
173
+ }
160
174
  async getAttribute(metadata, name) {
161
- return this._frame.getAttribute(metadata, ':scope', name, {}, this);
175
+ return this._frame.getAttribute(metadata, ":scope", name, {}, this);
162
176
  }
163
177
  async inputValue(metadata) {
164
- return this._frame.inputValue(metadata, ':scope', {}, this);
178
+ return this._frame.inputValue(metadata, ":scope", {}, this);
165
179
  }
166
180
  async textContent(metadata) {
167
- return this._frame.textContent(metadata, ':scope', {}, this);
181
+ return this._frame.textContent(metadata, ":scope", {}, this);
168
182
  }
169
183
  async innerText(metadata) {
170
- return this._frame.innerText(metadata, ':scope', {}, this);
184
+ return this._frame.innerText(metadata, ":scope", {}, this);
171
185
  }
172
186
  async innerHTML(metadata) {
173
- return this._frame.innerHTML(metadata, ':scope', {}, this);
187
+ return this._frame.innerHTML(metadata, ":scope", {}, this);
174
188
  }
175
189
  async dispatchEvent(metadata, type, eventInit = {}) {
176
- return this._frame.dispatchEvent(metadata, ':scope', type, eventInit, {}, this);
190
+ return this._frame.dispatchEvent(metadata, ":scope", type, eventInit, {}, this);
177
191
  }
178
192
  async _scrollRectIntoViewIfNeeded(rect) {
179
193
  return await this._page._delegate.scrollRectIntoViewIfNeeded(this, rect);
180
194
  }
181
195
  async _waitAndScrollIntoViewIfNeeded(progress, waitForVisible) {
182
- const result = await this._retryAction(progress, 'scroll into view', async () => {
196
+ const result = await this._retryAction(progress, "scroll into view", async () => {
183
197
  progress.log(` waiting for element to be stable`);
184
- const waitResult = await this.evaluateInUtility(async ([injected, node, {
185
- waitForVisible
186
- }]) => {
187
- return await injected.checkElementStates(node, waitForVisible ? ['visible', 'stable'] : ['stable']);
188
- }, {
189
- waitForVisible
190
- });
191
- if (waitResult) return waitResult;
198
+ const waitResult = await this.evaluateInUtility(async ([injected, node, { waitForVisible: waitForVisible2 }]) => {
199
+ return await injected.checkElementStates(node, waitForVisible2 ? ["visible", "stable"] : ["stable"]);
200
+ }, { waitForVisible });
201
+ if (waitResult)
202
+ return waitResult;
192
203
  return await this._scrollRectIntoViewIfNeeded();
193
204
  }, {});
194
205
  assertDone(throwRetargetableDOMError(result));
195
206
  }
196
207
  async scrollIntoViewIfNeeded(metadata, options = {}) {
197
- const controller = new _progress.ProgressController(metadata, this);
198
- return controller.run(progress => this._waitAndScrollIntoViewIfNeeded(progress, false /* waitForVisible */), this._page._timeoutSettings.timeout(options));
208
+ const controller = new import_progress.ProgressController(metadata, this);
209
+ return controller.run(
210
+ (progress) => this._waitAndScrollIntoViewIfNeeded(
211
+ progress,
212
+ false
213
+ /* waitForVisible */
214
+ ),
215
+ this._page._timeoutSettings.timeout(options)
216
+ );
199
217
  }
200
218
  async _clickablePoint() {
201
- const intersectQuadWithViewport = quad => {
202
- return quad.map(point => ({
219
+ const intersectQuadWithViewport = (quad) => {
220
+ return quad.map((point) => ({
203
221
  x: Math.min(Math.max(point.x, 0), metrics.width),
204
222
  y: Math.min(Math.max(point.y, 0), metrics.height)
205
223
  }));
206
224
  };
207
- const computeQuadArea = quad => {
208
- // Compute sum of all directed areas of adjacent triangles
209
- // https://en.wikipedia.org/wiki/Polygon#Simple_polygons
225
+ const computeQuadArea = (quad) => {
210
226
  let area = 0;
211
227
  for (let i = 0; i < quad.length; ++i) {
212
228
  const p1 = quad[i];
@@ -215,37 +231,36 @@ class ElementHandle extends js.JSHandle {
215
231
  }
216
232
  return Math.abs(area);
217
233
  };
218
- const [quads, metrics] = await Promise.all([this._page._delegate.getContentQuads(this), this._page.mainFrame()._utilityContext().then(utility => utility.evaluate(() => ({
219
- width: innerWidth,
220
- height: innerHeight
221
- })))]);
222
- if (quads === 'error:notconnected') return quads;
223
- if (!quads || !quads.length) return 'error:notvisible';
224
-
225
- // Allow 1x1 elements. Compensate for rounding errors by comparing with 0.99 instead.
226
- const filtered = quads.map(quad => intersectQuadWithViewport(quad)).filter(quad => computeQuadArea(quad) > 0.99);
227
- if (!filtered.length) return 'error:notinviewport';
228
- if (this._page._browserContext._browser.options.name === 'firefox') {
229
- // Firefox internally uses integer coordinates, so 8.x is converted to 8 or 9 when clicking.
230
- //
231
- // This does not work nicely for small elements. For example, 1x1 square with corners
232
- // (8;8) and (9;9) is targeted when clicking at (8;8) but not when clicking at (9;9).
233
- // So, clicking at (8.x;8.y) will sometimes click at (9;9) and miss the target.
234
- //
235
- // Therefore, we try to find an integer point within a quad to make sure we click inside the element.
234
+ const [quads, metrics] = await Promise.all([
235
+ this._page._delegate.getContentQuads(this),
236
+ this._page.mainFrame()._utilityContext().then((utility) => utility.evaluate(() => ({ width: innerWidth, height: innerHeight })))
237
+ ]);
238
+ if (quads === "error:notconnected")
239
+ return quads;
240
+ if (!quads || !quads.length)
241
+ return "error:notvisible";
242
+ const filtered = quads.map((quad) => intersectQuadWithViewport(quad)).filter((quad) => computeQuadArea(quad) > 0.99);
243
+ if (!filtered.length)
244
+ return "error:notinviewport";
245
+ if (this._page._browserContext._browser.options.name === "firefox") {
236
246
  for (const quad of filtered) {
237
247
  const integerPoint = findIntegerPointInsideQuad(quad);
238
- if (integerPoint) return integerPoint;
248
+ if (integerPoint)
249
+ return integerPoint;
239
250
  }
240
251
  }
241
- // Return the middle point of the first quad.
242
252
  return quadMiddlePoint(filtered[0]);
243
253
  }
244
254
  async _offsetPoint(offset) {
245
- const [box, border] = await Promise.all([this.boundingBox(), this.evaluateInUtility(([injected, node]) => injected.getElementBorderWidth(node), {}).catch(e => {})]);
246
- if (!box || !border) return 'error:notvisible';
247
- if (border === 'error:notconnected') return border;
248
- // Make point relative to the padding box to align with offsetX/offsetY.
255
+ const [box, border] = await Promise.all([
256
+ this.boundingBox(),
257
+ this.evaluateInUtility(([injected, node]) => injected.getElementBorderWidth(node), {}).catch((e) => {
258
+ })
259
+ ]);
260
+ if (!box || !border)
261
+ return "error:notvisible";
262
+ if (border === "error:notconnected")
263
+ return border;
249
264
  return {
250
265
  x: box.x + border.left + offset.x,
251
266
  y: box.y + border.top + offset.y
@@ -253,122 +268,105 @@ class ElementHandle extends js.JSHandle {
253
268
  }
254
269
  async _retryAction(progress, actionName, action, options) {
255
270
  let retry = 0;
256
- // We progressively wait longer between retries, up to 500ms.
257
271
  const waitTime = [0, 20, 100, 100, 500];
258
272
  while (progress.isRunning()) {
259
273
  if (retry) {
260
- progress.log(`retrying ${actionName} action${options.trial ? ' (trial run)' : ''}`);
274
+ progress.log(`retrying ${actionName} action${options.trial ? " (trial run)" : ""}`);
261
275
  const timeout = waitTime[Math.min(retry - 1, waitTime.length - 1)];
262
276
  if (timeout) {
263
277
  progress.log(` waiting ${timeout}ms`);
264
- const result = await this.evaluateInUtility(([injected, node, timeout]) => new Promise(f => setTimeout(f, timeout)), timeout);
265
- if (result === 'error:notconnected') return result;
278
+ const result2 = await this.evaluateInUtility(([injected, node, timeout2]) => new Promise((f) => setTimeout(f, timeout2)), timeout);
279
+ if (result2 === "error:notconnected")
280
+ return result2;
266
281
  }
267
282
  } else {
268
- progress.log(`attempting ${actionName} action${options.trial ? ' (trial run)' : ''}`);
283
+ progress.log(`attempting ${actionName} action${options.trial ? " (trial run)" : ""}`);
269
284
  }
270
- if (!options.skipActionPreChecks && !options.force) await this._frame._page.performActionPreChecks(progress);
285
+ if (!options.skipActionPreChecks && !options.force)
286
+ await this._frame._page.performActionPreChecks(progress);
271
287
  const result = await action(retry);
272
288
  ++retry;
273
- if (result === 'error:notvisible') {
274
- if (options.force) throw new NonRecoverableDOMError('Element is not visible');
275
- progress.log(' element is not visible');
289
+ if (result === "error:notvisible") {
290
+ if (options.force)
291
+ throw new NonRecoverableDOMError("Element is not visible");
292
+ progress.log(" element is not visible");
276
293
  continue;
277
294
  }
278
- if (result === 'error:notinviewport') {
279
- if (options.force) throw new NonRecoverableDOMError('Element is outside of the viewport');
280
- progress.log(' element is outside of the viewport');
295
+ if (result === "error:notinviewport") {
296
+ if (options.force)
297
+ throw new NonRecoverableDOMError("Element is outside of the viewport");
298
+ progress.log(" element is outside of the viewport");
281
299
  continue;
282
300
  }
283
- if (result === 'error:optionsnotfound') {
284
- progress.log(' did not find some options');
301
+ if (result === "error:optionsnotfound") {
302
+ progress.log(" did not find some options");
285
303
  continue;
286
304
  }
287
- if (typeof result === 'object' && 'hitTargetDescription' in result) {
305
+ if (typeof result === "object" && "hitTargetDescription" in result) {
288
306
  progress.log(` ${result.hitTargetDescription} intercepts pointer events`);
289
307
  continue;
290
308
  }
291
- if (typeof result === 'object' && 'missingState' in result) {
309
+ if (typeof result === "object" && "missingState" in result) {
292
310
  progress.log(` element is not ${result.missingState}`);
293
311
  continue;
294
312
  }
295
313
  return result;
296
314
  }
297
- return 'done';
315
+ return "done";
298
316
  }
299
317
  async _retryPointerAction(progress, actionName, waitForEnabled, action, options) {
300
- // Note: do not perform locator handlers checkpoint to avoid moving the mouse in the middle of a drag operation.
301
- const skipActionPreChecks = actionName === 'move and up';
302
- return await this._retryAction(progress, actionName, async retry => {
303
- // By default, we scroll with protocol method to reveal the action point.
304
- // However, that might not work to scroll from under position:sticky elements
305
- // that overlay the target element. To fight this, we cycle through different
306
- // scroll alignments. This works in most scenarios.
307
- const scrollOptions = [undefined, {
308
- block: 'end',
309
- inline: 'end'
310
- }, {
311
- block: 'center',
312
- inline: 'center'
313
- }, {
314
- block: 'start',
315
- inline: 'start'
316
- }];
318
+ const skipActionPreChecks = actionName === "move and up";
319
+ return await this._retryAction(progress, actionName, async (retry) => {
320
+ const scrollOptions = [
321
+ void 0,
322
+ { block: "end", inline: "end" },
323
+ { block: "center", inline: "center" },
324
+ { block: "start", inline: "start" }
325
+ ];
317
326
  const forceScrollOptions = scrollOptions[retry % scrollOptions.length];
318
327
  return await this._performPointerAction(progress, actionName, waitForEnabled, action, forceScrollOptions, options);
319
- }, {
320
- ...options,
321
- skipActionPreChecks
322
- });
328
+ }, { ...options, skipActionPreChecks });
323
329
  }
324
330
  async _performPointerAction(progress, actionName, waitForEnabled, action, forceScrollOptions, options) {
325
- const {
326
- force = false,
327
- position
328
- } = options;
331
+ const { force = false, position } = options;
329
332
  const doScrollIntoView = async () => {
330
333
  if (forceScrollOptions) {
331
- return await this.evaluateInUtility(([injected, node, options]) => {
332
- if (node.nodeType === 1 /* Node.ELEMENT_NODE */) node.scrollIntoView(options);
333
- return 'done';
334
+ return await this.evaluateInUtility(([injected, node, options2]) => {
335
+ if (node.nodeType === 1)
336
+ node.scrollIntoView(options2);
337
+ return "done";
334
338
  }, forceScrollOptions);
335
339
  }
336
- return await this._scrollRectIntoViewIfNeeded(position ? {
337
- x: position.x,
338
- y: position.y,
339
- width: 0,
340
- height: 0
341
- } : undefined);
340
+ return await this._scrollRectIntoViewIfNeeded(position ? { x: position.x, y: position.y, width: 0, height: 0 } : void 0);
342
341
  };
343
342
  if (this._frame.parentFrame()) {
344
- // Best-effort scroll to make sure any iframes containing this element are scrolled
345
- // into view and visible, so they are not throttled.
346
- // See https://github.com/microsoft/playwright/issues/27196 for an example.
347
- progress.throwIfAborted(); // Avoid action that has side-effects.
348
- await doScrollIntoView().catch(() => {});
343
+ progress.throwIfAborted();
344
+ await doScrollIntoView().catch(() => {
345
+ });
349
346
  }
350
- if (options.__testHookBeforeStable) await options.__testHookBeforeStable();
347
+ if (options.__testHookBeforeStable)
348
+ await options.__testHookBeforeStable();
351
349
  if (!force) {
352
- const elementStates = waitForEnabled ? ['visible', 'enabled', 'stable'] : ['visible', 'stable'];
353
- progress.log(` waiting for element to be ${waitForEnabled ? 'visible, enabled and stable' : 'visible and stable'}`);
354
- const result = await this.evaluateInUtility(async ([injected, node, {
355
- elementStates
356
- }]) => {
357
- return await injected.checkElementStates(node, elementStates);
358
- }, {
359
- elementStates
360
- });
361
- if (result) return result;
362
- progress.log(` element is ${waitForEnabled ? 'visible, enabled and stable' : 'visible and stable'}`);
350
+ const elementStates = waitForEnabled ? ["visible", "enabled", "stable"] : ["visible", "stable"];
351
+ progress.log(` waiting for element to be ${waitForEnabled ? "visible, enabled and stable" : "visible and stable"}`);
352
+ const result = await this.evaluateInUtility(async ([injected, node, { elementStates: elementStates2 }]) => {
353
+ return await injected.checkElementStates(node, elementStates2);
354
+ }, { elementStates });
355
+ if (result)
356
+ return result;
357
+ progress.log(` element is ${waitForEnabled ? "visible, enabled and stable" : "visible and stable"}`);
363
358
  }
364
- if (options.__testHookAfterStable) await options.__testHookAfterStable();
365
- progress.log(' scrolling into view if needed');
366
- progress.throwIfAborted(); // Avoid action that has side-effects.
359
+ if (options.__testHookAfterStable)
360
+ await options.__testHookAfterStable();
361
+ progress.log(" scrolling into view if needed");
362
+ progress.throwIfAborted();
367
363
  const scrolled = await doScrollIntoView();
368
- if (scrolled !== 'done') return scrolled;
369
- progress.log(' done scrolling');
364
+ if (scrolled !== "done")
365
+ return scrolled;
366
+ progress.log(" done scrolling");
370
367
  const maybePoint = position ? await this._offsetPoint(position) : await this._clickablePoint();
371
- if (typeof maybePoint === 'string') return maybePoint;
368
+ if (typeof maybePoint === "string")
369
+ return maybePoint;
372
370
  const point = roundPoint(maybePoint);
373
371
  progress.metadata.point = point;
374
372
  await this.instrumentation.onBeforeInputAction(this, progress.metadata);
@@ -376,132 +374,118 @@ class ElementHandle extends js.JSHandle {
376
374
  if (force) {
377
375
  progress.log(` forcing action`);
378
376
  } else {
379
- if (options.__testHookBeforeHitTarget) await options.__testHookBeforeHitTarget();
377
+ if (options.__testHookBeforeHitTarget)
378
+ await options.__testHookBeforeHitTarget();
380
379
  const frameCheckResult = await this._checkFrameIsHitTarget(point);
381
- if (frameCheckResult === 'error:notconnected' || 'hitTargetDescription' in frameCheckResult) return frameCheckResult;
380
+ if (frameCheckResult === "error:notconnected" || "hitTargetDescription" in frameCheckResult)
381
+ return frameCheckResult;
382
382
  const hitPoint = frameCheckResult.framePoint;
383
- const actionType = actionName === 'move and up' ? 'drag' : actionName === 'hover' || actionName === 'tap' ? actionName : 'mouse';
384
- const handle = await this.evaluateHandleInUtility(([injected, node, {
385
- actionType,
386
- hitPoint,
387
- trial
388
- }]) => injected.setupHitTargetInterceptor(node, actionType, hitPoint, trial), {
389
- actionType,
390
- hitPoint,
391
- trial: !!options.trial
392
- });
393
- if (handle === 'error:notconnected') return handle;
383
+ const actionType = actionName === "move and up" ? "drag" : actionName === "hover" || actionName === "tap" ? actionName : "mouse";
384
+ const handle = await this.evaluateHandleInUtility(([injected, node, { actionType: actionType2, hitPoint: hitPoint2, trial }]) => injected.setupHitTargetInterceptor(node, actionType2, hitPoint2, trial), { actionType, hitPoint, trial: !!options.trial });
385
+ if (handle === "error:notconnected")
386
+ return handle;
394
387
  if (!handle._objectId) {
395
388
  const error = handle.rawValue();
396
- if (error === 'error:notconnected') return error;
397
- return {
398
- hitTargetDescription: error
399
- };
389
+ if (error === "error:notconnected")
390
+ return error;
391
+ return { hitTargetDescription: error };
400
392
  }
401
393
  hitTargetInterceptionHandle = handle;
402
394
  progress.cleanupWhenAborted(() => {
403
- // Do not await here, just in case the renderer is stuck (e.g. on alert)
404
- // and we won't be able to cleanup.
405
- hitTargetInterceptionHandle.evaluate(h => h.stop()).catch(e => {});
395
+ hitTargetInterceptionHandle.evaluate((h) => h.stop()).catch((e) => {
396
+ });
406
397
  hitTargetInterceptionHandle.dispose();
407
398
  });
408
399
  }
409
400
  const actionResult = await this._page._frameManager.waitForSignalsCreatedBy(progress, options.waitAfter === true, async () => {
410
- if (options.__testHookBeforePointerAction) await options.__testHookBeforePointerAction();
411
- progress.throwIfAborted(); // Avoid action that has side-effects.
401
+ if (options.__testHookBeforePointerAction)
402
+ await options.__testHookBeforePointerAction();
403
+ progress.throwIfAborted();
412
404
  let restoreModifiers;
413
- if (options && options.modifiers) restoreModifiers = await this._page.keyboard.ensureModifiers(options.modifiers);
405
+ if (options && options.modifiers)
406
+ restoreModifiers = await this._page.keyboard.ensureModifiers(options.modifiers);
414
407
  progress.log(` performing ${actionName} action`);
415
408
  await action(point);
416
- if (restoreModifiers) await this._page.keyboard.ensureModifiers(restoreModifiers);
409
+ if (restoreModifiers)
410
+ await this._page.keyboard.ensureModifiers(restoreModifiers);
417
411
  if (hitTargetInterceptionHandle) {
418
412
  const stopHitTargetInterception = this._frame.raceAgainstEvaluationStallingEvents(() => {
419
- return hitTargetInterceptionHandle.evaluate(h => h.stop());
420
- }).catch(e => 'done').finally(() => {
421
- var _hitTargetInterceptio;
422
- (_hitTargetInterceptio = hitTargetInterceptionHandle) === null || _hitTargetInterceptio === void 0 || _hitTargetInterceptio.dispose();
413
+ return hitTargetInterceptionHandle.evaluate((h) => h.stop());
414
+ }).catch((e) => "done").finally(() => {
415
+ hitTargetInterceptionHandle?.dispose();
423
416
  });
424
417
  if (options.waitAfter !== false) {
425
- // When noWaitAfter is passed, we do not want to accidentally stall on
426
- // non-committed navigation blocking the evaluate.
427
418
  const hitTargetResult = await stopHitTargetInterception;
428
- if (hitTargetResult !== 'done') return hitTargetResult;
419
+ if (hitTargetResult !== "done")
420
+ return hitTargetResult;
429
421
  }
430
422
  }
431
- progress.log(` ${options.trial ? 'trial ' : ''}${actionName} action done`);
432
- progress.log(' waiting for scheduled navigations to finish');
433
- if (options.__testHookAfterPointerAction) await options.__testHookAfterPointerAction();
434
- return 'done';
423
+ progress.log(` ${options.trial ? "trial " : ""}${actionName} action done`);
424
+ progress.log(" waiting for scheduled navigations to finish");
425
+ if (options.__testHookAfterPointerAction)
426
+ await options.__testHookAfterPointerAction();
427
+ return "done";
435
428
  });
436
- if (actionResult !== 'done') return actionResult;
437
- progress.log(' navigations have finished');
438
- return 'done';
429
+ if (actionResult !== "done")
430
+ return actionResult;
431
+ progress.log(" navigations have finished");
432
+ return "done";
439
433
  }
440
434
  async _markAsTargetElement(metadata) {
441
- if (!metadata.id) return;
435
+ if (!metadata.id)
436
+ return;
442
437
  await this.evaluateInUtility(([injected, node, callId]) => {
443
- if (node.nodeType === 1 /* Node.ELEMENT_NODE */) injected.markTargetElements(new Set([node]), callId);
438
+ if (node.nodeType === 1)
439
+ injected.markTargetElements(/* @__PURE__ */ new Set([node]), callId);
444
440
  }, metadata.id);
445
441
  }
446
442
  async hover(metadata, options) {
447
- const controller = new _progress.ProgressController(metadata, this);
448
- return controller.run(async progress => {
443
+ const controller = new import_progress.ProgressController(metadata, this);
444
+ return controller.run(async (progress) => {
449
445
  await this._markAsTargetElement(metadata);
450
446
  const result = await this._hover(progress, options);
451
447
  return assertDone(throwRetargetableDOMError(result));
452
448
  }, this._page._timeoutSettings.timeout(options));
453
449
  }
454
450
  _hover(progress, options) {
455
- return this._retryPointerAction(progress, 'hover', false /* waitForEnabled */, point => this._page.mouse.move(point.x, point.y), {
456
- ...options,
457
- waitAfter: 'disabled'
458
- });
451
+ return this._retryPointerAction(progress, "hover", false, (point) => this._page.mouse.move(point.x, point.y), { ...options, waitAfter: "disabled" });
459
452
  }
460
453
  async click(metadata, options = {}) {
461
- const controller = new _progress.ProgressController(metadata, this);
462
- return controller.run(async progress => {
454
+ const controller = new import_progress.ProgressController(metadata, this);
455
+ return controller.run(async (progress) => {
463
456
  await this._markAsTargetElement(metadata);
464
- const result = await this._click(progress, {
465
- ...options,
466
- waitAfter: !options.noWaitAfter
467
- });
457
+ const result = await this._click(progress, { ...options, waitAfter: !options.noWaitAfter });
468
458
  return assertDone(throwRetargetableDOMError(result));
469
459
  }, this._page._timeoutSettings.timeout(options));
470
460
  }
471
461
  _click(progress, options) {
472
- return this._retryPointerAction(progress, 'click', true /* waitForEnabled */, point => this._page.mouse.click(point.x, point.y, options), options);
462
+ return this._retryPointerAction(progress, "click", true, (point) => this._page.mouse.click(point.x, point.y, options), options);
473
463
  }
474
464
  async dblclick(metadata, options) {
475
- const controller = new _progress.ProgressController(metadata, this);
476
- return controller.run(async progress => {
465
+ const controller = new import_progress.ProgressController(metadata, this);
466
+ return controller.run(async (progress) => {
477
467
  await this._markAsTargetElement(metadata);
478
468
  const result = await this._dblclick(progress, options);
479
469
  return assertDone(throwRetargetableDOMError(result));
480
470
  }, this._page._timeoutSettings.timeout(options));
481
471
  }
482
472
  _dblclick(progress, options) {
483
- return this._retryPointerAction(progress, 'dblclick', true /* waitForEnabled */, point => this._page.mouse.dblclick(point.x, point.y, options), {
484
- ...options,
485
- waitAfter: 'disabled'
486
- });
473
+ return this._retryPointerAction(progress, "dblclick", true, (point) => this._page.mouse.dblclick(point.x, point.y, options), { ...options, waitAfter: "disabled" });
487
474
  }
488
475
  async tap(metadata, options = {}) {
489
- const controller = new _progress.ProgressController(metadata, this);
490
- return controller.run(async progress => {
476
+ const controller = new import_progress.ProgressController(metadata, this);
477
+ return controller.run(async (progress) => {
491
478
  await this._markAsTargetElement(metadata);
492
479
  const result = await this._tap(progress, options);
493
480
  return assertDone(throwRetargetableDOMError(result));
494
481
  }, this._page._timeoutSettings.timeout(options));
495
482
  }
496
483
  _tap(progress, options) {
497
- return this._retryPointerAction(progress, 'tap', true /* waitForEnabled */, point => this._page.touchscreen.tap(point.x, point.y), {
498
- ...options,
499
- waitAfter: 'disabled'
500
- });
484
+ return this._retryPointerAction(progress, "tap", true, (point) => this._page.touchscreen.tap(point.x, point.y), { ...options, waitAfter: "disabled" });
501
485
  }
502
486
  async selectOption(metadata, elements, values, options) {
503
- const controller = new _progress.ProgressController(metadata, this);
504
- return controller.run(async progress => {
487
+ const controller = new import_progress.ProgressController(metadata, this);
488
+ return controller.run(async (progress) => {
505
489
  await this._markAsTargetElement(metadata);
506
490
  const result = await this._selectOption(progress, elements, values, options);
507
491
  return throwRetargetableDOMError(result);
@@ -509,35 +493,33 @@ class ElementHandle extends js.JSHandle {
509
493
  }
510
494
  async _selectOption(progress, elements, values, options) {
511
495
  let resultingOptions = [];
512
- await this._retryAction(progress, 'select option', async () => {
496
+ const result = await this._retryAction(progress, "select option", async () => {
513
497
  await this.instrumentation.onBeforeInputAction(this, progress.metadata);
514
- if (!options.force) progress.log(` waiting for element to be visible and enabled`);
498
+ if (!options.force)
499
+ progress.log(` waiting for element to be visible and enabled`);
515
500
  const optionsToSelect = [...elements, ...values];
516
- const result = await this.evaluateInUtility(async ([injected, node, {
517
- optionsToSelect,
518
- force
519
- }]) => {
501
+ const result2 = await this.evaluateInUtility(async ([injected, node, { optionsToSelect: optionsToSelect2, force }]) => {
520
502
  if (!force) {
521
- const checkResult = await injected.checkElementStates(node, ['visible', 'enabled']);
522
- if (checkResult) return checkResult;
503
+ const checkResult = await injected.checkElementStates(node, ["visible", "enabled"]);
504
+ if (checkResult)
505
+ return checkResult;
523
506
  }
524
- return injected.selectOptions(node, optionsToSelect);
525
- }, {
526
- optionsToSelect,
527
- force: options.force
528
- });
529
- if (Array.isArray(result)) {
530
- progress.log(' selected specified option(s)');
531
- resultingOptions = result;
532
- return 'done';
507
+ return injected.selectOptions(node, optionsToSelect2);
508
+ }, { optionsToSelect, force: options.force });
509
+ if (Array.isArray(result2)) {
510
+ progress.log(" selected specified option(s)");
511
+ resultingOptions = result2;
512
+ return "done";
533
513
  }
534
- return result;
514
+ return result2;
535
515
  }, options);
516
+ if (result === "error:notconnected")
517
+ return result;
536
518
  return resultingOptions;
537
519
  }
538
520
  async fill(metadata, value, options = {}) {
539
- const controller = new _progress.ProgressController(metadata, this);
540
- return controller.run(async progress => {
521
+ const controller = new import_progress.ProgressController(metadata, this);
522
+ return controller.run(async (progress) => {
541
523
  await this._markAsTargetElement(metadata);
542
524
  const result = await this._fill(progress, value, options);
543
525
  assertDone(throwRetargetableDOMError(result));
@@ -545,122 +527,113 @@ class ElementHandle extends js.JSHandle {
545
527
  }
546
528
  async _fill(progress, value, options) {
547
529
  progress.log(` fill("${value}")`);
548
- return await this._retryAction(progress, 'fill', async () => {
530
+ return await this._retryAction(progress, "fill", async () => {
549
531
  await this.instrumentation.onBeforeInputAction(this, progress.metadata);
550
- if (!options.force) progress.log(' waiting for element to be visible, enabled and editable');
551
- const result = await this.evaluateInUtility(async ([injected, node, {
552
- value,
553
- force
554
- }]) => {
532
+ if (!options.force)
533
+ progress.log(" waiting for element to be visible, enabled and editable");
534
+ const result = await this.evaluateInUtility(async ([injected, node, { value: value2, force }]) => {
555
535
  if (!force) {
556
- const checkResult = await injected.checkElementStates(node, ['visible', 'enabled', 'editable']);
557
- if (checkResult) return checkResult;
536
+ const checkResult = await injected.checkElementStates(node, ["visible", "enabled", "editable"]);
537
+ if (checkResult)
538
+ return checkResult;
558
539
  }
559
- return injected.fill(node, value);
560
- }, {
561
- value,
562
- force: options.force
563
- });
564
- progress.throwIfAborted(); // Avoid action that has side-effects.
565
- if (result === 'needsinput') {
566
- if (value) await this._page.keyboard.insertText(value);else await this._page.keyboard.press('Delete');
567
- return 'done';
540
+ return injected.fill(node, value2);
541
+ }, { value, force: options.force });
542
+ progress.throwIfAborted();
543
+ if (result === "needsinput") {
544
+ if (value)
545
+ await this._page.keyboard.insertText(value);
546
+ else
547
+ await this._page.keyboard.press("Delete");
548
+ return "done";
568
549
  } else {
569
550
  return result;
570
551
  }
571
552
  }, options);
572
553
  }
573
554
  async selectText(metadata, options = {}) {
574
- const controller = new _progress.ProgressController(metadata, this);
575
- return controller.run(async progress => {
576
- const result = await this._retryAction(progress, 'selectText', async () => {
577
- if (!options.force) progress.log(' waiting for element to be visible');
578
- return await this.evaluateInUtility(async ([injected, node, {
579
- force
580
- }]) => {
555
+ const controller = new import_progress.ProgressController(metadata, this);
556
+ return controller.run(async (progress) => {
557
+ const result = await this._retryAction(progress, "selectText", async () => {
558
+ if (!options.force)
559
+ progress.log(" waiting for element to be visible");
560
+ return await this.evaluateInUtility(async ([injected, node, { force }]) => {
581
561
  if (!force) {
582
- const checkResult = await injected.checkElementStates(node, ['visible']);
583
- if (checkResult) return checkResult;
562
+ const checkResult = await injected.checkElementStates(node, ["visible"]);
563
+ if (checkResult)
564
+ return checkResult;
584
565
  }
585
566
  return injected.selectText(node);
586
- }, {
587
- force: options.force
588
- });
567
+ }, { force: options.force });
589
568
  }, options);
590
569
  assertDone(throwRetargetableDOMError(result));
591
570
  }, this._page._timeoutSettings.timeout(options));
592
571
  }
593
572
  async setInputFiles(metadata, params) {
594
- const inputFileItems = await (0, _fileUploadUtils.prepareFilesForUpload)(this._frame, params);
595
- const controller = new _progress.ProgressController(metadata, this);
596
- return controller.run(async progress => {
573
+ const inputFileItems = await (0, import_fileUploadUtils.prepareFilesForUpload)(this._frame, params);
574
+ const controller = new import_progress.ProgressController(metadata, this);
575
+ return controller.run(async (progress) => {
597
576
  await this._markAsTargetElement(metadata);
598
577
  const result = await this._setInputFiles(progress, inputFileItems);
599
578
  return assertDone(throwRetargetableDOMError(result));
600
579
  }, this._page._timeoutSettings.timeout(params));
601
580
  }
602
581
  async _setInputFiles(progress, items) {
603
- const {
604
- filePayloads,
605
- localPaths,
606
- localDirectory
607
- } = items;
582
+ const { filePayloads, localPaths, localDirectory } = items;
608
583
  const multiple = filePayloads && filePayloads.length > 1 || localPaths && localPaths.length > 1;
609
- const result = await this.evaluateHandleInUtility(([injected, node, {
610
- multiple,
611
- directoryUpload
612
- }]) => {
613
- const element = injected.retarget(node, 'follow-label');
614
- if (!element) return;
615
- if (element.tagName !== 'INPUT') throw injected.createStacklessError('Node is not an HTMLInputElement');
584
+ const result = await this.evaluateHandleInUtility(([injected, node, { multiple: multiple2, directoryUpload }]) => {
585
+ const element = injected.retarget(node, "follow-label");
586
+ if (!element)
587
+ return;
588
+ if (element.tagName !== "INPUT")
589
+ throw injected.createStacklessError("Node is not an HTMLInputElement");
616
590
  const inputElement = element;
617
- if (multiple && !inputElement.multiple && !inputElement.webkitdirectory) throw injected.createStacklessError('Non-multiple file input can only accept single file');
618
- if (directoryUpload && !inputElement.webkitdirectory) throw injected.createStacklessError('File input does not support directories, pass individual files instead');
619
- if (!directoryUpload && inputElement.webkitdirectory) throw injected.createStacklessError('[webkitdirectory] input requires passing a path to a directory');
591
+ if (multiple2 && !inputElement.multiple && !inputElement.webkitdirectory)
592
+ throw injected.createStacklessError("Non-multiple file input can only accept single file");
593
+ if (directoryUpload && !inputElement.webkitdirectory)
594
+ throw injected.createStacklessError("File input does not support directories, pass individual files instead");
595
+ if (!directoryUpload && inputElement.webkitdirectory)
596
+ throw injected.createStacklessError("[webkitdirectory] input requires passing a path to a directory");
620
597
  return inputElement;
621
- }, {
622
- multiple,
623
- directoryUpload: !!localDirectory
624
- });
625
- if (result === 'error:notconnected' || !result.asElement()) return 'error:notconnected';
598
+ }, { multiple, directoryUpload: !!localDirectory });
599
+ if (result === "error:notconnected" || !result.asElement())
600
+ return "error:notconnected";
626
601
  const retargeted = result.asElement();
627
602
  await this.instrumentation.onBeforeInputAction(this, progress.metadata);
628
- progress.throwIfAborted(); // Avoid action that has side-effects.
603
+ progress.throwIfAborted();
629
604
  if (localPaths || localDirectory) {
630
605
  const localPathsOrDirectory = localDirectory ? [localDirectory] : localPaths;
631
- await Promise.all(localPathsOrDirectory.map(localPath => _fs.default.promises.access(localPath, _fs.default.constants.F_OK)));
632
- // Browsers traverse the given directory asynchronously and we want to ensure all files are uploaded.
633
- const waitForInputEvent = localDirectory ? this.evaluate(node => new Promise(fulfill => {
634
- node.addEventListener('input', fulfill, {
635
- once: true
636
- });
637
- })).catch(() => {}) : Promise.resolve();
606
+ await Promise.all(localPathsOrDirectory.map((localPath) => import_fs.default.promises.access(localPath, import_fs.default.constants.F_OK)));
607
+ const waitForInputEvent = localDirectory ? this.evaluate((node) => new Promise((fulfill) => {
608
+ node.addEventListener("input", fulfill, { once: true });
609
+ })).catch(() => {
610
+ }) : Promise.resolve();
638
611
  await this._page._delegate.setInputFilePaths(retargeted, localPathsOrDirectory);
639
612
  await waitForInputEvent;
640
613
  } else {
641
- await this._page._delegate.setInputFiles(retargeted, filePayloads);
614
+ await retargeted.evaluateInUtility(([injected, node, files]) => injected.setInputFiles(node, files), filePayloads);
642
615
  }
643
- return 'done';
616
+ return "done";
644
617
  }
645
618
  async focus(metadata) {
646
- const controller = new _progress.ProgressController(metadata, this);
647
- await controller.run(async progress => {
619
+ const controller = new import_progress.ProgressController(metadata, this);
620
+ await controller.run(async (progress) => {
648
621
  await this._markAsTargetElement(metadata);
649
622
  const result = await this._focus(progress);
650
623
  return assertDone(throwRetargetableDOMError(result));
651
624
  }, 0);
652
625
  }
653
626
  async _focus(progress, resetSelectionIfNotFocused) {
654
- progress.throwIfAborted(); // Avoid action that has side-effects.
655
- return await this.evaluateInUtility(([injected, node, resetSelectionIfNotFocused]) => injected.focusNode(node, resetSelectionIfNotFocused), resetSelectionIfNotFocused);
627
+ progress.throwIfAborted();
628
+ return await this.evaluateInUtility(([injected, node, resetSelectionIfNotFocused2]) => injected.focusNode(node, resetSelectionIfNotFocused2), resetSelectionIfNotFocused);
656
629
  }
657
630
  async _blur(progress) {
658
- progress.throwIfAborted(); // Avoid action that has side-effects.
631
+ progress.throwIfAborted();
659
632
  return await this.evaluateInUtility(([injected, node]) => injected.blurNode(node), {});
660
633
  }
661
634
  async type(metadata, text, options) {
662
- const controller = new _progress.ProgressController(metadata, this);
663
- return controller.run(async progress => {
635
+ const controller = new import_progress.ProgressController(metadata, this);
636
+ return controller.run(async (progress) => {
664
637
  await this._markAsTargetElement(metadata);
665
638
  const result = await this._type(progress, text, options);
666
639
  return assertDone(throwRetargetableDOMError(result));
@@ -669,15 +642,20 @@ class ElementHandle extends js.JSHandle {
669
642
  async _type(progress, text, options) {
670
643
  progress.log(`elementHandle.type("${text}")`);
671
644
  await this.instrumentation.onBeforeInputAction(this, progress.metadata);
672
- const result = await this._focus(progress, true /* resetSelectionIfNotFocused */);
673
- if (result !== 'done') return result;
674
- progress.throwIfAborted(); // Avoid action that has side-effects.
645
+ const result = await this._focus(
646
+ progress,
647
+ true
648
+ /* resetSelectionIfNotFocused */
649
+ );
650
+ if (result !== "done")
651
+ return result;
652
+ progress.throwIfAborted();
675
653
  await this._page.keyboard.type(text, options);
676
- return 'done';
654
+ return "done";
677
655
  }
678
656
  async press(metadata, key, options) {
679
- const controller = new _progress.ProgressController(metadata, this);
680
- return controller.run(async progress => {
657
+ const controller = new import_progress.ProgressController(metadata, this);
658
+ return controller.run(async (progress) => {
681
659
  await this._markAsTargetElement(metadata);
682
660
  const result = await this._press(progress, key, options);
683
661
  return assertDone(throwRetargetableDOMError(result));
@@ -687,52 +665,63 @@ class ElementHandle extends js.JSHandle {
687
665
  progress.log(`elementHandle.press("${key}")`);
688
666
  await this.instrumentation.onBeforeInputAction(this, progress.metadata);
689
667
  return this._page._frameManager.waitForSignalsCreatedBy(progress, !options.noWaitAfter, async () => {
690
- const result = await this._focus(progress, true /* resetSelectionIfNotFocused */);
691
- if (result !== 'done') return result;
692
- progress.throwIfAborted(); // Avoid action that has side-effects.
668
+ const result = await this._focus(
669
+ progress,
670
+ true
671
+ /* resetSelectionIfNotFocused */
672
+ );
673
+ if (result !== "done")
674
+ return result;
675
+ progress.throwIfAborted();
693
676
  await this._page.keyboard.press(key, options);
694
- return 'done';
677
+ return "done";
695
678
  });
696
679
  }
697
680
  async check(metadata, options) {
698
- const controller = new _progress.ProgressController(metadata, this);
699
- return controller.run(async progress => {
681
+ const controller = new import_progress.ProgressController(metadata, this);
682
+ return controller.run(async (progress) => {
700
683
  const result = await this._setChecked(progress, true, options);
701
684
  return assertDone(throwRetargetableDOMError(result));
702
685
  }, this._page._timeoutSettings.timeout(options));
703
686
  }
704
687
  async uncheck(metadata, options) {
705
- const controller = new _progress.ProgressController(metadata, this);
706
- return controller.run(async progress => {
688
+ const controller = new import_progress.ProgressController(metadata, this);
689
+ return controller.run(async (progress) => {
707
690
  const result = await this._setChecked(progress, false, options);
708
691
  return assertDone(throwRetargetableDOMError(result));
709
692
  }, this._page._timeoutSettings.timeout(options));
710
693
  }
711
694
  async _setChecked(progress, state, options) {
712
695
  const isChecked = async () => {
713
- const result = await this.evaluateInUtility(([injected, node]) => injected.elementState(node, 'checked'), {});
714
- return throwRetargetableDOMError(result);
696
+ const result2 = await this.evaluateInUtility(([injected, node]) => injected.elementState(node, "checked"), {});
697
+ if (result2 === "error:notconnected" || result2.received === "error:notconnected")
698
+ throwElementIsNotAttached();
699
+ return result2.matches;
715
700
  };
716
701
  await this._markAsTargetElement(progress.metadata);
717
- if ((await isChecked()) === state) return 'done';
718
- const result = await this._click(progress, {
719
- ...options,
720
- waitAfter: 'disabled'
721
- });
722
- if (result !== 'done') return result;
723
- if (options.trial) return 'done';
724
- if ((await isChecked()) !== state) throw new NonRecoverableDOMError('Clicking the checkbox did not change its state');
725
- return 'done';
702
+ if (await isChecked() === state)
703
+ return "done";
704
+ const result = await this._click(progress, { ...options, waitAfter: "disabled" });
705
+ if (result !== "done")
706
+ return result;
707
+ if (options.trial)
708
+ return "done";
709
+ if (await isChecked() !== state)
710
+ throw new NonRecoverableDOMError("Clicking the checkbox did not change its state");
711
+ return "done";
726
712
  }
727
713
  async boundingBox() {
728
714
  return this._page._delegate.getBoundingBox(this);
729
715
  }
730
- async ariaSnapshot() {
731
- return await this.evaluateInUtility(([injected, element]) => injected.ariaSnapshot(element), {});
716
+ async ariaSnapshot(options) {
717
+ return await this.evaluateInUtility(([injected, element, options2]) => injected.ariaSnapshot(element, options2), options);
732
718
  }
733
719
  async screenshot(metadata, options = {}) {
734
- const controller = new _progress.ProgressController(metadata, this);
735
- return controller.run(progress => this._page._screenshotter.screenshotElement(progress, this, options), this._page._timeoutSettings.timeout(options));
720
+ const controller = new import_progress.ProgressController(metadata, this);
721
+ return controller.run(
722
+ (progress) => this._page._screenshotter.screenshotElement(progress, this, options),
723
+ this._page._timeoutSettings.timeout(options)
724
+ );
736
725
  }
737
726
  async querySelector(selector, options) {
738
727
  return this._frame.selectors.query(selector, options, this);
@@ -747,30 +736,30 @@ class ElementHandle extends js.JSHandle {
747
736
  return this._frame.evalOnSelectorAll(selector, expression, isFunction, arg, this);
748
737
  }
749
738
  async isVisible(metadata) {
750
- return this._frame.isVisible(metadata, ':scope', {}, this);
739
+ return this._frame.isVisible(metadata, ":scope", {}, this);
751
740
  }
752
741
  async isHidden(metadata) {
753
- return this._frame.isHidden(metadata, ':scope', {}, this);
742
+ return this._frame.isHidden(metadata, ":scope", {}, this);
754
743
  }
755
744
  async isEnabled(metadata) {
756
- return this._frame.isEnabled(metadata, ':scope', {}, this);
745
+ return this._frame.isEnabled(metadata, ":scope", {}, this);
757
746
  }
758
747
  async isDisabled(metadata) {
759
- return this._frame.isDisabled(metadata, ':scope', {}, this);
748
+ return this._frame.isDisabled(metadata, ":scope", {}, this);
760
749
  }
761
750
  async isEditable(metadata) {
762
- return this._frame.isEditable(metadata, ':scope', {}, this);
751
+ return this._frame.isEditable(metadata, ":scope", {}, this);
763
752
  }
764
753
  async isChecked(metadata) {
765
- return this._frame.isChecked(metadata, ':scope', {}, this);
754
+ return this._frame.isChecked(metadata, ":scope", {}, this);
766
755
  }
767
756
  async waitForElementState(metadata, state, options = {}) {
768
- const controller = new _progress.ProgressController(metadata, this);
769
- return controller.run(async progress => {
757
+ const controller = new import_progress.ProgressController(metadata, this);
758
+ return controller.run(async (progress) => {
770
759
  const actionName = `wait for ${state}`;
771
760
  const result = await this._retryAction(progress, actionName, async () => {
772
- return await this.evaluateInUtility(async ([injected, node, state]) => {
773
- return (await injected.checkElementStates(node, [state])) || 'done';
761
+ return await this.evaluateInUtility(async ([injected, node, state2]) => {
762
+ return await injected.checkElementStates(node, [state2]) || "done";
774
763
  }, state);
775
764
  }, {});
776
765
  assertDone(throwRetargetableDOMError(result));
@@ -793,55 +782,38 @@ class ElementHandle extends js.JSHandle {
793
782
  while (frame.parentFrame()) {
794
783
  const frameElement = await frame.frameElement();
795
784
  const box = await frameElement.boundingBox();
796
- const style = await frameElement.evaluateInUtility(([injected, iframe]) => injected.describeIFrameStyle(iframe), {}).catch(e => 'error:notconnected');
797
- if (!box || style === 'error:notconnected') return 'error:notconnected';
798
- if (style === 'transformed') {
799
- // We cannot translate coordinates when iframe has any transform applied.
800
- // The best we can do right now is to skip the hitPoint check,
801
- // and solely rely on the event interceptor.
802
- return {
803
- framePoint: undefined
804
- };
785
+ const style = await frameElement.evaluateInUtility(([injected, iframe]) => injected.describeIFrameStyle(iframe), {}).catch((e) => "error:notconnected");
786
+ if (!box || style === "error:notconnected")
787
+ return "error:notconnected";
788
+ if (style === "transformed") {
789
+ return { framePoint: void 0 };
805
790
  }
806
- // Translate from viewport coordinates to frame coordinates.
807
- const pointInFrame = {
808
- x: point.x - box.x - style.left,
809
- y: point.y - box.y - style.top
810
- };
811
- data.push({
812
- frame,
813
- frameElement,
814
- pointInFrame
815
- });
791
+ const pointInFrame = { x: point.x - box.x - style.left, y: point.y - box.y - style.top };
792
+ data.push({ frame, frameElement, pointInFrame });
816
793
  frame = frame.parentFrame();
817
794
  }
818
- // Add main frame.
819
- data.push({
820
- frame,
821
- frameElement: null,
822
- pointInFrame: point
823
- });
795
+ data.push({ frame, frameElement: null, pointInFrame: point });
824
796
  for (let i = data.length - 1; i > 0; i--) {
825
797
  const element = data[i - 1].frameElement;
826
- const point = data[i].pointInFrame;
827
- // Hit target in the parent frame should hit the child frame element.
828
- const hitTargetResult = await element.evaluateInUtility(([injected, element, hitPoint]) => {
829
- return injected.expectHitTarget(hitPoint, element);
830
- }, point);
831
- if (hitTargetResult !== 'done') return hitTargetResult;
798
+ const point2 = data[i].pointInFrame;
799
+ const hitTargetResult = await element.evaluateInUtility(([injected, element2, hitPoint]) => {
800
+ return injected.expectHitTarget(hitPoint, element2);
801
+ }, point2);
802
+ if (hitTargetResult !== "done")
803
+ return hitTargetResult;
832
804
  }
833
- return {
834
- framePoint: data[0].pointInFrame
835
- };
805
+ return { framePoint: data[0].pointInFrame };
836
806
  }
837
807
  }
838
- exports.ElementHandle = ElementHandle;
839
808
  function throwRetargetableDOMError(result) {
840
- if (result === 'error:notconnected') throw new Error('Element is not attached to the DOM');
809
+ if (result === "error:notconnected")
810
+ throwElementIsNotAttached();
841
811
  return result;
842
812
  }
813
+ function throwElementIsNotAttached() {
814
+ throw new Error("Element is not attached to the DOM");
815
+ }
843
816
  function assertDone(result) {
844
- // This function converts 'done' to void and ensures typescript catches unhandled errors.
845
817
  }
846
818
  function roundPoint(point) {
847
819
  return {
@@ -850,10 +822,7 @@ function roundPoint(point) {
850
822
  };
851
823
  }
852
824
  function quadMiddlePoint(quad) {
853
- const result = {
854
- x: 0,
855
- y: 0
856
- };
825
+ const result = { x: 0, y: 0 };
857
826
  for (const point of quad) {
858
827
  result.x += point.x / 4;
859
828
  result.y += point.y / 4;
@@ -866,23 +835,35 @@ function triangleArea(p1, p2, p3) {
866
835
  function isPointInsideQuad(point, quad) {
867
836
  const area1 = triangleArea(point, quad[0], quad[1]) + triangleArea(point, quad[1], quad[2]) + triangleArea(point, quad[2], quad[3]) + triangleArea(point, quad[3], quad[0]);
868
837
  const area2 = triangleArea(quad[0], quad[1], quad[2]) + triangleArea(quad[1], quad[2], quad[3]);
869
- // Check that point is inside the quad.
870
- if (Math.abs(area1 - area2) > 0.1) return false;
871
- // Check that point is not on the right/bottom edge, because clicking
872
- // there does not actually click the element.
838
+ if (Math.abs(area1 - area2) > 0.1)
839
+ return false;
873
840
  return point.x < Math.max(quad[0].x, quad[1].x, quad[2].x, quad[3].x) && point.y < Math.max(quad[0].y, quad[1].y, quad[2].y, quad[3].y);
874
841
  }
875
842
  function findIntegerPointInsideQuad(quad) {
876
- // Try all four rounding directions of the middle point.
877
843
  const point = quadMiddlePoint(quad);
878
844
  point.x = Math.floor(point.x);
879
845
  point.y = Math.floor(point.y);
880
- if (isPointInsideQuad(point, quad)) return point;
846
+ if (isPointInsideQuad(point, quad))
847
+ return point;
881
848
  point.x += 1;
882
- if (isPointInsideQuad(point, quad)) return point;
849
+ if (isPointInsideQuad(point, quad))
850
+ return point;
883
851
  point.y += 1;
884
- if (isPointInsideQuad(point, quad)) return point;
852
+ if (isPointInsideQuad(point, quad))
853
+ return point;
885
854
  point.x -= 1;
886
- if (isPointInsideQuad(point, quad)) return point;
855
+ if (isPointInsideQuad(point, quad))
856
+ return point;
887
857
  }
888
- const kUnableToAdoptErrorMessage = exports.kUnableToAdoptErrorMessage = 'Unable to adopt element handle from a different document';
858
+ const kUnableToAdoptErrorMessage = "Unable to adopt element handle from a different document";
859
+ // Annotate the CommonJS export names for ESM import in node:
860
+ 0 && (module.exports = {
861
+ ElementHandle,
862
+ FrameExecutionContext,
863
+ NonRecoverableDOMError,
864
+ assertDone,
865
+ isNonRecoverableDOMError,
866
+ kUnableToAdoptErrorMessage,
867
+ throwElementIsNotAttached,
868
+ throwRetargetableDOMError
869
+ });