Title: [292686] trunk
Revision
292686
Author
tyle...@apple.com
Date
2022-04-10 00:29:13 -0700 (Sun, 10 Apr 2022)

Log Message

Fix accessibility/aria-invalid.html in isolated tree mode
https://bugs.webkit.org/show_bug.cgi?id=238978

Reviewed by Chris Fleizach.

Source/WebCore:

With this patch, we update the isolated tree when the aria-invalid
attribute changes.

Fixes accessibility/aria-invalid.html in isolated tree mode.

* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::updateIsolatedTree):
* accessibility/isolatedtree/AXIsolatedTree.cpp:
(WebCore::AXIsolatedTree::updateNodeProperty):
Drive-by re-ordering of `case AXPropertyName::IdentifierAttribute` such that this
function handles properties in alphabetical order.

LayoutTests:

* accessibility/aria-invalid-expected.txt:
* accessibility/aria-invalid.html:
Rewrite to call `debug` only once at the end of the test. Also made
this test use accessibleElementById instead of
accessibilityController.focusedElement.
* resources/accessibility-helper.js:
Add new `expect` function, which is like the more ubiquitous
`shouldBe` from js-test.js, but returns the output as a string instead
of calling `debug` to output to a console DOM element.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (292685 => 292686)


--- trunk/LayoutTests/ChangeLog	2022-04-10 02:59:35 UTC (rev 292685)
+++ trunk/LayoutTests/ChangeLog	2022-04-10 07:29:13 UTC (rev 292686)
@@ -1,3 +1,20 @@
+2022-04-10  Tyler Wilcock  <tyle...@apple.com>
+
+        Fix accessibility/aria-invalid.html in isolated tree mode
+        https://bugs.webkit.org/show_bug.cgi?id=238978
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/aria-invalid-expected.txt:
+        * accessibility/aria-invalid.html:
+        Rewrite to call `debug` only once at the end of the test. Also made
+        this test use accessibleElementById instead of
+        accessibilityController.focusedElement.
+        * resources/accessibility-helper.js:
+        Add new `expect` function, which is like the more ubiquitous
+        `shouldBe` from js-test.js, but returns the output as a string instead
+        of calling `debug` to output to a console DOM element.
+
 2022-04-09  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         [WKTR] Reset minimum font size WKPreference between tests

Modified: trunk/LayoutTests/accessibility/aria-invalid-expected.txt (292685 => 292686)


--- trunk/LayoutTests/accessibility/aria-invalid-expected.txt	2022-04-10 02:59:35 UTC (rev 292685)
+++ trunk/LayoutTests/accessibility/aria-invalid-expected.txt	2022-04-10 07:29:13 UTC (rev 292686)
@@ -1,8 +1,5 @@
 This tests that aria-invalid causes the right attribute to be returned and it ensures a notification is sent when it changes.
 
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
 PASS: AXInvalid is false.
 PASS: AXInvalid is false.
 PASS: AXInvalid is false.
@@ -22,9 +19,10 @@
 PASS: AXInvalid is true.
 PASS: AXInvalid is true.
 PASS: AXInvalid is true.
-PASS addedNotification is true
+PASS: didAddNotification === true
+Notification received successfully.
 PASS: AXInvalid is spelling.
-Notification received successfully.
+
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/accessibility/aria-invalid.html (292685 => 292686)


--- trunk/LayoutTests/accessibility/aria-invalid.html	2022-04-10 02:59:35 UTC (rev 292685)
+++ trunk/LayoutTests/accessibility/aria-invalid.html	2022-04-10 07:29:13 UTC (rev 292686)
@@ -1,91 +1,88 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
 <html>
 <head>
-<script src=""
 <script src=""
+<script src=""
 </head>
 <body id="body">
 
 <div id="examples">
     <!-- All of these eval to AXInvalid: 'false' -->
-    <input class="ex" data-expected="false" type="text">
-    <input class="ex" data-expected="false" type="text" aria-invalid>
-    <input class="ex" data-expected="false" type="text" aria-invalid="">
-    <input class="ex" data-expected="false" type="text" aria-invalid=" ">
-    <input class="ex" data-expected="false" type="text" aria-invalid="	"><!-- [sic] tab char -->
-    <input class="ex" data-expected="false" type="text" aria-invalid="
+    <input class="ex" id="ex1" data-expected="false" type="text">
+    <input class="ex" id="ex2" data-expected="false" type="text" aria-invalid>
+    <input class="ex" id="ex3" data-expected="false" type="text" aria-invalid="">
+    <input class="ex" id="ex4" data-expected="false" type="text" aria-invalid=" ">
+    <input class="ex" id="ex5" data-expected="false" type="text" aria-invalid="	"><!-- [sic] tab char -->
+    <input class="ex" id="ex6" data-expected="false" type="text" aria-invalid="
     "><!-- [sic] newline char -->
-    <input class="ex" data-expected="false" type="text" aria-invalid="false">
-    <input class="ex" data-expected="false" type="text" aria-invalid="undefined">
+    <input class="ex" id="ex7" data-expected="false" type="text" aria-invalid="false">
+    <input class="ex" id="ex8" data-expected="false" type="text" aria-invalid="undefined">
 
     <!-- Known token values in ARIA 1.0. -->
-    <input class="ex" data-expected="grammar" type="text" aria-invalid="grammar">
-    <input class="ex" data-expected="grammar" type="text" aria-invalid="grammar	"><!-- [sic] tab char -->
-    <input class="ex" data-expected="spelling" type="text" aria-invalid="spelling">
-    <input class="ex" data-expected="spelling" type="text" aria-invalid="spelling
+    <input class="ex" id="ex9" data-expected="grammar" type="text" aria-invalid="grammar">
+    <input class="ex" id="ex10" data-expected="grammar" type="text" aria-invalid="grammar	"><!-- [sic] tab char -->
+    <input class="ex" id="ex11" data-expected="spelling" type="text" aria-invalid="spelling">
+    <input class="ex" id="ex12" data-expected="spelling" type="text" aria-invalid="spelling
     "><!-- [sic] newline char -->
 
     <!-- All other string values are truthy, including a combination of otherwise valid tokens. -->
-    <input class="ex" data-expected="true" type="text" aria-invalid="true">
-    <input class="ex" data-expected="true" type="text" aria-invalid="notallowed">
-    <input class="ex" data-expected="true" type="text" aria-invalid="…">
-    <input class="ex" data-expected="true" type="text" aria-invalid="Ç">
-    <input class="ex" data-expected="true" type="text" aria-invalid="spelling grammar">
-    <input class="ex" data-expected="true" type="text" aria-invalid="spelling	grammar"><!-- [sic] tab char -->
-    <input class="ex" data-expected="true" type="text" aria-invalid="spelling
+    <input class="ex" id="ex13" data-expected="true" type="text" aria-invalid="true">
+    <input class="ex" id="ex14" data-expected="true" type="text" aria-invalid="notallowed">
+    <input class="ex" id="ex15" data-expected="true" type="text" aria-invalid="…">
+    <input class="ex" id="ex16" data-expected="true" type="text" aria-invalid="Ç">
+    <input class="ex" id="ex17" data-expected="true" type="text" aria-invalid="spelling grammar">
+    <input class="ex" id="ex18" data-expected="true" type="text" aria-invalid="spelling	grammar"><!-- [sic] tab char -->
+    <input class="ex" id="ex19" data-expected="true" type="text" aria-invalid="spelling
     grammar"><!-- [sic] newline char -->
 </div>
 
-<p id="description"></p>
-<div id="console"></div>
-
 <script>
-    description("This tests that aria-invalid causes the right attribute to be returned and it ensures a notification is sent when it changes.");
+    var testOutput = "This tests that aria-invalid causes the right attribute to be returned and it ensures a notification is sent when it changes.\n\n";
 
-    function $(id){
-        return document.getElementById(id);
-    }
-
     var axNotificationElement = null;
     function notificationCallback(notification) {
         if (notification == "AXInvalidStatusChanged") {
-            debug("Notification received successfully.");
+            testOutput += "Notification received successfully.\n";
 
             axNotificationElement.removeNotificationListener();
-            $("examples").hidden = true;
-            finishJSTest();
         }
     }
 
-    var result = $('console');
     function verify(value, expectation, element) {
         if (value === expectation)
-            result.innerText += "PASS: AXInvalid is " + value + ".\n";
+            testOutput += `PASS: AXInvalid is ${value}.\n`;
         else
-            result.innerText += "FAIL: AXInvalid is " + value + ". Expected: " + expectation + ". " + (element ? element.outerHTML : "") + "\n";
+            testOutput += `FAIL: AXInvalid is ${value}. Expected: ${expectation}. ${(element ? element.outerHTML : "")}\n`;
     }
 
     if (window.accessibilityController) {
-        jsTestIsAsync = true;
+        window.jsTestIsAsync = true;
 
         var examples = document.querySelectorAll(".ex");
         for (var i = 0, c = examples.length; i < c; i++) {
             var el = examples[i];
-            el.focus();
             var expectation = el.getAttribute("data-expected");
-            var value = accessibilityController.focusedElement.stringAttributeValue('AXInvalid');
+            var value = accessibilityController.accessibleElementById(el.id).stringAttributeValue("AXInvalid");
             verify(value, expectation, el);
         }
 
-        var domNotificationElement = document.querySelector(".ex");
-        domNotificationElement.focus();
-        axNotificationElement = accessibilityController.focusedElement;
-        var addedNotification = axNotificationElement.addNotificationListener(notificationCallback);
-        shouldBeTrue("addedNotification");
+        const domNotificationElement = document.querySelector(".ex");
+        axNotificationElement = accessibilityController.accessibleElementById(domNotificationElement.id);
+        var didAddNotification = axNotificationElement.addNotificationListener(notificationCallback);
+        testOutput += expect("didAddNotification", "true");
         domNotificationElement.setAttribute("aria-invalid", "spelling");
-        verify(axNotificationElement.stringAttributeValue('AXInvalid'), "spelling", domNotificationElement);
+
+        setTimeout(async () => {
+            await waitFor(() => {
+                return axNotificationElement.stringAttributeValue("AXInvalid") === "spelling";
+            });
+            verify(axNotificationElement.stringAttributeValue("AXInvalid"), "spelling", domNotificationElement);
+
+            document.getElementById("examples").hidden = true;
+            debug(testOutput);
+            finishJSTest();
+        });
     }
 </script>
-<script src=""
 </body>
 </html>

Modified: trunk/LayoutTests/resources/accessibility-helper.js (292685 => 292686)


--- trunk/LayoutTests/resources/accessibility-helper.js	2022-04-10 02:59:35 UTC (rev 292685)
+++ trunk/LayoutTests/resources/accessibility-helper.js	2022-04-10 07:29:13 UTC (rev 292686)
@@ -142,6 +142,19 @@
     return element;
 }
 
+// Expect an _expression_ to equal a value and return the result as a string.
+// This is essentially the more ubiquitous `shouldBe` function from js-test,
+// but returns the result as a string rather than `debug`ing to a console DOM element.
+function expect(_expression_, expectedValue) {
+    if (typeof _expression_ !== "string")
+        debug("WARN: The _expression_ arg in bufferShouldBe() should be a string.");
+
+    const evalExpression = `${_expression_} === ${expectedValue}`;
+    if (eval(evalExpression))
+        return `PASS: ${evalExpression}\n`;
+    return `FAIL: ${_expression_} !== ${expectedValue}\n`;
+}
+
 async function expectAsyncExpression(_expression_, expectedValue) {
     if (typeof _expression_ !== "string")
         debug("WARN: The _expression_ arg in waitForExpression() should be a string.");

Modified: trunk/Source/WebCore/ChangeLog (292685 => 292686)


--- trunk/Source/WebCore/ChangeLog	2022-04-10 02:59:35 UTC (rev 292685)
+++ trunk/Source/WebCore/ChangeLog	2022-04-10 07:29:13 UTC (rev 292686)
@@ -1,3 +1,22 @@
+2022-04-10  Tyler Wilcock  <tyle...@apple.com>
+
+        Fix accessibility/aria-invalid.html in isolated tree mode
+        https://bugs.webkit.org/show_bug.cgi?id=238978
+
+        Reviewed by Chris Fleizach.
+
+        With this patch, we update the isolated tree when the aria-invalid
+        attribute changes.
+
+        Fixes accessibility/aria-invalid.html in isolated tree mode.
+
+        * accessibility/AXObjectCache.cpp:
+        (WebCore::AXObjectCache::updateIsolatedTree):
+        * accessibility/isolatedtree/AXIsolatedTree.cpp:
+        (WebCore::AXIsolatedTree::updateNodeProperty):
+        Drive-by re-ordering of `case AXPropertyName::IdentifierAttribute` such that this
+        function handles properties in alphabetical order.
+
 2022-04-09  Alan Bujtas  <za...@apple.com>
 
         [Text autosizing] Remove redundant lineCountForTextAutosizing member function

Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (292685 => 292686)


--- trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2022-04-10 02:59:35 UTC (rev 292685)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2022-04-10 07:29:13 UTC (rev 292686)
@@ -3415,6 +3415,7 @@
             break;
         case AXActiveDescendantChanged:
         case AXAriaRoleChanged:
+        case AXInvalidStatusChanged:
         case AXMenuListValueChanged:
         case AXSelectedChildrenChanged:
         case AXValueChanged: {

Modified: trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp (292685 => 292686)


--- trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp	2022-04-10 02:59:35 UTC (rev 292685)
+++ trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp	2022-04-10 07:29:13 UTC (rev 292686)
@@ -336,6 +336,9 @@
     case AXPropertyName::DisclosedRows:
         propertyMap.set(AXPropertyName::DisclosedRows, idsForObjects(axObject.disclosedRows()));
         break;
+    case AXPropertyName::IdentifierAttribute:
+        propertyMap.set(AXPropertyName::IdentifierAttribute, axObject.identifierAttribute().isolatedCopy());
+        break;
     case AXPropertyName::IsChecked:
         ASSERT(axObject.supportsCheckedState());
         propertyMap.set(AXPropertyName::IsChecked, axObject.isChecked());
@@ -350,9 +353,6 @@
     case AXPropertyName::SortDirection:
         propertyMap.set(AXPropertyName::SortDirection, static_cast<int>(axObject.sortDirection()));
         break;
-    case AXPropertyName::IdentifierAttribute:
-        propertyMap.set(AXPropertyName::IdentifierAttribute, axObject.identifierAttribute().isolatedCopy());
-        break;
     default:
         return;
     }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to