Bug 235246

Summary: AX: Fix disabled-controls-not-focusable.html in isolated tree mode by updating AXPropertyName::CanSetFocusAttribute when the disabled attribute changes
Product: WebKit Reporter: Tyler Wilcock <tyler_w>
Component: AccessibilityAssignee: Tyler Wilcock <tyler_w>
Status: RESOLVED FIXED    
Severity: Normal CC: aboxhall, andresg_22, apinheiro, cfleizach, dmazzoni, ews-watchlist, jcraig, jdiggs, samuel_white, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

Description Tyler Wilcock 2022-01-14 12:29:40 PST
AX: Fix disabled-controls-not-focusable.html in isolated tree mode by updating AXPropertyName::CanSetFocusAttribute when the disabled attribute changes.
Comment 1 Radar WebKit Bug Importer 2022-01-14 12:29:52 PST
<rdar://problem/87613404>
Comment 2 Tyler Wilcock 2022-01-14 12:36:09 PST
Created attachment 449207 [details]
Patch
Comment 3 Andres Gonzalez 2022-01-14 13:14:38 PST
(In reply to Tyler Wilcock from comment #2)
> Created attachment 449207 [details]
> Patch

--- a/Source/WebCore/accessibility/AXObjectCache.cpp
+++ a/Source/WebCore/accessibility/AXObjectCache.cpp

+        case AXDisabledStateChanged:
+            tree->updateNodeProperty(*notification.first, AXPropertyName::CanSetFocusAttribute);
+            break;

Add this same case to the updateIsolatedTree that takes a single notification as opposed to a vector of notifications.

--- a/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h
+++ a/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h
@@ -139,6 +139,7 @@ public:
     JSRetainPtr<JSStringRef> stringAttributeValue(NSString *attribute) const;
     double numberAttributeValue(NSString *attribute) const;
     RetainPtr<id> attributeValue(NSString *) const;
+    bool isAttributeSettable(NSString *) const;

Can we make this private?

--- a/LayoutTests/accessibility/disabled-controls-not-focusable.html
+++ a/LayoutTests/accessibility/disabled-controls-not-focusable.html

+        async function checkControl(id) {
+            window.element = document.getElementById(id);
+            debug(`Testing #${id}`);
+            element.focus();
+            await waitFor(() => {
+                window.axElement = accessibilityController.focusedElement;
+                return axElement && accessibilityController.accessibleElementById(id);
+            });
+            shouldBeTrue("axElement.isFocusable");
+            debug(`Setting the disabled attribute of element #${id}`);
+            element.disabled = true;
+            await expectAsyncExpression("axElement.isFocusable", "false");
+            debug("");
+        }

The order of operations looks weird to me. I think it should be:
1. Check that an axElement is focusable.
2. Then focus it.
3. Disable the DOM element.
4. Check that now is not focusable.

Not sure that we even have to do 2., because that's not what the test is testing, correct?
Comment 4 Tyler Wilcock 2022-01-14 14:16:23 PST
Created attachment 449221 [details]
Patch
Comment 5 Tyler Wilcock 2022-01-14 14:17:30 PST
Thanks for the review -- addressed all of your comments in the latest patch.
Comment 6 Tyler Wilcock 2022-01-14 14:20:16 PST
(In reply to Andres Gonzalez from comment #3)
> (In reply to Tyler Wilcock from comment #2)
> > Created attachment 449207 [details]
> > Patch
> 
> --- a/Source/WebCore/accessibility/AXObjectCache.cpp
> +++ a/Source/WebCore/accessibility/AXObjectCache.cpp
> 
> +        case AXDisabledStateChanged:
> +            tree->updateNodeProperty(*notification.first,
> AXPropertyName::CanSetFocusAttribute);
> +            break;
> 
> Add this same case to the updateIsolatedTree that takes a single
> notification as opposed to a vector of notifications.
We should refactor this such that we don't have to remember to add new notification handling in two places.
Comment 7 Tyler Wilcock 2022-01-14 15:25:56 PST
Created attachment 449231 [details]
Patch
Comment 8 EWS 2022-01-15 09:24:33 PST
Committed r288058 (246078@main): <https://commits.webkit.org/246078@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 449231 [details].