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,1122 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.CRPage = void 0;
7
- var _path = _interopRequireDefault(require("path"));
8
- var _eventsHelper = require("../../utils/eventsHelper");
9
- var _registry = require("../registry");
10
- var _stackTrace = require("../../utils/stackTrace");
11
- var _utils = require("../../utils");
12
- var dialog = _interopRequireWildcard(require("../dialog"));
13
- var dom = _interopRequireWildcard(require("../dom"));
14
- var frames = _interopRequireWildcard(require("../frames"));
15
- var _helper = require("../helper");
16
- var network = _interopRequireWildcard(require("../network"));
17
- var _page = require("../page");
18
- var _crAccessibility = require("./crAccessibility");
19
- var _crBrowser = require("./crBrowser");
20
- var _crCoverage = require("./crCoverage");
21
- var _crDragDrop = require("./crDragDrop");
22
- var _crExecutionContext = require("./crExecutionContext");
23
- var _crInput = require("./crInput");
24
- var _crNetworkManager = require("./crNetworkManager");
25
- var _crPdf = require("./crPdf");
26
- var _crProtocolHelper = require("./crProtocolHelper");
27
- var _defaultFontFamilies = require("./defaultFontFamilies");
28
- var _videoRecorder = require("./videoRecorder");
29
- var _browserContext = require("../browserContext");
30
- var _errors = require("../errors");
31
- var _protocolError = require("../protocolError");
32
- 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); }
33
- 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; }
34
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
35
- /**
36
- * Copyright 2017 Google Inc. All rights reserved.
37
- * Modifications copyright (c) Microsoft Corporation.
38
- *
39
- * Licensed under the Apache License, Version 2.0 (the "License");
40
- * you may not use this file except in compliance with the License.
41
- * You may obtain a copy of the License at
42
- *
43
- * http://www.apache.org/licenses/LICENSE-2.0
44
- *
45
- * Unless required by applicable law or agreed to in writing, software
46
- * distributed under the License is distributed on an "AS IS" BASIS,
47
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
48
- * See the License for the specific language governing permissions and
49
- * limitations under the License.
50
- */
51
-
52
- const UTILITY_WORLD_NAME = '__playwright_utility_world__';
53
- class CRPage {
54
- static mainFrameSession(page) {
55
- const crPage = page._delegate;
56
- return crPage._mainFrameSession;
57
- }
58
- constructor(client, targetId, browserContext, opener, bits) {
59
- this._mainFrameSession = void 0;
60
- this._sessions = new Map();
61
- this._page = void 0;
62
- this.rawMouse = void 0;
63
- this.rawKeyboard = void 0;
64
- this.rawTouchscreen = void 0;
65
- this._targetId = void 0;
66
- this._opener = void 0;
67
- this._networkManager = void 0;
68
- this._pdf = void 0;
69
- this._coverage = void 0;
70
- this._browserContext = void 0;
71
- this._isBackgroundPage = void 0;
72
- // Holds window features for the next popup being opened via window.open,
73
- // until the popup target arrives. This could be racy if two oopifs
74
- // simultaneously call window.open with window features: the order
75
- // of their Page.windowOpen events is not guaranteed to match the order
76
- // of new popup targets.
77
- this._nextWindowOpenPopupFeatures = [];
78
- this._targetId = targetId;
79
- this._opener = opener;
80
- this._isBackgroundPage = bits.isBackgroundPage;
81
- const dragManager = new _crDragDrop.DragManager(this);
82
- this.rawKeyboard = new _crInput.RawKeyboardImpl(client, browserContext._browser._platform() === 'mac', dragManager);
83
- this.rawMouse = new _crInput.RawMouseImpl(this, client, dragManager);
84
- this.rawTouchscreen = new _crInput.RawTouchscreenImpl(client);
85
- this._pdf = new _crPdf.CRPDF(client);
86
- this._coverage = new _crCoverage.CRCoverage(client);
87
- this._browserContext = browserContext;
88
- this._page = new _page.Page(this, browserContext);
89
- this._networkManager = new _crNetworkManager.CRNetworkManager(this._page, null);
90
- // Sync any browser context state to the network manager. This does not talk over CDP because
91
- // we have not connected any sessions to the network manager yet.
92
- this.updateOffline();
93
- this.updateExtraHTTPHeaders();
94
- this.updateHttpCredentials();
95
- this.updateRequestInterception();
96
- this._mainFrameSession = new FrameSession(this, client, targetId, null);
97
- this._sessions.set(targetId, this._mainFrameSession);
98
- if (opener && !browserContext._options.noDefaultViewport) {
99
- const features = opener._nextWindowOpenPopupFeatures.shift() || [];
100
- const viewportSize = _helper.helper.getViewportSizeFromWindowFeatures(features);
101
- if (viewportSize) this._page._emulatedSize = {
102
- viewport: viewportSize,
103
- screen: viewportSize
104
- };
105
- }
106
- const createdEvent = this._isBackgroundPage ? _crBrowser.CRBrowserContext.CREvents.BackgroundPage : _browserContext.BrowserContext.Events.Page;
107
- this._mainFrameSession._initialize(bits.hasUIWindow).then(() => {
108
- var _this$_opener;
109
- return this._page.reportAsNew((_this$_opener = this._opener) === null || _this$_opener === void 0 ? void 0 : _this$_opener._page, undefined, createdEvent);
110
- }, error => {
111
- var _this$_opener2;
112
- return this._page.reportAsNew((_this$_opener2 = this._opener) === null || _this$_opener2 === void 0 ? void 0 : _this$_opener2._page, error, createdEvent);
113
- });
114
- }
115
- async _forAllFrameSessions(cb) {
116
- const frameSessions = Array.from(this._sessions.values());
117
- await Promise.all(frameSessions.map(frameSession => {
118
- if (frameSession._isMainFrame()) return cb(frameSession);
119
- return cb(frameSession).catch(e => {
120
- // Broadcasting a message to the closed iframe should be a noop.
121
- if ((0, _protocolError.isSessionClosedError)(e)) return;
122
- throw e;
123
- });
124
- }));
125
- }
126
- _sessionForFrame(frame) {
127
- // Frame id equals target id.
128
- while (!this._sessions.has(frame._id)) {
129
- const parent = frame.parentFrame();
130
- if (!parent) throw new Error(`Frame has been detached.`);
131
- frame = parent;
132
- }
133
- return this._sessions.get(frame._id);
134
- }
135
- _sessionForHandle(handle) {
136
- const frame = handle._context.frame;
137
- return this._sessionForFrame(frame);
138
- }
139
- willBeginDownload() {
140
- this._mainFrameSession._willBeginDownload();
141
- }
142
- didClose() {
143
- for (const session of this._sessions.values()) session.dispose();
144
- this._page._didClose();
145
- }
146
- async navigateFrame(frame, url, referrer) {
147
- return this._sessionForFrame(frame)._navigate(frame, url, referrer);
148
- }
149
- async updateExtraHTTPHeaders() {
150
- const headers = network.mergeHeaders([this._browserContext._options.extraHTTPHeaders, this._page.extraHTTPHeaders()]);
151
- await this._networkManager.setExtraHTTPHeaders(headers);
152
- }
153
- async updateGeolocation() {
154
- await this._forAllFrameSessions(frame => frame._updateGeolocation(false));
155
- }
156
- async updateOffline() {
157
- await this._networkManager.setOffline(!!this._browserContext._options.offline);
158
- }
159
- async updateHttpCredentials() {
160
- await this._networkManager.authenticate(this._browserContext._options.httpCredentials || null);
161
- }
162
- async updateEmulatedViewportSize(preserveWindowBoundaries) {
163
- await this._mainFrameSession._updateViewport(preserveWindowBoundaries);
164
- }
165
- async bringToFront() {
166
- await this._mainFrameSession._client.send('Page.bringToFront');
167
- }
168
- async updateEmulateMedia() {
169
- await this._forAllFrameSessions(frame => frame._updateEmulateMedia());
170
- }
171
- async updateUserAgent() {
172
- await this._forAllFrameSessions(frame => frame._updateUserAgent());
173
- }
174
- async updateRequestInterception() {
175
- await this._networkManager.setRequestInterception(this._page.needsRequestInterception());
176
- }
177
- async updateFileChooserInterception() {
178
- await this._forAllFrameSessions(frame => frame._updateFileChooserInterception(false));
179
- }
180
- async reload() {
181
- await this._mainFrameSession._client.send('Page.reload');
182
- }
183
- async _go(delta) {
184
- const history = await this._mainFrameSession._client.send('Page.getNavigationHistory');
185
- const entry = history.entries[history.currentIndex + delta];
186
- if (!entry) return false;
187
- await this._mainFrameSession._client.send('Page.navigateToHistoryEntry', {
188
- entryId: entry.id
189
- });
190
- return true;
191
- }
192
- goBack() {
193
- return this._go(-1);
194
- }
195
- goForward() {
196
- return this._go(+1);
197
- }
198
- async requestGC() {
199
- await this._mainFrameSession._client.send('HeapProfiler.collectGarbage');
200
- }
201
- async addInitScript(initScript, world = 'main') {
202
- await this._forAllFrameSessions(frame => frame._evaluateOnNewDocument(initScript, world));
203
- }
204
- async removeNonInternalInitScripts() {
205
- await this._forAllFrameSessions(frame => frame._removeEvaluatesOnNewDocument());
206
- }
207
- async closePage(runBeforeUnload) {
208
- if (runBeforeUnload) await this._mainFrameSession._client.send('Page.close');else await this._browserContext._browser._closePage(this);
209
- }
210
- async setBackgroundColor(color) {
211
- await this._mainFrameSession._client.send('Emulation.setDefaultBackgroundColorOverride', {
212
- color
213
- });
214
- }
215
- async takeScreenshot(progress, format, documentRect, viewportRect, quality, fitsViewport, scale) {
216
- const {
217
- visualViewport
218
- } = await this._mainFrameSession._client.send('Page.getLayoutMetrics');
219
- if (!documentRect) {
220
- documentRect = {
221
- x: visualViewport.pageX + viewportRect.x,
222
- y: visualViewport.pageY + viewportRect.y,
223
- ..._helper.helper.enclosingIntSize({
224
- width: viewportRect.width / visualViewport.scale,
225
- height: viewportRect.height / visualViewport.scale
226
- })
227
- };
228
- }
229
- // When taking screenshots with documentRect (based on the page content, not viewport),
230
- // ignore current page scale.
231
- const clip = {
232
- ...documentRect,
233
- scale: viewportRect ? visualViewport.scale : 1
234
- };
235
- if (scale === 'css') {
236
- const deviceScaleFactor = this._browserContext._options.deviceScaleFactor || 1;
237
- clip.scale /= deviceScaleFactor;
238
- }
239
- progress.throwIfAborted();
240
- const result = await this._mainFrameSession._client.send('Page.captureScreenshot', {
241
- format,
242
- quality,
243
- clip,
244
- captureBeyondViewport: !fitsViewport
245
- });
246
- return Buffer.from(result.data, 'base64');
247
- }
248
- async getContentFrame(handle) {
249
- return this._sessionForHandle(handle)._getContentFrame(handle);
250
- }
251
- async getOwnerFrame(handle) {
252
- return this._sessionForHandle(handle)._getOwnerFrame(handle);
253
- }
254
- isElementHandle(remoteObject) {
255
- return remoteObject.subtype === 'node';
256
- }
257
- async getBoundingBox(handle) {
258
- return this._sessionForHandle(handle)._getBoundingBox(handle);
259
- }
260
- async scrollRectIntoViewIfNeeded(handle, rect) {
261
- return this._sessionForHandle(handle)._scrollRectIntoViewIfNeeded(handle, rect);
262
- }
263
- async setScreencastOptions(options) {
264
- if (options) {
265
- await this._mainFrameSession._startScreencast(this, {
266
- format: 'jpeg',
267
- quality: options.quality,
268
- maxWidth: options.width,
269
- maxHeight: options.height
270
- });
271
- } else {
272
- await this._mainFrameSession._stopScreencast(this);
273
- }
274
- }
275
- rafCountForStablePosition() {
276
- return 1;
277
- }
278
- async getContentQuads(handle) {
279
- return this._sessionForHandle(handle)._getContentQuads(handle);
280
- }
281
- async setInputFiles(handle, files) {
282
- await handle.evaluateInUtility(([injected, node, files]) => injected.setInputFiles(node, files), files);
283
- }
284
- async setInputFilePaths(handle, files) {
285
- const frame = await handle.ownerFrame();
286
- if (!frame) throw new Error('Cannot set input files to detached input element');
287
- const parentSession = this._sessionForFrame(frame);
288
- await parentSession._client.send('DOM.setFileInputFiles', {
289
- objectId: handle._objectId,
290
- files
291
- });
292
- }
293
- async adoptElementHandle(handle, to) {
294
- return this._sessionForHandle(handle)._adoptElementHandle(handle, to);
295
- }
296
- async getAccessibilityTree(needle) {
297
- return (0, _crAccessibility.getAccessibilityTree)(this._mainFrameSession._client, needle);
298
- }
299
- async inputActionEpilogue() {
300
- await this._mainFrameSession._client.send('Page.enable').catch(e => {});
301
- }
302
- async resetForReuse() {
303
- // See https://github.com/microsoft/playwright/issues/22432.
304
- await this.rawMouse.move(-1, -1, 'none', new Set(), new Set(), true);
305
- }
306
- async pdf(options) {
307
- return this._pdf.generate(options);
308
- }
309
- coverage() {
310
- return this._coverage;
311
- }
312
- async getFrameElement(frame) {
313
- let parent = frame.parentFrame();
314
- if (!parent) throw new Error('Frame has been detached.');
315
- const parentSession = this._sessionForFrame(parent);
316
- const {
317
- backendNodeId
318
- } = await parentSession._client.send('DOM.getFrameOwner', {
319
- frameId: frame._id
320
- }).catch(e => {
321
- if (e instanceof Error && e.message.includes('Frame with the given id was not found.')) (0, _stackTrace.rewriteErrorMessage)(e, 'Frame has been detached.');
322
- throw e;
323
- });
324
- parent = frame.parentFrame();
325
- if (!parent) throw new Error('Frame has been detached.');
326
- return parentSession._adoptBackendNodeId(backendNodeId, await parent._mainContext());
327
- }
328
- shouldToggleStyleSheetToSyncAnimations() {
329
- return false;
330
- }
331
- }
332
- exports.CRPage = CRPage;
333
- class FrameSession {
334
- constructor(crPage, client, targetId, parentSession) {
335
- this._client = void 0;
336
- this._crPage = void 0;
337
- this._page = void 0;
338
- this._parentSession = void 0;
339
- this._childSessions = new Set();
340
- this._contextIdToContext = new Map();
341
- this._eventListeners = [];
342
- this._targetId = void 0;
343
- this._firstNonInitialNavigationCommittedPromise = void 0;
344
- this._firstNonInitialNavigationCommittedFulfill = () => {};
345
- this._firstNonInitialNavigationCommittedReject = e => {};
346
- this._windowId = void 0;
347
- // Marks the oopif session that remote -> local transition has happened in the parent.
348
- // See Target.detachedFromTarget handler for details.
349
- this._swappedIn = false;
350
- this._videoRecorder = null;
351
- this._screencastId = null;
352
- this._screencastClients = new Set();
353
- this._evaluateOnNewDocumentIdentifiers = [];
354
- this._metricsOverride = void 0;
355
- this._workerSessions = new Map();
356
- this._client = client;
357
- this._crPage = crPage;
358
- this._page = crPage._page;
359
- this._targetId = targetId;
360
- this._parentSession = parentSession;
361
- if (parentSession) parentSession._childSessions.add(this);
362
- this._firstNonInitialNavigationCommittedPromise = new Promise((f, r) => {
363
- this._firstNonInitialNavigationCommittedFulfill = f;
364
- this._firstNonInitialNavigationCommittedReject = r;
365
- });
366
- // The Promise is not always awaited (e.g. FrameSession._initialize can throw)
367
- // so we catch errors here to prevent unhandled promise rejection.
368
- this._firstNonInitialNavigationCommittedPromise.catch(() => {});
369
- }
370
- _isMainFrame() {
371
- return this._targetId === this._crPage._targetId;
372
- }
373
- _addRendererListeners() {
374
- this._eventListeners.push(...[_eventsHelper.eventsHelper.addEventListener(this._client, 'Log.entryAdded', event => this._onLogEntryAdded(event)), _eventsHelper.eventsHelper.addEventListener(this._client, 'Page.fileChooserOpened', event => this._onFileChooserOpened(event)), _eventsHelper.eventsHelper.addEventListener(this._client, 'Page.frameAttached', event => this._onFrameAttached(event.frameId, event.parentFrameId)), _eventsHelper.eventsHelper.addEventListener(this._client, 'Page.frameDetached', event => this._onFrameDetached(event.frameId, event.reason)), _eventsHelper.eventsHelper.addEventListener(this._client, 'Page.frameNavigated', event => this._onFrameNavigated(event.frame, false)), _eventsHelper.eventsHelper.addEventListener(this._client, 'Page.frameRequestedNavigation', event => this._onFrameRequestedNavigation(event)), _eventsHelper.eventsHelper.addEventListener(this._client, 'Page.javascriptDialogOpening', event => this._onDialog(event)), _eventsHelper.eventsHelper.addEventListener(this._client, 'Page.navigatedWithinDocument', event => this._onFrameNavigatedWithinDocument(event.frameId, event.url)), _eventsHelper.eventsHelper.addEventListener(this._client, 'Runtime.bindingCalled', event => this._onBindingCalled(event)), _eventsHelper.eventsHelper.addEventListener(this._client, 'Runtime.consoleAPICalled', event => this._onConsoleAPI(event)), _eventsHelper.eventsHelper.addEventListener(this._client, 'Runtime.exceptionThrown', exception => this._handleException(exception.exceptionDetails)), _eventsHelper.eventsHelper.addEventListener(this._client, 'Runtime.executionContextCreated', event => this._onExecutionContextCreated(event.context)), _eventsHelper.eventsHelper.addEventListener(this._client, 'Runtime.executionContextDestroyed', event => this._onExecutionContextDestroyed(event.executionContextId)), _eventsHelper.eventsHelper.addEventListener(this._client, 'Runtime.executionContextsCleared', event => this._onExecutionContextsCleared()), _eventsHelper.eventsHelper.addEventListener(this._client, 'Target.attachedToTarget', event => this._onAttachedToTarget(event)), _eventsHelper.eventsHelper.addEventListener(this._client, 'Target.detachedFromTarget', event => this._onDetachedFromTarget(event))]);
375
- }
376
- _addBrowserListeners() {
377
- this._eventListeners.push(...[_eventsHelper.eventsHelper.addEventListener(this._client, 'Inspector.targetCrashed', event => this._onTargetCrashed()), _eventsHelper.eventsHelper.addEventListener(this._client, 'Page.screencastFrame', event => this._onScreencastFrame(event)), _eventsHelper.eventsHelper.addEventListener(this._client, 'Page.windowOpen', event => this._onWindowOpen(event))]);
378
- }
379
- async _initialize(hasUIWindow) {
380
- const isSettingStorageState = this._page._browserContext.isSettingStorageState();
381
- if (!isSettingStorageState && hasUIWindow && !this._crPage._browserContext._browser.isClank() && !this._crPage._browserContext._options.noDefaultViewport) {
382
- const {
383
- windowId
384
- } = await this._client.send('Browser.getWindowForTarget');
385
- this._windowId = windowId;
386
- }
387
- let screencastOptions;
388
- if (!isSettingStorageState && this._isMainFrame() && this._crPage._browserContext._options.recordVideo && hasUIWindow) {
389
- const screencastId = (0, _utils.createGuid)();
390
- const outputFile = _path.default.join(this._crPage._browserContext._options.recordVideo.dir, screencastId + '.webm');
391
- screencastOptions = {
392
- // validateBrowserContextOptions ensures correct video size.
393
- ...this._crPage._browserContext._options.recordVideo.size,
394
- outputFile
395
- };
396
- await this._crPage._browserContext._ensureVideosPath();
397
- // Note: it is important to start video recorder before sending Page.startScreencast,
398
- // and it is equally important to send Page.startScreencast before sending Runtime.runIfWaitingForDebugger.
399
- await this._createVideoRecorder(screencastId, screencastOptions);
400
- this._crPage._page.waitForInitializedOrError().then(p => {
401
- if (p instanceof Error) this._stopVideoRecording().catch(() => {});
402
- });
403
- }
404
- let lifecycleEventsEnabled;
405
- if (!this._isMainFrame()) this._addRendererListeners();
406
- this._addBrowserListeners();
407
- const promises = [this._client.send('Page.enable'), this._client.send('Page.getFrameTree').then(({
408
- frameTree
409
- }) => {
410
- if (this._isMainFrame()) {
411
- this._handleFrameTree(frameTree);
412
- this._addRendererListeners();
413
- }
414
- const localFrames = this._isMainFrame() ? this._page.frames() : [this._page._frameManager.frame(this._targetId)];
415
- for (const frame of localFrames) {
416
- // Note: frames might be removed before we send these.
417
- this._client._sendMayFail('Page.createIsolatedWorld', {
418
- frameId: frame._id,
419
- grantUniveralAccess: true,
420
- worldName: UTILITY_WORLD_NAME
421
- });
422
- for (const initScript of this._crPage._page.allInitScripts()) frame.evaluateExpression(initScript.source).catch(e => {});
423
- }
424
- const isInitialEmptyPage = this._isMainFrame() && this._page.mainFrame().url() === ':';
425
- if (isInitialEmptyPage) {
426
- // Ignore lifecycle events, worlds and bindings for the initial empty page. It is never the final page
427
- // hence we are going to get more lifecycle updates after the actual navigation has
428
- // started (even if the target url is about:blank).
429
- lifecycleEventsEnabled.catch(e => {}).then(() => {
430
- this._eventListeners.push(_eventsHelper.eventsHelper.addEventListener(this._client, 'Page.lifecycleEvent', event => this._onLifecycleEvent(event)));
431
- });
432
- } else {
433
- this._firstNonInitialNavigationCommittedFulfill();
434
- this._eventListeners.push(_eventsHelper.eventsHelper.addEventListener(this._client, 'Page.lifecycleEvent', event => this._onLifecycleEvent(event)));
435
- }
436
- }), this._client.send('Log.enable', {}), lifecycleEventsEnabled = this._client.send('Page.setLifecycleEventsEnabled', {
437
- enabled: true
438
- }), this._client.send('Runtime.enable', {}), this._client.send('Runtime.addBinding', {
439
- name: _page.PageBinding.kPlaywrightBinding
440
- }), this._client.send('Page.addScriptToEvaluateOnNewDocument', {
441
- source: '',
442
- worldName: UTILITY_WORLD_NAME
443
- }), this._crPage._networkManager.addSession(this._client, undefined, this._isMainFrame()), this._client.send('Target.setAutoAttach', {
444
- autoAttach: true,
445
- waitForDebuggerOnStart: true,
446
- flatten: true
447
- })];
448
- if (!isSettingStorageState) {
449
- if (this._isMainFrame()) promises.push(this._client.send('Emulation.setFocusEmulationEnabled', {
450
- enabled: true
451
- }));
452
- const options = this._crPage._browserContext._options;
453
- if (options.bypassCSP) promises.push(this._client.send('Page.setBypassCSP', {
454
- enabled: true
455
- }));
456
- if (options.ignoreHTTPSErrors || options.internalIgnoreHTTPSErrors) promises.push(this._client.send('Security.setIgnoreCertificateErrors', {
457
- ignore: true
458
- }));
459
- if (this._isMainFrame()) promises.push(this._updateViewport());
460
- if (options.hasTouch) promises.push(this._client.send('Emulation.setTouchEmulationEnabled', {
461
- enabled: true
462
- }));
463
- if (options.javaScriptEnabled === false) promises.push(this._client.send('Emulation.setScriptExecutionDisabled', {
464
- value: true
465
- }));
466
- if (options.userAgent || options.locale) promises.push(this._updateUserAgent());
467
- if (options.locale) promises.push(emulateLocale(this._client, options.locale));
468
- if (options.timezoneId) promises.push(emulateTimezone(this._client, options.timezoneId));
469
- if (!this._crPage._browserContext._browser.options.headful) promises.push(this._setDefaultFontFamilies(this._client));
470
- promises.push(this._updateGeolocation(true));
471
- promises.push(this._updateEmulateMedia());
472
- promises.push(this._updateFileChooserInterception(true));
473
- for (const initScript of this._crPage._page.allInitScripts()) promises.push(this._evaluateOnNewDocument(initScript, 'main'));
474
- if (screencastOptions) promises.push(this._startVideoRecording(screencastOptions));
475
- }
476
- promises.push(this._client.send('Runtime.runIfWaitingForDebugger'));
477
- promises.push(this._firstNonInitialNavigationCommittedPromise);
478
- await Promise.all(promises);
479
- }
480
- dispose() {
481
- this._firstNonInitialNavigationCommittedReject(new _errors.TargetClosedError());
482
- for (const childSession of this._childSessions) childSession.dispose();
483
- if (this._parentSession) this._parentSession._childSessions.delete(this);
484
- _eventsHelper.eventsHelper.removeEventListeners(this._eventListeners);
485
- this._crPage._networkManager.removeSession(this._client);
486
- this._crPage._sessions.delete(this._targetId);
487
- this._client.dispose();
488
- }
489
- async _navigate(frame, url, referrer) {
490
- const response = await this._client.send('Page.navigate', {
491
- url,
492
- referrer,
493
- frameId: frame._id,
494
- referrerPolicy: 'unsafeUrl'
495
- });
496
- if (response.errorText) throw new frames.NavigationAbortedError(response.loaderId, `${response.errorText} at ${url}`);
497
- return {
498
- newDocumentId: response.loaderId
499
- };
500
- }
501
- _onLifecycleEvent(event) {
502
- if (this._eventBelongsToStaleFrame(event.frameId)) return;
503
- if (event.name === 'load') this._page._frameManager.frameLifecycleEvent(event.frameId, 'load');else if (event.name === 'DOMContentLoaded') this._page._frameManager.frameLifecycleEvent(event.frameId, 'domcontentloaded');
504
- }
505
- _handleFrameTree(frameTree) {
506
- this._onFrameAttached(frameTree.frame.id, frameTree.frame.parentId || null);
507
- this._onFrameNavigated(frameTree.frame, true);
508
- if (!frameTree.childFrames) return;
509
- for (const child of frameTree.childFrames) this._handleFrameTree(child);
510
- }
511
- _eventBelongsToStaleFrame(frameId) {
512
- const frame = this._page._frameManager.frame(frameId);
513
- // Subtree may be already gone because some ancestor navigation destroyed the oopif.
514
- if (!frame) return true;
515
- // When frame goes remote, parent process may still send some events
516
- // related to the local frame before it sends frameDetached.
517
- // In this case, we already have a new session for this frame, so events
518
- // in the old session should be ignored.
519
- const session = this._crPage._sessionForFrame(frame);
520
- return session && session !== this && !session._swappedIn;
521
- }
522
- _onFrameAttached(frameId, parentFrameId) {
523
- const frameSession = this._crPage._sessions.get(frameId);
524
- if (frameSession && frameId !== this._targetId) {
525
- // This is a remote -> local frame transition.
526
- frameSession._swappedIn = true;
527
- const frame = this._page._frameManager.frame(frameId);
528
- // Frame or even a whole subtree may be already gone, because some ancestor did navigate.
529
- if (frame) this._page._frameManager.removeChildFramesRecursively(frame);
530
- return;
531
- }
532
- if (parentFrameId && !this._page._frameManager.frame(parentFrameId)) {
533
- // Parent frame may be gone already because some ancestor frame navigated and
534
- // destroyed the whole subtree of some oopif, while oopif's process is still sending us events.
535
- // Be careful to not confuse this with "main frame navigated cross-process" scenario
536
- // where parentFrameId is null.
537
- return;
538
- }
539
- this._page._frameManager.frameAttached(frameId, parentFrameId);
540
- }
541
- _onFrameNavigated(framePayload, initial) {
542
- if (this._eventBelongsToStaleFrame(framePayload.id)) return;
543
- this._page._frameManager.frameCommittedNewDocumentNavigation(framePayload.id, framePayload.url + (framePayload.urlFragment || ''), framePayload.name || '', framePayload.loaderId, initial);
544
- if (!initial) this._firstNonInitialNavigationCommittedFulfill();
545
- }
546
- _onFrameRequestedNavigation(payload) {
547
- if (this._eventBelongsToStaleFrame(payload.frameId)) return;
548
- if (payload.disposition === 'currentTab') this._page._frameManager.frameRequestedNavigation(payload.frameId);
549
- }
550
- _onFrameNavigatedWithinDocument(frameId, url) {
551
- if (this._eventBelongsToStaleFrame(frameId)) return;
552
- this._page._frameManager.frameCommittedSameDocumentNavigation(frameId, url);
553
- }
554
- _onFrameDetached(frameId, reason) {
555
- if (this._crPage._sessions.has(frameId)) {
556
- // This is a local -> remote frame transition, where
557
- // Page.frameDetached arrives after Target.attachedToTarget.
558
- // We've already handled the new target and frame reattach - nothing to do here.
559
- return;
560
- }
561
- if (reason === 'swap') {
562
- // This is a local -> remote frame transition, where
563
- // Page.frameDetached arrives before Target.attachedToTarget.
564
- // We should keep the frame in the tree, and it will be used for the new target.
565
- const frame = this._page._frameManager.frame(frameId);
566
- if (frame) this._page._frameManager.removeChildFramesRecursively(frame);
567
- return;
568
- }
569
- // Just a regular frame detach.
570
- this._page._frameManager.frameDetached(frameId);
571
- }
572
- _onExecutionContextCreated(contextPayload) {
573
- const frame = contextPayload.auxData ? this._page._frameManager.frame(contextPayload.auxData.frameId) : null;
574
- if (!frame || this._eventBelongsToStaleFrame(frame._id)) return;
575
- const delegate = new _crExecutionContext.CRExecutionContext(this._client, contextPayload);
576
- let worldName = null;
577
- if (contextPayload.auxData && !!contextPayload.auxData.isDefault) worldName = 'main';else if (contextPayload.name === UTILITY_WORLD_NAME) worldName = 'utility';
578
- const context = new dom.FrameExecutionContext(delegate, frame, worldName);
579
- context[contextDelegateSymbol] = delegate;
580
- if (worldName) frame._contextCreated(worldName, context);
581
- this._contextIdToContext.set(contextPayload.id, context);
582
- }
583
- _onExecutionContextDestroyed(executionContextId) {
584
- const context = this._contextIdToContext.get(executionContextId);
585
- if (!context) return;
586
- this._contextIdToContext.delete(executionContextId);
587
- context.frame._contextDestroyed(context);
588
- }
589
- _onExecutionContextsCleared() {
590
- for (const contextId of Array.from(this._contextIdToContext.keys())) this._onExecutionContextDestroyed(contextId);
591
- }
592
- _onAttachedToTarget(event) {
593
- var _this$_page$_frameMan;
594
- const session = this._client.createChildSession(event.sessionId);
595
- if (event.targetInfo.type === 'iframe') {
596
- // Frame id equals target id.
597
- const targetId = event.targetInfo.targetId;
598
- const frame = this._page._frameManager.frame(targetId);
599
- if (!frame) return; // Subtree may be already gone due to renderer/browser race.
600
- this._page._frameManager.removeChildFramesRecursively(frame);
601
- for (const [contextId, context] of this._contextIdToContext) {
602
- if (context.frame === frame) this._onExecutionContextDestroyed(contextId);
603
- }
604
- const frameSession = new FrameSession(this._crPage, session, targetId, this);
605
- this._crPage._sessions.set(targetId, frameSession);
606
- frameSession._initialize(false).catch(e => e);
607
- return;
608
- }
609
- if (event.targetInfo.type !== 'worker') {
610
- session.detach().catch(() => {});
611
- return;
612
- }
613
- const url = event.targetInfo.url;
614
- const worker = new _page.Worker(this._page, url);
615
- this._page._addWorker(event.sessionId, worker);
616
- this._workerSessions.set(event.sessionId, session);
617
- session.once('Runtime.executionContextCreated', async event => {
618
- worker._createExecutionContext(new _crExecutionContext.CRExecutionContext(session, event.context));
619
- });
620
- // This might fail if the target is closed before we initialize.
621
- session._sendMayFail('Runtime.enable');
622
- // TODO: attribute workers to the right frame.
623
- this._crPage._networkManager.addSession(session, (_this$_page$_frameMan = this._page._frameManager.frame(this._targetId)) !== null && _this$_page$_frameMan !== void 0 ? _this$_page$_frameMan : undefined).catch(() => {});
624
- session._sendMayFail('Runtime.runIfWaitingForDebugger');
625
- session._sendMayFail('Target.setAutoAttach', {
626
- autoAttach: true,
627
- waitForDebuggerOnStart: true,
628
- flatten: true
629
- });
630
- session.on('Target.attachedToTarget', event => this._onAttachedToTarget(event));
631
- session.on('Target.detachedFromTarget', event => this._onDetachedFromTarget(event));
632
- session.on('Runtime.consoleAPICalled', event => {
633
- const args = event.args.map(o => worker._existingExecutionContext.createHandle(o));
634
- this._page._addConsoleMessage(event.type, args, (0, _crProtocolHelper.toConsoleMessageLocation)(event.stackTrace));
635
- });
636
- session.on('Runtime.exceptionThrown', exception => this._page.emitOnContextOnceInitialized(_browserContext.BrowserContext.Events.PageError, (0, _crProtocolHelper.exceptionToError)(exception.exceptionDetails), this._page));
637
- }
638
- _onDetachedFromTarget(event) {
639
- // This might be a worker...
640
- const workerSession = this._workerSessions.get(event.sessionId);
641
- if (workerSession) {
642
- workerSession.dispose();
643
- this._page._removeWorker(event.sessionId);
644
- return;
645
- }
646
-
647
- // ... or an oopif.
648
- const childFrameSession = this._crPage._sessions.get(event.targetId);
649
- if (!childFrameSession) return;
650
-
651
- // Usually, we get frameAttached in this session first and mark child as swappedIn.
652
- if (childFrameSession._swappedIn) {
653
- childFrameSession.dispose();
654
- return;
655
- }
656
-
657
- // However, sometimes we get detachedFromTarget before frameAttached.
658
- // In this case we don't know whether this is a remote frame detach,
659
- // or just a remote -> local transition. In the latter case, frameAttached
660
- // is already inflight, so let's make a safe roundtrip to ensure it arrives.
661
- this._client.send('Page.enable').catch(e => null).then(() => {
662
- // Child was not swapped in - that means frameAttached did not happen and
663
- // this is remote detach rather than remote -> local swap.
664
- if (!childFrameSession._swappedIn) this._page._frameManager.frameDetached(event.targetId);
665
- childFrameSession.dispose();
666
- });
667
- }
668
- _onWindowOpen(event) {
669
- this._crPage._nextWindowOpenPopupFeatures.push(event.windowFeatures);
670
- }
671
- async _onConsoleAPI(event) {
672
- if (event.executionContextId === 0) {
673
- // DevTools protocol stores the last 1000 console messages. These
674
- // messages are always reported even for removed execution contexts. In
675
- // this case, they are marked with executionContextId = 0 and are
676
- // reported upon enabling Runtime agent.
677
- //
678
- // Ignore these messages since:
679
- // - there's no execution context we can use to operate with message
680
- // arguments
681
- // - these messages are reported before Playwright clients can subscribe
682
- // to the 'console'
683
- // page event.
684
- //
685
- // @see https://github.com/GoogleChrome/puppeteer/issues/3865
686
- return;
687
- }
688
- const context = this._contextIdToContext.get(event.executionContextId);
689
- if (!context) return;
690
- const values = event.args.map(arg => context.createHandle(arg));
691
- this._page._addConsoleMessage(event.type, values, (0, _crProtocolHelper.toConsoleMessageLocation)(event.stackTrace));
692
- }
693
- async _onBindingCalled(event) {
694
- const pageOrError = await this._crPage._page.waitForInitializedOrError();
695
- if (!(pageOrError instanceof Error)) {
696
- const context = this._contextIdToContext.get(event.executionContextId);
697
- if (context) await this._page._onBindingCalled(event.payload, context);
698
- }
699
- }
700
- _onDialog(event) {
701
- if (!this._page._frameManager.frame(this._targetId)) return; // Our frame/subtree may be gone already.
702
- this._page.emitOnContext(_browserContext.BrowserContext.Events.Dialog, new dialog.Dialog(this._page, event.type, event.message, async (accept, promptText) => {
703
- // TODO: this should actually be a CDP event that notifies about a cancelled navigation attempt.
704
- if (this._isMainFrame() && event.type === 'beforeunload' && !accept) this._page._frameManager.frameAbortedNavigation(this._page.mainFrame()._id, 'navigation cancelled by beforeunload dialog');
705
- await this._client.send('Page.handleJavaScriptDialog', {
706
- accept,
707
- promptText
708
- });
709
- }, event.defaultPrompt));
710
- }
711
- _handleException(exceptionDetails) {
712
- this._page.emitOnContextOnceInitialized(_browserContext.BrowserContext.Events.PageError, (0, _crProtocolHelper.exceptionToError)(exceptionDetails), this._page);
713
- }
714
- async _onTargetCrashed() {
715
- this._client._markAsCrashed();
716
- this._page._didCrash();
717
- }
718
- _onLogEntryAdded(event) {
719
- const {
720
- level,
721
- text,
722
- args,
723
- source,
724
- url,
725
- lineNumber
726
- } = event.entry;
727
- if (args) args.map(arg => (0, _crProtocolHelper.releaseObject)(this._client, arg.objectId));
728
- if (source !== 'worker') {
729
- const location = {
730
- url: url || '',
731
- lineNumber: lineNumber || 0,
732
- columnNumber: 0
733
- };
734
- this._page._addConsoleMessage(level, [], location, text);
735
- }
736
- }
737
- async _onFileChooserOpened(event) {
738
- if (!event.backendNodeId) return;
739
- const frame = this._page._frameManager.frame(event.frameId);
740
- if (!frame) return;
741
- let handle;
742
- try {
743
- const utilityContext = await frame._utilityContext();
744
- handle = await this._adoptBackendNodeId(event.backendNodeId, utilityContext);
745
- } catch (e) {
746
- // During async processing, frame/context may go away. We should not throw.
747
- return;
748
- }
749
- await this._page._onFileChooserOpened(handle);
750
- }
751
- _willBeginDownload() {
752
- if (!this._crPage._page.initializedOrUndefined()) {
753
- // Resume the page creation with an error. The page will automatically close right
754
- // after the download begins.
755
- this._firstNonInitialNavigationCommittedReject(new Error('Starting new page download'));
756
- }
757
- }
758
- _onScreencastFrame(payload) {
759
- this._page.throttleScreencastFrameAck(() => {
760
- this._client.send('Page.screencastFrameAck', {
761
- sessionId: payload.sessionId
762
- }).catch(() => {});
763
- });
764
- const buffer = Buffer.from(payload.data, 'base64');
765
- this._page.emit(_page.Page.Events.ScreencastFrame, {
766
- buffer,
767
- frameSwapWallTime: payload.metadata.timestamp ? payload.metadata.timestamp * 1000 : undefined,
768
- width: payload.metadata.deviceWidth,
769
- height: payload.metadata.deviceHeight
770
- });
771
- }
772
- async _createVideoRecorder(screencastId, options) {
773
- (0, _utils.assert)(!this._screencastId);
774
- const ffmpegPath = _registry.registry.findExecutable('ffmpeg').executablePathOrDie(this._page.attribution.playwright.options.sdkLanguage);
775
- this._videoRecorder = await _videoRecorder.VideoRecorder.launch(this._crPage._page, ffmpegPath, options);
776
- this._screencastId = screencastId;
777
- }
778
- async _startVideoRecording(options) {
779
- const screencastId = this._screencastId;
780
- (0, _utils.assert)(screencastId);
781
- this._page.once(_page.Page.Events.Close, () => this._stopVideoRecording().catch(() => {}));
782
- const gotFirstFrame = new Promise(f => this._client.once('Page.screencastFrame', f));
783
- await this._startScreencast(this._videoRecorder, {
784
- format: 'jpeg',
785
- quality: 90,
786
- maxWidth: options.width,
787
- maxHeight: options.height
788
- });
789
- // Wait for the first frame before reporting video to the client.
790
- gotFirstFrame.then(() => {
791
- this._crPage._browserContext._browser._videoStarted(this._crPage._browserContext, screencastId, options.outputFile, this._crPage._page.waitForInitializedOrError());
792
- });
793
- }
794
- async _stopVideoRecording() {
795
- if (!this._screencastId) return;
796
- const screencastId = this._screencastId;
797
- this._screencastId = null;
798
- const recorder = this._videoRecorder;
799
- this._videoRecorder = null;
800
- await this._stopScreencast(recorder);
801
- await recorder.stop().catch(() => {});
802
- // Keep the video artifact in the map until encoding is fully finished, if the context
803
- // starts closing before the video is fully written to disk it will wait for it.
804
- const video = this._crPage._browserContext._browser._takeVideo(screencastId);
805
- video === null || video === void 0 || video.reportFinished();
806
- }
807
- async _startScreencast(client, options = {}) {
808
- this._screencastClients.add(client);
809
- if (this._screencastClients.size === 1) await this._client.send('Page.startScreencast', options);
810
- }
811
- async _stopScreencast(client) {
812
- this._screencastClients.delete(client);
813
- if (!this._screencastClients.size) await this._client._sendMayFail('Page.stopScreencast');
814
- }
815
- async _updateGeolocation(initial) {
816
- const geolocation = this._crPage._browserContext._options.geolocation;
817
- if (!initial || geolocation) await this._client.send('Emulation.setGeolocationOverride', geolocation || {});
818
- }
819
- async _updateViewport(preserveWindowBoundaries) {
820
- if (this._crPage._browserContext._browser.isClank()) return;
821
- (0, _utils.assert)(this._isMainFrame());
822
- const options = this._crPage._browserContext._options;
823
- const emulatedSize = this._page.emulatedSize();
824
- if (emulatedSize === null) return;
825
- const viewportSize = emulatedSize.viewport;
826
- const screenSize = emulatedSize.screen;
827
- const isLandscape = screenSize.width > screenSize.height;
828
- const metricsOverride = {
829
- mobile: !!options.isMobile,
830
- width: viewportSize.width,
831
- height: viewportSize.height,
832
- screenWidth: screenSize.width,
833
- screenHeight: screenSize.height,
834
- deviceScaleFactor: options.deviceScaleFactor || 1,
835
- screenOrientation: !!options.isMobile ? isLandscape ? {
836
- angle: 90,
837
- type: 'landscapePrimary'
838
- } : {
839
- angle: 0,
840
- type: 'portraitPrimary'
841
- } : {
842
- angle: 0,
843
- type: 'landscapePrimary'
844
- },
845
- dontSetVisibleSize: preserveWindowBoundaries
846
- };
847
- if (JSON.stringify(this._metricsOverride) === JSON.stringify(metricsOverride)) return;
848
- const promises = [this._client.send('Emulation.setDeviceMetricsOverride', metricsOverride)];
849
- if (!preserveWindowBoundaries && this._windowId) {
850
- let insets = {
851
- width: 0,
852
- height: 0
853
- };
854
- if (this._crPage._browserContext._browser.options.headful) {
855
- // TODO: popup windows have their own insets.
856
- insets = {
857
- width: 24,
858
- height: 88
859
- };
860
- if (process.platform === 'win32') insets = {
861
- width: 16,
862
- height: 88
863
- };else if (process.platform === 'linux') insets = {
864
- width: 8,
865
- height: 85
866
- };else if (process.platform === 'darwin') insets = {
867
- width: 2,
868
- height: 80
869
- };
870
- if (this._crPage._browserContext.isPersistentContext()) {
871
- // FIXME: Chrome bug: OOPIF router is confused when hit target is
872
- // outside browser window.
873
- // Account for the infobar here to work around the bug.
874
- insets.height += 46;
875
- }
876
- }
877
- promises.push(this.setWindowBounds({
878
- width: viewportSize.width + insets.width,
879
- height: viewportSize.height + insets.height
880
- }));
881
- }
882
- await Promise.all(promises);
883
- this._metricsOverride = metricsOverride;
884
- }
885
- async windowBounds() {
886
- const {
887
- bounds
888
- } = await this._client.send('Browser.getWindowBounds', {
889
- windowId: this._windowId
890
- });
891
- return bounds;
892
- }
893
- async setWindowBounds(bounds) {
894
- return await this._client.send('Browser.setWindowBounds', {
895
- windowId: this._windowId,
896
- bounds
897
- });
898
- }
899
- async _updateEmulateMedia() {
900
- const emulatedMedia = this._page.emulatedMedia();
901
- // Empty string disables the override.
902
- const media = emulatedMedia.media === 'no-override' ? '' : emulatedMedia.media;
903
- const colorScheme = emulatedMedia.colorScheme === 'no-override' ? '' : emulatedMedia.colorScheme;
904
- const reducedMotion = emulatedMedia.reducedMotion === 'no-override' ? '' : emulatedMedia.reducedMotion;
905
- const forcedColors = emulatedMedia.forcedColors === 'no-override' ? '' : emulatedMedia.forcedColors;
906
- const features = [{
907
- name: 'prefers-color-scheme',
908
- value: colorScheme
909
- }, {
910
- name: 'prefers-reduced-motion',
911
- value: reducedMotion
912
- }, {
913
- name: 'forced-colors',
914
- value: forcedColors
915
- }];
916
- await this._client.send('Emulation.setEmulatedMedia', {
917
- media,
918
- features
919
- });
920
- }
921
- async _updateUserAgent() {
922
- const options = this._crPage._browserContext._options;
923
- await this._client.send('Emulation.setUserAgentOverride', {
924
- userAgent: options.userAgent || '',
925
- acceptLanguage: options.locale,
926
- userAgentMetadata: calculateUserAgentMetadata(options)
927
- });
928
- }
929
- async _setDefaultFontFamilies(session) {
930
- const fontFamilies = _defaultFontFamilies.platformToFontFamilies[this._crPage._browserContext._browser._platform()];
931
- await session.send('Page.setFontFamilies', fontFamilies);
932
- }
933
- async _updateFileChooserInterception(initial) {
934
- const enabled = this._page.fileChooserIntercepted();
935
- if (initial && !enabled) return;
936
- await this._client.send('Page.setInterceptFileChooserDialog', {
937
- enabled
938
- }).catch(() => {}); // target can be closed.
939
- }
940
- async _evaluateOnNewDocument(initScript, world) {
941
- const worldName = world === 'utility' ? UTILITY_WORLD_NAME : undefined;
942
- const {
943
- identifier
944
- } = await this._client.send('Page.addScriptToEvaluateOnNewDocument', {
945
- source: initScript.source,
946
- worldName
947
- });
948
- if (!initScript.internal) this._evaluateOnNewDocumentIdentifiers.push(identifier);
949
- }
950
- async _removeEvaluatesOnNewDocument() {
951
- const identifiers = this._evaluateOnNewDocumentIdentifiers;
952
- this._evaluateOnNewDocumentIdentifiers = [];
953
- await Promise.all(identifiers.map(identifier => this._client.send('Page.removeScriptToEvaluateOnNewDocument', {
954
- identifier
955
- })));
956
- }
957
- async _getContentFrame(handle) {
958
- const nodeInfo = await this._client.send('DOM.describeNode', {
959
- objectId: handle._objectId
960
- });
961
- if (!nodeInfo || typeof nodeInfo.node.frameId !== 'string') return null;
962
- return this._page._frameManager.frame(nodeInfo.node.frameId);
963
- }
964
- async _getOwnerFrame(handle) {
965
- // document.documentElement has frameId of the owner frame.
966
- const documentElement = await handle.evaluateHandle(node => {
967
- const doc = node;
968
- if (doc.documentElement && doc.documentElement.ownerDocument === doc) return doc.documentElement;
969
- return node.ownerDocument ? node.ownerDocument.documentElement : null;
970
- });
971
- if (!documentElement) return null;
972
- if (!documentElement._objectId) return null;
973
- const nodeInfo = await this._client.send('DOM.describeNode', {
974
- objectId: documentElement._objectId
975
- });
976
- const frameId = nodeInfo && typeof nodeInfo.node.frameId === 'string' ? nodeInfo.node.frameId : null;
977
- documentElement.dispose();
978
- return frameId;
979
- }
980
- async _getBoundingBox(handle) {
981
- const result = await this._client._sendMayFail('DOM.getBoxModel', {
982
- objectId: handle._objectId
983
- });
984
- if (!result) return null;
985
- const quad = result.model.border;
986
- const x = Math.min(quad[0], quad[2], quad[4], quad[6]);
987
- const y = Math.min(quad[1], quad[3], quad[5], quad[7]);
988
- const width = Math.max(quad[0], quad[2], quad[4], quad[6]) - x;
989
- const height = Math.max(quad[1], quad[3], quad[5], quad[7]) - y;
990
- const position = await this._framePosition();
991
- if (!position) return null;
992
- return {
993
- x: x + position.x,
994
- y: y + position.y,
995
- width,
996
- height
997
- };
998
- }
999
- async _framePosition() {
1000
- const frame = this._page._frameManager.frame(this._targetId);
1001
- if (!frame) return null;
1002
- if (frame === this._page.mainFrame()) return {
1003
- x: 0,
1004
- y: 0
1005
- };
1006
- const element = await frame.frameElement();
1007
- const box = await element.boundingBox();
1008
- return box;
1009
- }
1010
- async _scrollRectIntoViewIfNeeded(handle, rect) {
1011
- return await this._client.send('DOM.scrollIntoViewIfNeeded', {
1012
- objectId: handle._objectId,
1013
- rect
1014
- }).then(() => 'done').catch(e => {
1015
- if (e instanceof Error && e.message.includes('Node does not have a layout object')) return 'error:notvisible';
1016
- if (e instanceof Error && e.message.includes('Node is detached from document')) return 'error:notconnected';
1017
- throw e;
1018
- });
1019
- }
1020
- async _getContentQuads(handle) {
1021
- const result = await this._client._sendMayFail('DOM.getContentQuads', {
1022
- objectId: handle._objectId
1023
- });
1024
- if (!result) return null;
1025
- const position = await this._framePosition();
1026
- if (!position) return null;
1027
- return result.quads.map(quad => [{
1028
- x: quad[0] + position.x,
1029
- y: quad[1] + position.y
1030
- }, {
1031
- x: quad[2] + position.x,
1032
- y: quad[3] + position.y
1033
- }, {
1034
- x: quad[4] + position.x,
1035
- y: quad[5] + position.y
1036
- }, {
1037
- x: quad[6] + position.x,
1038
- y: quad[7] + position.y
1039
- }]);
1040
- }
1041
- async _adoptElementHandle(handle, to) {
1042
- const nodeInfo = await this._client.send('DOM.describeNode', {
1043
- objectId: handle._objectId
1044
- });
1045
- return this._adoptBackendNodeId(nodeInfo.node.backendNodeId, to);
1046
- }
1047
- async _adoptBackendNodeId(backendNodeId, to) {
1048
- const result = await this._client._sendMayFail('DOM.resolveNode', {
1049
- backendNodeId,
1050
- executionContextId: to[contextDelegateSymbol]._contextId
1051
- });
1052
- if (!result || result.object.subtype === 'null') throw new Error(dom.kUnableToAdoptErrorMessage);
1053
- return to.createHandle(result.object).asElement();
1054
- }
1055
- }
1056
- async function emulateLocale(session, locale) {
1057
- try {
1058
- await session.send('Emulation.setLocaleOverride', {
1059
- locale
1060
- });
1061
- } catch (exception) {
1062
- // All pages in the same renderer share locale. All such pages belong to the same
1063
- // context and if locale is overridden for one of them its value is the same as
1064
- // we are trying to set so it's not a problem.
1065
- if (exception.message.includes('Another locale override is already in effect')) return;
1066
- throw exception;
1067
- }
1068
- }
1069
- async function emulateTimezone(session, timezoneId) {
1070
- try {
1071
- await session.send('Emulation.setTimezoneOverride', {
1072
- timezoneId: timezoneId
1073
- });
1074
- } catch (exception) {
1075
- if (exception.message.includes('Timezone override is already in effect')) return;
1076
- if (exception.message.includes('Invalid timezone')) throw new Error(`Invalid timezone ID: ${timezoneId}`);
1077
- throw exception;
1078
- }
1079
- }
1080
- const contextDelegateSymbol = Symbol('delegate');
1081
-
1082
- // Chromium reference: https://source.chromium.org/chromium/chromium/src/+/main:components/embedder_support/user_agent_utils.cc;l=434;drc=70a6711e08e9f9e0d8e4c48e9ba5cab62eb010c2
1083
- function calculateUserAgentMetadata(options) {
1084
- const ua = options.userAgent;
1085
- if (!ua) return undefined;
1086
- const metadata = {
1087
- mobile: !!options.isMobile,
1088
- model: '',
1089
- architecture: 'x64',
1090
- platform: 'Windows',
1091
- platformVersion: ''
1092
- };
1093
- const androidMatch = ua.match(/Android (\d+(\.\d+)?(\.\d+)?)/);
1094
- const iPhoneMatch = ua.match(/iPhone OS (\d+(_\d+)?)/);
1095
- const iPadMatch = ua.match(/iPad; CPU OS (\d+(_\d+)?)/);
1096
- const macOSMatch = ua.match(/Mac OS X (\d+(_\d+)?(_\d+)?)/);
1097
- const windowsMatch = ua.match(/Windows\D+(\d+(\.\d+)?(\.\d+)?)/);
1098
- if (androidMatch) {
1099
- metadata.platform = 'Android';
1100
- metadata.platformVersion = androidMatch[1];
1101
- metadata.architecture = 'arm';
1102
- } else if (iPhoneMatch) {
1103
- metadata.platform = 'iOS';
1104
- metadata.platformVersion = iPhoneMatch[1];
1105
- metadata.architecture = 'arm';
1106
- } else if (iPadMatch) {
1107
- metadata.platform = 'iOS';
1108
- metadata.platformVersion = iPadMatch[1];
1109
- metadata.architecture = 'arm';
1110
- } else if (macOSMatch) {
1111
- metadata.platform = 'macOS';
1112
- metadata.platformVersion = macOSMatch[1];
1113
- if (!ua.includes('Intel')) metadata.architecture = 'arm';
1114
- } else if (windowsMatch) {
1115
- metadata.platform = 'Windows';
1116
- metadata.platformVersion = windowsMatch[1];
1117
- } else if (ua.toLowerCase().includes('linux')) {
1118
- metadata.platform = 'Linux';
1119
- }
1120
- if (ua.includes('ARM')) metadata.architecture = 'arm';
1121
- return metadata;
1122
- }