@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.
- package/README.md +56 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -1
- package/dist/typescript/accessibility-snapshot-wire.d.ts +4 -0
- package/dist/typescript/accessibility-snapshot-wire.d.ts.map +1 -0
- package/dist/typescript/accessibility-snapshot-wire.js +18 -0
- package/dist/typescript/accessibility-snapshot-wire.js.map +1 -0
- package/dist/typescript/accessibility-snapshot.d.ts +3 -0
- package/dist/typescript/accessibility-snapshot.d.ts.map +1 -0
- package/dist/typescript/accessibility-snapshot.js +18 -0
- package/dist/typescript/accessibility-snapshot.js.map +1 -0
- package/dist/typescript/active-element.d.ts +2 -0
- package/dist/typescript/active-element.d.ts.map +1 -0
- package/dist/typescript/active-element.js +19 -0
- package/dist/typescript/active-element.js.map +1 -0
- package/dist/typescript/clear-local-storage.d.ts +3 -0
- package/dist/typescript/clear-local-storage.d.ts.map +1 -0
- package/dist/typescript/clear-local-storage.js +25 -0
- package/dist/typescript/clear-local-storage.js.map +1 -0
- package/dist/typescript/clear-session-storage.d.ts +3 -0
- package/dist/typescript/clear-session-storage.d.ts.map +1 -0
- package/dist/typescript/clear-session-storage.js +25 -0
- package/dist/typescript/clear-session-storage.js.map +1 -0
- package/dist/typescript/clear.d.ts +3 -0
- package/dist/typescript/clear.d.ts.map +1 -0
- package/dist/typescript/clear.js +67 -0
- package/dist/typescript/clear.js.map +1 -0
- package/dist/typescript/click.d.ts +4 -0
- package/dist/typescript/click.d.ts.map +1 -0
- package/dist/typescript/click.js +52 -0
- package/dist/typescript/click.js.map +1 -0
- package/dist/typescript/core/accessibility/accname.d.ts +6 -0
- package/dist/typescript/core/accessibility/accname.d.ts.map +1 -0
- package/dist/typescript/core/accessibility/accname.js +537 -0
- package/dist/typescript/core/accessibility/accname.js.map +1 -0
- package/dist/typescript/core/accessibility/context.d.ts +43 -0
- package/dist/typescript/core/accessibility/context.d.ts.map +1 -0
- package/dist/typescript/core/accessibility/context.js +49 -0
- package/dist/typescript/core/accessibility/context.js.map +1 -0
- package/dist/typescript/core/accessibility/hidden.d.ts +39 -0
- package/dist/typescript/core/accessibility/hidden.d.ts.map +1 -0
- package/dist/typescript/core/accessibility/hidden.js +216 -0
- package/dist/typescript/core/accessibility/hidden.js.map +1 -0
- package/dist/typescript/core/accessibility/roles.d.ts +28 -0
- package/dist/typescript/core/accessibility/roles.d.ts.map +1 -0
- package/dist/typescript/core/accessibility/roles.js +381 -0
- package/dist/typescript/core/accessibility/roles.js.map +1 -0
- package/dist/typescript/core/accessibility/snapshot.d.ts +13 -0
- package/dist/typescript/core/accessibility/snapshot.d.ts.map +1 -0
- package/dist/typescript/core/accessibility/snapshot.js +55 -0
- package/dist/typescript/core/accessibility/snapshot.js.map +1 -0
- package/dist/typescript/core/accessibility/states.d.ts +18 -0
- package/dist/typescript/core/accessibility/states.d.ts.map +1 -0
- package/dist/typescript/core/accessibility/states.js +215 -0
- package/dist/typescript/core/accessibility/states.js.map +1 -0
- package/dist/typescript/core/accessibility/tree.d.ts +10 -0
- package/dist/typescript/core/accessibility/tree.d.ts.map +1 -0
- package/dist/typescript/core/accessibility/tree.js +261 -0
- package/dist/typescript/core/accessibility/tree.js.map +1 -0
- package/dist/typescript/core/accessibility/types.d.ts +30 -0
- package/dist/typescript/core/accessibility/types.d.ts.map +1 -0
- package/dist/typescript/core/accessibility/types.js +18 -0
- package/dist/typescript/core/accessibility/types.js.map +1 -0
- package/dist/typescript/core/accessibility/value.d.ts +4 -0
- package/dist/typescript/core/accessibility/value.d.ts.map +1 -0
- package/dist/typescript/core/accessibility/value.js +83 -0
- package/dist/typescript/core/accessibility/value.js.map +1 -0
- package/dist/typescript/core/accessibility/wire.d.ts +57 -0
- package/dist/typescript/core/accessibility/wire.d.ts.map +1 -0
- package/dist/typescript/core/accessibility/wire.js +72 -0
- package/dist/typescript/core/accessibility/wire.js.map +1 -0
- package/dist/typescript/core/attribute.d.ts +3 -0
- package/dist/typescript/core/attribute.d.ts.map +1 -0
- package/dist/typescript/core/attribute.js +60 -0
- package/dist/typescript/core/attribute.js.map +1 -0
- package/dist/typescript/core/color.d.ts +2 -0
- package/dist/typescript/core/color.d.ts.map +1 -0
- package/dist/typescript/core/color.js +248 -0
- package/dist/typescript/core/color.js.map +1 -0
- package/dist/typescript/core/editable.d.ts +5 -0
- package/dist/typescript/core/editable.d.ts.map +1 -0
- package/dist/typescript/core/editable.js +55 -0
- package/dist/typescript/core/editable.js.map +1 -0
- package/dist/typescript/core/element.d.ts +6 -0
- package/dist/typescript/core/element.d.ts.map +1 -0
- package/dist/typescript/core/element.js +97 -0
- package/dist/typescript/core/element.js.map +1 -0
- package/dist/typescript/core/enabled.d.ts +2 -0
- package/dist/typescript/core/enabled.d.ts.map +1 -0
- package/dist/typescript/core/enabled.js +69 -0
- package/dist/typescript/core/enabled.js.map +1 -0
- package/dist/typescript/core/error.d.ts +13 -0
- package/dist/typescript/core/error.d.ts.map +1 -0
- package/dist/typescript/core/error.js +40 -0
- package/dist/typescript/core/error.js.map +1 -0
- package/dist/typescript/core/events.d.ts +91 -0
- package/dist/typescript/core/events.d.ts.map +1 -0
- package/dist/typescript/core/events.js +131 -0
- package/dist/typescript/core/events.js.map +1 -0
- package/dist/typescript/core/focus.d.ts +4 -0
- package/dist/typescript/core/focus.d.ts.map +1 -0
- package/dist/typescript/core/focus.js +88 -0
- package/dist/typescript/core/focus.js.map +1 -0
- package/dist/typescript/core/focusable.d.ts +2 -0
- package/dist/typescript/core/focusable.d.ts.map +1 -0
- package/dist/typescript/core/focusable.js +36 -0
- package/dist/typescript/core/focusable.js.map +1 -0
- package/dist/typescript/core/form.d.ts +2 -0
- package/dist/typescript/core/form.d.ts.map +1 -0
- package/dist/typescript/core/form.js +76 -0
- package/dist/typescript/core/form.js.map +1 -0
- package/dist/typescript/core/frame.d.ts +8 -0
- package/dist/typescript/core/frame.d.ts.map +1 -0
- package/dist/typescript/core/frame.js +95 -0
- package/dist/typescript/core/frame.js.map +1 -0
- package/dist/typescript/core/geometry.d.ts +28 -0
- package/dist/typescript/core/geometry.d.ts.map +1 -0
- package/dist/typescript/core/geometry.js +134 -0
- package/dist/typescript/core/geometry.js.map +1 -0
- package/dist/typescript/core/inject.d.ts +21 -0
- package/dist/typescript/core/inject.d.ts.map +1 -0
- package/dist/typescript/core/inject.js +282 -0
- package/dist/typescript/core/inject.js.map +1 -0
- package/dist/typescript/core/interactable.d.ts +2 -0
- package/dist/typescript/core/interactable.d.ts.map +1 -0
- package/dist/typescript/core/interactable.js +27 -0
- package/dist/typescript/core/interactable.js.map +1 -0
- package/dist/typescript/core/keyboard.d.ts +15 -0
- package/dist/typescript/core/keyboard.d.ts.map +1 -0
- package/dist/typescript/core/keyboard.js +356 -0
- package/dist/typescript/core/keyboard.js.map +1 -0
- package/dist/typescript/core/keys.d.ts +65 -0
- package/dist/typescript/core/keys.d.ts.map +1 -0
- package/dist/typescript/core/keys.js +125 -0
- package/dist/typescript/core/keys.js.map +1 -0
- package/dist/typescript/core/locators.d.ts +6 -0
- package/dist/typescript/core/locators.d.ts.map +1 -0
- package/dist/typescript/core/locators.js +610 -0
- package/dist/typescript/core/locators.js.map +1 -0
- package/dist/typescript/core/mouse.d.ts +17 -0
- package/dist/typescript/core/mouse.d.ts.map +1 -0
- package/dist/typescript/core/mouse.js +186 -0
- package/dist/typescript/core/mouse.js.map +1 -0
- package/dist/typescript/core/overflow.d.ts +5 -0
- package/dist/typescript/core/overflow.d.ts.map +1 -0
- package/dist/typescript/core/overflow.js +133 -0
- package/dist/typescript/core/overflow.js.map +1 -0
- package/dist/typescript/core/scroll.d.ts +3 -0
- package/dist/typescript/core/scroll.d.ts.map +1 -0
- package/dist/typescript/core/scroll.js +77 -0
- package/dist/typescript/core/scroll.js.map +1 -0
- package/dist/typescript/core/shown.d.ts +3 -0
- package/dist/typescript/core/shown.d.ts.map +1 -0
- package/dist/typescript/core/shown.js +190 -0
- package/dist/typescript/core/shown.js.map +1 -0
- package/dist/typescript/core/storage.d.ts +14 -0
- package/dist/typescript/core/storage.d.ts.map +1 -0
- package/dist/typescript/core/storage.js +98 -0
- package/dist/typescript/core/storage.js.map +1 -0
- package/dist/typescript/core/style.d.ts +2 -0
- package/dist/typescript/core/style.d.ts.map +1 -0
- package/dist/typescript/core/style.js +32 -0
- package/dist/typescript/core/style.js.map +1 -0
- package/dist/typescript/core/useragent.d.ts +3 -0
- package/dist/typescript/core/useragent.d.ts.map +1 -0
- package/dist/typescript/core/useragent.js +31 -0
- package/dist/typescript/core/useragent.js.map +1 -0
- package/dist/typescript/default-content.d.ts +2 -0
- package/dist/typescript/default-content.d.ts.map +1 -0
- package/dist/typescript/default-content.js +20 -0
- package/dist/typescript/default-content.js.map +1 -0
- package/dist/typescript/execute-async-script.d.ts +2 -0
- package/dist/typescript/execute-async-script.d.ts.map +1 -0
- package/dist/typescript/execute-async-script.js +20 -0
- package/dist/typescript/execute-async-script.js.map +1 -0
- package/dist/typescript/execute-script.d.ts +2 -0
- package/dist/typescript/execute-script.d.ts.map +1 -0
- package/dist/typescript/execute-script.js +20 -0
- package/dist/typescript/execute-script.js.map +1 -0
- package/dist/typescript/find-element-fragment.d.ts +8 -0
- package/dist/typescript/find-element-fragment.d.ts.map +1 -0
- package/dist/typescript/find-element-fragment.js +39 -0
- package/dist/typescript/find-element-fragment.js.map +1 -0
- package/dist/typescript/find-element.d.ts +2 -0
- package/dist/typescript/find-element.d.ts.map +1 -0
- package/dist/typescript/find-element.js +18 -0
- package/dist/typescript/find-element.js.map +1 -0
- package/dist/typescript/find-elements.d.ts +1 -2
- package/dist/typescript/find-elements.d.ts.map +1 -1
- package/dist/typescript/find-elements.js +1 -289
- package/dist/typescript/find-elements.js.map +1 -1
- package/dist/typescript/frame-by-id-or-name.d.ts +2 -0
- package/dist/typescript/frame-by-id-or-name.d.ts.map +1 -0
- package/dist/typescript/frame-by-id-or-name.js +22 -0
- package/dist/typescript/frame-by-id-or-name.js.map +1 -0
- package/dist/typescript/frame-by-index.d.ts +2 -0
- package/dist/typescript/frame-by-index.d.ts.map +1 -0
- package/dist/typescript/frame-by-index.js +19 -0
- package/dist/typescript/frame-by-index.js.map +1 -0
- package/dist/typescript/get-attribute-value.d.ts +2 -0
- package/dist/typescript/get-attribute-value.d.ts.map +1 -0
- package/dist/typescript/get-attribute-value.js +22 -0
- package/dist/typescript/get-attribute-value.js.map +1 -0
- package/dist/typescript/get-effective-style.d.ts +3 -0
- package/dist/typescript/get-effective-style.d.ts.map +1 -0
- package/dist/typescript/get-effective-style.js +84 -0
- package/dist/typescript/get-effective-style.js.map +1 -0
- package/dist/typescript/get-element-from-cache.d.ts +2 -0
- package/dist/typescript/get-element-from-cache.d.ts.map +1 -0
- package/dist/typescript/get-element-from-cache.js +20 -0
- package/dist/typescript/get-element-from-cache.js.map +1 -0
- package/dist/typescript/get-frame-window.d.ts +2 -0
- package/dist/typescript/get-frame-window.d.ts.map +1 -0
- package/dist/typescript/get-frame-window.js +22 -0
- package/dist/typescript/get-frame-window.js.map +1 -0
- package/dist/typescript/get-local-storage-item.d.ts +3 -0
- package/dist/typescript/get-local-storage-item.d.ts.map +1 -0
- package/dist/typescript/get-local-storage-item.js +25 -0
- package/dist/typescript/get-local-storage-item.js.map +1 -0
- package/dist/typescript/get-local-storage-key.d.ts +3 -0
- package/dist/typescript/get-local-storage-key.d.ts.map +1 -0
- package/dist/typescript/get-local-storage-key.js +26 -0
- package/dist/typescript/get-local-storage-key.js.map +1 -0
- package/dist/typescript/get-local-storage-keys.d.ts +3 -0
- package/dist/typescript/get-local-storage-keys.d.ts.map +1 -0
- package/dist/typescript/get-local-storage-keys.js +25 -0
- package/dist/typescript/get-local-storage-keys.js.map +1 -0
- package/dist/typescript/get-local-storage-size.d.ts +3 -0
- package/dist/typescript/get-local-storage-size.d.ts.map +1 -0
- package/dist/typescript/get-local-storage-size.js +25 -0
- package/dist/typescript/get-local-storage-size.js.map +1 -0
- package/dist/typescript/get-location.d.ts +9 -0
- package/dist/typescript/get-location.d.ts.map +1 -0
- package/dist/typescript/get-location.js +49 -0
- package/dist/typescript/get-location.js.map +1 -0
- package/dist/typescript/get-session-storage-item.d.ts +3 -0
- package/dist/typescript/get-session-storage-item.d.ts.map +1 -0
- package/dist/typescript/get-session-storage-item.js +25 -0
- package/dist/typescript/get-session-storage-item.js.map +1 -0
- package/dist/typescript/get-session-storage-key.d.ts +3 -0
- package/dist/typescript/get-session-storage-key.d.ts.map +1 -0
- package/dist/typescript/get-session-storage-key.js +26 -0
- package/dist/typescript/get-session-storage-key.js.map +1 -0
- package/dist/typescript/get-session-storage-keys.d.ts +3 -0
- package/dist/typescript/get-session-storage-keys.d.ts.map +1 -0
- package/dist/typescript/get-session-storage-keys.js +25 -0
- package/dist/typescript/get-session-storage-keys.js.map +1 -0
- package/dist/typescript/get-session-storage-size.d.ts +3 -0
- package/dist/typescript/get-session-storage-size.d.ts.map +1 -0
- package/dist/typescript/get-session-storage-size.js +25 -0
- package/dist/typescript/get-session-storage-size.js.map +1 -0
- package/dist/typescript/get-size.d.ts +7 -0
- package/dist/typescript/get-size.d.ts.map +1 -0
- package/dist/typescript/get-size.js +36 -0
- package/dist/typescript/get-size.js.map +1 -0
- package/dist/typescript/get-text.d.ts +3 -0
- package/dist/typescript/get-text.d.ts.map +1 -0
- package/dist/typescript/get-text.js +294 -0
- package/dist/typescript/get-text.js.map +1 -0
- package/dist/typescript/get-top-left-coordinates.d.ts +4 -0
- package/dist/typescript/get-top-left-coordinates.d.ts.map +1 -0
- package/dist/typescript/get-top-left-coordinates.js +36 -0
- package/dist/typescript/get-top-left-coordinates.js.map +1 -0
- package/dist/typescript/is-displayed.d.ts +1 -2
- package/dist/typescript/is-displayed.d.ts.map +1 -1
- package/dist/typescript/is-displayed.js +3 -396
- package/dist/typescript/is-displayed.js.map +1 -1
- package/dist/typescript/is-editable.d.ts +2 -0
- package/dist/typescript/is-editable.d.ts.map +1 -0
- package/dist/typescript/is-editable.js +18 -0
- package/dist/typescript/is-editable.js.map +1 -0
- package/dist/typescript/is-enabled.d.ts +2 -0
- package/dist/typescript/is-enabled.d.ts.map +1 -0
- package/dist/typescript/is-enabled.js +18 -0
- package/dist/typescript/is-enabled.js.map +1 -0
- package/dist/typescript/is-focusable.d.ts +2 -0
- package/dist/typescript/is-focusable.d.ts.map +1 -0
- package/dist/typescript/is-focusable.js +20 -0
- package/dist/typescript/is-focusable.js.map +1 -0
- package/dist/typescript/is-interactable.d.ts +2 -0
- package/dist/typescript/is-interactable.d.ts.map +1 -0
- package/dist/typescript/is-interactable.js +19 -0
- package/dist/typescript/is-interactable.js.map +1 -0
- package/dist/typescript/is-selected.d.ts +3 -0
- package/dist/typescript/is-selected.d.ts.map +1 -0
- package/dist/typescript/is-selected.js +29 -0
- package/dist/typescript/is-selected.js.map +1 -0
- package/dist/typescript/remove-local-storage-item.d.ts +3 -0
- package/dist/typescript/remove-local-storage-item.d.ts.map +1 -0
- package/dist/typescript/remove-local-storage-item.js +25 -0
- package/dist/typescript/remove-local-storage-item.js.map +1 -0
- package/dist/typescript/remove-session-storage-item.d.ts +3 -0
- package/dist/typescript/remove-session-storage-item.d.ts.map +1 -0
- package/dist/typescript/remove-session-storage-item.js +25 -0
- package/dist/typescript/remove-session-storage-item.js.map +1 -0
- package/dist/typescript/set-local-storage-item.d.ts +3 -0
- package/dist/typescript/set-local-storage-item.d.ts.map +1 -0
- package/dist/typescript/set-local-storage-item.js +26 -0
- package/dist/typescript/set-local-storage-item.js.map +1 -0
- package/dist/typescript/set-session-storage-item.d.ts +3 -0
- package/dist/typescript/set-session-storage-item.d.ts.map +1 -0
- package/dist/typescript/set-session-storage-item.js +26 -0
- package/dist/typescript/set-session-storage-item.js.map +1 -0
- package/dist/typescript/submit.d.ts +3 -0
- package/dist/typescript/submit.d.ts.map +1 -0
- package/dist/typescript/submit.js +50 -0
- package/dist/typescript/submit.js.map +1 -0
- package/dist/typescript/type.d.ts +3 -0
- package/dist/typescript/type.d.ts.map +1 -0
- package/dist/typescript/type.js +201 -0
- package/dist/typescript/type.js.map +1 -0
- package/index.ts +44 -0
- package/package.json +306 -5
- package/typescript/accessibility-snapshot-wire.ts +20 -0
- package/typescript/accessibility-snapshot.ts +21 -0
- package/typescript/active-element.ts +19 -0
- package/typescript/clear-local-storage.ts +27 -0
- package/typescript/clear-session-storage.ts +27 -0
- package/typescript/clear.ts +73 -0
- package/typescript/click.ts +55 -0
- package/typescript/core/accessibility/accname.ts +587 -0
- package/typescript/core/accessibility/context.ts +116 -0
- package/typescript/core/accessibility/hidden.ts +242 -0
- package/typescript/core/accessibility/roles.ts +410 -0
- package/typescript/core/accessibility/snapshot.ts +61 -0
- package/typescript/core/accessibility/states.ts +233 -0
- package/typescript/core/accessibility/tree.ts +306 -0
- package/typescript/core/accessibility/types.ts +52 -0
- package/typescript/core/accessibility/value.ts +89 -0
- package/typescript/core/accessibility/wire.ts +123 -0
- package/typescript/core/attribute.ts +68 -0
- package/typescript/core/color.ts +257 -0
- package/typescript/core/editable.ts +63 -0
- package/typescript/core/element.ts +110 -0
- package/typescript/core/enabled.ts +76 -0
- package/typescript/core/error.ts +41 -0
- package/typescript/core/events.ts +268 -0
- package/typescript/core/focus.ts +92 -0
- package/typescript/core/focusable.ts +38 -0
- package/typescript/core/form.ts +81 -0
- package/typescript/core/frame.ts +105 -0
- package/typescript/core/geometry.ts +183 -0
- package/typescript/core/inject.ts +336 -0
- package/typescript/core/interactable.ts +30 -0
- package/typescript/core/keyboard.ts +369 -0
- package/typescript/core/keys.ts +204 -0
- package/typescript/core/locators.ts +704 -0
- package/typescript/core/mouse.ts +211 -0
- package/typescript/core/overflow.ts +172 -0
- package/typescript/core/scroll.ts +92 -0
- package/typescript/core/shown.ts +233 -0
- package/typescript/core/storage.ts +111 -0
- package/typescript/core/style.ts +32 -0
- package/typescript/core/useragent.ts +33 -0
- package/typescript/default-content.ts +20 -0
- package/typescript/execute-async-script.ts +20 -0
- package/typescript/execute-script.ts +20 -0
- package/typescript/find-element-fragment.ts +45 -0
- package/typescript/find-element.ts +18 -0
- package/typescript/find-elements.ts +1 -326
- package/typescript/frame-by-id-or-name.ts +22 -0
- package/typescript/frame-by-index.ts +19 -0
- package/typescript/get-attribute-value.ts +22 -0
- package/typescript/get-effective-style.ts +93 -0
- package/typescript/get-element-from-cache.ts +20 -0
- package/typescript/get-frame-window.ts +22 -0
- package/typescript/get-local-storage-item.ts +27 -0
- package/typescript/get-local-storage-key.ts +28 -0
- package/typescript/get-local-storage-keys.ts +27 -0
- package/typescript/get-local-storage-size.ts +27 -0
- package/typescript/get-location.ts +63 -0
- package/typescript/get-session-storage-item.ts +27 -0
- package/typescript/get-session-storage-key.ts +28 -0
- package/typescript/get-session-storage-keys.ts +27 -0
- package/typescript/get-session-storage-size.ts +27 -0
- package/typescript/get-size.ts +43 -0
- package/typescript/get-text.ts +353 -0
- package/typescript/get-top-left-coordinates.ts +38 -0
- package/typescript/is-displayed.ts +3 -498
- package/typescript/is-editable.ts +18 -0
- package/typescript/is-enabled.ts +18 -0
- package/typescript/is-focusable.ts +20 -0
- package/typescript/is-interactable.ts +19 -0
- package/typescript/is-selected.ts +31 -0
- package/typescript/remove-local-storage-item.ts +27 -0
- package/typescript/remove-session-storage-item.ts +27 -0
- package/typescript/set-local-storage-item.ts +28 -0
- package/typescript/set-session-storage-item.ts +28 -0
- package/typescript/submit.ts +53 -0
- 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
|
+
}
|