rebrowser-playwright-core 1.49.1 → 1.64.1

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 (393) hide show
  1. package/ThirdPartyNotices.txt +7 -1228
  2. package/bin/install_webkit_wsl.ps1 +33 -0
  3. package/bin/reinstall_chrome_beta_linux.sh +1 -1
  4. package/bin/reinstall_chrome_beta_mac.sh +1 -1
  5. package/bin/reinstall_chrome_stable_linux.sh +1 -1
  6. package/bin/reinstall_chrome_stable_mac.sh +1 -1
  7. package/bin/reinstall_msedge_beta_linux.sh +7 -1
  8. package/bin/reinstall_msedge_beta_mac.sh +1 -1
  9. package/bin/reinstall_msedge_dev_linux.sh +7 -1
  10. package/bin/reinstall_msedge_dev_mac.sh +1 -1
  11. package/bin/reinstall_msedge_stable_linux.sh +7 -1
  12. package/bin/reinstall_msedge_stable_mac.sh +1 -1
  13. package/browsers.json +21 -34
  14. package/cli.js +5 -1
  15. package/index.js +2 -18
  16. package/lib/bootstrap.js +149 -0
  17. package/lib/coreBundle.js +78218 -0
  18. package/lib/entry/cliDaemon.js +5 -0
  19. package/lib/entry/dashboardApp.js +3 -0
  20. package/lib/entry/mcp.js +10 -0
  21. package/lib/entry/oopBrowserDownload.js +3 -0
  22. package/lib/package.js +50 -0
  23. package/lib/server/electron/loader.js +109 -43
  24. package/lib/serverRegistry.js +1939 -0
  25. package/lib/serverRegistry.js.LICENSE +65 -0
  26. package/lib/tools/cli-client/channelSessions.js +141 -0
  27. package/lib/tools/cli-client/cli.js +7 -0
  28. package/lib/tools/cli-client/help.json +808 -0
  29. package/lib/tools/cli-client/minimist.js +128 -0
  30. package/lib/tools/cli-client/output.js +352 -0
  31. package/lib/tools/cli-client/program.js +422 -0
  32. package/lib/tools/cli-client/registry.js +180 -0
  33. package/lib/tools/cli-client/session.js +261 -0
  34. package/lib/tools/dashboard/appIcon.png +0 -0
  35. package/lib/tools/skills/playwright-cli/SKILL.md +493 -0
  36. package/lib/tools/skills/playwright-cli/references/element-attributes.md +23 -0
  37. package/lib/tools/skills/playwright-cli/references/playwright-tests.md +39 -0
  38. package/lib/tools/skills/playwright-cli/references/pr-attachments.md +60 -0
  39. package/lib/tools/skills/playwright-cli/references/request-mocking.md +87 -0
  40. package/lib/tools/skills/playwright-cli/references/running-code.md +245 -0
  41. package/lib/tools/skills/playwright-cli/references/session-management.md +227 -0
  42. package/lib/tools/skills/playwright-cli/references/storage-state.md +275 -0
  43. package/lib/tools/skills/playwright-cli/references/test-generation.md +433 -0
  44. package/lib/tools/skills/playwright-cli/references/tracing.md +139 -0
  45. package/lib/tools/skills/playwright-cli/references/video-recording.md +216 -0
  46. package/lib/tools/skills/playwright-component-testing/SKILL.md +136 -0
  47. package/lib/tools/skills/playwright-component-testing/references/gallery-spec.md +144 -0
  48. package/lib/tools/skills/playwright-component-testing/references/migration.md +89 -0
  49. package/lib/tools/skills/playwright-component-testing/references/react.md +69 -0
  50. package/lib/tools/skills/playwright-component-testing/references/typing.md +173 -0
  51. package/lib/tools/skills/playwright-component-testing/references/vue.md +77 -0
  52. package/lib/tools/skills/playwright-trace/SKILL.md +174 -0
  53. package/lib/tools/utils/extension.js +112 -0
  54. package/lib/tools/utils/socketConnection.js +108 -0
  55. package/lib/utilsBundle.js +86076 -79
  56. package/lib/utilsBundle.js.LICENSE +1890 -0
  57. package/lib/vite/dashboard/assets/codeMirrorModule--QdMvsKi.css +1 -0
  58. package/lib/vite/dashboard/assets/codeMirrorModule-CQ8RZGBm.js +32 -0
  59. package/lib/vite/dashboard/assets/codicon-DCmgc-ay.ttf +0 -0
  60. package/lib/vite/dashboard/assets/firefox-1bWoP6pv.svg +1 -0
  61. package/lib/vite/dashboard/assets/firefox-beta-k3eOH_eK.svg +1 -0
  62. package/lib/vite/dashboard/assets/firefox-nightly-Cp5nfeDT.svg +1 -0
  63. package/lib/vite/dashboard/assets/index-AwgwcYie.css +1 -0
  64. package/lib/vite/dashboard/assets/index-hRvO4yU2.js +12 -0
  65. package/lib/vite/dashboard/assets/safari-na3_-uQk.svg +1 -0
  66. package/lib/vite/dashboard/index.html +29 -0
  67. package/lib/vite/dashboard/playwright-logo.svg +24 -0
  68. package/lib/vite/htmlReport/index.html +3 -56
  69. package/lib/vite/htmlReport/report.css +2 -0
  70. package/lib/vite/htmlReport/report.js +32 -0
  71. package/lib/vite/recorder/assets/codeMirrorModule--QdMvsKi.css +1 -0
  72. package/lib/vite/recorder/assets/codeMirrorModule-DK72OMRi.js +32 -0
  73. package/lib/vite/recorder/assets/index-BZpYJZ-P.css +1 -0
  74. package/lib/vite/recorder/assets/index-Cn0mmDuv.js +129 -0
  75. package/lib/vite/recorder/index.html +3 -3
  76. package/lib/vite/traceViewer/assets/codeMirrorModule-BEB2e8M3.js +32 -0
  77. package/lib/vite/traceViewer/assets/defaultSettingsView-D-g2vrvf.js +184 -0
  78. package/lib/vite/traceViewer/assets/urlMatch-L3liM589.js +1 -0
  79. package/lib/vite/traceViewer/assets/xtermModule-B794rD2Z.js +7 -0
  80. package/lib/vite/traceViewer/codeMirrorModule.-QdMvsKi.css +1 -0
  81. package/lib/vite/traceViewer/defaultSettingsView.C8BeHuxd.css +1 -0
  82. package/lib/vite/traceViewer/index.B_TqY17P.css +1 -0
  83. package/lib/vite/traceViewer/index.html +9 -11
  84. package/lib/vite/traceViewer/index.oNry3Hjv.js +1 -0
  85. package/lib/vite/traceViewer/manifest.webmanifest +16 -0
  86. package/lib/vite/traceViewer/snapshot.B_Jk1wbt.js +1 -0
  87. package/lib/vite/traceViewer/snapshot.html +4 -15
  88. package/lib/vite/traceViewer/sw.bundle.js +4 -3
  89. package/lib/vite/traceViewer/uiMode.CYwC_gH1.js +5 -0
  90. package/lib/vite/traceViewer/uiMode.CyMfwkXJ.css +1 -0
  91. package/lib/vite/traceViewer/uiMode.html +6 -8
  92. package/lib/vite/traceViewer/xtermModule.kHJ-D0s7.css +1 -0
  93. package/lib/webp_codec.LICENSE +173 -0
  94. package/lib/webp_codec.wasm +0 -0
  95. package/lib/{utilsBundleImpl/xdg-open → xdg-open} +338 -137
  96. package/package.json +6 -16
  97. package/types/protocol.d.ts +9357 -6200
  98. package/types/structs.d.ts +8 -1
  99. package/types/types.d.ts +9490 -4947
  100. package/bin/PrintDeps.exe +0 -0
  101. package/bin/README.md +0 -2
  102. package/lib/androidServerImpl.js +0 -69
  103. package/lib/browserServerImpl.js +0 -92
  104. package/lib/cli/driver.js +0 -95
  105. package/lib/cli/program.js +0 -607
  106. package/lib/cli/programWithTestStub.js +0 -67
  107. package/lib/client/accessibility.js +0 -50
  108. package/lib/client/android.js +0 -473
  109. package/lib/client/api.js +0 -285
  110. package/lib/client/artifact.js +0 -79
  111. package/lib/client/browser.js +0 -145
  112. package/lib/client/browserContext.js +0 -559
  113. package/lib/client/browserType.js +0 -241
  114. package/lib/client/cdpSession.js +0 -53
  115. package/lib/client/channelOwner.js +0 -235
  116. package/lib/client/clientHelper.js +0 -57
  117. package/lib/client/clientInstrumentation.js +0 -50
  118. package/lib/client/clock.js +0 -68
  119. package/lib/client/connection.js +0 -333
  120. package/lib/client/consoleMessage.js +0 -55
  121. package/lib/client/coverage.js +0 -41
  122. package/lib/client/dialog.js +0 -57
  123. package/lib/client/download.js +0 -62
  124. package/lib/client/electron.js +0 -135
  125. package/lib/client/elementHandle.js +0 -321
  126. package/lib/client/errors.js +0 -77
  127. package/lib/client/eventEmitter.js +0 -314
  128. package/lib/client/events.js +0 -94
  129. package/lib/client/fetch.js +0 -391
  130. package/lib/client/fileChooser.js +0 -45
  131. package/lib/client/frame.js +0 -504
  132. package/lib/client/harRouter.js +0 -99
  133. package/lib/client/input.js +0 -111
  134. package/lib/client/jsHandle.js +0 -121
  135. package/lib/client/jsonPipe.js +0 -35
  136. package/lib/client/localUtils.js +0 -36
  137. package/lib/client/locator.js +0 -448
  138. package/lib/client/network.js +0 -767
  139. package/lib/client/page.js +0 -748
  140. package/lib/client/playwright.js +0 -80
  141. package/lib/client/selectors.js +0 -67
  142. package/lib/client/stream.js +0 -54
  143. package/lib/client/tracing.js +0 -147
  144. package/lib/client/types.js +0 -24
  145. package/lib/client/video.js +0 -51
  146. package/lib/client/waiter.js +0 -162
  147. package/lib/client/webError.js +0 -37
  148. package/lib/client/worker.js +0 -71
  149. package/lib/client/writableStream.js +0 -54
  150. package/lib/common/socksProxy.js +0 -569
  151. package/lib/common/timeoutSettings.js +0 -73
  152. package/lib/common/types.js +0 -5
  153. package/lib/generated/clockSource.js +0 -7
  154. package/lib/generated/consoleApiSource.js +0 -7
  155. package/lib/generated/injectedScriptSource.js +0 -7
  156. package/lib/generated/pollingRecorderSource.js +0 -7
  157. package/lib/generated/utilityScriptSource.js +0 -7
  158. package/lib/generated/webSocketMockSource.js +0 -7
  159. package/lib/image_tools/colorUtils.js +0 -98
  160. package/lib/image_tools/compare.js +0 -108
  161. package/lib/image_tools/imageChannel.js +0 -70
  162. package/lib/image_tools/stats.js +0 -102
  163. package/lib/inProcessFactory.js +0 -54
  164. package/lib/inprocess.js +0 -20
  165. package/lib/outofprocess.js +0 -67
  166. package/lib/protocol/debug.js +0 -27
  167. package/lib/protocol/serializers.js +0 -173
  168. package/lib/protocol/transport.js +0 -82
  169. package/lib/protocol/validator.js +0 -2780
  170. package/lib/protocol/validatorPrimitives.js +0 -139
  171. package/lib/remote/playwrightConnection.js +0 -274
  172. package/lib/remote/playwrightServer.js +0 -110
  173. package/lib/server/accessibility.js +0 -62
  174. package/lib/server/android/android.js +0 -441
  175. package/lib/server/android/backendAdb.js +0 -172
  176. package/lib/server/ariaSnapshot.js +0 -33
  177. package/lib/server/artifact.js +0 -104
  178. package/lib/server/bidi/bidiBrowser.js +0 -311
  179. package/lib/server/bidi/bidiChromium.js +0 -124
  180. package/lib/server/bidi/bidiConnection.js +0 -204
  181. package/lib/server/bidi/bidiExecutionContext.js +0 -156
  182. package/lib/server/bidi/bidiFirefox.js +0 -104
  183. package/lib/server/bidi/bidiInput.js +0 -158
  184. package/lib/server/bidi/bidiNetworkManager.js +0 -338
  185. package/lib/server/bidi/bidiOverCdp.js +0 -103
  186. package/lib/server/bidi/bidiPage.js +0 -529
  187. package/lib/server/bidi/bidiPdf.js +0 -140
  188. package/lib/server/bidi/third_party/bidiDeserializer.js +0 -93
  189. package/lib/server/bidi/third_party/bidiKeyboard.js +0 -238
  190. package/lib/server/bidi/third_party/bidiProtocol.js +0 -139
  191. package/lib/server/bidi/third_party/bidiSerializer.js +0 -144
  192. package/lib/server/bidi/third_party/firefoxPrefs.js +0 -221
  193. package/lib/server/browser.js +0 -148
  194. package/lib/server/browserContext.js +0 -667
  195. package/lib/server/browserType.js +0 -338
  196. package/lib/server/chromium/chromium.js +0 -354
  197. package/lib/server/chromium/chromiumSwitches.js +0 -46
  198. package/lib/server/chromium/crAccessibility.js +0 -237
  199. package/lib/server/chromium/crBrowser.js +0 -516
  200. package/lib/server/chromium/crConnection.js +0 -381
  201. package/lib/server/chromium/crCoverage.js +0 -246
  202. package/lib/server/chromium/crDevTools.js +0 -108
  203. package/lib/server/chromium/crDragDrop.js +0 -143
  204. package/lib/server/chromium/crExecutionContext.js +0 -136
  205. package/lib/server/chromium/crInput.js +0 -171
  206. package/lib/server/chromium/crNetworkManager.js +0 -767
  207. package/lib/server/chromium/crPage.js +0 -1143
  208. package/lib/server/chromium/crPdf.js +0 -153
  209. package/lib/server/chromium/crProtocolHelper.js +0 -133
  210. package/lib/server/chromium/crServiceWorker.js +0 -114
  211. package/lib/server/chromium/defaultFontFamilies.js +0 -145
  212. package/lib/server/chromium/videoRecorder.js +0 -155
  213. package/lib/server/clock.js +0 -125
  214. package/lib/server/codegen/csharp.js +0 -294
  215. package/lib/server/codegen/java.js +0 -232
  216. package/lib/server/codegen/javascript.js +0 -245
  217. package/lib/server/codegen/jsonl.js +0 -47
  218. package/lib/server/codegen/language.js +0 -88
  219. package/lib/server/codegen/languages.js +0 -30
  220. package/lib/server/codegen/python.js +0 -261
  221. package/lib/server/codegen/types.js +0 -5
  222. package/lib/server/console.js +0 -57
  223. package/lib/server/cookieStore.js +0 -185
  224. package/lib/server/debugController.js +0 -237
  225. package/lib/server/debugger.js +0 -132
  226. package/lib/server/deviceDescriptors.js +0 -26
  227. package/lib/server/deviceDescriptorsSource.json +0 -1669
  228. package/lib/server/dialog.js +0 -71
  229. package/lib/server/dispatchers/androidDispatcher.js +0 -204
  230. package/lib/server/dispatchers/artifactDispatcher.js +0 -118
  231. package/lib/server/dispatchers/browserContextDispatcher.js +0 -368
  232. package/lib/server/dispatchers/browserDispatcher.js +0 -170
  233. package/lib/server/dispatchers/browserTypeDispatcher.js +0 -55
  234. package/lib/server/dispatchers/cdpSessionDispatcher.js +0 -48
  235. package/lib/server/dispatchers/debugControllerDispatcher.js +0 -103
  236. package/lib/server/dispatchers/dialogDispatcher.js +0 -44
  237. package/lib/server/dispatchers/dispatcher.js +0 -395
  238. package/lib/server/dispatchers/electronDispatcher.js +0 -93
  239. package/lib/server/dispatchers/elementHandlerDispatcher.js +0 -228
  240. package/lib/server/dispatchers/frameDispatcher.js +0 -293
  241. package/lib/server/dispatchers/jsHandleDispatcher.js +0 -97
  242. package/lib/server/dispatchers/jsonPipeDispatcher.js +0 -59
  243. package/lib/server/dispatchers/localUtilsDispatcher.js +0 -413
  244. package/lib/server/dispatchers/networkDispatchers.js +0 -221
  245. package/lib/server/dispatchers/pageDispatcher.js +0 -367
  246. package/lib/server/dispatchers/playwrightDispatcher.js +0 -107
  247. package/lib/server/dispatchers/selectorsDispatcher.js +0 -36
  248. package/lib/server/dispatchers/streamDispatcher.js +0 -62
  249. package/lib/server/dispatchers/tracingDispatcher.js +0 -64
  250. package/lib/server/dispatchers/webSocketRouteDispatcher.js +0 -189
  251. package/lib/server/dispatchers/writableStreamDispatcher.js +0 -58
  252. package/lib/server/dom.js +0 -888
  253. package/lib/server/download.js +0 -60
  254. package/lib/server/electron/electron.js +0 -296
  255. package/lib/server/errors.js +0 -68
  256. package/lib/server/fetch.js +0 -669
  257. package/lib/server/fileChooser.js +0 -42
  258. package/lib/server/fileUploadUtils.js +0 -75
  259. package/lib/server/firefox/ffAccessibility.js +0 -216
  260. package/lib/server/firefox/ffBrowser.js +0 -460
  261. package/lib/server/firefox/ffConnection.js +0 -168
  262. package/lib/server/firefox/ffExecutionContext.js +0 -123
  263. package/lib/server/firefox/ffInput.js +0 -150
  264. package/lib/server/firefox/ffNetworkManager.js +0 -233
  265. package/lib/server/firefox/ffPage.js +0 -559
  266. package/lib/server/firefox/firefox.js +0 -99
  267. package/lib/server/formData.js +0 -75
  268. package/lib/server/frameSelectors.js +0 -171
  269. package/lib/server/frames.js +0 -1691
  270. package/lib/server/har/harRecorder.js +0 -139
  271. package/lib/server/har/harTracer.js +0 -542
  272. package/lib/server/helper.js +0 -103
  273. package/lib/server/index.js +0 -108
  274. package/lib/server/input.js +0 -310
  275. package/lib/server/instrumentation.js +0 -70
  276. package/lib/server/isomorphic/utilityScriptSerializers.js +0 -226
  277. package/lib/server/javascript.js +0 -293
  278. package/lib/server/launchApp.js +0 -91
  279. package/lib/server/macEditingCommands.js +0 -139
  280. package/lib/server/network.js +0 -617
  281. package/lib/server/page.js +0 -873
  282. package/lib/server/pipeTransport.js +0 -85
  283. package/lib/server/playwright.js +0 -88
  284. package/lib/server/progress.js +0 -99
  285. package/lib/server/protocolError.js +0 -49
  286. package/lib/server/recorder/contextRecorder.js +0 -299
  287. package/lib/server/recorder/recorderApp.js +0 -187
  288. package/lib/server/recorder/recorderCollection.js +0 -116
  289. package/lib/server/recorder/recorderFrontend.js +0 -5
  290. package/lib/server/recorder/recorderInTraceViewer.js +0 -144
  291. package/lib/server/recorder/recorderRunner.js +0 -155
  292. package/lib/server/recorder/recorderUtils.js +0 -113
  293. package/lib/server/recorder/throttledFile.js +0 -46
  294. package/lib/server/recorder.js +0 -364
  295. package/lib/server/registry/browserFetcher.js +0 -168
  296. package/lib/server/registry/dependencies.js +0 -322
  297. package/lib/server/registry/index.js +0 -1052
  298. package/lib/server/registry/nativeDeps.js +0 -493
  299. package/lib/server/registry/oopDownloadBrowserMain.js +0 -138
  300. package/lib/server/screenshotter.js +0 -348
  301. package/lib/server/selectors.js +0 -73
  302. package/lib/server/socksClientCertificatesInterceptor.js +0 -340
  303. package/lib/server/socksInterceptor.js +0 -100
  304. package/lib/server/trace/recorder/snapshotter.js +0 -161
  305. package/lib/server/trace/recorder/snapshotterInjected.js +0 -511
  306. package/lib/server/trace/recorder/tracing.js +0 -596
  307. package/lib/server/trace/test/inMemorySnapshotter.js +0 -93
  308. package/lib/server/trace/viewer/traceViewer.js +0 -214
  309. package/lib/server/transport.js +0 -191
  310. package/lib/server/types.js +0 -24
  311. package/lib/server/usKeyboardLayout.js +0 -555
  312. package/lib/server/webkit/webkit.js +0 -87
  313. package/lib/server/webkit/wkAccessibility.js +0 -194
  314. package/lib/server/webkit/wkBrowser.js +0 -329
  315. package/lib/server/webkit/wkConnection.js +0 -173
  316. package/lib/server/webkit/wkExecutionContext.js +0 -130
  317. package/lib/server/webkit/wkInput.js +0 -169
  318. package/lib/server/webkit/wkInterceptableRequest.js +0 -162
  319. package/lib/server/webkit/wkPage.js +0 -1225
  320. package/lib/server/webkit/wkProvisionalPage.js +0 -94
  321. package/lib/server/webkit/wkWorkers.js +0 -104
  322. package/lib/third_party/pixelmatch.js +0 -255
  323. package/lib/utils/ascii.js +0 -31
  324. package/lib/utils/comparators.js +0 -153
  325. package/lib/utils/crypto.js +0 -171
  326. package/lib/utils/debug.js +0 -46
  327. package/lib/utils/debugLogger.js +0 -91
  328. package/lib/utils/env.js +0 -49
  329. package/lib/utils/eventsHelper.js +0 -38
  330. package/lib/utils/expectUtils.js +0 -33
  331. package/lib/utils/fileUtils.js +0 -205
  332. package/lib/utils/happy-eyeballs.js +0 -194
  333. package/lib/utils/headers.js +0 -52
  334. package/lib/utils/hostPlatform.js +0 -139
  335. package/lib/utils/httpServer.js +0 -237
  336. package/lib/utils/index.js +0 -368
  337. package/lib/utils/isomorphic/ariaSnapshot.js +0 -267
  338. package/lib/utils/isomorphic/cssParser.js +0 -250
  339. package/lib/utils/isomorphic/cssTokenizer.js +0 -979
  340. package/lib/utils/isomorphic/locatorGenerators.js +0 -660
  341. package/lib/utils/isomorphic/locatorParser.js +0 -179
  342. package/lib/utils/isomorphic/locatorUtils.js +0 -62
  343. package/lib/utils/isomorphic/mimeType.js +0 -29
  344. package/lib/utils/isomorphic/recorderUtils.js +0 -227
  345. package/lib/utils/isomorphic/selectorParser.js +0 -397
  346. package/lib/utils/isomorphic/stringUtils.js +0 -169
  347. package/lib/utils/isomorphic/traceUtils.js +0 -39
  348. package/lib/utils/isomorphic/urlMatch.js +0 -124
  349. package/lib/utils/linuxUtils.js +0 -78
  350. package/lib/utils/manualPromise.js +0 -109
  351. package/lib/utils/multimap.js +0 -75
  352. package/lib/utils/network.js +0 -160
  353. package/lib/utils/processLauncher.js +0 -248
  354. package/lib/utils/profiler.js +0 -53
  355. package/lib/utils/rtti.js +0 -44
  356. package/lib/utils/semaphore.js +0 -51
  357. package/lib/utils/sequence.js +0 -64
  358. package/lib/utils/spawnAsync.js +0 -45
  359. package/lib/utils/stackTrace.js +0 -134
  360. package/lib/utils/task.js +0 -58
  361. package/lib/utils/time.js +0 -37
  362. package/lib/utils/timeoutRunner.js +0 -66
  363. package/lib/utils/traceUtils.js +0 -44
  364. package/lib/utils/userAgent.js +0 -105
  365. package/lib/utils/wsServer.js +0 -127
  366. package/lib/utils/zipFile.js +0 -75
  367. package/lib/utils/zones.js +0 -71
  368. package/lib/utilsBundleImpl/index.js +0 -210
  369. package/lib/vite/recorder/assets/codeMirrorModule-C5j27SYZ.js +0 -24
  370. package/lib/vite/recorder/assets/codeMirrorModule-ez37Vkbh.css +0 -1
  371. package/lib/vite/recorder/assets/index-iA1aAGZg.css +0 -1
  372. package/lib/vite/recorder/assets/index-m0XdVJHe.js +0 -184
  373. package/lib/vite/traceViewer/assets/codeMirrorModule-BBCX0spr.js +0 -24
  374. package/lib/vite/traceViewer/assets/inspectorTab-B4Iw34Ow.js +0 -68
  375. package/lib/vite/traceViewer/assets/testServerConnection-DeE2kSzz.js +0 -1
  376. package/lib/vite/traceViewer/assets/workbench-DFlGYqou.js +0 -9
  377. package/lib/vite/traceViewer/assets/xtermModule-BeNbaIVa.js +0 -9
  378. package/lib/vite/traceViewer/codeMirrorModule.ez37Vkbh.css +0 -1
  379. package/lib/vite/traceViewer/embedded.CmarehFk.js +0 -2
  380. package/lib/vite/traceViewer/embedded.html +0 -18
  381. package/lib/vite/traceViewer/embedded.w7WN2u1R.css +0 -1
  382. package/lib/vite/traceViewer/index.CrbWWHbf.css +0 -1
  383. package/lib/vite/traceViewer/index.FBucu_gE.js +0 -2
  384. package/lib/vite/traceViewer/inspectorTab.DEOUW62d.css +0 -1
  385. package/lib/vite/traceViewer/recorder.B_SY1GJM.css +0 -0
  386. package/lib/vite/traceViewer/recorder.CW_rzcEp.js +0 -2
  387. package/lib/vite/traceViewer/recorder.html +0 -17
  388. package/lib/vite/traceViewer/uiMode.CDUVjusr.js +0 -5
  389. package/lib/vite/traceViewer/uiMode.voC1ZiOQ.css +0 -1
  390. package/lib/vite/traceViewer/workbench.C-zR9ysA.css +0 -1
  391. package/lib/vite/traceViewer/xtermModule.DSXBckUd.css +0 -32
  392. package/lib/zipBundle.js +0 -25
  393. package/lib/zipBundleImpl.js +0 -5
@@ -1,354 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Chromium = void 0;
7
- var _fs = _interopRequireDefault(require("fs"));
8
- var _os = _interopRequireDefault(require("os"));
9
- var _path = _interopRequireDefault(require("path"));
10
- var _crBrowser = require("./crBrowser");
11
- var _processLauncher = require("../../utils/processLauncher");
12
- var _crConnection = require("./crConnection");
13
- var _browserType = require("../browserType");
14
- var _transport = require("../transport");
15
- var _crDevTools = require("./crDevTools");
16
- var _browser = require("../browser");
17
- var _network = require("../../utils/network");
18
- var _userAgent = require("../../utils/userAgent");
19
- var _ascii = require("../../utils/ascii");
20
- var _utils = require("../../utils");
21
- var _fileUtils = require("../../utils/fileUtils");
22
- var _debugLogger = require("../../utils/debugLogger");
23
- var _progress = require("../progress");
24
- var _timeoutSettings = require("../../common/timeoutSettings");
25
- var _helper = require("../helper");
26
- var _registry = require("../registry");
27
- var _manualPromise = require("../../utils/manualPromise");
28
- var _browserContext = require("../browserContext");
29
- var _chromiumSwitches = require("./chromiumSwitches");
30
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
- /**
32
- * Copyright 2017 Google Inc. All rights reserved.
33
- * Modifications copyright (c) Microsoft Corporation.
34
- *
35
- * Licensed under the Apache License, Version 2.0 (the "License");
36
- * you may not use this file except in compliance with the License.
37
- * You may obtain a copy of the License at
38
- *
39
- * http://www.apache.org/licenses/LICENSE-2.0
40
- *
41
- * Unless required by applicable law or agreed to in writing, software
42
- * distributed under the License is distributed on an "AS IS" BASIS,
43
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
44
- * See the License for the specific language governing permissions and
45
- * limitations under the License.
46
- */
47
-
48
- const ARTIFACTS_FOLDER = _path.default.join(_os.default.tmpdir(), 'playwright-artifacts-');
49
- class Chromium extends _browserType.BrowserType {
50
- constructor(parent) {
51
- super(parent, 'chromium');
52
- this._devtools = void 0;
53
- if ((0, _utils.debugMode)()) this._devtools = this._createDevTools();
54
- }
55
- async connectOverCDP(metadata, endpointURL, options, timeout) {
56
- const controller = new _progress.ProgressController(metadata, this);
57
- controller.setLogName('browser');
58
- return controller.run(async progress => {
59
- return await this._connectOverCDPInternal(progress, endpointURL, options);
60
- }, _timeoutSettings.TimeoutSettings.timeout({
61
- timeout
62
- }));
63
- }
64
- async _connectOverCDPInternal(progress, endpointURL, options, onClose) {
65
- let headersMap;
66
- if (options.headers) headersMap = (0, _utils.headersArrayToObject)(options.headers, false);
67
- if (!headersMap) headersMap = {
68
- 'User-Agent': (0, _userAgent.getUserAgent)()
69
- };else if (headersMap && !Object.keys(headersMap).some(key => key.toLowerCase() === 'user-agent')) headersMap['User-Agent'] = (0, _userAgent.getUserAgent)();
70
- const artifactsDir = await _fs.default.promises.mkdtemp(ARTIFACTS_FOLDER);
71
- const wsEndpoint = await urlToWSEndpoint(progress, endpointURL, headersMap);
72
- progress.throwIfAborted();
73
- const chromeTransport = await _transport.WebSocketTransport.connect(progress, wsEndpoint, headersMap);
74
- const cleanedUp = new _manualPromise.ManualPromise();
75
- const doCleanup = async () => {
76
- await (0, _fileUtils.removeFolders)([artifactsDir]);
77
- await (onClose === null || onClose === void 0 ? void 0 : onClose());
78
- cleanedUp.resolve();
79
- };
80
- const doClose = async () => {
81
- await chromeTransport.closeAndWait();
82
- await cleanedUp;
83
- };
84
- const browserProcess = {
85
- close: doClose,
86
- kill: doClose
87
- };
88
- const persistent = {
89
- noDefaultViewport: true
90
- };
91
- const browserOptions = {
92
- slowMo: options.slowMo,
93
- name: 'chromium',
94
- isChromium: true,
95
- persistent,
96
- browserProcess,
97
- protocolLogger: _helper.helper.debugProtocolLogger(),
98
- browserLogsCollector: new _debugLogger.RecentLogsCollector(),
99
- artifactsDir,
100
- downloadsPath: options.downloadsPath || artifactsDir,
101
- tracesDir: options.tracesDir || artifactsDir,
102
- originalLaunchOptions: {}
103
- };
104
- (0, _browserContext.validateBrowserContextOptions)(persistent, browserOptions);
105
- progress.throwIfAborted();
106
- const browser = await _crBrowser.CRBrowser.connect(this.attribution.playwright, chromeTransport, browserOptions);
107
- browser._isCollocatedWithServer = false;
108
- browser.on(_browser.Browser.Events.Disconnected, doCleanup);
109
- return browser;
110
- }
111
- _createDevTools() {
112
- // TODO: this is totally wrong when using channels.
113
- const directory = _registry.registry.findExecutable('chromium').directory;
114
- return directory ? new _crDevTools.CRDevTools(_path.default.join(directory, 'devtools-preferences.json')) : undefined;
115
- }
116
- async connectToTransport(transport, options) {
117
- let devtools = this._devtools;
118
- if (options.__testHookForDevTools) {
119
- devtools = this._createDevTools();
120
- await options.__testHookForDevTools(devtools);
121
- }
122
- return _crBrowser.CRBrowser.connect(this.attribution.playwright, transport, options, devtools);
123
- }
124
- doRewriteStartupLog(error) {
125
- if (!error.logs) return error;
126
- if (error.logs.includes('Missing X server')) error.logs = '\n' + (0, _ascii.wrapInASCIIBox)(_browserType.kNoXServerRunningError, 1);
127
- // These error messages are taken from Chromium source code as of July, 2020:
128
- // https://github.com/chromium/chromium/blob/70565f67e79f79e17663ad1337dc6e63ee207ce9/content/browser/zygote_host/zygote_host_impl_linux.cc
129
- if (!error.logs.includes('crbug.com/357670') && !error.logs.includes('No usable sandbox!') && !error.logs.includes('crbug.com/638180')) return error;
130
- error.logs = [`Chromium sandboxing failed!`, `================================`, `To avoid the sandboxing issue, do either of the following:`, ` - (preferred): Configure your environment to support sandboxing`, ` - (alternative): Launch Chromium without sandbox using 'chromiumSandbox: false' option`, `================================`, ``].join('\n');
131
- return error;
132
- }
133
- amendEnvironment(env, userDataDir, executable, browserArguments) {
134
- return env;
135
- }
136
- attemptToGracefullyCloseBrowser(transport) {
137
- const message = {
138
- method: 'Browser.close',
139
- id: _crConnection.kBrowserCloseMessageId,
140
- params: {}
141
- };
142
- transport.send(message);
143
- }
144
- async _launchWithSeleniumHub(progress, hubUrl, options) {
145
- await this._createArtifactDirs(options);
146
- if (!hubUrl.endsWith('/')) hubUrl = hubUrl + '/';
147
- const args = this._innerDefaultArgs(options);
148
- args.push('--remote-debugging-port=0');
149
- const isEdge = options.channel && options.channel.startsWith('msedge');
150
- let desiredCapabilities = {
151
- 'browserName': isEdge ? 'MicrosoftEdge' : 'chrome',
152
- [isEdge ? 'ms:edgeOptions' : 'goog:chromeOptions']: {
153
- args
154
- }
155
- };
156
- if (process.env.SELENIUM_REMOTE_CAPABILITIES) {
157
- const remoteCapabilities = parseSeleniumRemoteParams({
158
- name: 'capabilities',
159
- value: process.env.SELENIUM_REMOTE_CAPABILITIES
160
- }, progress);
161
- if (remoteCapabilities) desiredCapabilities = {
162
- ...desiredCapabilities,
163
- ...remoteCapabilities
164
- };
165
- }
166
- let headers = {};
167
- if (process.env.SELENIUM_REMOTE_HEADERS) {
168
- const remoteHeaders = parseSeleniumRemoteParams({
169
- name: 'headers',
170
- value: process.env.SELENIUM_REMOTE_HEADERS
171
- }, progress);
172
- if (remoteHeaders) headers = remoteHeaders;
173
- }
174
- progress.log(`<selenium> connecting to ${hubUrl}`);
175
- const response = await (0, _network.fetchData)({
176
- url: hubUrl + 'session',
177
- method: 'POST',
178
- headers: {
179
- 'Content-Type': 'application/json; charset=utf-8',
180
- ...headers
181
- },
182
- data: JSON.stringify({
183
- capabilities: {
184
- alwaysMatch: desiredCapabilities
185
- }
186
- }),
187
- timeout: progress.timeUntilDeadline()
188
- }, seleniumErrorHandler);
189
- const value = JSON.parse(response).value;
190
- const sessionId = value.sessionId;
191
- progress.log(`<selenium> connected to sessionId=${sessionId}`);
192
- const disconnectFromSelenium = async () => {
193
- progress.log(`<selenium> disconnecting from sessionId=${sessionId}`);
194
- await (0, _network.fetchData)({
195
- url: hubUrl + 'session/' + sessionId,
196
- method: 'DELETE',
197
- headers
198
- }).catch(error => progress.log(`<error disconnecting from selenium>: ${error}`));
199
- progress.log(`<selenium> disconnected from sessionId=${sessionId}`);
200
- _processLauncher.gracefullyCloseSet.delete(disconnectFromSelenium);
201
- };
202
- _processLauncher.gracefullyCloseSet.add(disconnectFromSelenium);
203
- try {
204
- const capabilities = value.capabilities;
205
- let endpointURL;
206
- if (capabilities['se:cdp']) {
207
- // Selenium 4 - use built-in CDP websocket proxy.
208
- progress.log(`<selenium> using selenium v4`);
209
- const endpointURLString = addProtocol(capabilities['se:cdp']);
210
- endpointURL = new URL(endpointURLString);
211
- if (endpointURL.hostname === 'localhost' || endpointURL.hostname === '127.0.0.1') endpointURL.hostname = new URL(hubUrl).hostname;
212
- progress.log(`<selenium> retrieved endpoint ${endpointURL.toString()} for sessionId=${sessionId}`);
213
- } else {
214
- // Selenium 3 - resolve target node IP to use instead of localhost ws url.
215
- progress.log(`<selenium> using selenium v3`);
216
- const maybeChromeOptions = capabilities['goog:chromeOptions'];
217
- const chromeOptions = maybeChromeOptions && typeof maybeChromeOptions === 'object' ? maybeChromeOptions : undefined;
218
- const debuggerAddress = chromeOptions && typeof chromeOptions.debuggerAddress === 'string' ? chromeOptions.debuggerAddress : undefined;
219
- const chromeOptionsURL = typeof maybeChromeOptions === 'string' ? maybeChromeOptions : undefined;
220
- // TODO(dgozman): figure out if we can make ChromeDriver to return 127.0.0.1 instead of localhost.
221
- const endpointURLString = addProtocol(debuggerAddress || chromeOptionsURL).replace('localhost', '127.0.0.1');
222
- progress.log(`<selenium> retrieved endpoint ${endpointURLString} for sessionId=${sessionId}`);
223
- endpointURL = new URL(endpointURLString);
224
- if (endpointURL.hostname === 'localhost' || endpointURL.hostname === '127.0.0.1') {
225
- const sessionInfoUrl = new URL(hubUrl).origin + '/grid/api/testsession?session=' + sessionId;
226
- try {
227
- const sessionResponse = await (0, _network.fetchData)({
228
- url: sessionInfoUrl,
229
- method: 'GET',
230
- timeout: progress.timeUntilDeadline(),
231
- headers
232
- }, seleniumErrorHandler);
233
- const proxyId = JSON.parse(sessionResponse).proxyId;
234
- endpointURL.hostname = new URL(proxyId).hostname;
235
- progress.log(`<selenium> resolved endpoint ip ${endpointURL.toString()} for sessionId=${sessionId}`);
236
- } catch (e) {
237
- progress.log(`<selenium> unable to resolve endpoint ip for sessionId=${sessionId}, running in standalone?`);
238
- }
239
- }
240
- }
241
- return await this._connectOverCDPInternal(progress, endpointURL.toString(), {
242
- ...options,
243
- headers: (0, _utils.headersObjectToArray)(headers)
244
- }, disconnectFromSelenium);
245
- } catch (e) {
246
- await disconnectFromSelenium();
247
- throw e;
248
- }
249
- }
250
- defaultArgs(options, isPersistent, userDataDir) {
251
- const chromeArguments = this._innerDefaultArgs(options);
252
- chromeArguments.push(`--user-data-dir=${userDataDir}`);
253
- if (options.useWebSocket) chromeArguments.push('--remote-debugging-port=0');else chromeArguments.push('--remote-debugging-pipe');
254
- if (isPersistent) chromeArguments.push('about:blank');else chromeArguments.push('--no-startup-window');
255
- return chromeArguments;
256
- }
257
- _innerDefaultArgs(options) {
258
- const {
259
- args = []
260
- } = options;
261
- const userDataDirArg = args.find(arg => arg.startsWith('--user-data-dir'));
262
- if (userDataDirArg) throw this._createUserDataDirArgMisuseError('--user-data-dir');
263
- if (args.find(arg => arg.startsWith('--remote-debugging-pipe'))) throw new Error('Playwright manages remote debugging connection itself.');
264
- if (args.find(arg => !arg.startsWith('-'))) throw new Error('Arguments can not specify page to be opened');
265
- const chromeArguments = [..._chromiumSwitches.chromiumSwitches];
266
- if (_os.default.platform() === 'darwin') {
267
- // See https://github.com/microsoft/playwright/issues/7362
268
- chromeArguments.push('--enable-use-zoom-for-dsf=false');
269
- // See https://bugs.chromium.org/p/chromium/issues/detail?id=1407025.
270
- if (options.headless && (!options.channel || options.channel === 'chromium-headless-shell')) chromeArguments.push('--use-angle');
271
- }
272
- if (options.devtools) chromeArguments.push('--auto-open-devtools-for-tabs');
273
- if (options.headless) {
274
- chromeArguments.push('--headless');
275
- chromeArguments.push('--hide-scrollbars', '--mute-audio', '--blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4');
276
- }
277
- if (options.chromiumSandbox !== true) chromeArguments.push('--no-sandbox');
278
- const proxy = options.proxyOverride || options.proxy;
279
- if (proxy) {
280
- const proxyURL = new URL(proxy.server);
281
- const isSocks = proxyURL.protocol === 'socks5:';
282
- // https://www.chromium.org/developers/design-documents/network-settings
283
- if (isSocks && !this.attribution.playwright.options.socksProxyPort) {
284
- // https://www.chromium.org/developers/design-documents/network-stack/socks-proxy
285
- chromeArguments.push(`--host-resolver-rules="MAP * ~NOTFOUND , EXCLUDE ${proxyURL.hostname}"`);
286
- }
287
- chromeArguments.push(`--proxy-server=${proxy.server}`);
288
- const proxyBypassRules = [];
289
- // https://source.chromium.org/chromium/chromium/src/+/master:net/docs/proxy.md;l=548;drc=71698e610121078e0d1a811054dcf9fd89b49578
290
- if (this.attribution.playwright.options.socksProxyPort) proxyBypassRules.push('<-loopback>');
291
- if (proxy.bypass) proxyBypassRules.push(...proxy.bypass.split(',').map(t => t.trim()).map(t => t.startsWith('.') ? '*' + t : t));
292
- if (!process.env.PLAYWRIGHT_DISABLE_FORCED_CHROMIUM_PROXIED_LOOPBACK && !proxyBypassRules.includes('<-loopback>')) proxyBypassRules.push('<-loopback>');
293
- if (proxyBypassRules.length > 0) chromeArguments.push(`--proxy-bypass-list=${proxyBypassRules.join(';')}`);
294
- }
295
- chromeArguments.push(...args);
296
- return chromeArguments;
297
- }
298
- readyState(options) {
299
- var _options$args;
300
- if (options.useWebSocket || (_options$args = options.args) !== null && _options$args !== void 0 && _options$args.some(a => a.startsWith('--remote-debugging-port'))) return new ChromiumReadyState();
301
- return undefined;
302
- }
303
- getExecutableName(options) {
304
- if (options.channel) return options.channel;
305
- return options.headless ? 'chromium-headless-shell' : 'chromium';
306
- }
307
- }
308
- exports.Chromium = Chromium;
309
- class ChromiumReadyState extends _browserType.BrowserReadyState {
310
- onBrowserOutput(message) {
311
- const match = message.match(/DevTools listening on (.*)/);
312
- if (match) this._wsEndpoint.resolve(match[1]);
313
- }
314
- }
315
- async function urlToWSEndpoint(progress, endpointURL, headers) {
316
- if (endpointURL.startsWith('ws')) return endpointURL;
317
- progress.log(`<ws preparing> retrieving websocket url from ${endpointURL}`);
318
- const httpURL = endpointURL.endsWith('/') ? `${endpointURL}json/version/` : `${endpointURL}/json/version/`;
319
- const json = await (0, _network.fetchData)({
320
- url: httpURL,
321
- headers
322
- }, async (_, resp) => new Error(`Unexpected status ${resp.statusCode} when connecting to ${httpURL}.\n` + `This does not look like a DevTools server, try connecting via ws://.`));
323
- return JSON.parse(json).webSocketDebuggerUrl;
324
- }
325
- async function seleniumErrorHandler(params, response) {
326
- const body = await streamToString(response);
327
- let message = body;
328
- try {
329
- const json = JSON.parse(body);
330
- message = json.value.localizedMessage || json.value.message;
331
- } catch (e) {}
332
- return new Error(`Error connecting to Selenium at ${params.url}: ${message}`);
333
- }
334
- function addProtocol(url) {
335
- if (!['ws://', 'wss://', 'http://', 'https://'].some(protocol => url.startsWith(protocol))) return 'http://' + url;
336
- return url;
337
- }
338
- function streamToString(stream) {
339
- return new Promise((resolve, reject) => {
340
- const chunks = [];
341
- stream.on('data', chunk => chunks.push(Buffer.from(chunk)));
342
- stream.on('error', reject);
343
- stream.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
344
- });
345
- }
346
- function parseSeleniumRemoteParams(env, progress) {
347
- try {
348
- const parsed = JSON.parse(env.value);
349
- progress.log(`<selenium> using additional ${env.name} "${env.value}"`);
350
- return parsed;
351
- } catch (e) {
352
- progress.log(`<selenium> ignoring additional ${env.name} "${env.value}": ${e}`);
353
- }
354
- }
@@ -1,46 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.chromiumSwitches = void 0;
7
- /**
8
- * Copyright 2017 Google Inc. All rights reserved.
9
- * Modifications copyright (c) Microsoft Corporation.
10
- *
11
- * Licensed under the Apache License, Version 2.0 (the "License");
12
- * you may not use this file except in compliance with the License.
13
- * You may obtain a copy of the License at
14
- *
15
- * http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software
18
- * distributed under the License is distributed on an "AS IS" BASIS,
19
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
- * See the License for the specific language governing permissions and
21
- * limitations under the License.
22
- */
23
-
24
- // No dependencies as it is used from the Electron loader.
25
-
26
- const chromiumSwitches = exports.chromiumSwitches = ['--disable-field-trial-config',
27
- // https://source.chromium.org/chromium/chromium/src/+/main:testing/variations/README.md
28
- '--disable-background-networking', '--disable-background-timer-throttling', '--disable-backgrounding-occluded-windows', '--disable-back-forward-cache',
29
- // Avoids surprises like main request not being intercepted during page.goBack().
30
- '--disable-breakpad', '--disable-client-side-phishing-detection', '--disable-component-extensions-with-background-pages', '--disable-component-update',
31
- // Avoids unneeded network activity after startup.
32
- '--no-default-browser-check', '--disable-default-apps', '--disable-dev-shm-usage', '--disable-extensions',
33
- // AvoidUnnecessaryBeforeUnloadCheckSync - https://github.com/microsoft/playwright/issues/14047
34
- // Translate - https://github.com/microsoft/playwright/issues/16126
35
- // HttpsUpgrades - https://github.com/microsoft/playwright/pull/27605
36
- // PaintHolding - https://github.com/microsoft/playwright/issues/28023
37
- // ThirdPartyStoragePartitioning - https://github.com/microsoft/playwright/issues/32230
38
- // LensOverlay - Hides the Lens feature in the URL address bar. Its not working in unofficial builds.
39
- // PlzDedicatedWorker - https://github.com/microsoft/playwright/issues/31747
40
- '--disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate,HttpsUpgrades,PaintHolding,ThirdPartyStoragePartitioning,LensOverlay,PlzDedicatedWorker', '--allow-pre-commit-input', '--disable-hang-monitor', '--disable-ipc-flooding-protection', '--disable-popup-blocking', '--disable-prompt-on-repost', '--disable-renderer-backgrounding', '--force-color-profile=srgb', '--metrics-recording-only', '--no-first-run', '--enable-automation', '--password-store=basic', '--use-mock-keychain',
41
- // See https://chromium-review.googlesource.com/c/chromium/src/+/2436773
42
- '--no-service-autorun', '--export-tagged-pdf',
43
- // https://chromium-review.googlesource.com/c/chromium/src/+/4853540
44
- '--disable-search-engine-choice-screen',
45
- // https://issues.chromium.org/41491762
46
- '--unsafely-disable-devtools-self-xss-warnings'];
@@ -1,237 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getAccessibilityTree = getAccessibilityTree;
7
- /**
8
- * Copyright 2018 Google Inc. All rights reserved.
9
- * Modifications copyright (c) Microsoft Corporation.
10
- *
11
- * Licensed under the Apache License, Version 2.0 (the 'License');
12
- * you may not use this file except in compliance with the License.
13
- * You may obtain a copy of the License at
14
- *
15
- * http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software
18
- * distributed under the License is distributed on an 'AS IS' BASIS,
19
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
- * See the License for the specific language governing permissions and
21
- * limitations under the License.
22
- */
23
-
24
- async function getAccessibilityTree(client, needle) {
25
- const {
26
- nodes
27
- } = await client.send('Accessibility.getFullAXTree');
28
- const tree = CRAXNode.createTree(client, nodes);
29
- return {
30
- tree,
31
- needle: needle ? await tree._findElement(needle) : null
32
- };
33
- }
34
- class CRAXNode {
35
- constructor(client, payload) {
36
- this._payload = void 0;
37
- this._children = [];
38
- this._richlyEditable = false;
39
- this._editable = false;
40
- this._focusable = false;
41
- this._expanded = false;
42
- this._hidden = false;
43
- this._name = void 0;
44
- this._role = void 0;
45
- this._cachedHasFocusableChild = void 0;
46
- this._client = void 0;
47
- this._client = client;
48
- this._payload = payload;
49
- this._name = this._payload.name ? this._payload.name.value : '';
50
- this._role = this._payload.role ? this._payload.role.value : 'Unknown';
51
- for (const property of this._payload.properties || []) {
52
- if (property.name === 'editable') {
53
- this._richlyEditable = property.value.value === 'richtext';
54
- this._editable = true;
55
- }
56
- if (property.name === 'focusable') this._focusable = property.value.value;
57
- if (property.name === 'expanded') this._expanded = property.value.value;
58
- if (property.name === 'hidden') this._hidden = property.value.value;
59
- }
60
- }
61
- _isPlainTextField() {
62
- if (this._richlyEditable) return false;
63
- if (this._editable) return true;
64
- return this._role === 'textbox' || this._role === 'ComboBox' || this._role === 'searchbox';
65
- }
66
- _isTextOnlyObject() {
67
- const role = this._role;
68
- return role === 'LineBreak' || role === 'text' || role === 'InlineTextBox' || role === 'StaticText';
69
- }
70
- _hasFocusableChild() {
71
- if (this._cachedHasFocusableChild === undefined) {
72
- this._cachedHasFocusableChild = false;
73
- for (const child of this._children) {
74
- if (child._focusable || child._hasFocusableChild()) {
75
- this._cachedHasFocusableChild = true;
76
- break;
77
- }
78
- }
79
- }
80
- return this._cachedHasFocusableChild;
81
- }
82
- children() {
83
- return this._children;
84
- }
85
- async _findElement(element) {
86
- const objectId = element._objectId;
87
- const {
88
- node: {
89
- backendNodeId
90
- }
91
- } = await this._client.send('DOM.describeNode', {
92
- objectId
93
- });
94
- const needle = this.find(node => node._payload.backendDOMNodeId === backendNodeId);
95
- return needle || null;
96
- }
97
- find(predicate) {
98
- if (predicate(this)) return this;
99
- for (const child of this._children) {
100
- const result = child.find(predicate);
101
- if (result) return result;
102
- }
103
- return null;
104
- }
105
- isLeafNode() {
106
- if (!this._children.length) return true;
107
-
108
- // These types of objects may have children that we use as internal
109
- // implementation details, but we want to expose them as leaves to platform
110
- // accessibility APIs because screen readers might be confused if they find
111
- // any children.
112
- if (this._isPlainTextField() || this._isTextOnlyObject()) return true;
113
-
114
- // Roles whose children are only presentational according to the ARIA and
115
- // HTML5 Specs should be hidden from screen readers.
116
- // (Note that whilst ARIA buttons can have only presentational children, HTML5
117
- // buttons are allowed to have content.)
118
- switch (this._role) {
119
- case 'doc-cover':
120
- case 'graphics-symbol':
121
- case 'img':
122
- case 'Meter':
123
- case 'scrollbar':
124
- case 'slider':
125
- case 'separator':
126
- case 'progressbar':
127
- return true;
128
- default:
129
- break;
130
- }
131
-
132
- // Here and below: Android heuristics
133
- if (this._hasFocusableChild()) return false;
134
- if (this._focusable && this._role !== 'WebArea' && this._role !== 'RootWebArea' && this._name) return true;
135
- if (this._role === 'heading' && this._name) return true;
136
- return false;
137
- }
138
- isControl() {
139
- switch (this._role) {
140
- case 'button':
141
- case 'checkbox':
142
- case 'ColorWell':
143
- case 'combobox':
144
- case 'DisclosureTriangle':
145
- case 'listbox':
146
- case 'menu':
147
- case 'menubar':
148
- case 'menuitem':
149
- case 'menuitemcheckbox':
150
- case 'menuitemradio':
151
- case 'radio':
152
- case 'scrollbar':
153
- case 'searchbox':
154
- case 'slider':
155
- case 'spinbutton':
156
- case 'switch':
157
- case 'tab':
158
- case 'textbox':
159
- case 'tree':
160
- return true;
161
- default:
162
- return false;
163
- }
164
- }
165
- isInteresting(insideControl) {
166
- const role = this._role;
167
- if (role === 'Ignored' || this._hidden) return false;
168
- if (this._focusable || this._richlyEditable) return true;
169
-
170
- // If it's not focusable but has a control role, then it's interesting.
171
- if (this.isControl()) return true;
172
-
173
- // A non focusable child of a control is not interesting
174
- if (insideControl) return false;
175
- return this.isLeafNode() && !!this._name;
176
- }
177
- normalizedRole() {
178
- switch (this._role) {
179
- case 'RootWebArea':
180
- return 'WebArea';
181
- case 'StaticText':
182
- return 'text';
183
- default:
184
- return this._role;
185
- }
186
- }
187
- serialize() {
188
- const properties = new Map();
189
- for (const property of this._payload.properties || []) properties.set(property.name.toLowerCase(), property.value.value);
190
- if (this._payload.description) properties.set('description', this._payload.description.value);
191
- const node = {
192
- role: this.normalizedRole(),
193
- name: this._payload.name ? this._payload.name.value || '' : ''
194
- };
195
- const userStringProperties = ['description', 'keyshortcuts', 'roledescription', 'valuetext'];
196
- for (const userStringProperty of userStringProperties) {
197
- if (!properties.has(userStringProperty)) continue;
198
- node[userStringProperty] = properties.get(userStringProperty);
199
- }
200
- const booleanProperties = ['disabled', 'expanded', 'focused', 'modal', 'multiline', 'multiselectable', 'readonly', 'required', 'selected'];
201
- for (const booleanProperty of booleanProperties) {
202
- // WebArea's treat focus differently than other nodes. They report whether their frame has focus,
203
- // not whether focus is specifically on the root node.
204
- if (booleanProperty === 'focused' && (this._role === 'WebArea' || this._role === 'RootWebArea')) continue;
205
- const value = properties.get(booleanProperty);
206
- if (!value) continue;
207
- node[booleanProperty] = value;
208
- }
209
- const numericalProperties = ['level', 'valuemax', 'valuemin'];
210
- for (const numericalProperty of numericalProperties) {
211
- if (!properties.has(numericalProperty)) continue;
212
- node[numericalProperty] = properties.get(numericalProperty);
213
- }
214
- const tokenProperties = ['autocomplete', 'haspopup', 'invalid', 'orientation'];
215
- for (const tokenProperty of tokenProperties) {
216
- const value = properties.get(tokenProperty);
217
- if (!value || value === 'false') continue;
218
- node[tokenProperty] = value;
219
- }
220
- const axNode = node;
221
- if (this._payload.value) {
222
- if (typeof this._payload.value.value === 'string') axNode.valueString = this._payload.value.value;
223
- if (typeof this._payload.value.value === 'number') axNode.valueNumber = this._payload.value.value;
224
- }
225
- if (properties.has('checked')) axNode.checked = properties.get('checked') === 'true' ? 'checked' : properties.get('checked') === 'false' ? 'unchecked' : 'mixed';
226
- if (properties.has('pressed')) axNode.pressed = properties.get('pressed') === 'true' ? 'pressed' : properties.get('pressed') === 'false' ? 'released' : 'mixed';
227
- return axNode;
228
- }
229
- static createTree(client, payloads) {
230
- const nodeById = new Map();
231
- for (const payload of payloads) nodeById.set(payload.nodeId, new CRAXNode(client, payload));
232
- for (const node of nodeById.values()) {
233
- for (const childId of node._payload.childIds || []) node._children.push(nodeById.get(childId));
234
- }
235
- return nodeById.values().next().value;
236
- }
237
- }