@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,123 @@
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 { isElement } from '../element.js'
19
+ import accessibilitySnapshot from './snapshot.js'
20
+ import type { AccessibilityNode, SnapshotOptions, StateValue } from './types.js'
21
+
22
+ /**
23
+ * A node as the language bindings receive it: the same fields as
24
+ * `AccessibilityNode`, with every reference replaced by an index into the
25
+ * arrays that travel beside the JSON text.
26
+ */
27
+ export interface WireNode {
28
+ role: string
29
+ name: string
30
+ description: string
31
+ value?: string
32
+ url?: string
33
+ states: Record<string, StateValue>
34
+ /** Index into `WireSnapshot.elements`; absent for text leaves. */
35
+ element?: number
36
+ /** Index into `WireSnapshot.windows`, on a frame node whose frame has a content window. */
37
+ frame?: number
38
+ children: WireNode[]
39
+ }
40
+
41
+ /**
42
+ * The shape the bindings fetch over WebDriver BiDi. The tree travels as one
43
+ * JSON string, so a binding parses it with its own JSON library instead of
44
+ * decoding a nested remote value; the elements and frame windows travel as
45
+ * plain arrays, which BiDi serializes as node references and browsing context
46
+ * ids in one pass.
47
+ */
48
+ export interface WireSnapshot {
49
+ json: string
50
+ /** Every element the tree references, in order of first mention. */
51
+ elements: Element[]
52
+ /** The content window of every frame node, in order of first mention. */
53
+ windows: Window[]
54
+ }
55
+
56
+ /** The root is an element of this document that is no longer attached to it. */
57
+ export interface WireError {
58
+ error: 'detached'
59
+ }
60
+
61
+ interface Encoded {
62
+ node: WireNode
63
+ elements: Element[]
64
+ windows: Window[]
65
+ }
66
+
67
+ /** Replaces the references in a tree with indices; pure, so it is unit tested without a DOM. */
68
+ export function encodeWire(tree: AccessibilityNode): Encoded {
69
+ const elements: Element[] = []
70
+ const windows: Window[] = []
71
+
72
+ function encode(node: AccessibilityNode): WireNode {
73
+ const out: WireNode = { role: node.role, name: node.name, description: node.description, states: node.states, children: [] }
74
+ if (node.value !== undefined) {
75
+ out.value = node.value
76
+ }
77
+ if (node.url !== undefined) {
78
+ out.url = node.url
79
+ }
80
+ if (node.element) {
81
+ out.element = elements.push(node.element) - 1
82
+ const window = node.role === 'iframe' ? (node.element as HTMLIFrameElement).contentWindow : null
83
+ if (window) {
84
+ out.frame = windows.push(window) - 1
85
+ }
86
+ }
87
+ out.children = node.children.map(encode)
88
+ return out
89
+ }
90
+
91
+ return { node: encode(tree), elements, windows }
92
+ }
93
+
94
+ /**
95
+ * The snapshot of this document (no `root`), or of the subtree under `root`,
96
+ * in the wire shape. Answers `null` for a root this document does not own,
97
+ * so a binding tries each document until one answers: Firefox hands a shared
98
+ * id of another document's node to the called function as `null`, and may
99
+ * resolve one to the node itself in any document of the browsing context
100
+ * group, which the ownership check catches. Answers `{ error: 'detached' }`
101
+ * for a root no longer in its document, so a binding never has to read an
102
+ * exception's text.
103
+ */
104
+ function accessibilitySnapshotWire(root?: Element | null, options?: SnapshotOptions): WireSnapshot | WireError | null {
105
+ if (root === null) {
106
+ return null
107
+ }
108
+ if (root !== undefined) {
109
+ if (!isElement(root)) {
110
+ throw new Error('accessibilitySnapshotWire: root must be an Element')
111
+ }
112
+ if (root.ownerDocument !== document) {
113
+ return null
114
+ }
115
+ if (!root.isConnected) {
116
+ return { error: 'detached' }
117
+ }
118
+ }
119
+ const { node, elements, windows } = encodeWire(accessibilitySnapshot(root, options))
120
+ return { json: JSON.stringify(node), elements, windows }
121
+ }
122
+
123
+ export default accessibilitySnapshotWire
@@ -0,0 +1,68 @@
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
+ // Raw attribute and property access, ported from bot.dom.core (domcore.js).
19
+ //
20
+ // This is *not* the WebDriver getAttribute algorithm — that one consults
21
+ // properties, boolean-attribute tables and aliases, and lives in
22
+ // get-attribute.ts. This returns what the author actually wrote in the markup.
23
+ //
24
+ // The IE-only branches in the Closure original (IE_DOC_PRE8's <input value>,
25
+ // IE_DOC_PRE9's boolean attributes, the <option value> text fallback) are
26
+ // dropped, matching every other TypeScript atom in this directory.
27
+
28
+ // Splits on semicolons that are not inside quotes or parens, so a value like
29
+ // `background: url(a;b)` or `content: ";"` survives intact. If the attribute
30
+ // ends in a semicolon the split yields a trailing empty entry, which the
31
+ // caller skips.
32
+ const SPLIT_STYLE_ATTRIBUTE_ON_SEMICOLONS = new RegExp(
33
+ '[;]+' +
34
+ '(?=(?:(?:[^"]*"){2})*[^"]*$)' +
35
+ "(?=(?:(?:[^']*'){2})*[^']*$)" +
36
+ '(?=(?:[^()]*\\([^()]*\\))*[^()]*$)',
37
+ )
38
+
39
+ // Lower-cases property names and guarantees a trailing semicolon, so the same
40
+ // style attribute reads identically no matter how the browser serialised it.
41
+ function standardizeStyleAttribute(value: string): string {
42
+ const declarations: string[] = []
43
+ for (const pair of value.split(SPLIT_STYLE_ATTRIBUTE_ON_SEMICOLONS)) {
44
+ const separator = pair.indexOf(':')
45
+ if (separator > 0) {
46
+ declarations.push(pair.slice(0, separator).toLowerCase(), ':', pair.slice(separator + 1), ';')
47
+ }
48
+ }
49
+ const css = declarations.join('')
50
+ return css.charAt(css.length - 1) === ';' ? css : css + ';'
51
+ }
52
+
53
+ export function getAttribute(element: Element, attributeName: string): string | null {
54
+ const name = attributeName.toLowerCase()
55
+
56
+ if (name === 'style') {
57
+ return standardizeStyleAttribute((element as HTMLElement).style.cssText)
58
+ }
59
+
60
+ // `specified` distinguishes an attribute the author wrote from one the
61
+ // browser defaulted in.
62
+ const attr = element.getAttributeNode(name)
63
+ return attr && attr.specified ? attr.value : null
64
+ }
65
+
66
+ export function getProperty(element: Element, propertyName: string): unknown {
67
+ return (element as unknown as Record<string, unknown>)[propertyName]
68
+ }
@@ -0,0 +1,257 @@
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
+ // Ported from bot.color (javascript/atoms/color.js), which normalises every
19
+ // colour-valued CSS property to "rgba(r, g, b, a)". Bindings and user tests
20
+ // have asserted against that exact spelling for years -- getComputedStyle on
21
+ // its own returns "rgb(...)" when alpha is 1 -- so the normalisation is part
22
+ // of the contract, not a tidy-up.
23
+
24
+ // The CSS2 extended colour keywords, from goog.color.names. getComputedStyle
25
+ // resolves keywords to rgb() itself, so this table is only reached through the
26
+ // cascaded-style fallback, where a keyword can still surface.
27
+ const COLOR_NAMES: Record<string, string> = {
28
+ aliceblue: '#f0f8ff',
29
+ antiquewhite: '#faebd7',
30
+ aqua: '#00ffff',
31
+ aquamarine: '#7fffd4',
32
+ azure: '#f0ffff',
33
+ beige: '#f5f5dc',
34
+ bisque: '#ffe4c4',
35
+ black: '#000000',
36
+ blanchedalmond: '#ffebcd',
37
+ blue: '#0000ff',
38
+ blueviolet: '#8a2be2',
39
+ brown: '#a52a2a',
40
+ burlywood: '#deb887',
41
+ cadetblue: '#5f9ea0',
42
+ chartreuse: '#7fff00',
43
+ chocolate: '#d2691e',
44
+ coral: '#ff7f50',
45
+ cornflowerblue: '#6495ed',
46
+ cornsilk: '#fff8dc',
47
+ crimson: '#dc143c',
48
+ cyan: '#00ffff',
49
+ darkblue: '#00008b',
50
+ darkcyan: '#008b8b',
51
+ darkgoldenrod: '#b8860b',
52
+ darkgray: '#a9a9a9',
53
+ darkgreen: '#006400',
54
+ darkgrey: '#a9a9a9',
55
+ darkkhaki: '#bdb76b',
56
+ darkmagenta: '#8b008b',
57
+ darkolivegreen: '#556b2f',
58
+ darkorange: '#ff8c00',
59
+ darkorchid: '#9932cc',
60
+ darkred: '#8b0000',
61
+ darksalmon: '#e9967a',
62
+ darkseagreen: '#8fbc8f',
63
+ darkslateblue: '#483d8b',
64
+ darkslategray: '#2f4f4f',
65
+ darkslategrey: '#2f4f4f',
66
+ darkturquoise: '#00ced1',
67
+ darkviolet: '#9400d3',
68
+ deeppink: '#ff1493',
69
+ deepskyblue: '#00bfff',
70
+ dimgray: '#696969',
71
+ dimgrey: '#696969',
72
+ dodgerblue: '#1e90ff',
73
+ firebrick: '#b22222',
74
+ floralwhite: '#fffaf0',
75
+ forestgreen: '#228b22',
76
+ fuchsia: '#ff00ff',
77
+ gainsboro: '#dcdcdc',
78
+ ghostwhite: '#f8f8ff',
79
+ gold: '#ffd700',
80
+ goldenrod: '#daa520',
81
+ gray: '#808080',
82
+ green: '#008000',
83
+ greenyellow: '#adff2f',
84
+ grey: '#808080',
85
+ honeydew: '#f0fff0',
86
+ hotpink: '#ff69b4',
87
+ indianred: '#cd5c5c',
88
+ indigo: '#4b0082',
89
+ ivory: '#fffff0',
90
+ khaki: '#f0e68c',
91
+ lavender: '#e6e6fa',
92
+ lavenderblush: '#fff0f5',
93
+ lawngreen: '#7cfc00',
94
+ lemonchiffon: '#fffacd',
95
+ lightblue: '#add8e6',
96
+ lightcoral: '#f08080',
97
+ lightcyan: '#e0ffff',
98
+ lightgoldenrodyellow: '#fafad2',
99
+ lightgray: '#d3d3d3',
100
+ lightgreen: '#90ee90',
101
+ lightgrey: '#d3d3d3',
102
+ lightpink: '#ffb6c1',
103
+ lightsalmon: '#ffa07a',
104
+ lightseagreen: '#20b2aa',
105
+ lightskyblue: '#87cefa',
106
+ lightslategray: '#778899',
107
+ lightslategrey: '#778899',
108
+ lightsteelblue: '#b0c4de',
109
+ lightyellow: '#ffffe0',
110
+ lime: '#00ff00',
111
+ limegreen: '#32cd32',
112
+ linen: '#faf0e6',
113
+ magenta: '#ff00ff',
114
+ maroon: '#800000',
115
+ mediumaquamarine: '#66cdaa',
116
+ mediumblue: '#0000cd',
117
+ mediumorchid: '#ba55d3',
118
+ mediumpurple: '#9370db',
119
+ mediumseagreen: '#3cb371',
120
+ mediumslateblue: '#7b68ee',
121
+ mediumspringgreen: '#00fa9a',
122
+ mediumturquoise: '#48d1cc',
123
+ mediumvioletred: '#c71585',
124
+ midnightblue: '#191970',
125
+ mintcream: '#f5fffa',
126
+ mistyrose: '#ffe4e1',
127
+ moccasin: '#ffe4b5',
128
+ navajowhite: '#ffdead',
129
+ navy: '#000080',
130
+ oldlace: '#fdf5e6',
131
+ olive: '#808000',
132
+ olivedrab: '#6b8e23',
133
+ orange: '#ffa500',
134
+ orangered: '#ff4500',
135
+ orchid: '#da70d6',
136
+ palegoldenrod: '#eee8aa',
137
+ palegreen: '#98fb98',
138
+ paleturquoise: '#afeeee',
139
+ palevioletred: '#db7093',
140
+ papayawhip: '#ffefd5',
141
+ peachpuff: '#ffdab9',
142
+ peru: '#cd853f',
143
+ pink: '#ffc0cb',
144
+ plum: '#dda0dd',
145
+ powderblue: '#b0e0e6',
146
+ purple: '#800080',
147
+ red: '#ff0000',
148
+ rosybrown: '#bc8f8f',
149
+ royalblue: '#4169e1',
150
+ saddlebrown: '#8b4513',
151
+ salmon: '#fa8072',
152
+ sandybrown: '#f4a460',
153
+ seagreen: '#2e8b57',
154
+ seashell: '#fff5ee',
155
+ sienna: '#a0522d',
156
+ silver: '#c0c0c0',
157
+ skyblue: '#87ceeb',
158
+ slateblue: '#6a5acd',
159
+ slategray: '#708090',
160
+ slategrey: '#708090',
161
+ snow: '#fffafa',
162
+ springgreen: '#00ff7f',
163
+ steelblue: '#4682b4',
164
+ tan: '#d2b48c',
165
+ teal: '#008080',
166
+ thistle: '#d8bfd8',
167
+ tomato: '#ff6347',
168
+ turquoise: '#40e0d0',
169
+ violet: '#ee82ee',
170
+ wheat: '#f5deb3',
171
+ white: '#ffffff',
172
+ whitesmoke: '#f5f5f5',
173
+ yellow: '#ffff00',
174
+ yellowgreen: '#9acd32',
175
+ }
176
+
177
+ // Only these properties are standardised. A colour-looking value on any other
178
+ // property is returned untouched.
179
+ const COLOR_PROPERTIES = [
180
+ 'backgroundColor',
181
+ 'borderTopColor',
182
+ 'borderRightColor',
183
+ 'borderBottomColor',
184
+ 'borderLeftColor',
185
+ 'color',
186
+ 'outlineColor',
187
+ ]
188
+
189
+ // Components are captured separately rather than with a repeater, and each is
190
+ // pinned to either 0 or a non-zero leading digit, so octal literals cannot slip
191
+ // through.
192
+ const RGBA_COLOR_RE = /^(?:rgba)?\((\d{1,3}),\s?(\d{1,3}),\s?(\d{1,3}),\s?(0|1|0\.\d*)\)$/i
193
+ const RGB_COLOR_RE = /^(?:rgb)?\((0|[1-9]\d{0,2}),\s?(0|[1-9]\d{0,2}),\s?(0|[1-9]\d{0,2})\)$/i
194
+ const HEX_TRIPLET_RE = /#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/
195
+ const VALID_HEX_COLOR_RE = /^#(?:[0-9a-f]{3}){1,2}$/i
196
+
197
+ type Rgba = [number, number, number, number];
198
+
199
+ function maybeParseRgbaColor(value: string): Rgba | null {
200
+ const match = value.match(RGBA_COLOR_RE)
201
+ if (!match) {
202
+ return null
203
+ }
204
+ const r = Number(match[1])
205
+ const g = Number(match[2])
206
+ const b = Number(match[3])
207
+ const a = Number(match[4])
208
+ if (r >= 0 && r <= 255 && g >= 0 && g <= 255 && b >= 0 && b <= 255 && a >= 0 && a <= 1) {
209
+ return [r, g, b, a]
210
+ }
211
+ return null
212
+ }
213
+
214
+ function maybeParseRgbColor(value: string): Rgba | null {
215
+ const match = value.match(RGB_COLOR_RE)
216
+ if (!match) {
217
+ return null
218
+ }
219
+ const r = Number(match[1])
220
+ const g = Number(match[2])
221
+ const b = Number(match[3])
222
+ if (r >= 0 && r <= 255 && g >= 0 && g <= 255 && b >= 0 && b <= 255) {
223
+ return [r, g, b, 1]
224
+ }
225
+ return null
226
+ }
227
+
228
+ function maybeConvertHexOrColorName(value: string): Rgba | null {
229
+ const lowered = value.toLowerCase()
230
+ let hex = COLOR_NAMES[lowered]
231
+ if (!hex) {
232
+ hex = lowered.charAt(0) === '#' ? lowered : '#' + lowered
233
+ if (hex.length === 4) {
234
+ // #RGB -> #RRGGBB
235
+ hex = hex.replace(HEX_TRIPLET_RE, '#$1$1$2$2$3$3')
236
+ }
237
+ if (!VALID_HEX_COLOR_RE.test(hex)) {
238
+ return null
239
+ }
240
+ }
241
+ return [
242
+ parseInt(hex.substr(1, 2), 16),
243
+ parseInt(hex.substr(3, 2), 16),
244
+ parseInt(hex.substr(5, 2), 16),
245
+ 1,
246
+ ]
247
+ }
248
+
249
+ export function standardizeColor(propertyName: string, propertyValue: string): string {
250
+ if (COLOR_PROPERTIES.indexOf(propertyName) < 0) {
251
+ return propertyValue
252
+ }
253
+ const rgba = maybeParseRgbaColor(propertyValue) ||
254
+ maybeParseRgbColor(propertyValue) ||
255
+ maybeConvertHexOrColorName(propertyValue)
256
+ return rgba ? 'rgba(' + rgba.join(', ') + ')' : propertyValue
257
+ }
@@ -0,0 +1,63 @@
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 { getProperty } from './attribute.js'
19
+ import { isElement } from './element.js'
20
+
21
+ // <input> types that present a free-text field.
22
+ const TEXTUAL_INPUT_TYPES = ['text', 'search', 'tel', 'url', 'email', 'password', 'number']
23
+
24
+ // Typeable <input> types that are not free text — each is a distinct control,
25
+ // but the user can still put a value into it.
26
+ const NON_TEXTUAL_EDITABLE_INPUT_TYPES = ['range', 'date', 'month', 'week', 'time', 'datetime-local', 'color']
27
+
28
+ function inputType(element: Element): string | null {
29
+ if (!isElement(element, 'INPUT')) {
30
+ return null
31
+ }
32
+ return (element as HTMLInputElement).type.toLowerCase()
33
+ }
34
+
35
+ export function isContentEditable(element: Element): boolean {
36
+ // Non-HTML elements (SVG, MathML) have no contentEditable at all.
37
+ if ((element as HTMLElement).contentEditable === undefined) {
38
+ return false
39
+ }
40
+ return !!(element as HTMLElement).isContentEditable
41
+ }
42
+
43
+ export function isTextual(element: Element): boolean {
44
+ if (isElement(element, 'TEXTAREA')) {
45
+ return true
46
+ }
47
+ const type = inputType(element)
48
+ if (type !== null) {
49
+ return TEXTUAL_INPUT_TYPES.indexOf(type) >= 0
50
+ }
51
+ return isContentEditable(element)
52
+ }
53
+
54
+ export function isFileInput(element: Element): boolean {
55
+ return inputType(element) === 'file'
56
+ }
57
+
58
+ export function isEditable(element: Element): boolean {
59
+ const type = inputType(element)
60
+ const typeable =
61
+ isTextual(element) || isFileInput(element) || (type !== null && NON_TEXTUAL_EDITABLE_INPUT_TYPES.indexOf(type) >= 0)
62
+ return typeable && !getProperty(element, 'readOnly')
63
+ }
@@ -0,0 +1,110 @@
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
+ // Element primitives shared by the atoms. The bodies here were lifted verbatim
19
+ // from is-displayed.ts so the move stays reviewable as a move.
20
+ //
21
+ // Note what is deliberately *not* here: the style, client-rect and displayed
22
+ // helpers from the same file close over caches that is-displayed.ts builds
23
+ // fresh on every call, precisely so a long-running page cannot read stale
24
+ // layout back. Hoisting those to module scope would turn a per-call memo into
25
+ // a process-lifetime one and silently reintroduce that bug, so they stay where
26
+ // their caches live.
27
+
28
+ import { getProperty } from './attribute.js'
29
+
30
+ // Guards against form children that shadow tagName (e.g. <form><input name="tagName">).
31
+ // Element.prototype's descriptor never changes, so it is read once -- but on
32
+ // first use, not at module load: Node consumers load the atoms where there is
33
+ // no Element at all (see load-in-node.mjs).
34
+ let tagNameDescriptor: PropertyDescriptor | undefined | null = null;
35
+
36
+ function getTagNameDescriptor(): PropertyDescriptor | undefined {
37
+ if (tagNameDescriptor === null) {
38
+ tagNameDescriptor = Object.getOwnPropertyDescriptor(Element.prototype, 'tagName');
39
+ }
40
+ return tagNameDescriptor;
41
+ }
42
+
43
+ function toUpperCaseTag(tagName?: string): string | undefined {
44
+ return tagName ? tagName.toUpperCase() : undefined;
45
+ }
46
+
47
+ export function isElement(node: unknown, tagName?: string): node is Element {
48
+ // Use nodeType instead of instanceof to handle cross-realm Elements
49
+ // (e.g., from iframes), where instanceof checks against a different Element.
50
+ if (!node || (node as Node).nodeType !== 1 /* ELEMENT_NODE */) {
51
+ return false;
52
+ }
53
+ var asElement = node as Element;
54
+ var descriptor = getTagNameDescriptor();
55
+ var rawTagName = descriptor && typeof descriptor.get === 'function'
56
+ ? descriptor.get.call(asElement)
57
+ : asElement.tagName;
58
+ var upperTagName = typeof rawTagName === 'string' ? rawTagName.toUpperCase() : '';
59
+ var normalizedTagName = toUpperCaseTag(tagName);
60
+ if (upperTagName === 'FORM') {
61
+ return !normalizedTagName || normalizedTagName === 'FORM';
62
+ }
63
+ return !!upperTagName && (!normalizedTagName || upperTagName === normalizedTagName);
64
+ }
65
+
66
+ export function getParentElement(node: Node): Element | null {
67
+ var current = node.parentNode;
68
+ while (
69
+ current &&
70
+ current.nodeType !== Node.ELEMENT_NODE &&
71
+ current.nodeType !== Node.DOCUMENT_NODE &&
72
+ current.nodeType !== Node.DOCUMENT_FRAGMENT_NODE
73
+ ) {
74
+ current = current.parentNode;
75
+ }
76
+ return current && current.nodeType === 1 /* ELEMENT_NODE */ ? (current as Element) : null;
77
+ }
78
+
79
+ export function isSelectable(element: Element): boolean {
80
+ if (isElement(element, 'OPTION')) {
81
+ return true
82
+ }
83
+ if (isElement(element, 'INPUT')) {
84
+ const type = (element as HTMLInputElement).type.toLowerCase()
85
+ return type === 'checkbox' || type === 'radio'
86
+ }
87
+ return false
88
+ }
89
+
90
+ // Reads the selected/checked state. Callers are responsible for checking
91
+ // isSelectable first — the Closure bot.dom.core.isSelected threw for anything
92
+ // else, but the atom Appium consumes returns false instead, so the decision
93
+ // belongs to the caller rather than here.
94
+ export function isSelectedState(element: Element): boolean {
95
+ const type = (element as HTMLInputElement).type && (element as HTMLInputElement).type.toLowerCase()
96
+ const propertyName = type === 'checkbox' || type === 'radio' ? 'checked' : 'selected'
97
+ return !!getProperty(element, propertyName)
98
+ }
99
+
100
+ export function getParentNodeInComposedDom(node: Node): Node | null {
101
+ var parent = node.parentNode;
102
+ var slottable = node as Node & { assignedSlot?: HTMLSlotElement | null };
103
+ var parentWithShadow = parent as (Node & { shadowRoot?: ShadowRoot | null }) | null;
104
+
105
+ if (parentWithShadow && parentWithShadow.shadowRoot && slottable.assignedSlot !== undefined) {
106
+ return slottable.assignedSlot ? slottable.assignedSlot.parentNode : null;
107
+ }
108
+
109
+ return parent;
110
+ }