easytouch-linux 1.0.7 → 1.0.18

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