@selenium/atoms 4.51.0 → 4.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (392) hide show
  1. package/README.md +56 -0
  2. package/dist/index.d.ts +44 -0
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +42 -0
  5. package/dist/index.js.map +1 -1
  6. package/dist/typescript/accessibility-snapshot-wire.d.ts +4 -0
  7. package/dist/typescript/accessibility-snapshot-wire.d.ts.map +1 -0
  8. package/dist/typescript/accessibility-snapshot-wire.js +18 -0
  9. package/dist/typescript/accessibility-snapshot-wire.js.map +1 -0
  10. package/dist/typescript/accessibility-snapshot.d.ts +3 -0
  11. package/dist/typescript/accessibility-snapshot.d.ts.map +1 -0
  12. package/dist/typescript/accessibility-snapshot.js +18 -0
  13. package/dist/typescript/accessibility-snapshot.js.map +1 -0
  14. package/dist/typescript/active-element.d.ts +2 -0
  15. package/dist/typescript/active-element.d.ts.map +1 -0
  16. package/dist/typescript/active-element.js +19 -0
  17. package/dist/typescript/active-element.js.map +1 -0
  18. package/dist/typescript/clear-local-storage.d.ts +3 -0
  19. package/dist/typescript/clear-local-storage.d.ts.map +1 -0
  20. package/dist/typescript/clear-local-storage.js +25 -0
  21. package/dist/typescript/clear-local-storage.js.map +1 -0
  22. package/dist/typescript/clear-session-storage.d.ts +3 -0
  23. package/dist/typescript/clear-session-storage.d.ts.map +1 -0
  24. package/dist/typescript/clear-session-storage.js +25 -0
  25. package/dist/typescript/clear-session-storage.js.map +1 -0
  26. package/dist/typescript/clear.d.ts +3 -0
  27. package/dist/typescript/clear.d.ts.map +1 -0
  28. package/dist/typescript/clear.js +67 -0
  29. package/dist/typescript/clear.js.map +1 -0
  30. package/dist/typescript/click.d.ts +4 -0
  31. package/dist/typescript/click.d.ts.map +1 -0
  32. package/dist/typescript/click.js +52 -0
  33. package/dist/typescript/click.js.map +1 -0
  34. package/dist/typescript/core/accessibility/accname.d.ts +6 -0
  35. package/dist/typescript/core/accessibility/accname.d.ts.map +1 -0
  36. package/dist/typescript/core/accessibility/accname.js +537 -0
  37. package/dist/typescript/core/accessibility/accname.js.map +1 -0
  38. package/dist/typescript/core/accessibility/context.d.ts +43 -0
  39. package/dist/typescript/core/accessibility/context.d.ts.map +1 -0
  40. package/dist/typescript/core/accessibility/context.js +49 -0
  41. package/dist/typescript/core/accessibility/context.js.map +1 -0
  42. package/dist/typescript/core/accessibility/hidden.d.ts +39 -0
  43. package/dist/typescript/core/accessibility/hidden.d.ts.map +1 -0
  44. package/dist/typescript/core/accessibility/hidden.js +216 -0
  45. package/dist/typescript/core/accessibility/hidden.js.map +1 -0
  46. package/dist/typescript/core/accessibility/roles.d.ts +28 -0
  47. package/dist/typescript/core/accessibility/roles.d.ts.map +1 -0
  48. package/dist/typescript/core/accessibility/roles.js +381 -0
  49. package/dist/typescript/core/accessibility/roles.js.map +1 -0
  50. package/dist/typescript/core/accessibility/snapshot.d.ts +13 -0
  51. package/dist/typescript/core/accessibility/snapshot.d.ts.map +1 -0
  52. package/dist/typescript/core/accessibility/snapshot.js +55 -0
  53. package/dist/typescript/core/accessibility/snapshot.js.map +1 -0
  54. package/dist/typescript/core/accessibility/states.d.ts +18 -0
  55. package/dist/typescript/core/accessibility/states.d.ts.map +1 -0
  56. package/dist/typescript/core/accessibility/states.js +215 -0
  57. package/dist/typescript/core/accessibility/states.js.map +1 -0
  58. package/dist/typescript/core/accessibility/tree.d.ts +10 -0
  59. package/dist/typescript/core/accessibility/tree.d.ts.map +1 -0
  60. package/dist/typescript/core/accessibility/tree.js +261 -0
  61. package/dist/typescript/core/accessibility/tree.js.map +1 -0
  62. package/dist/typescript/core/accessibility/types.d.ts +30 -0
  63. package/dist/typescript/core/accessibility/types.d.ts.map +1 -0
  64. package/dist/typescript/core/accessibility/types.js +18 -0
  65. package/dist/typescript/core/accessibility/types.js.map +1 -0
  66. package/dist/typescript/core/accessibility/value.d.ts +4 -0
  67. package/dist/typescript/core/accessibility/value.d.ts.map +1 -0
  68. package/dist/typescript/core/accessibility/value.js +83 -0
  69. package/dist/typescript/core/accessibility/value.js.map +1 -0
  70. package/dist/typescript/core/accessibility/wire.d.ts +57 -0
  71. package/dist/typescript/core/accessibility/wire.d.ts.map +1 -0
  72. package/dist/typescript/core/accessibility/wire.js +72 -0
  73. package/dist/typescript/core/accessibility/wire.js.map +1 -0
  74. package/dist/typescript/core/attribute.d.ts +3 -0
  75. package/dist/typescript/core/attribute.d.ts.map +1 -0
  76. package/dist/typescript/core/attribute.js +60 -0
  77. package/dist/typescript/core/attribute.js.map +1 -0
  78. package/dist/typescript/core/color.d.ts +2 -0
  79. package/dist/typescript/core/color.d.ts.map +1 -0
  80. package/dist/typescript/core/color.js +248 -0
  81. package/dist/typescript/core/color.js.map +1 -0
  82. package/dist/typescript/core/editable.d.ts +5 -0
  83. package/dist/typescript/core/editable.d.ts.map +1 -0
  84. package/dist/typescript/core/editable.js +55 -0
  85. package/dist/typescript/core/editable.js.map +1 -0
  86. package/dist/typescript/core/element.d.ts +6 -0
  87. package/dist/typescript/core/element.d.ts.map +1 -0
  88. package/dist/typescript/core/element.js +97 -0
  89. package/dist/typescript/core/element.js.map +1 -0
  90. package/dist/typescript/core/enabled.d.ts +2 -0
  91. package/dist/typescript/core/enabled.d.ts.map +1 -0
  92. package/dist/typescript/core/enabled.js +69 -0
  93. package/dist/typescript/core/enabled.js.map +1 -0
  94. package/dist/typescript/core/error.d.ts +13 -0
  95. package/dist/typescript/core/error.d.ts.map +1 -0
  96. package/dist/typescript/core/error.js +40 -0
  97. package/dist/typescript/core/error.js.map +1 -0
  98. package/dist/typescript/core/events.d.ts +91 -0
  99. package/dist/typescript/core/events.d.ts.map +1 -0
  100. package/dist/typescript/core/events.js +131 -0
  101. package/dist/typescript/core/events.js.map +1 -0
  102. package/dist/typescript/core/focus.d.ts +4 -0
  103. package/dist/typescript/core/focus.d.ts.map +1 -0
  104. package/dist/typescript/core/focus.js +88 -0
  105. package/dist/typescript/core/focus.js.map +1 -0
  106. package/dist/typescript/core/focusable.d.ts +2 -0
  107. package/dist/typescript/core/focusable.d.ts.map +1 -0
  108. package/dist/typescript/core/focusable.js +36 -0
  109. package/dist/typescript/core/focusable.js.map +1 -0
  110. package/dist/typescript/core/form.d.ts +2 -0
  111. package/dist/typescript/core/form.d.ts.map +1 -0
  112. package/dist/typescript/core/form.js +76 -0
  113. package/dist/typescript/core/form.js.map +1 -0
  114. package/dist/typescript/core/frame.d.ts +8 -0
  115. package/dist/typescript/core/frame.d.ts.map +1 -0
  116. package/dist/typescript/core/frame.js +95 -0
  117. package/dist/typescript/core/frame.js.map +1 -0
  118. package/dist/typescript/core/geometry.d.ts +28 -0
  119. package/dist/typescript/core/geometry.d.ts.map +1 -0
  120. package/dist/typescript/core/geometry.js +134 -0
  121. package/dist/typescript/core/geometry.js.map +1 -0
  122. package/dist/typescript/core/inject.d.ts +21 -0
  123. package/dist/typescript/core/inject.d.ts.map +1 -0
  124. package/dist/typescript/core/inject.js +282 -0
  125. package/dist/typescript/core/inject.js.map +1 -0
  126. package/dist/typescript/core/interactable.d.ts +2 -0
  127. package/dist/typescript/core/interactable.d.ts.map +1 -0
  128. package/dist/typescript/core/interactable.js +27 -0
  129. package/dist/typescript/core/interactable.js.map +1 -0
  130. package/dist/typescript/core/keyboard.d.ts +15 -0
  131. package/dist/typescript/core/keyboard.d.ts.map +1 -0
  132. package/dist/typescript/core/keyboard.js +356 -0
  133. package/dist/typescript/core/keyboard.js.map +1 -0
  134. package/dist/typescript/core/keys.d.ts +65 -0
  135. package/dist/typescript/core/keys.d.ts.map +1 -0
  136. package/dist/typescript/core/keys.js +125 -0
  137. package/dist/typescript/core/keys.js.map +1 -0
  138. package/dist/typescript/core/locators.d.ts +6 -0
  139. package/dist/typescript/core/locators.d.ts.map +1 -0
  140. package/dist/typescript/core/locators.js +610 -0
  141. package/dist/typescript/core/locators.js.map +1 -0
  142. package/dist/typescript/core/mouse.d.ts +17 -0
  143. package/dist/typescript/core/mouse.d.ts.map +1 -0
  144. package/dist/typescript/core/mouse.js +186 -0
  145. package/dist/typescript/core/mouse.js.map +1 -0
  146. package/dist/typescript/core/overflow.d.ts +5 -0
  147. package/dist/typescript/core/overflow.d.ts.map +1 -0
  148. package/dist/typescript/core/overflow.js +133 -0
  149. package/dist/typescript/core/overflow.js.map +1 -0
  150. package/dist/typescript/core/scroll.d.ts +3 -0
  151. package/dist/typescript/core/scroll.d.ts.map +1 -0
  152. package/dist/typescript/core/scroll.js +77 -0
  153. package/dist/typescript/core/scroll.js.map +1 -0
  154. package/dist/typescript/core/shown.d.ts +3 -0
  155. package/dist/typescript/core/shown.d.ts.map +1 -0
  156. package/dist/typescript/core/shown.js +190 -0
  157. package/dist/typescript/core/shown.js.map +1 -0
  158. package/dist/typescript/core/storage.d.ts +14 -0
  159. package/dist/typescript/core/storage.d.ts.map +1 -0
  160. package/dist/typescript/core/storage.js +98 -0
  161. package/dist/typescript/core/storage.js.map +1 -0
  162. package/dist/typescript/core/style.d.ts +2 -0
  163. package/dist/typescript/core/style.d.ts.map +1 -0
  164. package/dist/typescript/core/style.js +32 -0
  165. package/dist/typescript/core/style.js.map +1 -0
  166. package/dist/typescript/core/useragent.d.ts +3 -0
  167. package/dist/typescript/core/useragent.d.ts.map +1 -0
  168. package/dist/typescript/core/useragent.js +31 -0
  169. package/dist/typescript/core/useragent.js.map +1 -0
  170. package/dist/typescript/default-content.d.ts +2 -0
  171. package/dist/typescript/default-content.d.ts.map +1 -0
  172. package/dist/typescript/default-content.js +20 -0
  173. package/dist/typescript/default-content.js.map +1 -0
  174. package/dist/typescript/execute-async-script.d.ts +2 -0
  175. package/dist/typescript/execute-async-script.d.ts.map +1 -0
  176. package/dist/typescript/execute-async-script.js +20 -0
  177. package/dist/typescript/execute-async-script.js.map +1 -0
  178. package/dist/typescript/execute-script.d.ts +2 -0
  179. package/dist/typescript/execute-script.d.ts.map +1 -0
  180. package/dist/typescript/execute-script.js +20 -0
  181. package/dist/typescript/execute-script.js.map +1 -0
  182. package/dist/typescript/find-element-fragment.d.ts +8 -0
  183. package/dist/typescript/find-element-fragment.d.ts.map +1 -0
  184. package/dist/typescript/find-element-fragment.js +39 -0
  185. package/dist/typescript/find-element-fragment.js.map +1 -0
  186. package/dist/typescript/find-element.d.ts +2 -0
  187. package/dist/typescript/find-element.d.ts.map +1 -0
  188. package/dist/typescript/find-element.js +18 -0
  189. package/dist/typescript/find-element.js.map +1 -0
  190. package/dist/typescript/find-elements.d.ts +1 -2
  191. package/dist/typescript/find-elements.d.ts.map +1 -1
  192. package/dist/typescript/find-elements.js +1 -289
  193. package/dist/typescript/find-elements.js.map +1 -1
  194. package/dist/typescript/frame-by-id-or-name.d.ts +2 -0
  195. package/dist/typescript/frame-by-id-or-name.d.ts.map +1 -0
  196. package/dist/typescript/frame-by-id-or-name.js +22 -0
  197. package/dist/typescript/frame-by-id-or-name.js.map +1 -0
  198. package/dist/typescript/frame-by-index.d.ts +2 -0
  199. package/dist/typescript/frame-by-index.d.ts.map +1 -0
  200. package/dist/typescript/frame-by-index.js +19 -0
  201. package/dist/typescript/frame-by-index.js.map +1 -0
  202. package/dist/typescript/get-attribute-value.d.ts +2 -0
  203. package/dist/typescript/get-attribute-value.d.ts.map +1 -0
  204. package/dist/typescript/get-attribute-value.js +22 -0
  205. package/dist/typescript/get-attribute-value.js.map +1 -0
  206. package/dist/typescript/get-effective-style.d.ts +3 -0
  207. package/dist/typescript/get-effective-style.d.ts.map +1 -0
  208. package/dist/typescript/get-effective-style.js +84 -0
  209. package/dist/typescript/get-effective-style.js.map +1 -0
  210. package/dist/typescript/get-element-from-cache.d.ts +2 -0
  211. package/dist/typescript/get-element-from-cache.d.ts.map +1 -0
  212. package/dist/typescript/get-element-from-cache.js +20 -0
  213. package/dist/typescript/get-element-from-cache.js.map +1 -0
  214. package/dist/typescript/get-frame-window.d.ts +2 -0
  215. package/dist/typescript/get-frame-window.d.ts.map +1 -0
  216. package/dist/typescript/get-frame-window.js +22 -0
  217. package/dist/typescript/get-frame-window.js.map +1 -0
  218. package/dist/typescript/get-local-storage-item.d.ts +3 -0
  219. package/dist/typescript/get-local-storage-item.d.ts.map +1 -0
  220. package/dist/typescript/get-local-storage-item.js +25 -0
  221. package/dist/typescript/get-local-storage-item.js.map +1 -0
  222. package/dist/typescript/get-local-storage-key.d.ts +3 -0
  223. package/dist/typescript/get-local-storage-key.d.ts.map +1 -0
  224. package/dist/typescript/get-local-storage-key.js +26 -0
  225. package/dist/typescript/get-local-storage-key.js.map +1 -0
  226. package/dist/typescript/get-local-storage-keys.d.ts +3 -0
  227. package/dist/typescript/get-local-storage-keys.d.ts.map +1 -0
  228. package/dist/typescript/get-local-storage-keys.js +25 -0
  229. package/dist/typescript/get-local-storage-keys.js.map +1 -0
  230. package/dist/typescript/get-local-storage-size.d.ts +3 -0
  231. package/dist/typescript/get-local-storage-size.d.ts.map +1 -0
  232. package/dist/typescript/get-local-storage-size.js +25 -0
  233. package/dist/typescript/get-local-storage-size.js.map +1 -0
  234. package/dist/typescript/get-location.d.ts +9 -0
  235. package/dist/typescript/get-location.d.ts.map +1 -0
  236. package/dist/typescript/get-location.js +49 -0
  237. package/dist/typescript/get-location.js.map +1 -0
  238. package/dist/typescript/get-session-storage-item.d.ts +3 -0
  239. package/dist/typescript/get-session-storage-item.d.ts.map +1 -0
  240. package/dist/typescript/get-session-storage-item.js +25 -0
  241. package/dist/typescript/get-session-storage-item.js.map +1 -0
  242. package/dist/typescript/get-session-storage-key.d.ts +3 -0
  243. package/dist/typescript/get-session-storage-key.d.ts.map +1 -0
  244. package/dist/typescript/get-session-storage-key.js +26 -0
  245. package/dist/typescript/get-session-storage-key.js.map +1 -0
  246. package/dist/typescript/get-session-storage-keys.d.ts +3 -0
  247. package/dist/typescript/get-session-storage-keys.d.ts.map +1 -0
  248. package/dist/typescript/get-session-storage-keys.js +25 -0
  249. package/dist/typescript/get-session-storage-keys.js.map +1 -0
  250. package/dist/typescript/get-session-storage-size.d.ts +3 -0
  251. package/dist/typescript/get-session-storage-size.d.ts.map +1 -0
  252. package/dist/typescript/get-session-storage-size.js +25 -0
  253. package/dist/typescript/get-session-storage-size.js.map +1 -0
  254. package/dist/typescript/get-size.d.ts +7 -0
  255. package/dist/typescript/get-size.d.ts.map +1 -0
  256. package/dist/typescript/get-size.js +36 -0
  257. package/dist/typescript/get-size.js.map +1 -0
  258. package/dist/typescript/get-text.d.ts +3 -0
  259. package/dist/typescript/get-text.d.ts.map +1 -0
  260. package/dist/typescript/get-text.js +294 -0
  261. package/dist/typescript/get-text.js.map +1 -0
  262. package/dist/typescript/get-top-left-coordinates.d.ts +4 -0
  263. package/dist/typescript/get-top-left-coordinates.d.ts.map +1 -0
  264. package/dist/typescript/get-top-left-coordinates.js +36 -0
  265. package/dist/typescript/get-top-left-coordinates.js.map +1 -0
  266. package/dist/typescript/is-displayed.d.ts +1 -2
  267. package/dist/typescript/is-displayed.d.ts.map +1 -1
  268. package/dist/typescript/is-displayed.js +3 -396
  269. package/dist/typescript/is-displayed.js.map +1 -1
  270. package/dist/typescript/is-editable.d.ts +2 -0
  271. package/dist/typescript/is-editable.d.ts.map +1 -0
  272. package/dist/typescript/is-editable.js +18 -0
  273. package/dist/typescript/is-editable.js.map +1 -0
  274. package/dist/typescript/is-enabled.d.ts +2 -0
  275. package/dist/typescript/is-enabled.d.ts.map +1 -0
  276. package/dist/typescript/is-enabled.js +18 -0
  277. package/dist/typescript/is-enabled.js.map +1 -0
  278. package/dist/typescript/is-focusable.d.ts +2 -0
  279. package/dist/typescript/is-focusable.d.ts.map +1 -0
  280. package/dist/typescript/is-focusable.js +20 -0
  281. package/dist/typescript/is-focusable.js.map +1 -0
  282. package/dist/typescript/is-interactable.d.ts +2 -0
  283. package/dist/typescript/is-interactable.d.ts.map +1 -0
  284. package/dist/typescript/is-interactable.js +19 -0
  285. package/dist/typescript/is-interactable.js.map +1 -0
  286. package/dist/typescript/is-selected.d.ts +3 -0
  287. package/dist/typescript/is-selected.d.ts.map +1 -0
  288. package/dist/typescript/is-selected.js +29 -0
  289. package/dist/typescript/is-selected.js.map +1 -0
  290. package/dist/typescript/remove-local-storage-item.d.ts +3 -0
  291. package/dist/typescript/remove-local-storage-item.d.ts.map +1 -0
  292. package/dist/typescript/remove-local-storage-item.js +25 -0
  293. package/dist/typescript/remove-local-storage-item.js.map +1 -0
  294. package/dist/typescript/remove-session-storage-item.d.ts +3 -0
  295. package/dist/typescript/remove-session-storage-item.d.ts.map +1 -0
  296. package/dist/typescript/remove-session-storage-item.js +25 -0
  297. package/dist/typescript/remove-session-storage-item.js.map +1 -0
  298. package/dist/typescript/set-local-storage-item.d.ts +3 -0
  299. package/dist/typescript/set-local-storage-item.d.ts.map +1 -0
  300. package/dist/typescript/set-local-storage-item.js +26 -0
  301. package/dist/typescript/set-local-storage-item.js.map +1 -0
  302. package/dist/typescript/set-session-storage-item.d.ts +3 -0
  303. package/dist/typescript/set-session-storage-item.d.ts.map +1 -0
  304. package/dist/typescript/set-session-storage-item.js +26 -0
  305. package/dist/typescript/set-session-storage-item.js.map +1 -0
  306. package/dist/typescript/submit.d.ts +3 -0
  307. package/dist/typescript/submit.d.ts.map +1 -0
  308. package/dist/typescript/submit.js +50 -0
  309. package/dist/typescript/submit.js.map +1 -0
  310. package/dist/typescript/type.d.ts +3 -0
  311. package/dist/typescript/type.d.ts.map +1 -0
  312. package/dist/typescript/type.js +201 -0
  313. package/dist/typescript/type.js.map +1 -0
  314. package/index.ts +44 -0
  315. package/package.json +306 -5
  316. package/typescript/accessibility-snapshot-wire.ts +20 -0
  317. package/typescript/accessibility-snapshot.ts +21 -0
  318. package/typescript/active-element.ts +19 -0
  319. package/typescript/clear-local-storage.ts +27 -0
  320. package/typescript/clear-session-storage.ts +27 -0
  321. package/typescript/clear.ts +73 -0
  322. package/typescript/click.ts +55 -0
  323. package/typescript/core/accessibility/accname.ts +587 -0
  324. package/typescript/core/accessibility/context.ts +116 -0
  325. package/typescript/core/accessibility/hidden.ts +242 -0
  326. package/typescript/core/accessibility/roles.ts +410 -0
  327. package/typescript/core/accessibility/snapshot.ts +61 -0
  328. package/typescript/core/accessibility/states.ts +233 -0
  329. package/typescript/core/accessibility/tree.ts +306 -0
  330. package/typescript/core/accessibility/types.ts +52 -0
  331. package/typescript/core/accessibility/value.ts +89 -0
  332. package/typescript/core/accessibility/wire.ts +123 -0
  333. package/typescript/core/attribute.ts +68 -0
  334. package/typescript/core/color.ts +257 -0
  335. package/typescript/core/editable.ts +63 -0
  336. package/typescript/core/element.ts +110 -0
  337. package/typescript/core/enabled.ts +76 -0
  338. package/typescript/core/error.ts +41 -0
  339. package/typescript/core/events.ts +268 -0
  340. package/typescript/core/focus.ts +92 -0
  341. package/typescript/core/focusable.ts +38 -0
  342. package/typescript/core/form.ts +81 -0
  343. package/typescript/core/frame.ts +105 -0
  344. package/typescript/core/geometry.ts +183 -0
  345. package/typescript/core/inject.ts +336 -0
  346. package/typescript/core/interactable.ts +30 -0
  347. package/typescript/core/keyboard.ts +369 -0
  348. package/typescript/core/keys.ts +204 -0
  349. package/typescript/core/locators.ts +704 -0
  350. package/typescript/core/mouse.ts +211 -0
  351. package/typescript/core/overflow.ts +172 -0
  352. package/typescript/core/scroll.ts +92 -0
  353. package/typescript/core/shown.ts +233 -0
  354. package/typescript/core/storage.ts +111 -0
  355. package/typescript/core/style.ts +32 -0
  356. package/typescript/core/useragent.ts +33 -0
  357. package/typescript/default-content.ts +20 -0
  358. package/typescript/execute-async-script.ts +20 -0
  359. package/typescript/execute-script.ts +20 -0
  360. package/typescript/find-element-fragment.ts +45 -0
  361. package/typescript/find-element.ts +18 -0
  362. package/typescript/find-elements.ts +1 -326
  363. package/typescript/frame-by-id-or-name.ts +22 -0
  364. package/typescript/frame-by-index.ts +19 -0
  365. package/typescript/get-attribute-value.ts +22 -0
  366. package/typescript/get-effective-style.ts +93 -0
  367. package/typescript/get-element-from-cache.ts +20 -0
  368. package/typescript/get-frame-window.ts +22 -0
  369. package/typescript/get-local-storage-item.ts +27 -0
  370. package/typescript/get-local-storage-key.ts +28 -0
  371. package/typescript/get-local-storage-keys.ts +27 -0
  372. package/typescript/get-local-storage-size.ts +27 -0
  373. package/typescript/get-location.ts +63 -0
  374. package/typescript/get-session-storage-item.ts +27 -0
  375. package/typescript/get-session-storage-key.ts +28 -0
  376. package/typescript/get-session-storage-keys.ts +27 -0
  377. package/typescript/get-session-storage-size.ts +27 -0
  378. package/typescript/get-size.ts +43 -0
  379. package/typescript/get-text.ts +353 -0
  380. package/typescript/get-top-left-coordinates.ts +38 -0
  381. package/typescript/is-displayed.ts +3 -498
  382. package/typescript/is-editable.ts +18 -0
  383. package/typescript/is-enabled.ts +18 -0
  384. package/typescript/is-focusable.ts +20 -0
  385. package/typescript/is-interactable.ts +19 -0
  386. package/typescript/is-selected.ts +31 -0
  387. package/typescript/remove-local-storage-item.ts +27 -0
  388. package/typescript/remove-session-storage-item.ts +27 -0
  389. package/typescript/set-local-storage-item.ts +28 -0
  390. package/typescript/set-session-storage-item.ts +28 -0
  391. package/typescript/submit.ts +53 -0
  392. package/typescript/type.ts +210 -0
@@ -0,0 +1,233 @@
1
+ // Licensed to the Software Freedom Conservancy (SFC) under one
2
+ // or more contributor license agreements. See the NOTICE file
3
+ // distributed with this work for additional information
4
+ // regarding copyright ownership. The SFC licenses this file
5
+ // to you under the Apache License, Version 2.0 (the
6
+ // "License"); you may not use this file except in compliance
7
+ // with the License. You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing,
12
+ // software distributed under the License is distributed on an
13
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ // KIND, either express or implied. See the License for the
15
+ // specific language governing permissions and limitations
16
+ // under the License.
17
+
18
+ import { isEnabled } from '../enabled.js'
19
+ import { canTakeFocus } from './roles.js'
20
+ import type { StateValue } from './types.js'
21
+ import { embeddedValue } from './value.js'
22
+
23
+ // The `states` map and `value` field of ADR 18205 §2. Which keys appear:
24
+ //
25
+ // checked whenever the role supports it; "mixed" where the role allows it
26
+ // pressed when the element sets aria-pressed: a button without it is not
27
+ // a toggle button, so reporting pressed=false would mislead
28
+ // expanded when the element sets aria-expanded, and on a summary from its
29
+ // details' open state
30
+ // selected always for option, tab and treeitem, where selection is part of
31
+ // the role; for gridcell, row and headers only when the element
32
+ // sets aria-selected, since most grids are not selectable
33
+ // level always for headings (tag, aria-level, or ARIA's default of 2);
34
+ // elsewhere when the element sets aria-level
35
+ // disabled true only when disabled, natively or through aria-disabled on
36
+ // the element, or on an ancestor when the element can take focus
37
+ // (WAI-ARIA 1.2: the state reaches focusable descendants)
38
+ // focused true only on the focused element
39
+ //
40
+ // For pressed, expanded and the grid parts' selected, "undefined" and an
41
+ // empty value mean the attribute is not set: ARIA defines undefined as "not
42
+ // a toggle", "not expandable", "not selectable".
43
+ //
44
+ // Adding a key is additive under the ADR's compatibility rule; the states
45
+ // page pins the current set.
46
+
47
+ const CHECKED_ROLES: ReadonlySet<string> = new Set(['checkbox', 'menuitemcheckbox', 'menuitemradio', 'radio', 'switch'])
48
+ const MIXED_ALLOWED: ReadonlySet<string> = new Set(['checkbox', 'menuitemcheckbox'])
49
+ const ALWAYS_SELECTED_ROLES: ReadonlySet<string> = new Set(['option', 'tab', 'treeitem'])
50
+ const SELECTABLE_ROLES: ReadonlySet<string> = new Set(['columnheader', 'gridcell', 'row', 'rowheader'])
51
+ const LEVEL_ROLES: ReadonlySet<string> = new Set(['comment', 'listitem', 'row', 'tablist', 'treeitem'])
52
+ const VALUE_ROLES: ReadonlySet<string> = new Set([
53
+ 'combobox', 'meter', 'progressbar', 'scrollbar', 'searchbox', 'slider', 'spinbutton', 'textbox',
54
+ ])
55
+ // The elements core/enabled.ts can report as disabled; for anything else it
56
+ // answers enabled without looking, so it is not asked.
57
+ const DISABLEABLE_ELEMENTS: ReadonlySet<string> = new Set(['button', 'input', 'optgroup', 'option', 'select', 'textarea'])
58
+
59
+ function token(element: Element, name: string): string | null {
60
+ const value = element.getAttribute(name)
61
+ return value === null ? null : value.trim().toLowerCase()
62
+ }
63
+
64
+ // A token whose "undefined" and empty values count as the attribute being absent.
65
+ function optionalToken(element: Element, name: string): string | null {
66
+ const value = token(element, name)
67
+ return value === '' || value === 'undefined' ? null : value
68
+ }
69
+
70
+ function tristate(element: Element, name: string, allowMixed: boolean): StateValue {
71
+ const value = token(element, name)
72
+ if (value === 'true') {
73
+ return true
74
+ }
75
+ if (value === 'mixed' && allowMixed) {
76
+ return 'mixed'
77
+ }
78
+ return false
79
+ }
80
+
81
+ function checked(element: Element, role: string): StateValue {
82
+ if (element.localName === 'input') {
83
+ const input = element as HTMLInputElement
84
+ if (input.type === 'checkbox' || input.type === 'radio') {
85
+ return input.indeterminate && MIXED_ALLOWED.has(role) ? 'mixed' : input.checked
86
+ }
87
+ }
88
+ return tristate(element, 'aria-checked', MIXED_ALLOWED.has(role))
89
+ }
90
+
91
+ function expanded(element: Element): boolean | null {
92
+ const value = optionalToken(element, 'aria-expanded')
93
+ if (value !== null) {
94
+ return value === 'true'
95
+ }
96
+ if (element.localName === 'summary') {
97
+ const details = element.parentElement
98
+ if (details && details.localName === 'details') {
99
+ return details.hasAttribute('open')
100
+ }
101
+ }
102
+ return null
103
+ }
104
+
105
+ function selected(element: Element, role: string): boolean | null {
106
+ if (element.localName === 'option' && role === 'option') {
107
+ return (element as HTMLOptionElement).selected
108
+ }
109
+ if (ALWAYS_SELECTED_ROLES.has(role)) {
110
+ return token(element, 'aria-selected') === 'true'
111
+ }
112
+ if (SELECTABLE_ROLES.has(role)) {
113
+ const value = optionalToken(element, 'aria-selected')
114
+ return value === null ? null : value === 'true'
115
+ }
116
+ return null
117
+ }
118
+
119
+ function ariaLevel(element: Element): number | null {
120
+ const value = element.getAttribute('aria-level')
121
+ if (value === null || !/^\s*\d+\s*$/.test(value)) {
122
+ return null
123
+ }
124
+ const level = parseInt(value, 10)
125
+ return level >= 1 ? level : null
126
+ }
127
+
128
+ function level(element: Element, role: string): number | null {
129
+ if (role === 'heading') {
130
+ const explicit = ariaLevel(element)
131
+ if (explicit !== null) {
132
+ return explicit
133
+ }
134
+ const tag = /^h([1-6])$/.exec(element.localName)
135
+ return tag ? Number(tag[1]) : 2
136
+ }
137
+ return LEVEL_ROLES.has(role) ? ariaLevel(element) : null
138
+ }
139
+
140
+ /** Whether the element itself sets aria-disabled=true. */
141
+ export function setsAriaDisabled(element: Element): boolean {
142
+ return token(element, 'aria-disabled') === 'true'
143
+ }
144
+
145
+ // The DOM parent, or the host for a shadow root's child: aria-disabled on
146
+ // a host reaches into its shadow tree.
147
+ function parentOrHost(element: Element): Element | null {
148
+ if (element.parentElement) {
149
+ return element.parentElement
150
+ }
151
+ return (element.getRootNode() as ShadowRoot).host || null
152
+ }
153
+
154
+ /**
155
+ * Whether an ancestor sets aria-disabled. The walk threads that down, so
156
+ * this check is only for a root or an owned element, whose ancestors the
157
+ * walk has not seen.
158
+ */
159
+ export function isDisabledByAncestor(element: Element): boolean {
160
+ for (let current = parentOrHost(element); current; current = parentOrHost(current)) {
161
+ if (setsAriaDisabled(current)) {
162
+ return true
163
+ }
164
+ }
165
+ return false
166
+ }
167
+
168
+ // An ancestor's aria-disabled reaches the descendants that can take focus
169
+ // (WAI-ARIA 1.2), not the headings and paragraphs between them.
170
+ function disabled(element: Element, disabledByAncestor: boolean): boolean {
171
+ if (setsAriaDisabled(element) || (disabledByAncestor && canTakeFocus(element))) {
172
+ return true
173
+ }
174
+ return DISABLEABLE_ELEMENTS.has(element.localName) && !isEnabled(element)
175
+ }
176
+
177
+ // The body is the default active element and is not "focused" in any sense a
178
+ // user would recognise. Focus inside a shadow tree is known to that tree's
179
+ // root; the document only knows the host, which is not itself focused while
180
+ // something it can see inside its shadow root is.
181
+ function focused(element: Element): boolean {
182
+ const doc = element.ownerDocument
183
+ if (element === doc.body || element === doc.documentElement) {
184
+ return false
185
+ }
186
+ const root = element.getRootNode() as Document | ShadowRoot
187
+ if (root.activeElement !== element) {
188
+ return false
189
+ }
190
+ return !(element.shadowRoot && element.shadowRoot.activeElement)
191
+ }
192
+
193
+ /**
194
+ * The states map for an element with the given role; {} when there are none.
195
+ * `disabledByAncestor` is whether an ancestor sets aria-disabled, which the
196
+ * walk knows without climbing.
197
+ */
198
+ export function computeStates(element: Element, role: string, disabledByAncestor: boolean): Record<string, StateValue> {
199
+ const states: Record<string, StateValue> = {}
200
+ if (CHECKED_ROLES.has(role)) {
201
+ states.checked = checked(element, role)
202
+ }
203
+ if (role === 'button') {
204
+ const pressed = optionalToken(element, 'aria-pressed')
205
+ if (pressed !== null) {
206
+ states.pressed = tristate(element, 'aria-pressed', true)
207
+ }
208
+ }
209
+ const isExpanded = expanded(element)
210
+ if (isExpanded !== null) {
211
+ states.expanded = isExpanded
212
+ }
213
+ const isSelected = selected(element, role)
214
+ if (isSelected !== null) {
215
+ states.selected = isSelected
216
+ }
217
+ const headingLevel = level(element, role)
218
+ if (headingLevel !== null) {
219
+ states.level = headingLevel
220
+ }
221
+ if (disabled(element, disabledByAncestor)) {
222
+ states.disabled = true
223
+ }
224
+ if (focused(element)) {
225
+ states.focused = true
226
+ }
227
+ return states
228
+ }
229
+
230
+ /** The current value for textbox, searchbox, combobox and range roles; null when the field is absent. */
231
+ export function computeValue(element: Element, role: string): string | null {
232
+ return VALUE_ROLES.has(role) ? embeddedValue(element, role) : null
233
+ }
@@ -0,0 +1,306 @@
1
+ // Licensed to the Software Freedom Conservancy (SFC) under one
2
+ // or more contributor license agreements. See the NOTICE file
3
+ // distributed with this work for additional information
4
+ // regarding copyright ownership. The SFC licenses this file
5
+ // to you under the Apache License, Version 2.0 (the
6
+ // "License"); you may not use this file except in compliance
7
+ // with the License. You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing,
12
+ // software distributed under the License is distributed on an
13
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ // KIND, either express or implied. See the License for the
15
+ // specific language governing permissions and limitations
16
+ // under the License.
17
+
18
+ import { computeDescription, computeName } from './accname.js'
19
+ import { roleOf, SnapshotContext } from './context.js'
20
+ import { flatTreeChildren, hiddenState, isClosedDetails, isCollapsedDetailsContent, isHiddenByAncestor } from './hidden.js'
21
+ import { isPresentational } from './roles.js'
22
+ import { computeStates, computeValue, isDisabledByAncestor, setsAriaDisabled } from './states.js'
23
+ import type { AccessibilityNode } from './types.js'
24
+
25
+ const ELEMENT_NODE = 1
26
+ const TEXT_NODE = 3
27
+
28
+ // WAI-ARIA 1.2 roles with "Children Presentational: True" (plus the graphics
29
+ // module's symbol). Their content only contributes to their name, never to
30
+ // the tree.
31
+ const CHILDREN_PRESENTATIONAL: ReadonlySet<string> = new Set([
32
+ 'button', 'checkbox', 'graphics-symbol', 'img', 'menuitemcheckbox', 'menuitemradio', 'meter',
33
+ 'option', 'progressbar', 'radio', 'scrollbar', 'separator', 'slider', 'switch', 'tab',
34
+ ])
35
+
36
+ // Elements whose DOM children are not rendered content, whatever role they
37
+ // end up with: a frame's children are fallback for a browsing context only
38
+ // the bindings can reach (the ADR's iframe leaf), a textarea's text child is
39
+ // its default value, and media fallback shows only when the media cannot.
40
+ const LEAF_ELEMENTS: ReadonlySet<string> = new Set(['audio', 'frame', 'iframe', 'textarea', 'video'])
41
+
42
+ function textLeaf(text: string): AccessibilityNode {
43
+ // No `element` or `value` key at all rather than undefined, so the
44
+ // serialized shape matches the schema literally.
45
+ return { role: 'text', name: text, description: '', states: {}, children: [] }
46
+ }
47
+
48
+ function elementNode(
49
+ element: Element,
50
+ role: string,
51
+ name: string,
52
+ context: SnapshotContext,
53
+ disabledByAncestor: boolean,
54
+ ): AccessibilityNode {
55
+ const node: AccessibilityNode = {
56
+ role,
57
+ name,
58
+ description: computeDescription(element, context),
59
+ states: computeStates(element, role, disabledByAncestor),
60
+ element,
61
+ children: [],
62
+ }
63
+ const value = computeValue(element, role)
64
+ if (value !== null) {
65
+ node.value = value
66
+ }
67
+ const url = linkUrl(element, role)
68
+ if (url !== null) {
69
+ node.url = url
70
+ }
71
+ return node
72
+ }
73
+
74
+ const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml'
75
+
76
+ // ADR 18205 §2: a link node carries the resolved href of an `a` or `area`
77
+ // element, as CDP's accessibility tree exposes it; an element made a link by
78
+ // role alone has nothing to resolve. The href property, not the attribute,
79
+ // so the URL is absolute. Checked by namespace and name rather than
80
+ // instanceof, which fails across realms when the atom runs in a sandbox.
81
+ function linkUrl(element: Element, role: string): string | null {
82
+ if (role !== 'link' || element.namespaceURI !== HTML_NAMESPACE) {
83
+ return null
84
+ }
85
+ const local = element.localName
86
+ if ((local !== 'a' && local !== 'area') || !element.hasAttribute('href')) {
87
+ return null
88
+ }
89
+ return (element as HTMLAnchorElement | HTMLAreaElement).href
90
+ }
91
+
92
+ function normalizeText(text: string): string {
93
+ return text.replace(/\s+/g, ' ').trim()
94
+ }
95
+
96
+ // ADR 18205 §2: an element produces a node when its role is not generic,
97
+ // none or presentation, or it has a name. With interestingOnly off every
98
+ // element does, and the container nodes stay in place.
99
+ function producesNode(role: string, name: string, context: SnapshotContext): boolean {
100
+ return !context.interestingOnly || !(role === 'generic' || isPresentational(role)) || name !== ''
101
+ }
102
+
103
+ function isLeaf(element: Element, role: string): boolean {
104
+ return LEAF_ELEMENTS.has(element.localName) || CHILDREN_PRESENTATIONAL.has(role)
105
+ }
106
+
107
+ // What the walk carries down from the ancestors of the element it visits:
108
+ // whether their visibility hides text, whether an ancestor's name consumed
109
+ // the text, and whether an ancestor sets aria-disabled.
110
+ interface Inherited {
111
+ readonly textHidden: boolean
112
+ readonly textConsumed: boolean
113
+ readonly disabled: boolean
114
+ }
115
+
116
+ /**
117
+ * Appends the node(s) for one element to `out`: its own node with its
118
+ * children, or, when it produces no node (pruned role, visibility-hidden),
119
+ * its children in its place so hoisting keeps order.
120
+ *
121
+ * `textHidden` is true while inside an element whose visibility hides its
122
+ * text: visibility is inherited, so the text of such an element and of
123
+ * descendants that do not set themselves visible again is not rendered.
124
+ * `textConsumed` is true below a node whose name was computed from its
125
+ * content: that text already appears as the name and is not repeated as
126
+ * leaves, while the element structure below is still reported. `disabled`
127
+ * is true below an element that sets aria-disabled, which the states module
128
+ * applies to the descendants that can take focus.
129
+ */
130
+ function visitElement(element: Element, context: SnapshotContext, above: Inherited, out: AccessibilityNode[]): void {
131
+ if (context.placed.has(element)) {
132
+ return
133
+ }
134
+ context.placed.add(element)
135
+ const inherited: Inherited = above.disabled || !setsAriaDisabled(element) ? above : { ...above, disabled: true }
136
+
137
+ const domParent = element.parentElement
138
+ if (domParent && isCollapsedDetailsContent(element, domParent)) {
139
+ return
140
+ }
141
+ const hidden = hiddenState(element, context)
142
+ if (hidden === 'subtree') {
143
+ return
144
+ }
145
+ if (hidden === 'self') {
146
+ collectChildren(element, context, { ...inherited, textHidden: true }, out)
147
+ return
148
+ }
149
+
150
+ const role = roleOf(element, context)
151
+ const name = computeName(element, context)
152
+ const descend = hidden !== 'contents' && !isLeaf(element, role)
153
+ if (!producesNode(role, name.text, context)) {
154
+ // The element is rendered, so its own visibility is visible even under
155
+ // an invisible ancestor: its text shows.
156
+ if (descend) {
157
+ collectChildren(element, context, { ...inherited, textHidden: false }, out)
158
+ }
159
+ return
160
+ }
161
+ const node = elementNode(element, role, name.text, context, above.disabled)
162
+ if (descend) {
163
+ collectChildren(
164
+ element,
165
+ context,
166
+ { ...inherited, textHidden: false, textConsumed: inherited.textConsumed || name.source === 'content' },
167
+ node.children,
168
+ )
169
+ }
170
+ out.push(node)
171
+ }
172
+
173
+ /**
174
+ * Appends the nodes for `parent`'s children to `out`: its flat-tree children
175
+ * in render order, then the elements it owns through aria-owns. An element
176
+ * some owner in the walked subtree claims is skipped at its DOM position and
177
+ * placed under that owner instead (ADR 18205 §3).
178
+ */
179
+ function collectChildren(parent: Element, context: SnapshotContext, inherited: Inherited, out: AccessibilityNode[]): void {
180
+ // Text directly inside a closed details is collapsed content like any
181
+ // element other than its summary.
182
+ const textCollapsed = isClosedDetails(parent)
183
+ const children = flatTreeChildren(parent)
184
+ for (let i = 0; i < children.length; i++) {
185
+ const child = children[i]
186
+ if (child.nodeType === TEXT_NODE) {
187
+ if (!inherited.textHidden && !inherited.textConsumed && !textCollapsed) {
188
+ const text = normalizeText(child.nodeValue || '')
189
+ if (text !== '') {
190
+ out.push(textLeaf(text))
191
+ }
192
+ }
193
+ continue
194
+ }
195
+ if (child.nodeType === ELEMENT_NODE && !context.claimed.has(child as Element)) {
196
+ visitElement(child as Element, context, inherited, out)
197
+ }
198
+ }
199
+ const owned = context.owned.get(parent)
200
+ if (owned) {
201
+ for (const element of owned) {
202
+ // Hidden-ness still follows DOM ancestry: the walk never reaches the
203
+ // owned element's DOM ancestors on its way here, so they are checked
204
+ // now. So does aria-disabled, which an owned element does not share
205
+ // with its owner.
206
+ if (isHiddenByAncestor(element, context)) {
207
+ continue
208
+ }
209
+ visitElement(element, context, { ...inherited, disabled: isDisabledByAncestor(element) }, out)
210
+ }
211
+ }
212
+ }
213
+
214
+ // Whether placing `target` under `owner` would make the tree circular: the
215
+ // target is, or contains, the owner or one of the owner's accessibility
216
+ // ancestors, following the ownership recorded so far and DOM parentage
217
+ // otherwise.
218
+ function wouldCycle(target: Element, owner: Element, ownerOf: Map<Element, Element>): boolean {
219
+ for (let current: Element | null = owner; current; current = ownerOf.get(current) || current.parentElement) {
220
+ if (target.contains(current)) {
221
+ return true
222
+ }
223
+ }
224
+ return false
225
+ }
226
+
227
+ // The elements with aria-owns under `root`, in the flat tree the walk itself
228
+ // visits: an owner inside an open shadow root is found, and a light-DOM
229
+ // owner no slot takes is not, since it is never rendered and must not take
230
+ // a rendered element away from its place.
231
+ function collectOwners(element: Element, out: Element[]): void {
232
+ if (element.hasAttribute('aria-owns')) {
233
+ out.push(element)
234
+ }
235
+ const children = flatTreeChildren(element)
236
+ for (let i = 0; i < children.length; i++) {
237
+ const child = children[i]
238
+ if (child.nodeType === ELEMENT_NODE) {
239
+ collectOwners(child as Element, out)
240
+ }
241
+ }
242
+ }
243
+
244
+ /**
245
+ * Records every aria-owns relation whose owner is in the flat tree under
246
+ * `root`, so owned elements can be skipped where they sit and placed under
247
+ * their owner. An element is owned by the first owner in flat-tree order
248
+ * that can take it: a relation that would make the tree circular (owning
249
+ * yourself, an ancestor, or something that already owns you) is dropped, as
250
+ * is one whose owner has presentational children and so no children to own,
251
+ * and an id that resolves to nothing is ignored.
252
+ */
253
+ function recordOwnership(root: Element, context: SnapshotContext): void {
254
+ const owners: Element[] = []
255
+ collectOwners(root, owners)
256
+ const ownerOf = new Map<Element, Element>()
257
+ for (const owner of owners) {
258
+ if (isLeaf(owner, roleOf(owner, context))) {
259
+ continue
260
+ }
261
+ const scope = owner.getRootNode() as Document | ShadowRoot
262
+ const targets: Element[] = []
263
+ for (const id of (owner.getAttribute('aria-owns') || '').trim().split(/\s+/)) {
264
+ const target = id ? scope.getElementById(id) : null
265
+ if (target && !context.claimed.has(target) && !wouldCycle(target, owner, ownerOf)) {
266
+ targets.push(target)
267
+ context.claimed.add(target)
268
+ ownerOf.set(target, owner)
269
+ }
270
+ }
271
+ if (targets.length) {
272
+ context.owned.set(owner, targets)
273
+ }
274
+ }
275
+ }
276
+
277
+ /**
278
+ * The snapshot rooted at `root`. The root always produces a node, whatever
279
+ * its role or hidden state, so a subtree snapshot of a plain div is still
280
+ * deterministic; a root whose subtree is hidden, by itself or by an
281
+ * ancestor, has no children.
282
+ */
283
+ export function buildTree(root: Element, context: SnapshotContext): AccessibilityNode {
284
+ recordOwnership(root, context)
285
+ context.placed.add(root)
286
+ const role = roleOf(root, context)
287
+ const name = computeName(root, context)
288
+ const disabledByAncestor = isDisabledByAncestor(root)
289
+ const node = elementNode(root, role, name.text, context, disabledByAncestor)
290
+ const hidden = hiddenState(root, context)
291
+ const descend =
292
+ hidden !== 'subtree' && hidden !== 'contents' && !isLeaf(root, role) && !isHiddenByAncestor(root, context)
293
+ if (descend) {
294
+ collectChildren(
295
+ root,
296
+ context,
297
+ {
298
+ textHidden: hidden === 'self',
299
+ textConsumed: name.source === 'content',
300
+ disabled: disabledByAncestor || setsAriaDisabled(root),
301
+ },
302
+ node.children,
303
+ )
304
+ }
305
+ return node
306
+ }
@@ -0,0 +1,52 @@
1
+ // Licensed to the Software Freedom Conservancy (SFC) under one
2
+ // or more contributor license agreements. See the NOTICE file
3
+ // distributed with this work for additional information
4
+ // regarding copyright ownership. The SFC licenses this file
5
+ // to you under the Apache License, Version 2.0 (the
6
+ // "License"); you may not use this file except in compliance
7
+ // with the License. You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing,
12
+ // software distributed under the License is distributed on an
13
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ // KIND, either express or implied. See the License for the
15
+ // specific language governing permissions and limitations
16
+ // under the License.
17
+
18
+ // The shape every binding exposes, from docs/decisions/18205-accessibility-tree-snapshot.md §2.
19
+ // Adding an optional field or a `states` key is additive; removing or renaming one is a
20
+ // breaking change that needs a new decision record.
21
+
22
+ export type StateValue = boolean | number | 'mixed'
23
+
24
+ /** What a snapshot leaves out; every option has a default, so `{}` is the default snapshot. */
25
+ export interface SnapshotOptions {
26
+ /**
27
+ * With the default `true`, elements of role generic, none or presentation with
28
+ * no name produce no node and their children take their place (ADR 18205 §2).
29
+ * With `false` every rendered element produces a node, as Puppeteer's
30
+ * `accessibility.snapshot({ interestingOnly: false })` does.
31
+ */
32
+ interestingOnly?: boolean
33
+ }
34
+
35
+ export interface AccessibilityNode {
36
+ /** WAI-ARIA role token; "text" for text leaves, "iframe" for frame leaves. */
37
+ role: string
38
+ /** Computed accessible name; "" when there is none. */
39
+ name: string
40
+ /** Computed accessible description; "" when there is none. */
41
+ description: string
42
+ /** Current value, present only for textbox, combobox, searchbox and range roles. */
43
+ value?: string
44
+ /** The resolved href of a link, present only on role link whose element has one. */
45
+ url?: string
46
+ /** States the role supports or the element sets; {} when there are none. */
47
+ states: Record<string, StateValue>
48
+ /** The backing element; absent for text leaves and synthesized nodes. */
49
+ element?: Element
50
+ /** [] for leaves. */
51
+ children: AccessibilityNode[]
52
+ }
@@ -0,0 +1,89 @@
1
+ // Licensed to the Software Freedom Conservancy (SFC) under one
2
+ // or more contributor license agreements. See the NOTICE file
3
+ // distributed with this work for additional information
4
+ // regarding copyright ownership. The SFC licenses this file
5
+ // to you under the Apache License, Version 2.0 (the
6
+ // "License"); you may not use this file except in compliance
7
+ // with the License. You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing,
12
+ // software distributed under the License is distributed on an
13
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ // KIND, either express or implied. See the License for the
15
+ // specific language governing permissions and limitations
16
+ // under the License.
17
+
18
+ // Values of embedded controls, as accname step 2E reads them when a control
19
+ // sits inside something whose name is being computed. The states slice
20
+ // reuses this for the `value` field.
21
+
22
+ const TEXT_ROLES: ReadonlySet<string> = new Set(['textbox', 'searchbox'])
23
+ const SELECTION_ROLES: ReadonlySet<string> = new Set(['combobox', 'listbox'])
24
+ const RANGE_ROLES: ReadonlySet<string> = new Set(['meter', 'progressbar', 'scrollbar', 'slider', 'spinbutton'])
25
+
26
+ export function isEmbeddedControl(role: string): boolean {
27
+ return TEXT_ROLES.has(role) || SELECTION_ROLES.has(role) || RANGE_ROLES.has(role)
28
+ }
29
+
30
+ function selectedOptionsText(select: HTMLSelectElement): string {
31
+ const texts: string[] = []
32
+ for (let i = 0; i < select.options.length; i++) {
33
+ const option = select.options[i]
34
+ if (option.selected) {
35
+ texts.push(option.label || option.text)
36
+ }
37
+ }
38
+ return texts.join(' ')
39
+ }
40
+
41
+ // What the user sees: innerText follows CSS (display: none, visibility) where
42
+ // textContent would include hidden descendants.
43
+ function renderedText(element: Element): string {
44
+ const text = (element as HTMLElement).innerText
45
+ return typeof text === 'string' ? text : element.textContent || ''
46
+ }
47
+
48
+ // A listbox built from ARIA: its selected options, in document order.
49
+ function selectedAriaOptions(listbox: Element): string {
50
+ const selected = listbox.querySelectorAll('[aria-selected="true"]')
51
+ const texts: string[] = []
52
+ for (let i = 0; i < selected.length; i++) {
53
+ texts.push(renderedText(selected[i]))
54
+ }
55
+ return texts.join(' ')
56
+ }
57
+
58
+ /** The current value of an embedded control, or null when the role has none. */
59
+ export function embeddedValue(element: Element, role: string): string | null {
60
+ if (RANGE_ROLES.has(role)) {
61
+ const text = element.getAttribute('aria-valuetext')
62
+ if (text !== null && text.trim() !== '') {
63
+ return text.trim()
64
+ }
65
+ const now = element.getAttribute('aria-valuenow')
66
+ if (now !== null) {
67
+ return now.trim()
68
+ }
69
+ return 'value' in element ? String((element as HTMLInputElement).value) : null
70
+ }
71
+ if (TEXT_ROLES.has(role) || SELECTION_ROLES.has(role)) {
72
+ if (element.localName === 'select') {
73
+ return selectedOptionsText(element as HTMLSelectElement)
74
+ }
75
+ if ('value' in element && typeof (element as HTMLInputElement).value === 'string') {
76
+ const value = (element as HTMLInputElement).value
77
+ // A password is masked one bullet per character, as Chromium's
78
+ // accessibility tree exposes it: snapshots end up in logs and reports.
79
+ return element.localName === 'input' && (element as HTMLInputElement).type === 'password'
80
+ ? '\u2022'.repeat(value.length)
81
+ : value
82
+ }
83
+ if (role === 'listbox') {
84
+ return selectedAriaOptions(element)
85
+ }
86
+ return renderedText(element)
87
+ }
88
+ return null
89
+ }