mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
fix(web): read aria-disabled as disabled
the enabled fact came off the disabled property, which only real form controls have. it reads undefined on the role-based controls the tappable set now covers, so every one of them looked enabled however plainly it was marked otherwise, and the fuzzer would spend actions on inert ones. both producers answer the same two ways, and the parity fixture carries a disabled row so the comparison covers it: reverting one side alone names the element and the fact.
This commit is contained in:
1 parent
f3096d195b
commit
f09c6b5d4d
3 files changed
+22
-3
No files matched your search
@@ -328,6 +328,16 @@ function selectorTag(selector: unknown): string {
|
||||
return "";
|
||||
}
|
||||
|
||||
// isEnabled answers the `enabled` fact. `.disabled` is a property only real form
|
||||
// controls have, so it reads undefined on the role-based controls the tappable
|
||||
// set now covers, and every one of them looked enabled however plainly it was
|
||||
// marked otherwise. internal/driver/chrome/driver.go answers the same two ways
|
||||
// for the dump the goja host reads.
|
||||
function isEnabled(element: Element): boolean {
|
||||
if ((element as HTMLButtonElement).disabled) return false;
|
||||
return element.getAttribute("aria-disabled") !== "true";
|
||||
}
|
||||
|
||||
function elementHandle(element: Element, selector: unknown): Record<string, unknown> {
|
||||
const rect = element.getBoundingClientRect();
|
||||
const x = Math.round(rect.left + rect.width / 2);
|
||||
@@ -346,7 +356,7 @@ function elementHandle(element: Element, selector: unknown): Record<string, unkn
|
||||
desc: ariaLabel,
|
||||
class: (element as HTMLElement).className ?? "",
|
||||
clickable: true,
|
||||
enabled: !(element as HTMLButtonElement).disabled,
|
||||
enabled: isEnabled(element),
|
||||
focused: document.activeElement === element,
|
||||
x,
|
||||
y,
|
||||
@@ -716,7 +726,7 @@ function collectTargets(): TargetElement[] {
|
||||
...pointOf(element),
|
||||
selector: selectors[index],
|
||||
clickable: clickable.has(element),
|
||||
enabled: !(element as HTMLButtonElement).disabled,
|
||||
enabled: isEnabled(element),
|
||||
editable: editable.has(element),
|
||||
scrollable: isScrollable(element),
|
||||
}));
|
||||
|
||||
Reference in new issue
Block a user