pokeedex 0.1.0 → 0.1.5

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 (560) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -5
  3. data/bin/pokeedex +1 -44
  4. data/lib/pokeedex/configuration.rb +0 -6
  5. data/lib/pokeedex/install_playwright.rb +62 -0
  6. data/lib/pokeedex/pokemon/scrapper/fetchers/base.rb +1 -1
  7. data/lib/pokeedex/version.rb +1 -1
  8. data/lib/pokeedex.rb +5 -2
  9. data/spec/pokeedex/configuration_spec.rb +0 -7
  10. data/spec/spec_helper.rb +1 -1
  11. metadata +2 -550
  12. data/node_modules/.bin/playwright +0 -1
  13. data/node_modules/.bin/playwright-core +0 -1
  14. data/node_modules/.yarn-integrity +0 -22
  15. data/node_modules/@playwright/test/LICENSE +0 -202
  16. data/node_modules/@playwright/test/NOTICE +0 -5
  17. data/node_modules/@playwright/test/README.md +0 -169
  18. data/node_modules/@playwright/test/cli.js +0 -19
  19. data/node_modules/@playwright/test/index.d.ts +0 -18
  20. data/node_modules/@playwright/test/index.js +0 -17
  21. data/node_modules/@playwright/test/index.mjs +0 -18
  22. data/node_modules/@playwright/test/node_modules/.bin/playwright +0 -1
  23. data/node_modules/@playwright/test/package.json +0 -35
  24. data/node_modules/@playwright/test/reporter.d.ts +0 -17
  25. data/node_modules/@playwright/test/reporter.js +0 -17
  26. data/node_modules/@playwright/test/reporter.mjs +0 -17
  27. data/node_modules/@types/node/LICENSE +0 -21
  28. data/node_modules/@types/node/README.md +0 -15
  29. data/node_modules/@types/node/assert/strict.d.ts +0 -8
  30. data/node_modules/@types/node/assert.d.ts +0 -1040
  31. data/node_modules/@types/node/async_hooks.d.ts +0 -541
  32. data/node_modules/@types/node/buffer.d.ts +0 -2300
  33. data/node_modules/@types/node/child_process.d.ts +0 -1544
  34. data/node_modules/@types/node/cluster.d.ts +0 -578
  35. data/node_modules/@types/node/console.d.ts +0 -452
  36. data/node_modules/@types/node/constants.d.ts +0 -19
  37. data/node_modules/@types/node/crypto.d.ts +0 -4451
  38. data/node_modules/@types/node/dgram.d.ts +0 -596
  39. data/node_modules/@types/node/diagnostics_channel.d.ts +0 -554
  40. data/node_modules/@types/node/dns/promises.d.ts +0 -476
  41. data/node_modules/@types/node/dns.d.ts +0 -865
  42. data/node_modules/@types/node/dom-events.d.ts +0 -124
  43. data/node_modules/@types/node/domain.d.ts +0 -170
  44. data/node_modules/@types/node/events.d.ts +0 -931
  45. data/node_modules/@types/node/fs/promises.d.ts +0 -1264
  46. data/node_modules/@types/node/fs.d.ts +0 -4390
  47. data/node_modules/@types/node/globals.d.ts +0 -611
  48. data/node_modules/@types/node/globals.global.d.ts +0 -1
  49. data/node_modules/@types/node/http.d.ts +0 -1921
  50. data/node_modules/@types/node/http2.d.ts +0 -2555
  51. data/node_modules/@types/node/https.d.ts +0 -544
  52. data/node_modules/@types/node/index.d.ts +0 -90
  53. data/node_modules/@types/node/inspector.d.ts +0 -3966
  54. data/node_modules/@types/node/module.d.ts +0 -301
  55. data/node_modules/@types/node/net.d.ts +0 -995
  56. data/node_modules/@types/node/os.d.ts +0 -495
  57. data/node_modules/@types/node/package.json +0 -217
  58. data/node_modules/@types/node/path.d.ts +0 -200
  59. data/node_modules/@types/node/perf_hooks.d.ts +0 -941
  60. data/node_modules/@types/node/process.d.ts +0 -1912
  61. data/node_modules/@types/node/punycode.d.ts +0 -117
  62. data/node_modules/@types/node/querystring.d.ts +0 -153
  63. data/node_modules/@types/node/readline/promises.d.ts +0 -150
  64. data/node_modules/@types/node/readline.d.ts +0 -540
  65. data/node_modules/@types/node/repl.d.ts +0 -430
  66. data/node_modules/@types/node/sea.d.ts +0 -153
  67. data/node_modules/@types/node/sqlite.d.ts +0 -213
  68. data/node_modules/@types/node/stream/consumers.d.ts +0 -12
  69. data/node_modules/@types/node/stream/promises.d.ts +0 -83
  70. data/node_modules/@types/node/stream/web.d.ts +0 -606
  71. data/node_modules/@types/node/stream.d.ts +0 -1726
  72. data/node_modules/@types/node/string_decoder.d.ts +0 -67
  73. data/node_modules/@types/node/test.d.ts +0 -2098
  74. data/node_modules/@types/node/timers/promises.d.ts +0 -97
  75. data/node_modules/@types/node/timers.d.ts +0 -240
  76. data/node_modules/@types/node/tls.d.ts +0 -1220
  77. data/node_modules/@types/node/trace_events.d.ts +0 -197
  78. data/node_modules/@types/node/tty.d.ts +0 -208
  79. data/node_modules/@types/node/url.d.ts +0 -969
  80. data/node_modules/@types/node/util.d.ts +0 -2301
  81. data/node_modules/@types/node/v8.d.ts +0 -808
  82. data/node_modules/@types/node/vm.d.ts +0 -922
  83. data/node_modules/@types/node/wasi.d.ts +0 -181
  84. data/node_modules/@types/node/worker_threads.d.ts +0 -712
  85. data/node_modules/@types/node/zlib.d.ts +0 -539
  86. data/node_modules/fsevents/LICENSE +0 -22
  87. data/node_modules/fsevents/README.md +0 -83
  88. data/node_modules/fsevents/fsevents.d.ts +0 -46
  89. data/node_modules/fsevents/fsevents.js +0 -82
  90. data/node_modules/fsevents/fsevents.node +0 -0
  91. data/node_modules/fsevents/package.json +0 -62
  92. data/node_modules/playwright/.eslintrc.js +0 -6
  93. data/node_modules/playwright/LICENSE +0 -202
  94. data/node_modules/playwright/NOTICE +0 -5
  95. data/node_modules/playwright/README.md +0 -169
  96. data/node_modules/playwright/ThirdPartyNotices.txt +0 -4356
  97. data/node_modules/playwright/cli.js +0 -19
  98. data/node_modules/playwright/index.d.ts +0 -17
  99. data/node_modules/playwright/index.js +0 -17
  100. data/node_modules/playwright/index.mjs +0 -18
  101. data/node_modules/playwright/jsx-runtime.js +0 -41
  102. data/node_modules/playwright/jsx-runtime.mjs +0 -21
  103. data/node_modules/playwright/lib/common/config.js +0 -256
  104. data/node_modules/playwright/lib/common/configLoader.js +0 -321
  105. data/node_modules/playwright/lib/common/esmLoaderHost.js +0 -93
  106. data/node_modules/playwright/lib/common/expectBundle.js +0 -27
  107. data/node_modules/playwright/lib/common/expectBundleImpl.js +0 -389
  108. data/node_modules/playwright/lib/common/fixtures.js +0 -323
  109. data/node_modules/playwright/lib/common/globals.js +0 -48
  110. data/node_modules/playwright/lib/common/ipc.js +0 -48
  111. data/node_modules/playwright/lib/common/poolBuilder.js +0 -79
  112. data/node_modules/playwright/lib/common/process.js +0 -140
  113. data/node_modules/playwright/lib/common/suiteUtils.js +0 -133
  114. data/node_modules/playwright/lib/common/test.js +0 -311
  115. data/node_modules/playwright/lib/common/testLoader.js +0 -102
  116. data/node_modules/playwright/lib/common/testType.js +0 -284
  117. data/node_modules/playwright/lib/fsWatcher.js +0 -69
  118. data/node_modules/playwright/lib/index.js +0 -888
  119. data/node_modules/playwright/lib/internalsForTest.js +0 -28
  120. data/node_modules/playwright/lib/isomorphic/events.js +0 -72
  121. data/node_modules/playwright/lib/isomorphic/folders.js +0 -25
  122. data/node_modules/playwright/lib/isomorphic/stringInternPool.js +0 -58
  123. data/node_modules/playwright/lib/isomorphic/teleReceiver.js +0 -504
  124. data/node_modules/playwright/lib/isomorphic/teleSuiteUpdater.js +0 -149
  125. data/node_modules/playwright/lib/isomorphic/testServerConnection.js +0 -210
  126. data/node_modules/playwright/lib/isomorphic/testServerInterface.js +0 -5
  127. data/node_modules/playwright/lib/isomorphic/testTree.js +0 -272
  128. data/node_modules/playwright/lib/loader/loaderMain.js +0 -58
  129. data/node_modules/playwright/lib/matchers/expect.js +0 -297
  130. data/node_modules/playwright/lib/matchers/matcherHint.js +0 -50
  131. data/node_modules/playwright/lib/matchers/matchers.js +0 -449
  132. data/node_modules/playwright/lib/matchers/toBeTruthy.js +0 -55
  133. data/node_modules/playwright/lib/matchers/toEqual.js +0 -57
  134. data/node_modules/playwright/lib/matchers/toMatchSnapshot.js +0 -383
  135. data/node_modules/playwright/lib/matchers/toMatchText.js +0 -76
  136. data/node_modules/playwright/lib/plugins/gitCommitInfoPlugin.js +0 -78
  137. data/node_modules/playwright/lib/plugins/index.js +0 -19
  138. data/node_modules/playwright/lib/plugins/webServerPlugin.js +0 -187
  139. data/node_modules/playwright/lib/program.js +0 -346
  140. data/node_modules/playwright/lib/reporters/base.js +0 -553
  141. data/node_modules/playwright/lib/reporters/blob.js +0 -133
  142. data/node_modules/playwright/lib/reporters/dot.js +0 -82
  143. data/node_modules/playwright/lib/reporters/empty.js +0 -42
  144. data/node_modules/playwright/lib/reporters/github.js +0 -115
  145. data/node_modules/playwright/lib/reporters/html.js +0 -623
  146. data/node_modules/playwright/lib/reporters/internalReporter.js +0 -123
  147. data/node_modules/playwright/lib/reporters/json.js +0 -243
  148. data/node_modules/playwright/lib/reporters/junit.js +0 -233
  149. data/node_modules/playwright/lib/reporters/line.js +0 -108
  150. data/node_modules/playwright/lib/reporters/list.js +0 -222
  151. data/node_modules/playwright/lib/reporters/markdown.js +0 -76
  152. data/node_modules/playwright/lib/reporters/merge.js +0 -477
  153. data/node_modules/playwright/lib/reporters/multiplexer.js +0 -90
  154. data/node_modules/playwright/lib/reporters/reporterV2.js +0 -118
  155. data/node_modules/playwright/lib/reporters/teleEmitter.js +0 -268
  156. data/node_modules/playwright/lib/reporters/versions/blobV1.js +0 -5
  157. data/node_modules/playwright/lib/runner/dispatcher.js +0 -532
  158. data/node_modules/playwright/lib/runner/failureTracker.js +0 -60
  159. data/node_modules/playwright/lib/runner/loadUtils.js +0 -308
  160. data/node_modules/playwright/lib/runner/loaderHost.js +0 -85
  161. data/node_modules/playwright/lib/runner/processHost.js +0 -175
  162. data/node_modules/playwright/lib/runner/projectUtils.js +0 -203
  163. data/node_modules/playwright/lib/runner/reporters.js +0 -151
  164. data/node_modules/playwright/lib/runner/runner.js +0 -179
  165. data/node_modules/playwright/lib/runner/sigIntWatcher.js +0 -100
  166. data/node_modules/playwright/lib/runner/taskRunner.js +0 -147
  167. data/node_modules/playwright/lib/runner/tasks.js +0 -407
  168. data/node_modules/playwright/lib/runner/testGroups.js +0 -136
  169. data/node_modules/playwright/lib/runner/testServer.js +0 -605
  170. data/node_modules/playwright/lib/runner/uiModeReporter.js +0 -31
  171. data/node_modules/playwright/lib/runner/vcs.js +0 -55
  172. data/node_modules/playwright/lib/runner/watchMode.js +0 -398
  173. data/node_modules/playwright/lib/runner/workerHost.js +0 -85
  174. data/node_modules/playwright/lib/third_party/tsconfig-loader.js +0 -134
  175. data/node_modules/playwright/lib/transform/babelBundle.js +0 -28
  176. data/node_modules/playwright/lib/transform/babelBundleImpl.js +0 -2032
  177. data/node_modules/playwright/lib/transform/compilationCache.js +0 -254
  178. data/node_modules/playwright/lib/transform/esmLoader.js +0 -117
  179. data/node_modules/playwright/lib/transform/esmUtils.js +0 -32
  180. data/node_modules/playwright/lib/transform/portTransport.js +0 -81
  181. data/node_modules/playwright/lib/transform/transform.js +0 -267
  182. data/node_modules/playwright/lib/util.js +0 -356
  183. data/node_modules/playwright/lib/utilsBundle.js +0 -28
  184. data/node_modules/playwright/lib/utilsBundleImpl.js +0 -102
  185. data/node_modules/playwright/lib/worker/fixtureRunner.js +0 -279
  186. data/node_modules/playwright/lib/worker/testInfo.js +0 -397
  187. data/node_modules/playwright/lib/worker/testTracing.js +0 -314
  188. data/node_modules/playwright/lib/worker/timeoutManager.js +0 -153
  189. data/node_modules/playwright/lib/worker/workerMain.js +0 -637
  190. data/node_modules/playwright/node_modules/.bin/playwright-core +0 -1
  191. data/node_modules/playwright/package.json +0 -66
  192. data/node_modules/playwright/test.d.ts +0 -18
  193. data/node_modules/playwright/test.js +0 -24
  194. data/node_modules/playwright/test.mjs +0 -33
  195. data/node_modules/playwright/types/test.d.ts +0 -8444
  196. data/node_modules/playwright/types/testReporter.d.ts +0 -749
  197. data/node_modules/playwright-core/LICENSE +0 -202
  198. data/node_modules/playwright-core/NOTICE +0 -5
  199. data/node_modules/playwright-core/README.md +0 -3
  200. data/node_modules/playwright-core/ThirdPartyNotices.txt +0 -1548
  201. data/node_modules/playwright-core/bin/PrintDeps.exe +0 -0
  202. data/node_modules/playwright-core/bin/README.md +0 -2
  203. data/node_modules/playwright-core/bin/install_media_pack.ps1 +0 -5
  204. data/node_modules/playwright-core/bin/reinstall_chrome_beta_linux.sh +0 -40
  205. data/node_modules/playwright-core/bin/reinstall_chrome_beta_mac.sh +0 -13
  206. data/node_modules/playwright-core/bin/reinstall_chrome_beta_win.ps1 +0 -24
  207. data/node_modules/playwright-core/bin/reinstall_chrome_stable_linux.sh +0 -40
  208. data/node_modules/playwright-core/bin/reinstall_chrome_stable_mac.sh +0 -12
  209. data/node_modules/playwright-core/bin/reinstall_chrome_stable_win.ps1 +0 -24
  210. data/node_modules/playwright-core/bin/reinstall_msedge_beta_linux.sh +0 -40
  211. data/node_modules/playwright-core/bin/reinstall_msedge_beta_mac.sh +0 -11
  212. data/node_modules/playwright-core/bin/reinstall_msedge_beta_win.ps1 +0 -23
  213. data/node_modules/playwright-core/bin/reinstall_msedge_dev_linux.sh +0 -40
  214. data/node_modules/playwright-core/bin/reinstall_msedge_dev_mac.sh +0 -11
  215. data/node_modules/playwright-core/bin/reinstall_msedge_dev_win.ps1 +0 -23
  216. data/node_modules/playwright-core/bin/reinstall_msedge_stable_linux.sh +0 -40
  217. data/node_modules/playwright-core/bin/reinstall_msedge_stable_mac.sh +0 -11
  218. data/node_modules/playwright-core/bin/reinstall_msedge_stable_win.ps1 +0 -24
  219. data/node_modules/playwright-core/browsers.json +0 -53
  220. data/node_modules/playwright-core/cli.js +0 -18
  221. data/node_modules/playwright-core/index.d.ts +0 -17
  222. data/node_modules/playwright-core/index.js +0 -33
  223. data/node_modules/playwright-core/index.mjs +0 -28
  224. data/node_modules/playwright-core/lib/androidServerImpl.js +0 -69
  225. data/node_modules/playwright-core/lib/browserServerImpl.js +0 -92
  226. data/node_modules/playwright-core/lib/cli/driver.js +0 -95
  227. data/node_modules/playwright-core/lib/cli/program.js +0 -577
  228. data/node_modules/playwright-core/lib/cli/programWithTestStub.js +0 -67
  229. data/node_modules/playwright-core/lib/client/accessibility.js +0 -50
  230. data/node_modules/playwright-core/lib/client/android.js +0 -473
  231. data/node_modules/playwright-core/lib/client/api.js +0 -279
  232. data/node_modules/playwright-core/lib/client/artifact.js +0 -79
  233. data/node_modules/playwright-core/lib/client/browser.js +0 -145
  234. data/node_modules/playwright-core/lib/client/browserContext.js +0 -541
  235. data/node_modules/playwright-core/lib/client/browserType.js +0 -241
  236. data/node_modules/playwright-core/lib/client/cdpSession.js +0 -53
  237. data/node_modules/playwright-core/lib/client/channelOwner.js +0 -231
  238. data/node_modules/playwright-core/lib/client/clientHelper.js +0 -57
  239. data/node_modules/playwright-core/lib/client/clientInstrumentation.js +0 -50
  240. data/node_modules/playwright-core/lib/client/clock.js +0 -68
  241. data/node_modules/playwright-core/lib/client/connection.js +0 -330
  242. data/node_modules/playwright-core/lib/client/consoleMessage.js +0 -55
  243. data/node_modules/playwright-core/lib/client/coverage.js +0 -41
  244. data/node_modules/playwright-core/lib/client/dialog.js +0 -57
  245. data/node_modules/playwright-core/lib/client/download.js +0 -62
  246. data/node_modules/playwright-core/lib/client/electron.js +0 -135
  247. data/node_modules/playwright-core/lib/client/elementHandle.js +0 -321
  248. data/node_modules/playwright-core/lib/client/errors.js +0 -77
  249. data/node_modules/playwright-core/lib/client/eventEmitter.js +0 -314
  250. data/node_modules/playwright-core/lib/client/events.js +0 -94
  251. data/node_modules/playwright-core/lib/client/fetch.js +0 -396
  252. data/node_modules/playwright-core/lib/client/fileChooser.js +0 -45
  253. data/node_modules/playwright-core/lib/client/frame.js +0 -504
  254. data/node_modules/playwright-core/lib/client/harRouter.js +0 -99
  255. data/node_modules/playwright-core/lib/client/input.js +0 -111
  256. data/node_modules/playwright-core/lib/client/jsHandle.js +0 -129
  257. data/node_modules/playwright-core/lib/client/jsonPipe.js +0 -35
  258. data/node_modules/playwright-core/lib/client/localUtils.js +0 -35
  259. data/node_modules/playwright-core/lib/client/locator.js +0 -441
  260. data/node_modules/playwright-core/lib/client/network.js +0 -604
  261. data/node_modules/playwright-core/lib/client/page.js +0 -725
  262. data/node_modules/playwright-core/lib/client/playwright.js +0 -77
  263. data/node_modules/playwright-core/lib/client/selectors.js +0 -67
  264. data/node_modules/playwright-core/lib/client/stream.js +0 -54
  265. data/node_modules/playwright-core/lib/client/tracing.js +0 -138
  266. data/node_modules/playwright-core/lib/client/types.js +0 -24
  267. data/node_modules/playwright-core/lib/client/video.js +0 -51
  268. data/node_modules/playwright-core/lib/client/waiter.js +0 -158
  269. data/node_modules/playwright-core/lib/client/webError.js +0 -37
  270. data/node_modules/playwright-core/lib/client/worker.js +0 -71
  271. data/node_modules/playwright-core/lib/client/writableStream.js +0 -54
  272. data/node_modules/playwright-core/lib/common/socksProxy.js +0 -569
  273. data/node_modules/playwright-core/lib/common/timeoutSettings.js +0 -73
  274. data/node_modules/playwright-core/lib/common/types.js +0 -5
  275. data/node_modules/playwright-core/lib/generated/clockSource.js +0 -7
  276. data/node_modules/playwright-core/lib/generated/consoleApiSource.js +0 -7
  277. data/node_modules/playwright-core/lib/generated/injectedScriptSource.js +0 -7
  278. data/node_modules/playwright-core/lib/generated/recorderSource.js +0 -7
  279. data/node_modules/playwright-core/lib/generated/utilityScriptSource.js +0 -7
  280. data/node_modules/playwright-core/lib/image_tools/colorUtils.js +0 -98
  281. data/node_modules/playwright-core/lib/image_tools/compare.js +0 -108
  282. data/node_modules/playwright-core/lib/image_tools/imageChannel.js +0 -70
  283. data/node_modules/playwright-core/lib/image_tools/stats.js +0 -102
  284. data/node_modules/playwright-core/lib/inProcessFactory.js +0 -54
  285. data/node_modules/playwright-core/lib/inprocess.js +0 -20
  286. data/node_modules/playwright-core/lib/outofprocess.js +0 -67
  287. data/node_modules/playwright-core/lib/protocol/debug.js +0 -27
  288. data/node_modules/playwright-core/lib/protocol/serializers.js +0 -173
  289. data/node_modules/playwright-core/lib/protocol/transport.js +0 -82
  290. data/node_modules/playwright-core/lib/protocol/validator.js +0 -2694
  291. data/node_modules/playwright-core/lib/protocol/validatorPrimitives.js +0 -139
  292. data/node_modules/playwright-core/lib/remote/playwrightConnection.js +0 -274
  293. data/node_modules/playwright-core/lib/remote/playwrightServer.js +0 -110
  294. data/node_modules/playwright-core/lib/server/accessibility.js +0 -62
  295. data/node_modules/playwright-core/lib/server/android/android.js +0 -441
  296. data/node_modules/playwright-core/lib/server/android/backendAdb.js +0 -172
  297. data/node_modules/playwright-core/lib/server/artifact.js +0 -104
  298. data/node_modules/playwright-core/lib/server/bidi/bidiBrowser.js +0 -296
  299. data/node_modules/playwright-core/lib/server/bidi/bidiConnection.js +0 -206
  300. data/node_modules/playwright-core/lib/server/bidi/bidiExecutionContext.js +0 -162
  301. data/node_modules/playwright-core/lib/server/bidi/bidiFirefox.js +0 -110
  302. data/node_modules/playwright-core/lib/server/bidi/bidiInput.js +0 -174
  303. data/node_modules/playwright-core/lib/server/bidi/bidiNetworkManager.js +0 -304
  304. data/node_modules/playwright-core/lib/server/bidi/bidiPage.js +0 -456
  305. data/node_modules/playwright-core/lib/server/bidi/third_party/bidiDeserializer.js +0 -93
  306. data/node_modules/playwright-core/lib/server/bidi/third_party/bidiKeyboard.js +0 -238
  307. data/node_modules/playwright-core/lib/server/bidi/third_party/bidiProtocol.js +0 -139
  308. data/node_modules/playwright-core/lib/server/bidi/third_party/bidiSerializer.js +0 -144
  309. data/node_modules/playwright-core/lib/server/browser.js +0 -137
  310. data/node_modules/playwright-core/lib/server/browserContext.js +0 -684
  311. data/node_modules/playwright-core/lib/server/browserType.js +0 -307
  312. data/node_modules/playwright-core/lib/server/chromium/appIcon.png +0 -0
  313. data/node_modules/playwright-core/lib/server/chromium/chromium.js +0 -362
  314. data/node_modules/playwright-core/lib/server/chromium/chromiumSwitches.js +0 -44
  315. data/node_modules/playwright-core/lib/server/chromium/crAccessibility.js +0 -237
  316. data/node_modules/playwright-core/lib/server/chromium/crBrowser.js +0 -515
  317. data/node_modules/playwright-core/lib/server/chromium/crConnection.js +0 -228
  318. data/node_modules/playwright-core/lib/server/chromium/crCoverage.js +0 -246
  319. data/node_modules/playwright-core/lib/server/chromium/crDevTools.js +0 -104
  320. data/node_modules/playwright-core/lib/server/chromium/crDragDrop.js +0 -143
  321. data/node_modules/playwright-core/lib/server/chromium/crExecutionContext.js +0 -156
  322. data/node_modules/playwright-core/lib/server/chromium/crInput.js +0 -171
  323. data/node_modules/playwright-core/lib/server/chromium/crNetworkManager.js +0 -767
  324. data/node_modules/playwright-core/lib/server/chromium/crPage.js +0 -1128
  325. data/node_modules/playwright-core/lib/server/chromium/crPdf.js +0 -153
  326. data/node_modules/playwright-core/lib/server/chromium/crProtocolHelper.js +0 -133
  327. data/node_modules/playwright-core/lib/server/chromium/crServiceWorker.js +0 -112
  328. data/node_modules/playwright-core/lib/server/chromium/defaultFontFamilies.js +0 -145
  329. data/node_modules/playwright-core/lib/server/chromium/videoRecorder.js +0 -155
  330. data/node_modules/playwright-core/lib/server/clock.js +0 -125
  331. data/node_modules/playwright-core/lib/server/codegen/csharp.js +0 -299
  332. data/node_modules/playwright-core/lib/server/codegen/java.js +0 -235
  333. data/node_modules/playwright-core/lib/server/codegen/javascript.js +0 -223
  334. data/node_modules/playwright-core/lib/server/codegen/jsonl.js +0 -47
  335. data/node_modules/playwright-core/lib/server/codegen/language.js +0 -76
  336. data/node_modules/playwright-core/lib/server/codegen/languages.js +0 -30
  337. data/node_modules/playwright-core/lib/server/codegen/python.js +0 -265
  338. data/node_modules/playwright-core/lib/server/codegen/types.js +0 -5
  339. data/node_modules/playwright-core/lib/server/console.js +0 -57
  340. data/node_modules/playwright-core/lib/server/cookieStore.js +0 -112
  341. data/node_modules/playwright-core/lib/server/debugController.js +0 -234
  342. data/node_modules/playwright-core/lib/server/debugger.js +0 -132
  343. data/node_modules/playwright-core/lib/server/deviceDescriptors.js +0 -26
  344. data/node_modules/playwright-core/lib/server/deviceDescriptorsSource.json +0 -1669
  345. data/node_modules/playwright-core/lib/server/dialog.js +0 -70
  346. data/node_modules/playwright-core/lib/server/dispatchers/androidDispatcher.js +0 -193
  347. data/node_modules/playwright-core/lib/server/dispatchers/artifactDispatcher.js +0 -118
  348. data/node_modules/playwright-core/lib/server/dispatchers/browserContextDispatcher.js +0 -351
  349. data/node_modules/playwright-core/lib/server/dispatchers/browserDispatcher.js +0 -170
  350. data/node_modules/playwright-core/lib/server/dispatchers/browserTypeDispatcher.js +0 -55
  351. data/node_modules/playwright-core/lib/server/dispatchers/cdpSessionDispatcher.js +0 -48
  352. data/node_modules/playwright-core/lib/server/dispatchers/debugControllerDispatcher.js +0 -103
  353. data/node_modules/playwright-core/lib/server/dispatchers/dialogDispatcher.js +0 -44
  354. data/node_modules/playwright-core/lib/server/dispatchers/dispatcher.js +0 -395
  355. data/node_modules/playwright-core/lib/server/dispatchers/electronDispatcher.js +0 -93
  356. data/node_modules/playwright-core/lib/server/dispatchers/elementHandlerDispatcher.js +0 -228
  357. data/node_modules/playwright-core/lib/server/dispatchers/frameDispatcher.js +0 -286
  358. data/node_modules/playwright-core/lib/server/dispatchers/jsHandleDispatcher.js +0 -102
  359. data/node_modules/playwright-core/lib/server/dispatchers/jsonPipeDispatcher.js +0 -59
  360. data/node_modules/playwright-core/lib/server/dispatchers/localUtilsDispatcher.js +0 -413
  361. data/node_modules/playwright-core/lib/server/dispatchers/networkDispatchers.js +0 -221
  362. data/node_modules/playwright-core/lib/server/dispatchers/pageDispatcher.js +0 -358
  363. data/node_modules/playwright-core/lib/server/dispatchers/playwrightDispatcher.js +0 -106
  364. data/node_modules/playwright-core/lib/server/dispatchers/selectorsDispatcher.js +0 -36
  365. data/node_modules/playwright-core/lib/server/dispatchers/streamDispatcher.js +0 -62
  366. data/node_modules/playwright-core/lib/server/dispatchers/tracingDispatcher.js +0 -54
  367. data/node_modules/playwright-core/lib/server/dispatchers/writableStreamDispatcher.js +0 -58
  368. data/node_modules/playwright-core/lib/server/dom.js +0 -845
  369. data/node_modules/playwright-core/lib/server/download.js +0 -53
  370. data/node_modules/playwright-core/lib/server/electron/electron.js +0 -296
  371. data/node_modules/playwright-core/lib/server/electron/loader.js +0 -57
  372. data/node_modules/playwright-core/lib/server/errors.js +0 -68
  373. data/node_modules/playwright-core/lib/server/fetch.js +0 -660
  374. data/node_modules/playwright-core/lib/server/fileChooser.js +0 -42
  375. data/node_modules/playwright-core/lib/server/fileUploadUtils.js +0 -75
  376. data/node_modules/playwright-core/lib/server/firefox/ffAccessibility.js +0 -216
  377. data/node_modules/playwright-core/lib/server/firefox/ffBrowser.js +0 -458
  378. data/node_modules/playwright-core/lib/server/firefox/ffConnection.js +0 -168
  379. data/node_modules/playwright-core/lib/server/firefox/ffExecutionContext.js +0 -138
  380. data/node_modules/playwright-core/lib/server/firefox/ffInput.js +0 -150
  381. data/node_modules/playwright-core/lib/server/firefox/ffNetworkManager.js +0 -233
  382. data/node_modules/playwright-core/lib/server/firefox/ffPage.js +0 -556
  383. data/node_modules/playwright-core/lib/server/firefox/firefox.js +0 -110
  384. data/node_modules/playwright-core/lib/server/formData.js +0 -75
  385. data/node_modules/playwright-core/lib/server/frameSelectors.js +0 -171
  386. data/node_modules/playwright-core/lib/server/frames.js +0 -1654
  387. data/node_modules/playwright-core/lib/server/har/harRecorder.js +0 -139
  388. data/node_modules/playwright-core/lib/server/har/harTracer.js +0 -531
  389. data/node_modules/playwright-core/lib/server/helper.js +0 -103
  390. data/node_modules/playwright-core/lib/server/index.js +0 -114
  391. data/node_modules/playwright-core/lib/server/input.js +0 -311
  392. data/node_modules/playwright-core/lib/server/instrumentation.js +0 -70
  393. data/node_modules/playwright-core/lib/server/isomorphic/utilityScriptSerializers.js +0 -226
  394. data/node_modules/playwright-core/lib/server/javascript.js +0 -306
  395. data/node_modules/playwright-core/lib/server/launchApp.js +0 -91
  396. data/node_modules/playwright-core/lib/server/macEditingCommands.js +0 -139
  397. data/node_modules/playwright-core/lib/server/network.js +0 -617
  398. data/node_modules/playwright-core/lib/server/page.js +0 -825
  399. data/node_modules/playwright-core/lib/server/pipeTransport.js +0 -85
  400. data/node_modules/playwright-core/lib/server/playwright.js +0 -85
  401. data/node_modules/playwright-core/lib/server/progress.js +0 -102
  402. data/node_modules/playwright-core/lib/server/protocolError.js +0 -49
  403. data/node_modules/playwright-core/lib/server/recorder/contextRecorder.js +0 -316
  404. data/node_modules/playwright-core/lib/server/recorder/recorderActions.js +0 -5
  405. data/node_modules/playwright-core/lib/server/recorder/recorderApp.js +0 -190
  406. data/node_modules/playwright-core/lib/server/recorder/recorderCollection.js +0 -127
  407. data/node_modules/playwright-core/lib/server/recorder/recorderRunner.js +0 -177
  408. data/node_modules/playwright-core/lib/server/recorder/recorderUtils.js +0 -71
  409. data/node_modules/playwright-core/lib/server/recorder/throttledFile.js +0 -46
  410. data/node_modules/playwright-core/lib/server/recorder.js +0 -324
  411. data/node_modules/playwright-core/lib/server/registry/browserFetcher.js +0 -168
  412. data/node_modules/playwright-core/lib/server/registry/dependencies.js +0 -322
  413. data/node_modules/playwright-core/lib/server/registry/index.js +0 -924
  414. data/node_modules/playwright-core/lib/server/registry/nativeDeps.js +0 -490
  415. data/node_modules/playwright-core/lib/server/registry/oopDownloadBrowserMain.js +0 -138
  416. data/node_modules/playwright-core/lib/server/screenshotter.js +0 -348
  417. data/node_modules/playwright-core/lib/server/selectors.js +0 -73
  418. data/node_modules/playwright-core/lib/server/socksClientCertificatesInterceptor.js +0 -328
  419. data/node_modules/playwright-core/lib/server/socksInterceptor.js +0 -100
  420. data/node_modules/playwright-core/lib/server/trace/recorder/snapshotter.js +0 -171
  421. data/node_modules/playwright-core/lib/server/trace/recorder/snapshotterInjected.js +0 -493
  422. data/node_modules/playwright-core/lib/server/trace/recorder/tracing.js +0 -486
  423. data/node_modules/playwright-core/lib/server/trace/test/inMemorySnapshotter.js +0 -93
  424. data/node_modules/playwright-core/lib/server/trace/viewer/traceViewer.js +0 -216
  425. data/node_modules/playwright-core/lib/server/transport.js +0 -191
  426. data/node_modules/playwright-core/lib/server/types.js +0 -24
  427. data/node_modules/playwright-core/lib/server/usKeyboardLayout.js +0 -555
  428. data/node_modules/playwright-core/lib/server/webkit/webkit.js +0 -87
  429. data/node_modules/playwright-core/lib/server/webkit/wkAccessibility.js +0 -194
  430. data/node_modules/playwright-core/lib/server/webkit/wkBrowser.js +0 -328
  431. data/node_modules/playwright-core/lib/server/webkit/wkConnection.js +0 -173
  432. data/node_modules/playwright-core/lib/server/webkit/wkExecutionContext.js +0 -146
  433. data/node_modules/playwright-core/lib/server/webkit/wkInput.js +0 -169
  434. data/node_modules/playwright-core/lib/server/webkit/wkInterceptableRequest.js +0 -162
  435. data/node_modules/playwright-core/lib/server/webkit/wkPage.js +0 -1216
  436. data/node_modules/playwright-core/lib/server/webkit/wkProvisionalPage.js +0 -94
  437. data/node_modules/playwright-core/lib/server/webkit/wkWorkers.js +0 -104
  438. data/node_modules/playwright-core/lib/third_party/diff_match_patch.js +0 -2222
  439. data/node_modules/playwright-core/lib/third_party/pixelmatch.js +0 -255
  440. data/node_modules/playwright-core/lib/utils/ascii.js +0 -31
  441. data/node_modules/playwright-core/lib/utils/comparators.js +0 -171
  442. data/node_modules/playwright-core/lib/utils/crypto.js +0 -174
  443. data/node_modules/playwright-core/lib/utils/debug.js +0 -46
  444. data/node_modules/playwright-core/lib/utils/debugLogger.js +0 -91
  445. data/node_modules/playwright-core/lib/utils/env.js +0 -49
  446. data/node_modules/playwright-core/lib/utils/eventsHelper.js +0 -38
  447. data/node_modules/playwright-core/lib/utils/expectUtils.js +0 -33
  448. data/node_modules/playwright-core/lib/utils/fileUtils.js +0 -205
  449. data/node_modules/playwright-core/lib/utils/happy-eyeballs.js +0 -181
  450. data/node_modules/playwright-core/lib/utils/headers.js +0 -52
  451. data/node_modules/playwright-core/lib/utils/hostPlatform.js +0 -133
  452. data/node_modules/playwright-core/lib/utils/httpServer.js +0 -236
  453. data/node_modules/playwright-core/lib/utils/index.js +0 -368
  454. data/node_modules/playwright-core/lib/utils/isomorphic/cssParser.js +0 -250
  455. data/node_modules/playwright-core/lib/utils/isomorphic/cssTokenizer.js +0 -979
  456. data/node_modules/playwright-core/lib/utils/isomorphic/locatorGenerators.js +0 -651
  457. data/node_modules/playwright-core/lib/utils/isomorphic/locatorParser.js +0 -179
  458. data/node_modules/playwright-core/lib/utils/isomorphic/locatorUtils.js +0 -62
  459. data/node_modules/playwright-core/lib/utils/isomorphic/mimeType.js +0 -29
  460. data/node_modules/playwright-core/lib/utils/isomorphic/selectorParser.js +0 -397
  461. data/node_modules/playwright-core/lib/utils/isomorphic/stringUtils.js +0 -139
  462. data/node_modules/playwright-core/lib/utils/isomorphic/traceUtils.js +0 -39
  463. data/node_modules/playwright-core/lib/utils/isomorphic/urlMatch.js +0 -120
  464. data/node_modules/playwright-core/lib/utils/linuxUtils.js +0 -78
  465. data/node_modules/playwright-core/lib/utils/manualPromise.js +0 -109
  466. data/node_modules/playwright-core/lib/utils/multimap.js +0 -75
  467. data/node_modules/playwright-core/lib/utils/network.js +0 -160
  468. data/node_modules/playwright-core/lib/utils/processLauncher.js +0 -248
  469. data/node_modules/playwright-core/lib/utils/profiler.js +0 -53
  470. data/node_modules/playwright-core/lib/utils/rtti.js +0 -44
  471. data/node_modules/playwright-core/lib/utils/semaphore.js +0 -51
  472. data/node_modules/playwright-core/lib/utils/spawnAsync.js +0 -45
  473. data/node_modules/playwright-core/lib/utils/stackTrace.js +0 -121
  474. data/node_modules/playwright-core/lib/utils/task.js +0 -58
  475. data/node_modules/playwright-core/lib/utils/time.js +0 -37
  476. data/node_modules/playwright-core/lib/utils/timeoutRunner.js +0 -66
  477. data/node_modules/playwright-core/lib/utils/traceUtils.js +0 -44
  478. data/node_modules/playwright-core/lib/utils/userAgent.js +0 -105
  479. data/node_modules/playwright-core/lib/utils/wsServer.js +0 -127
  480. data/node_modules/playwright-core/lib/utils/zipFile.js +0 -75
  481. data/node_modules/playwright-core/lib/utils/zones.js +0 -62
  482. data/node_modules/playwright-core/lib/utilsBundle.js +0 -82
  483. data/node_modules/playwright-core/lib/utilsBundleImpl/index.js +0 -53
  484. data/node_modules/playwright-core/lib/utilsBundleImpl/xdg-open +0 -1066
  485. data/node_modules/playwright-core/lib/vite/htmlReport/index.html +0 -66
  486. data/node_modules/playwright-core/lib/vite/recorder/assets/codeMirrorModule-aW6Vz3gf.js +0 -24
  487. data/node_modules/playwright-core/lib/vite/recorder/assets/codeMirrorModule-ez37Vkbh.css +0 -1
  488. data/node_modules/playwright-core/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
  489. data/node_modules/playwright-core/lib/vite/recorder/assets/index-B-MT5gKo.css +0 -1
  490. data/node_modules/playwright-core/lib/vite/recorder/assets/index-DCpXOVIh.js +0 -47
  491. data/node_modules/playwright-core/lib/vite/recorder/index.html +0 -29
  492. data/node_modules/playwright-core/lib/vite/recorder/playwright-logo.svg +0 -9
  493. data/node_modules/playwright-core/lib/vite/traceViewer/assets/codeMirrorModule-eFKCUIu2.js +0 -24
  494. data/node_modules/playwright-core/lib/vite/traceViewer/assets/testServerConnection-DeE2kSzz.js +0 -1
  495. data/node_modules/playwright-core/lib/vite/traceViewer/assets/workbench-D0cirtfA.js +0 -72
  496. data/node_modules/playwright-core/lib/vite/traceViewer/assets/xtermModule-BeNbaIVa.js +0 -9
  497. data/node_modules/playwright-core/lib/vite/traceViewer/codeMirrorModule.ez37Vkbh.css +0 -1
  498. data/node_modules/playwright-core/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
  499. data/node_modules/playwright-core/lib/vite/traceViewer/embedded.BkuvsLJp.js +0 -2
  500. data/node_modules/playwright-core/lib/vite/traceViewer/embedded.html +0 -16
  501. data/node_modules/playwright-core/lib/vite/traceViewer/embedded.w7WN2u1R.css +0 -1
  502. data/node_modules/playwright-core/lib/vite/traceViewer/index.C968kAiC.js +0 -2
  503. data/node_modules/playwright-core/lib/vite/traceViewer/index.CrbWWHbf.css +0 -1
  504. data/node_modules/playwright-core/lib/vite/traceViewer/index.html +0 -27
  505. data/node_modules/playwright-core/lib/vite/traceViewer/playwright-logo.svg +0 -9
  506. data/node_modules/playwright-core/lib/vite/traceViewer/snapshot.html +0 -21
  507. data/node_modules/playwright-core/lib/vite/traceViewer/sw.bundle.js +0 -3
  508. data/node_modules/playwright-core/lib/vite/traceViewer/uiMode.BkFnr4V0.js +0 -10
  509. data/node_modules/playwright-core/lib/vite/traceViewer/uiMode.D3cNFP6u.css +0 -1
  510. data/node_modules/playwright-core/lib/vite/traceViewer/uiMode.html +0 -18
  511. data/node_modules/playwright-core/lib/vite/traceViewer/workbench.DjbIuxix.css +0 -1
  512. data/node_modules/playwright-core/lib/vite/traceViewer/xtermModule.DSXBckUd.css +0 -32
  513. data/node_modules/playwright-core/lib/zipBundle.js +0 -25
  514. data/node_modules/playwright-core/lib/zipBundleImpl.js +0 -5
  515. data/node_modules/playwright-core/package.json +0 -44
  516. data/node_modules/playwright-core/types/protocol.d.ts +0 -21500
  517. data/node_modules/playwright-core/types/structs.d.ts +0 -45
  518. data/node_modules/playwright-core/types/types.d.ts +0 -21431
  519. data/node_modules/undici-types/LICENSE +0 -21
  520. data/node_modules/undici-types/README.md +0 -6
  521. data/node_modules/undici-types/agent.d.ts +0 -31
  522. data/node_modules/undici-types/api.d.ts +0 -43
  523. data/node_modules/undici-types/balanced-pool.d.ts +0 -29
  524. data/node_modules/undici-types/cache.d.ts +0 -36
  525. data/node_modules/undici-types/client.d.ts +0 -108
  526. data/node_modules/undici-types/connector.d.ts +0 -34
  527. data/node_modules/undici-types/content-type.d.ts +0 -21
  528. data/node_modules/undici-types/cookies.d.ts +0 -28
  529. data/node_modules/undici-types/diagnostics-channel.d.ts +0 -66
  530. data/node_modules/undici-types/dispatcher.d.ts +0 -255
  531. data/node_modules/undici-types/env-http-proxy-agent.d.ts +0 -21
  532. data/node_modules/undici-types/errors.d.ts +0 -149
  533. data/node_modules/undici-types/eventsource.d.ts +0 -63
  534. data/node_modules/undici-types/fetch.d.ts +0 -209
  535. data/node_modules/undici-types/file.d.ts +0 -39
  536. data/node_modules/undici-types/filereader.d.ts +0 -54
  537. data/node_modules/undici-types/formdata.d.ts +0 -108
  538. data/node_modules/undici-types/global-dispatcher.d.ts +0 -9
  539. data/node_modules/undici-types/global-origin.d.ts +0 -7
  540. data/node_modules/undici-types/handlers.d.ts +0 -15
  541. data/node_modules/undici-types/header.d.ts +0 -4
  542. data/node_modules/undici-types/index.d.ts +0 -71
  543. data/node_modules/undici-types/interceptors.d.ts +0 -15
  544. data/node_modules/undici-types/mock-agent.d.ts +0 -50
  545. data/node_modules/undici-types/mock-client.d.ts +0 -25
  546. data/node_modules/undici-types/mock-errors.d.ts +0 -12
  547. data/node_modules/undici-types/mock-interceptor.d.ts +0 -93
  548. data/node_modules/undici-types/mock-pool.d.ts +0 -25
  549. data/node_modules/undici-types/package.json +0 -55
  550. data/node_modules/undici-types/patch.d.ts +0 -71
  551. data/node_modules/undici-types/pool-stats.d.ts +0 -19
  552. data/node_modules/undici-types/pool.d.ts +0 -39
  553. data/node_modules/undici-types/proxy-agent.d.ts +0 -28
  554. data/node_modules/undici-types/readable.d.ts +0 -60
  555. data/node_modules/undici-types/retry-agent.d.ts +0 -8
  556. data/node_modules/undici-types/retry-handler.d.ts +0 -116
  557. data/node_modules/undici-types/util.d.ts +0 -18
  558. data/node_modules/undici-types/webidl.d.ts +0 -222
  559. data/node_modules/undici-types/websocket.d.ts +0 -152
  560. data/yarn.lock +0 -41
@@ -1,1128 +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._pagePromise = void 0;
72
- this._initializedPage = null;
73
- this._isBackgroundPage = void 0;
74
- // Holds window features for the next popup being opened via window.open,
75
- // until the popup target arrives. This could be racy if two oopifs
76
- // simultaneously call window.open with window features: the order
77
- // of their Page.windowOpen events is not guaranteed to match the order
78
- // of new popup targets.
79
- this._nextWindowOpenPopupFeatures = [];
80
- this._targetId = targetId;
81
- this._opener = opener;
82
- this._isBackgroundPage = bits.isBackgroundPage;
83
- const dragManager = new _crDragDrop.DragManager(this);
84
- this.rawKeyboard = new _crInput.RawKeyboardImpl(client, browserContext._browser._platform() === 'mac', dragManager);
85
- this.rawMouse = new _crInput.RawMouseImpl(this, client, dragManager);
86
- this.rawTouchscreen = new _crInput.RawTouchscreenImpl(client);
87
- this._pdf = new _crPdf.CRPDF(client);
88
- this._coverage = new _crCoverage.CRCoverage(client);
89
- this._browserContext = browserContext;
90
- this._page = new _page.Page(this, browserContext);
91
- this._networkManager = new _crNetworkManager.CRNetworkManager(this._page, null);
92
- // Sync any browser context state to the network manager. This does not talk over CDP because
93
- // we have not connected any sessions to the network manager yet.
94
- this.updateOffline();
95
- this.updateExtraHTTPHeaders();
96
- this.updateHttpCredentials();
97
- this.updateRequestInterception();
98
- this._mainFrameSession = new FrameSession(this, client, targetId, null);
99
- this._sessions.set(targetId, this._mainFrameSession);
100
- if (opener && !browserContext._options.noDefaultViewport) {
101
- const features = opener._nextWindowOpenPopupFeatures.shift() || [];
102
- const viewportSize = _helper.helper.getViewportSizeFromWindowFeatures(features);
103
- if (viewportSize) this._page._emulatedSize = {
104
- viewport: viewportSize,
105
- screen: viewportSize
106
- };
107
- }
108
- // Note: it is important to call |reportAsNew| before resolving pageOrError promise,
109
- // so that anyone who awaits pageOrError got a ready and reported page.
110
- this._pagePromise = this._mainFrameSession._initialize(bits.hasUIWindow).then(async r => {
111
- await this._page.initOpener(this._opener);
112
- return r;
113
- }).catch(async e => {
114
- await this._page.initOpener(this._opener);
115
- throw e;
116
- }).then(() => {
117
- this._initializedPage = this._page;
118
- this._reportAsNew();
119
- return this._page;
120
- }).catch(e => {
121
- this._reportAsNew(e);
122
- return e;
123
- });
124
- }
125
- potentiallyUninitializedPage() {
126
- return this._page;
127
- }
128
- _reportAsNew(error) {
129
- this._page.reportAsNew(error, this._isBackgroundPage ? _crBrowser.CRBrowserContext.CREvents.BackgroundPage : _browserContext.BrowserContext.Events.Page);
130
- }
131
- async _forAllFrameSessions(cb) {
132
- const frameSessions = Array.from(this._sessions.values());
133
- await Promise.all(frameSessions.map(frameSession => {
134
- if (frameSession._isMainFrame()) return cb(frameSession);
135
- return cb(frameSession).catch(e => {
136
- // Broadcasting a message to the closed iframe should be a noop.
137
- if ((0, _protocolError.isSessionClosedError)(e)) return;
138
- throw e;
139
- });
140
- }));
141
- }
142
- _sessionForFrame(frame) {
143
- // Frame id equals target id.
144
- while (!this._sessions.has(frame._id)) {
145
- const parent = frame.parentFrame();
146
- if (!parent) throw new Error(`Frame has been detached.`);
147
- frame = parent;
148
- }
149
- return this._sessions.get(frame._id);
150
- }
151
- _sessionForHandle(handle) {
152
- const frame = handle._context.frame;
153
- return this._sessionForFrame(frame);
154
- }
155
- willBeginDownload() {
156
- this._mainFrameSession._willBeginDownload();
157
- }
158
- async pageOrError() {
159
- return this._pagePromise;
160
- }
161
- didClose() {
162
- for (const session of this._sessions.values()) session.dispose();
163
- this._page._didClose();
164
- }
165
- async navigateFrame(frame, url, referrer) {
166
- return this._sessionForFrame(frame)._navigate(frame, url, referrer);
167
- }
168
- async updateExtraHTTPHeaders() {
169
- const headers = network.mergeHeaders([this._browserContext._options.extraHTTPHeaders, this._page.extraHTTPHeaders()]);
170
- await this._networkManager.setExtraHTTPHeaders(headers);
171
- }
172
- async updateGeolocation() {
173
- await this._forAllFrameSessions(frame => frame._updateGeolocation(false));
174
- }
175
- async updateOffline() {
176
- await this._networkManager.setOffline(!!this._browserContext._options.offline);
177
- }
178
- async updateHttpCredentials() {
179
- await this._networkManager.authenticate(this._browserContext._options.httpCredentials || null);
180
- }
181
- async updateEmulatedViewportSize(preserveWindowBoundaries) {
182
- await this._mainFrameSession._updateViewport(preserveWindowBoundaries);
183
- }
184
- async bringToFront() {
185
- await this._mainFrameSession._client.send('Page.bringToFront');
186
- }
187
- async updateEmulateMedia() {
188
- await this._forAllFrameSessions(frame => frame._updateEmulateMedia());
189
- }
190
- async updateUserAgent() {
191
- await this._forAllFrameSessions(frame => frame._updateUserAgent());
192
- }
193
- async updateRequestInterception() {
194
- await this._networkManager.setRequestInterception(this._page.needsRequestInterception());
195
- }
196
- async updateFileChooserInterception() {
197
- await this._forAllFrameSessions(frame => frame._updateFileChooserInterception(false));
198
- }
199
- async reload() {
200
- await this._mainFrameSession._client.send('Page.reload');
201
- }
202
- async _go(delta) {
203
- const history = await this._mainFrameSession._client.send('Page.getNavigationHistory');
204
- const entry = history.entries[history.currentIndex + delta];
205
- if (!entry) return false;
206
- await this._mainFrameSession._client.send('Page.navigateToHistoryEntry', {
207
- entryId: entry.id
208
- });
209
- return true;
210
- }
211
- goBack() {
212
- return this._go(-1);
213
- }
214
- goForward() {
215
- return this._go(+1);
216
- }
217
- async addInitScript(initScript, world = 'main') {
218
- await this._forAllFrameSessions(frame => frame._evaluateOnNewDocument(initScript, world));
219
- }
220
- async removeNonInternalInitScripts() {
221
- await this._forAllFrameSessions(frame => frame._removeEvaluatesOnNewDocument());
222
- }
223
- async closePage(runBeforeUnload) {
224
- if (runBeforeUnload) await this._mainFrameSession._client.send('Page.close');else await this._browserContext._browser._closePage(this);
225
- }
226
- async setBackgroundColor(color) {
227
- await this._mainFrameSession._client.send('Emulation.setDefaultBackgroundColorOverride', {
228
- color
229
- });
230
- }
231
- async takeScreenshot(progress, format, documentRect, viewportRect, quality, fitsViewport, scale) {
232
- const {
233
- visualViewport
234
- } = await this._mainFrameSession._client.send('Page.getLayoutMetrics');
235
- if (!documentRect) {
236
- documentRect = {
237
- x: visualViewport.pageX + viewportRect.x,
238
- y: visualViewport.pageY + viewportRect.y,
239
- ..._helper.helper.enclosingIntSize({
240
- width: viewportRect.width / visualViewport.scale,
241
- height: viewportRect.height / visualViewport.scale
242
- })
243
- };
244
- }
245
- // When taking screenshots with documentRect (based on the page content, not viewport),
246
- // ignore current page scale.
247
- const clip = {
248
- ...documentRect,
249
- scale: viewportRect ? visualViewport.scale : 1
250
- };
251
- if (scale === 'css') {
252
- const deviceScaleFactor = this._browserContext._options.deviceScaleFactor || 1;
253
- clip.scale /= deviceScaleFactor;
254
- }
255
- progress.throwIfAborted();
256
- const result = await this._mainFrameSession._client.send('Page.captureScreenshot', {
257
- format,
258
- quality,
259
- clip,
260
- captureBeyondViewport: !fitsViewport
261
- });
262
- return Buffer.from(result.data, 'base64');
263
- }
264
- async getContentFrame(handle) {
265
- return this._sessionForHandle(handle)._getContentFrame(handle);
266
- }
267
- async getOwnerFrame(handle) {
268
- return this._sessionForHandle(handle)._getOwnerFrame(handle);
269
- }
270
- isElementHandle(remoteObject) {
271
- return remoteObject.subtype === 'node';
272
- }
273
- async getBoundingBox(handle) {
274
- return this._sessionForHandle(handle)._getBoundingBox(handle);
275
- }
276
- async scrollRectIntoViewIfNeeded(handle, rect) {
277
- return this._sessionForHandle(handle)._scrollRectIntoViewIfNeeded(handle, rect);
278
- }
279
- async setScreencastOptions(options) {
280
- if (options) {
281
- await this._mainFrameSession._startScreencast(this, {
282
- format: 'jpeg',
283
- quality: options.quality,
284
- maxWidth: options.width,
285
- maxHeight: options.height
286
- });
287
- } else {
288
- await this._mainFrameSession._stopScreencast(this);
289
- }
290
- }
291
- rafCountForStablePosition() {
292
- return 1;
293
- }
294
- async getContentQuads(handle) {
295
- return this._sessionForHandle(handle)._getContentQuads(handle);
296
- }
297
- async setInputFiles(handle, files) {
298
- await handle.evaluateInUtility(([injected, node, files]) => injected.setInputFiles(node, files), files);
299
- }
300
- async setInputFilePaths(handle, files) {
301
- const frame = await handle.ownerFrame();
302
- if (!frame) throw new Error('Cannot set input files to detached input element');
303
- const parentSession = this._sessionForFrame(frame);
304
- await parentSession._client.send('DOM.setFileInputFiles', {
305
- objectId: handle._objectId,
306
- files
307
- });
308
- }
309
- async adoptElementHandle(handle, to) {
310
- return this._sessionForHandle(handle)._adoptElementHandle(handle, to);
311
- }
312
- async getAccessibilityTree(needle) {
313
- return (0, _crAccessibility.getAccessibilityTree)(this._mainFrameSession._client, needle);
314
- }
315
- async inputActionEpilogue() {
316
- await this._mainFrameSession._client.send('Page.enable').catch(e => {});
317
- }
318
- async resetForReuse() {}
319
- async pdf(options) {
320
- return this._pdf.generate(options);
321
- }
322
- coverage() {
323
- return this._coverage;
324
- }
325
- async getFrameElement(frame) {
326
- let parent = frame.parentFrame();
327
- if (!parent) throw new Error('Frame has been detached.');
328
- const parentSession = this._sessionForFrame(parent);
329
- const {
330
- backendNodeId
331
- } = await parentSession._client.send('DOM.getFrameOwner', {
332
- frameId: frame._id
333
- }).catch(e => {
334
- if (e instanceof Error && e.message.includes('Frame with the given id was not found.')) (0, _stackTrace.rewriteErrorMessage)(e, 'Frame has been detached.');
335
- throw e;
336
- });
337
- parent = frame.parentFrame();
338
- if (!parent) throw new Error('Frame has been detached.');
339
- return parentSession._adoptBackendNodeId(backendNodeId, await parent._mainContext());
340
- }
341
- shouldToggleStyleSheetToSyncAnimations() {
342
- return false;
343
- }
344
- }
345
- exports.CRPage = CRPage;
346
- class FrameSession {
347
- constructor(crPage, client, targetId, parentSession) {
348
- this._client = void 0;
349
- this._crPage = void 0;
350
- this._page = void 0;
351
- this._parentSession = void 0;
352
- this._childSessions = new Set();
353
- this._contextIdToContext = new Map();
354
- this._eventListeners = [];
355
- this._targetId = void 0;
356
- this._firstNonInitialNavigationCommittedPromise = void 0;
357
- this._firstNonInitialNavigationCommittedFulfill = () => {};
358
- this._firstNonInitialNavigationCommittedReject = e => {};
359
- this._windowId = void 0;
360
- // Marks the oopif session that remote -> local transition has happened in the parent.
361
- // See Target.detachedFromTarget handler for details.
362
- this._swappedIn = false;
363
- this._videoRecorder = null;
364
- this._screencastId = null;
365
- this._screencastClients = new Set();
366
- this._evaluateOnNewDocumentIdentifiers = [];
367
- this._metricsOverride = void 0;
368
- this._workerSessions = new Map();
369
- this._client = client;
370
- this._crPage = crPage;
371
- this._page = crPage._page;
372
- this._targetId = targetId;
373
- this._parentSession = parentSession;
374
- if (parentSession) parentSession._childSessions.add(this);
375
- this._firstNonInitialNavigationCommittedPromise = new Promise((f, r) => {
376
- this._firstNonInitialNavigationCommittedFulfill = f;
377
- this._firstNonInitialNavigationCommittedReject = r;
378
- });
379
- }
380
- _isMainFrame() {
381
- return this._targetId === this._crPage._targetId;
382
- }
383
- _addRendererListeners() {
384
- 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))]);
385
- }
386
- _addBrowserListeners() {
387
- 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))]);
388
- }
389
- async _initialize(hasUIWindow) {
390
- const isSettingStorageState = this._page._browserContext.isSettingStorageState();
391
- if (!isSettingStorageState && hasUIWindow && !this._crPage._browserContext._browser.isClank() && !this._crPage._browserContext._options.noDefaultViewport) {
392
- const {
393
- windowId
394
- } = await this._client.send('Browser.getWindowForTarget');
395
- this._windowId = windowId;
396
- }
397
- let screencastOptions;
398
- if (!isSettingStorageState && this._isMainFrame() && this._crPage._browserContext._options.recordVideo && hasUIWindow) {
399
- const screencastId = (0, _utils.createGuid)();
400
- const outputFile = _path.default.join(this._crPage._browserContext._options.recordVideo.dir, screencastId + '.webm');
401
- screencastOptions = {
402
- // validateBrowserContextOptions ensures correct video size.
403
- ...this._crPage._browserContext._options.recordVideo.size,
404
- outputFile
405
- };
406
- await this._crPage._browserContext._ensureVideosPath();
407
- // Note: it is important to start video recorder before sending Page.startScreencast,
408
- // and it is equally important to send Page.startScreencast before sending Runtime.runIfWaitingForDebugger.
409
- await this._createVideoRecorder(screencastId, screencastOptions);
410
- this._crPage.pageOrError().then(p => {
411
- if (p instanceof Error) this._stopVideoRecording().catch(() => {});
412
- });
413
- }
414
- let lifecycleEventsEnabled;
415
- if (!this._isMainFrame()) this._addRendererListeners();
416
- this._addBrowserListeners();
417
- const promises = [this._client.send('Page.enable'), this._client.send('Page.getFrameTree').then(({
418
- frameTree
419
- }) => {
420
- if (this._isMainFrame()) {
421
- this._handleFrameTree(frameTree);
422
- this._addRendererListeners();
423
- }
424
- const localFrames = this._isMainFrame() ? this._page.frames() : [this._page._frameManager.frame(this._targetId)];
425
- for (const frame of localFrames) {
426
- // Note: frames might be removed before we send these.
427
- this._client._sendMayFail('Page.createIsolatedWorld', {
428
- frameId: frame._id,
429
- grantUniveralAccess: true,
430
- worldName: UTILITY_WORLD_NAME
431
- });
432
- for (const initScript of this._crPage._page.allInitScripts()) frame.evaluateExpression(initScript.source).catch(e => {});
433
- }
434
- const isInitialEmptyPage = this._isMainFrame() && this._page.mainFrame().url() === ':';
435
- if (isInitialEmptyPage) {
436
- // Ignore lifecycle events, worlds and bindings for the initial empty page. It is never the final page
437
- // hence we are going to get more lifecycle updates after the actual navigation has
438
- // started (even if the target url is about:blank).
439
- lifecycleEventsEnabled.catch(e => {}).then(() => {
440
- this._eventListeners.push(_eventsHelper.eventsHelper.addEventListener(this._client, 'Page.lifecycleEvent', event => this._onLifecycleEvent(event)));
441
- });
442
- } else {
443
- this._firstNonInitialNavigationCommittedFulfill();
444
- this._eventListeners.push(_eventsHelper.eventsHelper.addEventListener(this._client, 'Page.lifecycleEvent', event => this._onLifecycleEvent(event)));
445
- }
446
- }), this._client.send('Log.enable', {}), lifecycleEventsEnabled = this._client.send('Page.setLifecycleEventsEnabled', {
447
- enabled: true
448
- }), this._client.send('Runtime.enable', {}), this._client.send('Runtime.addBinding', {
449
- name: _page.PageBinding.kPlaywrightBinding
450
- }), this._client.send('Page.addScriptToEvaluateOnNewDocument', {
451
- source: '',
452
- worldName: UTILITY_WORLD_NAME
453
- }), this._crPage._networkManager.addSession(this._client, undefined, this._isMainFrame()), this._client.send('Target.setAutoAttach', {
454
- autoAttach: true,
455
- waitForDebuggerOnStart: true,
456
- flatten: true
457
- })];
458
- if (!isSettingStorageState) {
459
- if (this._isMainFrame()) promises.push(this._client.send('Emulation.setFocusEmulationEnabled', {
460
- enabled: true
461
- }));
462
- const options = this._crPage._browserContext._options;
463
- if (options.bypassCSP) promises.push(this._client.send('Page.setBypassCSP', {
464
- enabled: true
465
- }));
466
- if (options.ignoreHTTPSErrors) promises.push(this._client.send('Security.setIgnoreCertificateErrors', {
467
- ignore: true
468
- }));
469
- if (this._isMainFrame()) promises.push(this._updateViewport());
470
- if (options.hasTouch) promises.push(this._client.send('Emulation.setTouchEmulationEnabled', {
471
- enabled: true
472
- }));
473
- if (options.javaScriptEnabled === false) promises.push(this._client.send('Emulation.setScriptExecutionDisabled', {
474
- value: true
475
- }));
476
- if (options.userAgent || options.locale) promises.push(this._updateUserAgent());
477
- if (options.locale) promises.push(emulateLocale(this._client, options.locale));
478
- if (options.timezoneId) promises.push(emulateTimezone(this._client, options.timezoneId));
479
- if (!this._crPage._browserContext._browser.options.headful) promises.push(this._setDefaultFontFamilies(this._client));
480
- promises.push(this._updateGeolocation(true));
481
- promises.push(this._updateEmulateMedia());
482
- promises.push(this._updateFileChooserInterception(true));
483
- for (const initScript of this._crPage._page.allInitScripts()) promises.push(this._evaluateOnNewDocument(initScript, 'main'));
484
- if (screencastOptions) promises.push(this._startVideoRecording(screencastOptions));
485
- }
486
- promises.push(this._client.send('Runtime.runIfWaitingForDebugger'));
487
- promises.push(this._firstNonInitialNavigationCommittedPromise);
488
- await Promise.all(promises);
489
- }
490
- dispose() {
491
- this._firstNonInitialNavigationCommittedReject(new _errors.TargetClosedError());
492
- for (const childSession of this._childSessions) childSession.dispose();
493
- if (this._parentSession) this._parentSession._childSessions.delete(this);
494
- _eventsHelper.eventsHelper.removeEventListeners(this._eventListeners);
495
- this._crPage._networkManager.removeSession(this._client);
496
- this._crPage._sessions.delete(this._targetId);
497
- this._client.dispose();
498
- }
499
- async _navigate(frame, url, referrer) {
500
- const response = await this._client.send('Page.navigate', {
501
- url,
502
- referrer,
503
- frameId: frame._id,
504
- referrerPolicy: 'unsafeUrl'
505
- });
506
- if (response.errorText) throw new frames.NavigationAbortedError(response.loaderId, `${response.errorText} at ${url}`);
507
- return {
508
- newDocumentId: response.loaderId
509
- };
510
- }
511
- _onLifecycleEvent(event) {
512
- if (this._eventBelongsToStaleFrame(event.frameId)) return;
513
- if (event.name === 'load') this._page._frameManager.frameLifecycleEvent(event.frameId, 'load');else if (event.name === 'DOMContentLoaded') this._page._frameManager.frameLifecycleEvent(event.frameId, 'domcontentloaded');
514
- }
515
- _handleFrameTree(frameTree) {
516
- this._onFrameAttached(frameTree.frame.id, frameTree.frame.parentId || null);
517
- this._onFrameNavigated(frameTree.frame, true);
518
- if (!frameTree.childFrames) return;
519
- for (const child of frameTree.childFrames) this._handleFrameTree(child);
520
- }
521
- _eventBelongsToStaleFrame(frameId) {
522
- const frame = this._page._frameManager.frame(frameId);
523
- // Subtree may be already gone because some ancestor navigation destroyed the oopif.
524
- if (!frame) return true;
525
- // When frame goes remote, parent process may still send some events
526
- // related to the local frame before it sends frameDetached.
527
- // In this case, we already have a new session for this frame, so events
528
- // in the old session should be ignored.
529
- const session = this._crPage._sessionForFrame(frame);
530
- return session && session !== this && !session._swappedIn;
531
- }
532
- _onFrameAttached(frameId, parentFrameId) {
533
- const frameSession = this._crPage._sessions.get(frameId);
534
- if (frameSession && frameId !== this._targetId) {
535
- // This is a remote -> local frame transition.
536
- frameSession._swappedIn = true;
537
- const frame = this._page._frameManager.frame(frameId);
538
- // Frame or even a whole subtree may be already gone, because some ancestor did navigate.
539
- if (frame) this._page._frameManager.removeChildFramesRecursively(frame);
540
- return;
541
- }
542
- if (parentFrameId && !this._page._frameManager.frame(parentFrameId)) {
543
- // Parent frame may be gone already because some ancestor frame navigated and
544
- // destroyed the whole subtree of some oopif, while oopif's process is still sending us events.
545
- // Be careful to not confuse this with "main frame navigated cross-process" scenario
546
- // where parentFrameId is null.
547
- return;
548
- }
549
- this._page._frameManager.frameAttached(frameId, parentFrameId);
550
- }
551
- _onFrameNavigated(framePayload, initial) {
552
- if (this._eventBelongsToStaleFrame(framePayload.id)) return;
553
- this._page._frameManager.frameCommittedNewDocumentNavigation(framePayload.id, framePayload.url + (framePayload.urlFragment || ''), framePayload.name || '', framePayload.loaderId, initial);
554
- if (!initial) this._firstNonInitialNavigationCommittedFulfill();
555
- }
556
- _onFrameRequestedNavigation(payload) {
557
- if (this._eventBelongsToStaleFrame(payload.frameId)) return;
558
- if (payload.disposition === 'currentTab') this._page._frameManager.frameRequestedNavigation(payload.frameId);
559
- }
560
- _onFrameNavigatedWithinDocument(frameId, url) {
561
- if (this._eventBelongsToStaleFrame(frameId)) return;
562
- this._page._frameManager.frameCommittedSameDocumentNavigation(frameId, url);
563
- }
564
- _onFrameDetached(frameId, reason) {
565
- if (this._crPage._sessions.has(frameId)) {
566
- // This is a local -> remote frame transition, where
567
- // Page.frameDetached arrives after Target.attachedToTarget.
568
- // We've already handled the new target and frame reattach - nothing to do here.
569
- return;
570
- }
571
- if (reason === 'swap') {
572
- // This is a local -> remote frame transition, where
573
- // Page.frameDetached arrives before Target.attachedToTarget.
574
- // We should keep the frame in the tree, and it will be used for the new target.
575
- const frame = this._page._frameManager.frame(frameId);
576
- if (frame) this._page._frameManager.removeChildFramesRecursively(frame);
577
- return;
578
- }
579
- // Just a regular frame detach.
580
- this._page._frameManager.frameDetached(frameId);
581
- }
582
- _onExecutionContextCreated(contextPayload) {
583
- const frame = contextPayload.auxData ? this._page._frameManager.frame(contextPayload.auxData.frameId) : null;
584
- if (!frame || this._eventBelongsToStaleFrame(frame._id)) return;
585
- const delegate = new _crExecutionContext.CRExecutionContext(this._client, contextPayload);
586
- let worldName;
587
- if (contextPayload.auxData && !!contextPayload.auxData.isDefault) worldName = 'main';else if (contextPayload.name === UTILITY_WORLD_NAME) worldName = 'utility';else return;
588
- const context = new dom.FrameExecutionContext(delegate, frame, worldName);
589
- context[contextDelegateSymbol] = delegate;
590
- frame._contextCreated(worldName, context);
591
- this._contextIdToContext.set(contextPayload.id, context);
592
- }
593
- _onExecutionContextDestroyed(executionContextId) {
594
- const context = this._contextIdToContext.get(executionContextId);
595
- if (!context) return;
596
- this._contextIdToContext.delete(executionContextId);
597
- context.frame._contextDestroyed(context);
598
- }
599
- _onExecutionContextsCleared() {
600
- for (const contextId of Array.from(this._contextIdToContext.keys())) this._onExecutionContextDestroyed(contextId);
601
- }
602
- _onAttachedToTarget(event) {
603
- var _this$_page$_frameMan;
604
- const session = this._client.createChildSession(event.sessionId);
605
- if (event.targetInfo.type === 'iframe') {
606
- // Frame id equals target id.
607
- const targetId = event.targetInfo.targetId;
608
- const frame = this._page._frameManager.frame(targetId);
609
- if (!frame) return; // Subtree may be already gone due to renderer/browser race.
610
- this._page._frameManager.removeChildFramesRecursively(frame);
611
- const frameSession = new FrameSession(this._crPage, session, targetId, this);
612
- this._crPage._sessions.set(targetId, frameSession);
613
- frameSession._initialize(false).catch(e => e);
614
- return;
615
- }
616
- if (event.targetInfo.type !== 'worker') {
617
- session.detach().catch(() => {});
618
- return;
619
- }
620
- const url = event.targetInfo.url;
621
- const worker = new _page.Worker(this._page, url);
622
- this._page._addWorker(event.sessionId, worker);
623
- this._workerSessions.set(event.sessionId, session);
624
- session.once('Runtime.executionContextCreated', async event => {
625
- worker._createExecutionContext(new _crExecutionContext.CRExecutionContext(session, event.context));
626
- });
627
- // This might fail if the target is closed before we initialize.
628
- session._sendMayFail('Runtime.enable');
629
- // TODO: attribute workers to the right frame.
630
- 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(() => {});
631
- session._sendMayFail('Runtime.runIfWaitingForDebugger');
632
- session._sendMayFail('Target.setAutoAttach', {
633
- autoAttach: true,
634
- waitForDebuggerOnStart: true,
635
- flatten: true
636
- });
637
- session.on('Target.attachedToTarget', event => this._onAttachedToTarget(event));
638
- session.on('Target.detachedFromTarget', event => this._onDetachedFromTarget(event));
639
- session.on('Runtime.consoleAPICalled', event => {
640
- const args = event.args.map(o => worker._existingExecutionContext.createHandle(o));
641
- this._page._addConsoleMessage(event.type, args, (0, _crProtocolHelper.toConsoleMessageLocation)(event.stackTrace));
642
- });
643
- session.on('Runtime.exceptionThrown', exception => this._page.emitOnContextOnceInitialized(_browserContext.BrowserContext.Events.PageError, (0, _crProtocolHelper.exceptionToError)(exception.exceptionDetails), this._page));
644
- }
645
- _onDetachedFromTarget(event) {
646
- // This might be a worker...
647
- const workerSession = this._workerSessions.get(event.sessionId);
648
- if (workerSession) {
649
- workerSession.dispose();
650
- this._page._removeWorker(event.sessionId);
651
- return;
652
- }
653
-
654
- // ... or an oopif.
655
- const childFrameSession = this._crPage._sessions.get(event.targetId);
656
- if (!childFrameSession) return;
657
-
658
- // Usually, we get frameAttached in this session first and mark child as swappedIn.
659
- if (childFrameSession._swappedIn) {
660
- childFrameSession.dispose();
661
- return;
662
- }
663
-
664
- // However, sometimes we get detachedFromTarget before frameAttached.
665
- // In this case we don't know whether this is a remote frame detach,
666
- // or just a remote -> local transition. In the latter case, frameAttached
667
- // is already inflight, so let's make a safe roundtrip to ensure it arrives.
668
- this._client.send('Page.enable').catch(e => null).then(() => {
669
- // Child was not swapped in - that means frameAttached did not happen and
670
- // this is remote detach rather than remote -> local swap.
671
- if (!childFrameSession._swappedIn) this._page._frameManager.frameDetached(event.targetId);
672
- childFrameSession.dispose();
673
- });
674
- }
675
- _onWindowOpen(event) {
676
- this._crPage._nextWindowOpenPopupFeatures.push(event.windowFeatures);
677
- }
678
- async _onConsoleAPI(event) {
679
- if (event.executionContextId === 0) {
680
- // DevTools protocol stores the last 1000 console messages. These
681
- // messages are always reported even for removed execution contexts. In
682
- // this case, they are marked with executionContextId = 0 and are
683
- // reported upon enabling Runtime agent.
684
- //
685
- // Ignore these messages since:
686
- // - there's no execution context we can use to operate with message
687
- // arguments
688
- // - these messages are reported before Playwright clients can subscribe
689
- // to the 'console'
690
- // page event.
691
- //
692
- // @see https://github.com/GoogleChrome/puppeteer/issues/3865
693
- return;
694
- }
695
- const context = this._contextIdToContext.get(event.executionContextId);
696
- if (!context) return;
697
- const values = event.args.map(arg => context.createHandle(arg));
698
- this._page._addConsoleMessage(event.type, values, (0, _crProtocolHelper.toConsoleMessageLocation)(event.stackTrace));
699
- }
700
- async _onBindingCalled(event) {
701
- const pageOrError = await this._crPage.pageOrError();
702
- if (!(pageOrError instanceof Error)) {
703
- const context = this._contextIdToContext.get(event.executionContextId);
704
- if (context) await this._page._onBindingCalled(event.payload, context);
705
- }
706
- }
707
- _onDialog(event) {
708
- if (!this._page._frameManager.frame(this._targetId)) return; // Our frame/subtree may be gone already.
709
- this._page.emitOnContext(_browserContext.BrowserContext.Events.Dialog, new dialog.Dialog(this._page, event.type, event.message, async (accept, promptText) => {
710
- await this._client.send('Page.handleJavaScriptDialog', {
711
- accept,
712
- promptText
713
- });
714
- }, event.defaultPrompt));
715
- }
716
- _handleException(exceptionDetails) {
717
- this._page.emitOnContextOnceInitialized(_browserContext.BrowserContext.Events.PageError, (0, _crProtocolHelper.exceptionToError)(exceptionDetails), this._page);
718
- }
719
- async _onTargetCrashed() {
720
- this._client._markAsCrashed();
721
- this._page._didCrash();
722
- }
723
- _onLogEntryAdded(event) {
724
- const {
725
- level,
726
- text,
727
- args,
728
- source,
729
- url,
730
- lineNumber
731
- } = event.entry;
732
- if (args) args.map(arg => (0, _crProtocolHelper.releaseObject)(this._client, arg.objectId));
733
- if (source !== 'worker') {
734
- const location = {
735
- url: url || '',
736
- lineNumber: lineNumber || 0,
737
- columnNumber: 0
738
- };
739
- this._page._addConsoleMessage(level, [], location, text);
740
- }
741
- }
742
- async _onFileChooserOpened(event) {
743
- if (!event.backendNodeId) return;
744
- const frame = this._page._frameManager.frame(event.frameId);
745
- if (!frame) return;
746
- let handle;
747
- try {
748
- const utilityContext = await frame._utilityContext();
749
- handle = await this._adoptBackendNodeId(event.backendNodeId, utilityContext);
750
- } catch (e) {
751
- // During async processing, frame/context may go away. We should not throw.
752
- return;
753
- }
754
- await this._page._onFileChooserOpened(handle);
755
- }
756
- _willBeginDownload() {
757
- const originPage = this._crPage._initializedPage;
758
- if (!originPage) {
759
- // Resume the page creation with an error. The page will automatically close right
760
- // after the download begins.
761
- this._firstNonInitialNavigationCommittedReject(new Error('Starting new page download'));
762
- }
763
- }
764
- _onScreencastFrame(payload) {
765
- this._page.throttleScreencastFrameAck(() => {
766
- this._client.send('Page.screencastFrameAck', {
767
- sessionId: payload.sessionId
768
- }).catch(() => {});
769
- });
770
- const buffer = Buffer.from(payload.data, 'base64');
771
- this._page.emit(_page.Page.Events.ScreencastFrame, {
772
- buffer,
773
- timestamp: payload.metadata.timestamp,
774
- width: payload.metadata.deviceWidth,
775
- height: payload.metadata.deviceHeight
776
- });
777
- }
778
- async _createVideoRecorder(screencastId, options) {
779
- (0, _utils.assert)(!this._screencastId);
780
- const ffmpegPath = _registry.registry.findExecutable('ffmpeg').executablePathOrDie(this._page.attribution.playwright.options.sdkLanguage);
781
- this._videoRecorder = await _videoRecorder.VideoRecorder.launch(this._crPage._page, ffmpegPath, options);
782
- this._screencastId = screencastId;
783
- }
784
- async _startVideoRecording(options) {
785
- const screencastId = this._screencastId;
786
- (0, _utils.assert)(screencastId);
787
- this._page.once(_page.Page.Events.Close, () => this._stopVideoRecording().catch(() => {}));
788
- const gotFirstFrame = new Promise(f => this._client.once('Page.screencastFrame', f));
789
- await this._startScreencast(this._videoRecorder, {
790
- format: 'jpeg',
791
- quality: 90,
792
- maxWidth: options.width,
793
- maxHeight: options.height
794
- });
795
- // Wait for the first frame before reporting video to the client.
796
- gotFirstFrame.then(() => {
797
- this._crPage._browserContext._browser._videoStarted(this._crPage._browserContext, screencastId, options.outputFile, this._crPage.pageOrError());
798
- });
799
- }
800
- async _stopVideoRecording() {
801
- if (!this._screencastId) return;
802
- const screencastId = this._screencastId;
803
- this._screencastId = null;
804
- const recorder = this._videoRecorder;
805
- this._videoRecorder = null;
806
- await this._stopScreencast(recorder);
807
- await recorder.stop().catch(() => {});
808
- // Keep the video artifact in the map until encoding is fully finished, if the context
809
- // starts closing before the video is fully written to disk it will wait for it.
810
- const video = this._crPage._browserContext._browser._takeVideo(screencastId);
811
- video === null || video === void 0 || video.reportFinished();
812
- }
813
- async _startScreencast(client, options = {}) {
814
- this._screencastClients.add(client);
815
- if (this._screencastClients.size === 1) await this._client.send('Page.startScreencast', options);
816
- }
817
- async _stopScreencast(client) {
818
- this._screencastClients.delete(client);
819
- if (!this._screencastClients.size) await this._client._sendMayFail('Page.stopScreencast');
820
- }
821
- async _updateGeolocation(initial) {
822
- const geolocation = this._crPage._browserContext._options.geolocation;
823
- if (!initial || geolocation) await this._client.send('Emulation.setGeolocationOverride', geolocation || {});
824
- }
825
- async _updateViewport(preserveWindowBoundaries) {
826
- if (this._crPage._browserContext._browser.isClank()) return;
827
- (0, _utils.assert)(this._isMainFrame());
828
- const options = this._crPage._browserContext._options;
829
- const emulatedSize = this._page.emulatedSize();
830
- if (emulatedSize === null) return;
831
- const viewportSize = emulatedSize.viewport;
832
- const screenSize = emulatedSize.screen;
833
- const isLandscape = screenSize.width > screenSize.height;
834
- const metricsOverride = {
835
- mobile: !!options.isMobile,
836
- width: viewportSize.width,
837
- height: viewportSize.height,
838
- screenWidth: screenSize.width,
839
- screenHeight: screenSize.height,
840
- deviceScaleFactor: options.deviceScaleFactor || 1,
841
- screenOrientation: !!options.isMobile ? isLandscape ? {
842
- angle: 90,
843
- type: 'landscapePrimary'
844
- } : {
845
- angle: 0,
846
- type: 'portraitPrimary'
847
- } : {
848
- angle: 0,
849
- type: 'landscapePrimary'
850
- },
851
- dontSetVisibleSize: preserveWindowBoundaries
852
- };
853
- if (JSON.stringify(this._metricsOverride) === JSON.stringify(metricsOverride)) return;
854
- const promises = [this._client.send('Emulation.setDeviceMetricsOverride', metricsOverride)];
855
- if (!preserveWindowBoundaries && this._windowId) {
856
- let insets = {
857
- width: 0,
858
- height: 0
859
- };
860
- if (this._crPage._browserContext._browser.options.headful) {
861
- // TODO: popup windows have their own insets.
862
- insets = {
863
- width: 24,
864
- height: 88
865
- };
866
- if (process.platform === 'win32') insets = {
867
- width: 16,
868
- height: 88
869
- };else if (process.platform === 'linux') insets = {
870
- width: 8,
871
- height: 85
872
- };else if (process.platform === 'darwin') insets = {
873
- width: 2,
874
- height: 80
875
- };
876
- if (this._crPage._browserContext.isPersistentContext()) {
877
- // FIXME: Chrome bug: OOPIF router is confused when hit target is
878
- // outside browser window.
879
- // Account for the infobar here to work around the bug.
880
- insets.height += 46;
881
- }
882
- }
883
- promises.push(this.setWindowBounds({
884
- width: viewportSize.width + insets.width,
885
- height: viewportSize.height + insets.height
886
- }));
887
- }
888
- await Promise.all(promises);
889
- this._metricsOverride = metricsOverride;
890
- }
891
- async windowBounds() {
892
- const {
893
- bounds
894
- } = await this._client.send('Browser.getWindowBounds', {
895
- windowId: this._windowId
896
- });
897
- return bounds;
898
- }
899
- async setWindowBounds(bounds) {
900
- return await this._client.send('Browser.setWindowBounds', {
901
- windowId: this._windowId,
902
- bounds
903
- });
904
- }
905
- async _updateEmulateMedia() {
906
- const emulatedMedia = this._page.emulatedMedia();
907
- // Empty string disables the override.
908
- const media = emulatedMedia.media === 'no-override' ? '' : emulatedMedia.media;
909
- const colorScheme = emulatedMedia.colorScheme === 'no-override' ? '' : emulatedMedia.colorScheme;
910
- const reducedMotion = emulatedMedia.reducedMotion === 'no-override' ? '' : emulatedMedia.reducedMotion;
911
- const forcedColors = emulatedMedia.forcedColors === 'no-override' ? '' : emulatedMedia.forcedColors;
912
- const features = [{
913
- name: 'prefers-color-scheme',
914
- value: colorScheme
915
- }, {
916
- name: 'prefers-reduced-motion',
917
- value: reducedMotion
918
- }, {
919
- name: 'forced-colors',
920
- value: forcedColors
921
- }];
922
- await this._client.send('Emulation.setEmulatedMedia', {
923
- media,
924
- features
925
- });
926
- }
927
- async _updateUserAgent() {
928
- const options = this._crPage._browserContext._options;
929
- await this._client.send('Emulation.setUserAgentOverride', {
930
- userAgent: options.userAgent || '',
931
- acceptLanguage: options.locale,
932
- userAgentMetadata: calculateUserAgentMetadata(options)
933
- });
934
- }
935
- async _setDefaultFontFamilies(session) {
936
- const fontFamilies = _defaultFontFamilies.platformToFontFamilies[this._crPage._browserContext._browser._platform()];
937
- await session.send('Page.setFontFamilies', fontFamilies);
938
- }
939
- async _updateFileChooserInterception(initial) {
940
- const enabled = this._page.fileChooserIntercepted();
941
- if (initial && !enabled) return;
942
- await this._client.send('Page.setInterceptFileChooserDialog', {
943
- enabled
944
- }).catch(() => {}); // target can be closed.
945
- }
946
- async _evaluateOnNewDocument(initScript, world) {
947
- const worldName = world === 'utility' ? UTILITY_WORLD_NAME : undefined;
948
- const {
949
- identifier
950
- } = await this._client.send('Page.addScriptToEvaluateOnNewDocument', {
951
- source: initScript.source,
952
- worldName
953
- });
954
- if (!initScript.internal) this._evaluateOnNewDocumentIdentifiers.push(identifier);
955
- }
956
- async _removeEvaluatesOnNewDocument() {
957
- const identifiers = this._evaluateOnNewDocumentIdentifiers;
958
- this._evaluateOnNewDocumentIdentifiers = [];
959
- await Promise.all(identifiers.map(identifier => this._client.send('Page.removeScriptToEvaluateOnNewDocument', {
960
- identifier
961
- })));
962
- }
963
- async _getContentFrame(handle) {
964
- const nodeInfo = await this._client.send('DOM.describeNode', {
965
- objectId: handle._objectId
966
- });
967
- if (!nodeInfo || typeof nodeInfo.node.frameId !== 'string') return null;
968
- return this._page._frameManager.frame(nodeInfo.node.frameId);
969
- }
970
- async _getOwnerFrame(handle) {
971
- // document.documentElement has frameId of the owner frame.
972
- const documentElement = await handle.evaluateHandle(node => {
973
- const doc = node;
974
- if (doc.documentElement && doc.documentElement.ownerDocument === doc) return doc.documentElement;
975
- return node.ownerDocument ? node.ownerDocument.documentElement : null;
976
- });
977
- if (!documentElement) return null;
978
- if (!documentElement._objectId) return null;
979
- const nodeInfo = await this._client.send('DOM.describeNode', {
980
- objectId: documentElement._objectId
981
- });
982
- const frameId = nodeInfo && typeof nodeInfo.node.frameId === 'string' ? nodeInfo.node.frameId : null;
983
- documentElement.dispose();
984
- return frameId;
985
- }
986
- async _getBoundingBox(handle) {
987
- const result = await this._client._sendMayFail('DOM.getBoxModel', {
988
- objectId: handle._objectId
989
- });
990
- if (!result) return null;
991
- const quad = result.model.border;
992
- const x = Math.min(quad[0], quad[2], quad[4], quad[6]);
993
- const y = Math.min(quad[1], quad[3], quad[5], quad[7]);
994
- const width = Math.max(quad[0], quad[2], quad[4], quad[6]) - x;
995
- const height = Math.max(quad[1], quad[3], quad[5], quad[7]) - y;
996
- const position = await this._framePosition();
997
- if (!position) return null;
998
- return {
999
- x: x + position.x,
1000
- y: y + position.y,
1001
- width,
1002
- height
1003
- };
1004
- }
1005
- async _framePosition() {
1006
- const frame = this._page._frameManager.frame(this._targetId);
1007
- if (!frame) return null;
1008
- if (frame === this._page.mainFrame()) return {
1009
- x: 0,
1010
- y: 0
1011
- };
1012
- const element = await frame.frameElement();
1013
- const box = await element.boundingBox();
1014
- return box;
1015
- }
1016
- async _scrollRectIntoViewIfNeeded(handle, rect) {
1017
- return await this._client.send('DOM.scrollIntoViewIfNeeded', {
1018
- objectId: handle._objectId,
1019
- rect
1020
- }).then(() => 'done').catch(e => {
1021
- if (e instanceof Error && e.message.includes('Node does not have a layout object')) return 'error:notvisible';
1022
- if (e instanceof Error && e.message.includes('Node is detached from document')) return 'error:notconnected';
1023
- throw e;
1024
- });
1025
- }
1026
- async _getContentQuads(handle) {
1027
- const result = await this._client._sendMayFail('DOM.getContentQuads', {
1028
- objectId: handle._objectId
1029
- });
1030
- if (!result) return null;
1031
- const position = await this._framePosition();
1032
- if (!position) return null;
1033
- return result.quads.map(quad => [{
1034
- x: quad[0] + position.x,
1035
- y: quad[1] + position.y
1036
- }, {
1037
- x: quad[2] + position.x,
1038
- y: quad[3] + position.y
1039
- }, {
1040
- x: quad[4] + position.x,
1041
- y: quad[5] + position.y
1042
- }, {
1043
- x: quad[6] + position.x,
1044
- y: quad[7] + position.y
1045
- }]);
1046
- }
1047
- async _adoptElementHandle(handle, to) {
1048
- const nodeInfo = await this._client.send('DOM.describeNode', {
1049
- objectId: handle._objectId
1050
- });
1051
- return this._adoptBackendNodeId(nodeInfo.node.backendNodeId, to);
1052
- }
1053
- async _adoptBackendNodeId(backendNodeId, to) {
1054
- const result = await this._client._sendMayFail('DOM.resolveNode', {
1055
- backendNodeId,
1056
- executionContextId: to[contextDelegateSymbol]._contextId
1057
- });
1058
- if (!result || result.object.subtype === 'null') throw new Error(dom.kUnableToAdoptErrorMessage);
1059
- return to.createHandle(result.object).asElement();
1060
- }
1061
- }
1062
- async function emulateLocale(session, locale) {
1063
- try {
1064
- await session.send('Emulation.setLocaleOverride', {
1065
- locale
1066
- });
1067
- } catch (exception) {
1068
- // All pages in the same renderer share locale. All such pages belong to the same
1069
- // context and if locale is overridden for one of them its value is the same as
1070
- // we are trying to set so it's not a problem.
1071
- if (exception.message.includes('Another locale override is already in effect')) return;
1072
- throw exception;
1073
- }
1074
- }
1075
- async function emulateTimezone(session, timezoneId) {
1076
- try {
1077
- await session.send('Emulation.setTimezoneOverride', {
1078
- timezoneId: timezoneId
1079
- });
1080
- } catch (exception) {
1081
- if (exception.message.includes('Timezone override is already in effect')) return;
1082
- if (exception.message.includes('Invalid timezone')) throw new Error(`Invalid timezone ID: ${timezoneId}`);
1083
- throw exception;
1084
- }
1085
- }
1086
- const contextDelegateSymbol = Symbol('delegate');
1087
-
1088
- // Chromium reference: https://source.chromium.org/chromium/chromium/src/+/main:components/embedder_support/user_agent_utils.cc;l=434;drc=70a6711e08e9f9e0d8e4c48e9ba5cab62eb010c2
1089
- function calculateUserAgentMetadata(options) {
1090
- const ua = options.userAgent;
1091
- if (!ua) return undefined;
1092
- const metadata = {
1093
- mobile: !!options.isMobile,
1094
- model: '',
1095
- architecture: 'x64',
1096
- platform: 'Windows',
1097
- platformVersion: ''
1098
- };
1099
- const androidMatch = ua.match(/Android (\d+(\.\d+)?(\.\d+)?)/);
1100
- const iPhoneMatch = ua.match(/iPhone OS (\d+(_\d+)?)/);
1101
- const iPadMatch = ua.match(/iPad; CPU OS (\d+(_\d+)?)/);
1102
- const macOSMatch = ua.match(/Mac OS X (\d+(_\d+)?(_\d+)?)/);
1103
- const windowsMatch = ua.match(/Windows\D+(\d+(\.\d+)?(\.\d+)?)/);
1104
- if (androidMatch) {
1105
- metadata.platform = 'Android';
1106
- metadata.platformVersion = androidMatch[1];
1107
- metadata.architecture = 'arm';
1108
- } else if (iPhoneMatch) {
1109
- metadata.platform = 'iOS';
1110
- metadata.platformVersion = iPhoneMatch[1];
1111
- metadata.architecture = 'arm';
1112
- } else if (iPadMatch) {
1113
- metadata.platform = 'iOS';
1114
- metadata.platformVersion = iPadMatch[1];
1115
- metadata.architecture = 'arm';
1116
- } else if (macOSMatch) {
1117
- metadata.platform = 'macOS';
1118
- metadata.platformVersion = macOSMatch[1];
1119
- if (!ua.includes('Intel')) metadata.architecture = 'arm';
1120
- } else if (windowsMatch) {
1121
- metadata.platform = 'Windows';
1122
- metadata.platformVersion = windowsMatch[1];
1123
- } else if (ua.toLowerCase().includes('linux')) {
1124
- metadata.platform = 'Linux';
1125
- }
1126
- if (ua.includes('ARM')) metadata.architecture = 'arm';
1127
- return metadata;
1128
- }