@selenium/atoms 4.51.0-nightly202609302012 → 4.52.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/dist/index.d.ts +40 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -1
- 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/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 +40 -0
- package/package.json +296 -5
- 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/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
|
@@ -15,329 +15,4 @@
|
|
|
15
15
|
// specific language governing permissions and limitations
|
|
16
16
|
// under the License.
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
type LocatorTarget = Record<string, unknown>
|
|
20
|
-
type Root = Document | Element | ShadowRoot
|
|
21
|
-
type Rect = { left: number; top: number; width: number; height: number }
|
|
22
|
-
type RelativeFilter = { kind: string; args: unknown[] }
|
|
23
|
-
|
|
24
|
-
const INVALID_SELECTOR = 'invalid selector'
|
|
25
|
-
const INVALID_ARGUMENT = 'invalid argument'
|
|
26
|
-
const NO_SUCH_ELEMENT = 'no such element'
|
|
27
|
-
|
|
28
|
-
function botError(code: string, message: string): Error {
|
|
29
|
-
const err = new Error(message)
|
|
30
|
-
;(err as unknown as Record<string, unknown>)['code'] = code
|
|
31
|
-
return err
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function cssEscapeId(s: string): string {
|
|
35
|
-
return s.replace(/[\s'"\\#.:;,!?+<>=~*^$|%&@`{}\-/\[\]()]/g, (c) => '\\' + c)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function classNameMany(target: string, root: Root): Element[] {
|
|
39
|
-
if (!target) {
|
|
40
|
-
throw botError(INVALID_SELECTOR, 'No class name specified')
|
|
41
|
-
}
|
|
42
|
-
target = target.trim()
|
|
43
|
-
if (target.indexOf(' ') !== -1) {
|
|
44
|
-
throw botError(INVALID_SELECTOR, 'Compound class names not permitted')
|
|
45
|
-
}
|
|
46
|
-
try {
|
|
47
|
-
return Array.from(root.querySelectorAll('.' + target.replace(/\\/g, '\\\\').replace(/\./g, '\\.')))
|
|
48
|
-
} catch (_e) {
|
|
49
|
-
throw botError(INVALID_SELECTOR, 'An invalid or illegal class name was specified')
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function cssMany(target: string, root: Root): Element[] {
|
|
54
|
-
try {
|
|
55
|
-
return Array.from(root.querySelectorAll(target))
|
|
56
|
-
} catch (_e) {
|
|
57
|
-
throw botError(INVALID_SELECTOR, 'An invalid or illegal CSS selector was specified: ' + target)
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function idMany(target: string, root: Root): Element[] {
|
|
62
|
-
if (!target) {
|
|
63
|
-
return []
|
|
64
|
-
}
|
|
65
|
-
if (!/^\d/.test(target)) {
|
|
66
|
-
try {
|
|
67
|
-
return Array.from(root.querySelectorAll('#' + cssEscapeId(target)))
|
|
68
|
-
} catch (_e) {
|
|
69
|
-
return []
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return Array.from(root.querySelectorAll('*')).filter(el => el.getAttribute('id') === target)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function getLinkText(el: Element): string {
|
|
76
|
-
const text = (el as HTMLElement).innerText !== undefined ? (el as HTMLElement).innerText : el.textContent || ''
|
|
77
|
-
return text.replace(/^[\s]+|[\s]+$/g, '')
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function linkTextMany(target: string, root: Root, partial: boolean): Element[] {
|
|
81
|
-
return Array.from(root.querySelectorAll('a')).filter(el => {
|
|
82
|
-
const text = getLinkText(el)
|
|
83
|
-
return partial ? text.indexOf(target) !== -1 : text === target
|
|
84
|
-
})
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function nameMany(target: string, root: Root): Element[] {
|
|
88
|
-
return Array.from(root.querySelectorAll('[name="' + target.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"]'))
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function tagNameMany(target: string, root: Root): Element[] {
|
|
92
|
-
if (target === '') {
|
|
93
|
-
throw botError(INVALID_SELECTOR, 'Unable to locate an element with the tagName ""')
|
|
94
|
-
}
|
|
95
|
-
if ('getElementsByTagName' in root) {
|
|
96
|
-
return Array.from(root.getElementsByTagName(target))
|
|
97
|
-
}
|
|
98
|
-
const elements = Array.from(root.querySelectorAll('*'))
|
|
99
|
-
if (target === '*') {
|
|
100
|
-
return elements
|
|
101
|
-
}
|
|
102
|
-
const html = 'http://www.w3.org/1999/xhtml'
|
|
103
|
-
const folded = target.toLowerCase()
|
|
104
|
-
return elements.filter(el =>
|
|
105
|
-
el.namespaceURI === html ? el.localName === folded : el.localName === target)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const DEFAULT_NS_RESOLVER = (function () {
|
|
109
|
-
const ns: Record<string, string> = { svg: 'http://www.w3.org/2000/svg' }
|
|
110
|
-
return (prefix: string): string | null => ns[prefix] || null
|
|
111
|
-
})()
|
|
112
|
-
|
|
113
|
-
const ORDERED_NODE_SNAPSHOT_TYPE = 7
|
|
114
|
-
|
|
115
|
-
function xpathMany(target: string, root: Root): Element[] {
|
|
116
|
-
const doc = (root as Document).documentElement ? (root as Document) : root.ownerDocument!
|
|
117
|
-
if (!doc.documentElement) {
|
|
118
|
-
return []
|
|
119
|
-
}
|
|
120
|
-
try {
|
|
121
|
-
// Namespace prefixes require a colon in the XPath expression. Skip the
|
|
122
|
-
// expensive full-DOM scan when the expression contains no colon at all.
|
|
123
|
-
let resolver: ((prefix: string | null) => string | null) | null = null
|
|
124
|
-
if (target.indexOf(':') !== -1) {
|
|
125
|
-
const reversedNs: Record<string, string> = {}
|
|
126
|
-
const allNodes = doc.getElementsByTagName('*')
|
|
127
|
-
for (let i = 0; i < allNodes.length; i++) {
|
|
128
|
-
const n = allNodes[i]
|
|
129
|
-
const ns = n.namespaceURI
|
|
130
|
-
if (ns && !reversedNs[ns]) {
|
|
131
|
-
let prefix = n.lookupPrefix(ns)
|
|
132
|
-
if (!prefix) {
|
|
133
|
-
const m = ns.match('.*/(\\w+)/?$')
|
|
134
|
-
prefix = m ? m[1] : 'xhtml'
|
|
135
|
-
}
|
|
136
|
-
reversedNs[ns] = prefix!
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
const namespaces: Record<string, string> = {}
|
|
140
|
-
for (const key in reversedNs) {
|
|
141
|
-
namespaces[reversedNs[key]] = key
|
|
142
|
-
}
|
|
143
|
-
resolver = (prefix: string | null): string | null => namespaces[prefix || ''] || null
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
let result: XPathResult | null = null
|
|
147
|
-
try {
|
|
148
|
-
result = doc.evaluate(target, root, resolver, ORDERED_NODE_SNAPSHOT_TYPE, null)
|
|
149
|
-
} catch (te) {
|
|
150
|
-
if ((te as Error).name === 'TypeError') {
|
|
151
|
-
const fallback = doc.createNSResolver ? doc.createNSResolver(doc.documentElement!) : DEFAULT_NS_RESOLVER
|
|
152
|
-
result = doc.evaluate(target, root, fallback, ORDERED_NODE_SNAPSHOT_TYPE, null)
|
|
153
|
-
} else {
|
|
154
|
-
throw te
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (!result) {
|
|
159
|
-
return []
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
const results: Element[] = []
|
|
163
|
-
for (let i = 0; i < result.snapshotLength; i++) {
|
|
164
|
-
const node = result.snapshotItem(i)
|
|
165
|
-
if (!node || node.nodeType !== Node.ELEMENT_NODE) {
|
|
166
|
-
throw botError(
|
|
167
|
-
INVALID_SELECTOR,
|
|
168
|
-
'The result of the xpath expression "' + target + '" is: ' + node + '. It should be an element.',
|
|
169
|
-
)
|
|
170
|
-
}
|
|
171
|
-
results.push(node as Element)
|
|
172
|
-
}
|
|
173
|
-
return results
|
|
174
|
-
} catch (ex) {
|
|
175
|
-
if ((ex as Error & { name?: string }).name === 'NS_ERROR_ILLEGAL_VALUE') {
|
|
176
|
-
return []
|
|
177
|
-
}
|
|
178
|
-
if ((ex as Error & { code?: string }).code === INVALID_SELECTOR) {
|
|
179
|
-
throw ex
|
|
180
|
-
}
|
|
181
|
-
throw botError(
|
|
182
|
-
INVALID_SELECTOR,
|
|
183
|
-
'Unable to locate an element with the xpath expression ' + target + ' because of the following error:\n' + ex,
|
|
184
|
-
)
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function getClientRect(element: Element): Rect {
|
|
189
|
-
const r = element.getBoundingClientRect()
|
|
190
|
-
return { left: r.left, top: r.top, width: r.width, height: r.height }
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function resolveAnchor(selector: unknown): Element {
|
|
194
|
-
if (selector instanceof Element) {
|
|
195
|
-
return selector
|
|
196
|
-
}
|
|
197
|
-
if (typeof selector === 'function') {
|
|
198
|
-
return resolveAnchor((selector as () => unknown)())
|
|
199
|
-
}
|
|
200
|
-
if (selector && typeof selector === 'object') {
|
|
201
|
-
// Prefer an anchor inside the root, since a document search cannot see into a shadow root,
|
|
202
|
-
// but an anchor is only a reference point and may live anywhere on the page.
|
|
203
|
-
let found = root ? findElements(selector as LocatorTarget, root) : []
|
|
204
|
-
if (!found.length) {
|
|
205
|
-
found = findElements(selector as LocatorTarget)
|
|
206
|
-
}
|
|
207
|
-
if (!found.length) {
|
|
208
|
-
throw botError(NO_SUCH_ELEMENT, 'No element has been found by ' + JSON.stringify(selector))
|
|
209
|
-
}
|
|
210
|
-
return found[0]
|
|
211
|
-
}
|
|
212
|
-
throw botError(INVALID_ARGUMENT, 'Selector is of wrong type: ' + JSON.stringify(selector))
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function makeProximityFilter(selector: unknown, test: (anchor: Rect, candidate: Rect) => boolean) {
|
|
216
|
-
return (candidate: Element): boolean => test(getClientRect(resolveAnchor(selector)), getClientRect(candidate))
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
const RELATIVE_STRATEGIES: Record<string, (...args: unknown[]) => (el: Element) => boolean> = {
|
|
220
|
-
above: (sel) => makeProximityFilter(sel, (a, c) => c.top + c.height <= a.top),
|
|
221
|
-
below: (sel) => makeProximityFilter(sel, (a, c) => c.top >= a.top + a.height),
|
|
222
|
-
left: (sel) => makeProximityFilter(sel, (a, c) => c.left + c.width <= a.left),
|
|
223
|
-
right: (sel) => makeProximityFilter(sel, (a, c) => c.left >= a.left + a.width),
|
|
224
|
-
near: (sel, distArg) => {
|
|
225
|
-
const distFromSelector = typeof (sel as Record<string, unknown>)['distance'] === 'number'
|
|
226
|
-
? ((sel as Record<string, unknown>)['distance'] as number)
|
|
227
|
-
: 0
|
|
228
|
-
const distance = typeof distArg === 'number' && distArg > 0 ? distArg : distFromSelector || 50
|
|
229
|
-
return (candidate: Element): boolean => {
|
|
230
|
-
const anchor = resolveAnchor(sel)
|
|
231
|
-
if (anchor === candidate) return false
|
|
232
|
-
const a = getClientRect(anchor)
|
|
233
|
-
const c = getClientRect(candidate)
|
|
234
|
-
const expanded = { left: a.left - distance, top: a.top - distance, width: a.width + distance * 2, height: a.height + distance * 2 }
|
|
235
|
-
return (
|
|
236
|
-
c.left < expanded.left + expanded.width &&
|
|
237
|
-
c.left + c.width > expanded.left &&
|
|
238
|
-
c.top < expanded.top + expanded.height &&
|
|
239
|
-
c.top + c.height > expanded.top
|
|
240
|
-
)
|
|
241
|
-
}
|
|
242
|
-
},
|
|
243
|
-
straightAbove: (sel) =>
|
|
244
|
-
makeProximityFilter(sel, (a, c) => c.left < a.left + a.width && c.left + c.width > a.left && c.top + c.height <= a.top),
|
|
245
|
-
straightBelow: (sel) =>
|
|
246
|
-
makeProximityFilter(sel, (a, c) => c.left < a.left + a.width && c.left + c.width > a.left && c.top >= a.top + a.height),
|
|
247
|
-
straightLeft: (sel) =>
|
|
248
|
-
makeProximityFilter(sel, (a, c) => c.top < a.top + a.height && c.top + c.height > a.top && c.left + c.width <= a.left),
|
|
249
|
-
straightRight: (sel) =>
|
|
250
|
-
makeProximityFilter(sel, (a, c) => c.top < a.top + a.height && c.top + c.height > a.top && c.left >= a.left + a.width),
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
function sortByProximity(anchor: Element, elements: Element[]): Element[] {
|
|
254
|
-
const ar = getClientRect(anchor)
|
|
255
|
-
const acx = ar.left + Math.max(1, ar.width) / 2
|
|
256
|
-
const acy = ar.top + Math.max(1, ar.height) / 2
|
|
257
|
-
return elements.slice().sort((a, b) => {
|
|
258
|
-
const ra = getClientRect(a)
|
|
259
|
-
const rb = getClientRect(b)
|
|
260
|
-
const da = Math.sqrt(Math.pow(acx - (ra.left + Math.max(1, ra.width) / 2), 2) + Math.pow(acy - (ra.top + Math.max(1, ra.height) / 2), 2))
|
|
261
|
-
const db = Math.sqrt(Math.pow(acx - (rb.left + Math.max(1, rb.width) / 2), 2) + Math.pow(acy - (rb.top + Math.max(1, rb.height) / 2), 2))
|
|
262
|
-
return da - db
|
|
263
|
-
})
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
function relativeMany(target: Record<string, unknown>, root: Root): Element[] {
|
|
267
|
-
if (!Object.prototype.hasOwnProperty.call(target, 'root') || !Object.prototype.hasOwnProperty.call(target, 'filters')) {
|
|
268
|
-
throw botError(INVALID_ARGUMENT, 'Locator not suitable for relative locators: ' + JSON.stringify(target))
|
|
269
|
-
}
|
|
270
|
-
const filters = target['filters']
|
|
271
|
-
if (!Array.isArray(filters)) {
|
|
272
|
-
throw botError(INVALID_ARGUMENT, 'Targets should be an array: ' + JSON.stringify(target))
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
let elements: Element[]
|
|
276
|
-
const rootTarget = target['root']
|
|
277
|
-
if (rootTarget instanceof Element) {
|
|
278
|
-
elements = [rootTarget]
|
|
279
|
-
} else {
|
|
280
|
-
elements = findElements(rootTarget as LocatorTarget, root)
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
if (!elements.length) {
|
|
284
|
-
return []
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
const matched = elements.filter(el => {
|
|
288
|
-
if (!el) return false
|
|
289
|
-
return (filters as RelativeFilter[]).every(filter => {
|
|
290
|
-
const strategy = RELATIVE_STRATEGIES[filter.kind]
|
|
291
|
-
if (!strategy) {
|
|
292
|
-
throw botError(INVALID_ARGUMENT, 'Cannot find filter suitable for ' + filter.kind)
|
|
293
|
-
}
|
|
294
|
-
return strategy(...filter.args)(el)
|
|
295
|
-
})
|
|
296
|
-
})
|
|
297
|
-
|
|
298
|
-
const finalFilter = filters[filters.length - 1] as RelativeFilter | undefined
|
|
299
|
-
if (!finalFilter || !RELATIVE_STRATEGIES[finalFilter.kind]) {
|
|
300
|
-
return matched
|
|
301
|
-
}
|
|
302
|
-
const lastAnchor = resolveAnchor(finalFilter.args[0])
|
|
303
|
-
return sortByProximity(lastAnchor, matched)
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
const actualRoot: Root = root || document
|
|
307
|
-
const keys = Object.keys(target).filter(k => Object.prototype.hasOwnProperty.call(target, k))
|
|
308
|
-
if (!keys.length) {
|
|
309
|
-
throw botError(INVALID_ARGUMENT, 'Unsupported locator strategy: (empty)')
|
|
310
|
-
}
|
|
311
|
-
const key = keys[0]
|
|
312
|
-
const value = target[key]
|
|
313
|
-
|
|
314
|
-
switch (key) {
|
|
315
|
-
case 'className':
|
|
316
|
-
case 'class name':
|
|
317
|
-
return classNameMany(value as string, actualRoot)
|
|
318
|
-
case 'css':
|
|
319
|
-
case 'css selector':
|
|
320
|
-
return cssMany(value as string, actualRoot)
|
|
321
|
-
case 'id':
|
|
322
|
-
return idMany(value as string, actualRoot)
|
|
323
|
-
case 'linkText':
|
|
324
|
-
case 'link text':
|
|
325
|
-
return linkTextMany(value as string, actualRoot, false)
|
|
326
|
-
case 'partialLinkText':
|
|
327
|
-
case 'partial link text':
|
|
328
|
-
return linkTextMany(value as string, actualRoot, true)
|
|
329
|
-
case 'name':
|
|
330
|
-
return nameMany(value as string, actualRoot)
|
|
331
|
-
case 'tagName':
|
|
332
|
-
case 'tag name':
|
|
333
|
-
return tagNameMany(value as string, actualRoot)
|
|
334
|
-
case 'xpath':
|
|
335
|
-
return xpathMany(value as string, actualRoot)
|
|
336
|
-
case 'relative':
|
|
337
|
-
return relativeMany(value as Record<string, unknown>, actualRoot)
|
|
338
|
-
default:
|
|
339
|
-
throw botError(INVALID_ARGUMENT, 'Unsupported locator strategy: ' + key)
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
export default findElements;
|
|
18
|
+
export { findElements as default } from './core/locators.js'
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
// A child frame of the given window, matched on name first and then id.
|
|
19
|
+
//
|
|
20
|
+
// Shallow by design: neither nested frames nor the parent are reachable from
|
|
21
|
+
// here, and a miss is null rather than an error.
|
|
22
|
+
export { findFrameByNameOrId as default } from './core/frame.js'
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
// A child frame of the given window by position, or null when out of range.
|
|
19
|
+
export { findFrameByIndex as default } from './core/frame.js'
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Licensed to the Software Freedom Conservancy (SFC) under one
|
|
2
|
+
// or more contributor license agreements. See the NOTICE file
|
|
3
|
+
// distributed with this work for additional information
|
|
4
|
+
// regarding copyright ownership. The SFC licenses this file
|
|
5
|
+
// to you under the Apache License, Version 2.0 (the
|
|
6
|
+
// "License"); you may not use this file except in compliance
|
|
7
|
+
// with the License. You may obtain a copy of the License at
|
|
8
|
+
//
|
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
//
|
|
11
|
+
// Unless required by applicable law or agreed to in writing,
|
|
12
|
+
// software distributed under the License is distributed on an
|
|
13
|
+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
// KIND, either express or implied. See the License for the
|
|
15
|
+
// specific language governing permissions and limitations
|
|
16
|
+
// under the License.
|
|
17
|
+
|
|
18
|
+
// The raw markup attribute. Distinct from the get_attribute atom, which
|
|
19
|
+
// implements the WebDriver algorithm (properties, boolean attributes, aliases)
|
|
20
|
+
// and will often disagree with this one — e.g. for a checkbox the user has
|
|
21
|
+
// clicked, this still returns what the HTML said.
|
|
22
|
+
export { getAttribute as default } from './core/attribute.js'
|
|
@@ -0,0 +1,93 @@
|
|
|
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 { standardizeColor } from './core/color.js'
|
|
19
|
+
import { getParentElement } from './core/element.js'
|
|
20
|
+
|
|
21
|
+
// goog.string.toCamelCase: 'background-color' -> 'backgroundColor'. Callers
|
|
22
|
+
// pass either spelling, so both have to land on the same property.
|
|
23
|
+
function toCamelCase(name: string): string {
|
|
24
|
+
return String(name).replace(/-([a-z])/g, function (_all, letter: string) {
|
|
25
|
+
return letter.toUpperCase()
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// goog.style.getComputedStyle indexed the declaration with the camel-cased
|
|
30
|
+
// name and fell back to getPropertyValue, returning '' rather than null when
|
|
31
|
+
// there is no view to compute against. The empty string is what makes the
|
|
32
|
+
// cascaded fallback below fire.
|
|
33
|
+
function getComputedStyleValue(elem: Element, styleName: string, cssName: string): string {
|
|
34
|
+
const view = elem.ownerDocument.defaultView
|
|
35
|
+
if (!view) {
|
|
36
|
+
return ''
|
|
37
|
+
}
|
|
38
|
+
const styles = view.getComputedStyle(elem, null)
|
|
39
|
+
if (!styles) {
|
|
40
|
+
return ''
|
|
41
|
+
}
|
|
42
|
+
return (styles as unknown as Record<string, string>)[styleName] ||
|
|
43
|
+
styles.getPropertyValue(cssName) ||
|
|
44
|
+
''
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// bot.dom.getCascadedStyle_. The elem.currentStyle preference the original
|
|
48
|
+
// opened with was IE-only and is dropped; every browser we support fell
|
|
49
|
+
// through to elem.style anyway.
|
|
50
|
+
function getCascadedStyle(elem: Element, styleName: string, cssName: string): string | null {
|
|
51
|
+
const style = (elem as HTMLElement).style
|
|
52
|
+
let value: string | undefined = (style as unknown as Record<string, string>)[styleName]
|
|
53
|
+
if (value === undefined && typeof style.getPropertyValue === 'function') {
|
|
54
|
+
value = style.getPropertyValue(cssName)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (value !== 'inherit') {
|
|
58
|
+
return value !== undefined ? value : null
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const parent = getParentElement(elem)
|
|
62
|
+
return parent ? getCascadedStyle(parent, styleName, cssName) : null
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// The effective value of a CSS property, with colours normalised.
|
|
66
|
+
//
|
|
67
|
+
// This is bot.dom.getEffectiveStyle. It is exported twice -- as
|
|
68
|
+
// getEffectiveStyle and as getValueOfCssProperty -- because the bindings do
|
|
69
|
+
// not agree on a name (value_of_css_property, css_value, getCssValue,
|
|
70
|
+
// GetCssValue) and the implementation's own name is the only neutral one. The
|
|
71
|
+
// alias is an export-map entry over this single artifact, never a second
|
|
72
|
+
// build target, so the two names cannot drift apart.
|
|
73
|
+
function getEffectiveStyle(elem: Element, propertyName: string): string | null {
|
|
74
|
+
let styleName = toCamelCase(propertyName)
|
|
75
|
+
if (styleName === 'float' || styleName === 'cssFloat' || styleName === 'styleFloat') {
|
|
76
|
+
// 'float' is a reserved word, so the CSSOM spells the property cssFloat.
|
|
77
|
+
// The IE-only styleFloat spelling the original also chose between is gone.
|
|
78
|
+
styleName = 'cssFloat'
|
|
79
|
+
}
|
|
80
|
+
// getPropertyValue takes the CSS spelling, not the camel-cased one; without
|
|
81
|
+
// it a custom property such as --accent, which has no camel-cased form,
|
|
82
|
+
// could never be read.
|
|
83
|
+
const cssName = styleName === 'cssFloat' ? 'float' : propertyName
|
|
84
|
+
|
|
85
|
+
const style = getComputedStyleValue(elem, styleName, cssName) || getCascadedStyle(elem, styleName, cssName)
|
|
86
|
+
if (style === null) {
|
|
87
|
+
return null
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return standardizeColor(styleName, style)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export default getEffectiveStyle
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
// bot.inject.cache.getElement: the live element or window behind a cache id.
|
|
19
|
+
// Raises stale element reference for an unknown or detached entry.
|
|
20
|
+
export { getElement as default } from './core/inject.js'
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Licensed to the Software Freedom Conservancy (SFC) under one
|
|
2
|
+
// or more contributor license agreements. See the NOTICE file
|
|
3
|
+
// distributed with this work for additional information
|
|
4
|
+
// regarding copyright ownership. The SFC licenses this file
|
|
5
|
+
// to you under the Apache License, Version 2.0 (the
|
|
6
|
+
// "License"); you may not use this file except in compliance
|
|
7
|
+
// with the License. You may obtain a copy of the License at
|
|
8
|
+
//
|
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
//
|
|
11
|
+
// Unless required by applicable law or agreed to in writing,
|
|
12
|
+
// software distributed under the License is distributed on an
|
|
13
|
+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
// KIND, either express or implied. See the License for the
|
|
15
|
+
// specific language governing permissions and limitations
|
|
16
|
+
// under the License.
|
|
17
|
+
|
|
18
|
+
// The window inside a frame or iframe element.
|
|
19
|
+
//
|
|
20
|
+
// Raises "no such frame" when handed anything else, which is the one way a
|
|
21
|
+
// caller learns it picked the wrong element.
|
|
22
|
+
export { getFrameWindow as default } from './core/frame.js'
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { getLocalStorage } from './core/storage.js'
|
|
19
|
+
|
|
20
|
+
// The stored value, or null when the key is absent.
|
|
21
|
+
//
|
|
22
|
+
// optWindow targets a frame other than the one the atom is running in.
|
|
23
|
+
function getLocalStorageItem(key: string, optWindow?: Window): string | null {
|
|
24
|
+
return getLocalStorage(optWindow).getItem(key)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default getLocalStorageItem
|
|
@@ -0,0 +1,28 @@
|
|
|
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 { getLocalStorage } from './core/storage.js'
|
|
19
|
+
|
|
20
|
+
// The key at a position in the store, or null when the index is out of range.
|
|
21
|
+
// Storage order is not specified, so this is only meaningful alongside size().
|
|
22
|
+
//
|
|
23
|
+
// optWindow targets a frame other than the one the atom is running in.
|
|
24
|
+
function getLocalStorageKey(index: number, optWindow?: Window): string | null {
|
|
25
|
+
return getLocalStorage(optWindow).key(index)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default getLocalStorageKey
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { getLocalStorage } from './core/storage.js'
|
|
19
|
+
|
|
20
|
+
// Every key in the store, as an Array.
|
|
21
|
+
//
|
|
22
|
+
// optWindow targets a frame other than the one the atom is running in.
|
|
23
|
+
function getLocalStorageKeys(optWindow?: Window): string[] {
|
|
24
|
+
return getLocalStorage(optWindow).keySet()
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default getLocalStorageKeys
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { getLocalStorage } from './core/storage.js'
|
|
19
|
+
|
|
20
|
+
// How many key/value pairs the store holds.
|
|
21
|
+
//
|
|
22
|
+
// optWindow targets a frame other than the one the atom is running in.
|
|
23
|
+
function getLocalStorageSize(optWindow?: Window): number {
|
|
24
|
+
return getLocalStorage(optWindow).size()
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default getLocalStorageSize
|