Title: [286426] trunk
Revision
286426
Author
tyle...@apple.com
Date
2021-12-02 07:25:52 -0800 (Thu, 02 Dec 2021)

Log Message

AX Isolated Tree: Document links should be stored in web areas, not the root
https://bugs.webkit.org/show_bug.cgi?id=233728

Reviewed by Chris Fleizach.

Source/WebCore:

In WebAccessibilityObjectWrapperMac.mm, we expose the document links attribute (AXLinkUIElements)
on web areas. However, in AXIsolatedObject::initializeAttributeData we currently only store
AXPropertyName::DocumentLinks for the root element, which is not a web area.

In this patch, we store document links for web area elements instead
of the root element.

This patch fixes accessibility/visible-elements.html, which tests document links.

https://github.com/WebKit/WebKit/blob/109c8234854a0fa28955d81994bb98daa1fa14fe/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm#L2235#L2237

* accessibility/isolatedtree/AXIsolatedObject.cpp:
(WebCore::AXIsolatedObject::initializeAttributeData):

LayoutTests:

* accessibility/visible-elements.html:
* accessibility/visible-elements-expected.txt:
Make this test async so it passes in isolated tree mode.
This test must be async because it includes JS that dynamically
changes page content.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (286425 => 286426)


--- trunk/LayoutTests/ChangeLog	2021-12-02 15:21:12 UTC (rev 286425)
+++ trunk/LayoutTests/ChangeLog	2021-12-02 15:25:52 UTC (rev 286426)
@@ -1,3 +1,16 @@
+2021-12-02  Tyler Wilcock  <tyle...@apple.com>
+
+        AX Isolated Tree: Document links should be stored in web areas, not the root
+        https://bugs.webkit.org/show_bug.cgi?id=233728
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/visible-elements.html:
+        * accessibility/visible-elements-expected.txt:
+        Make this test async so it passes in isolated tree mode.
+        This test must be async because it includes JS that dynamically
+        changes page content.
+
 2021-12-02  Kimmo Kinnunen  <kkinnu...@apple.com>
 
         GraphicsContextGLANGLE should not have Cocoa Mac specific display reconfiguration code

Modified: trunk/LayoutTests/accessibility/visible-elements-expected.txt (286425 => 286426)


--- trunk/LayoutTests/accessibility/visible-elements-expected.txt	2021-12-02 15:21:12 UTC (rev 286425)
+++ trunk/LayoutTests/accessibility/visible-elements-expected.txt	2021-12-02 15:25:52 UTC (rev 286426)
@@ -1,3 +1,16 @@
+This test ensures that document links appropriately respect a link's visibility.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS initialDocumentLinks.includes('#first-link') is true
+PASS initialDocumentLinks.includes('#second-link') is false
+PASS numberOfSubstringOccurences(initialDocumentLinks, 'AXRole: AXLink') is 1
+PASS finalDocumentLinks.includes('#first-link') is true
+PASS finalDocumentLinks.includes('#second-link') is true
+PASS numberOfSubstringOccurences(finalDocumentLinks, 'AXRole: AXLink') is 2
+PASS successfullyParsed is true
+
+TEST COMPLETE
 more
 hello
-PASS

Modified: trunk/LayoutTests/accessibility/visible-elements.html (286425 => 286426)


--- trunk/LayoutTests/accessibility/visible-elements.html	2021-12-02 15:21:12 UTC (rev 286425)
+++ trunk/LayoutTests/accessibility/visible-elements.html	2021-12-02 15:25:52 UTC (rev 286426)
@@ -1,40 +1,45 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
 <html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+
+<a href=""
+<div id="hidden-div" style="visibility: hidden; left: 0px;"><a href=""
+    
 <script>
-    if (window.testRunner)
-        testRunner.dumpAsText();
+    description("This test ensures that document links appropriately respect a link's visibility.")
 
-</script>
-<body id="body">
-    <!-- This test ensures that a plugin that is not accessible, will not appear in the AX hierachy-->
+    function numberOfSubstringOccurences(string, substring) {
+        return string.split(substring).length - 1;
+    }
 
-    <a href=""
-    <div id="hiddenDiv" style="visibility: hidden; left: 0px; "><a href=""
-    
-    <div id="result"></div>
+    if (window.accessibilityController) {
+        window.jsTestIsAsync = true;
 
-     
-    <script>
-        if (window.accessibilityController) {
-            var result = document.getElementById("result");
-
-            var body = document.getElementById("body");
-            body.focus();
-            var links1 = accessibilityController.focusedElement.attributesOfDocumentLinks();
+        var webarea, initialDocumentLinks, finalDocumentLinks;
+        setTimeout(async function() {
+            webarea = accessibilityController.rootElement.childAtIndex(0);
+            initialDocumentLinks = webarea.attributesOfDocumentLinks();
+            shouldBeTrue("initialDocumentLinks.includes('#first-link')")
+            shouldBeFalse("initialDocumentLinks.includes('#second-link')")
+            shouldBe("numberOfSubstringOccurences(initialDocumentLinks, 'AXRole: AXLink')", "1")
  
-            // toggle the div
-            var divElement = document.getElementById("hiddenDiv");
-            divElement.style.visibility = "visible";
+            document.getElementById("hidden-div").style.visibility = "visible";
+            await waitFor(() => {
+                finalDocumentLinks = webarea.attributesOfDocumentLinks();
+                return finalDocumentLinks && initialDocumentLinks != finalDocumentLinks;
+            });
+            shouldBeTrue("finalDocumentLinks.includes('#first-link')")
+            shouldBeTrue("finalDocumentLinks.includes('#second-link')")
+            shouldBe("numberOfSubstringOccurences(finalDocumentLinks, 'AXRole: AXLink')", "2")
 
-            accessibilityController.focusedElement.attributesOfChildren();
-            var links2 = accessibilityController.focusedElement.attributesOfDocumentLinks();
-            if (links1 != links2) {
-                result.innerHTML += "PASS";
-            }
-            else {
-                result.innerHTML += "FAIL - The div's visibility was toggled, but the new link did not appear\n\n";
-                result.innerHTML += "Links1: " + links1 + "\n\nLinks2: " + links2 + "\n\n";
-            }
-        }
-    </script>
+            finishJSTest();
+        }, 0);
+    }
+</script>
 </body>
 </html>
+

Modified: trunk/Source/WebCore/ChangeLog (286425 => 286426)


--- trunk/Source/WebCore/ChangeLog	2021-12-02 15:21:12 UTC (rev 286425)
+++ trunk/Source/WebCore/ChangeLog	2021-12-02 15:25:52 UTC (rev 286426)
@@ -1,3 +1,24 @@
+2021-12-02  Tyler Wilcock  <tyle...@apple.com>
+
+        AX Isolated Tree: Document links should be stored in web areas, not the root
+        https://bugs.webkit.org/show_bug.cgi?id=233728
+
+        Reviewed by Chris Fleizach.
+
+        In WebAccessibilityObjectWrapperMac.mm, we expose the document links attribute (AXLinkUIElements)
+        on web areas. However, in AXIsolatedObject::initializeAttributeData we currently only store
+        AXPropertyName::DocumentLinks for the root element, which is not a web area.
+
+        In this patch, we store document links for web area elements instead
+        of the root element.
+
+        This patch fixes accessibility/visible-elements.html, which tests document links.
+
+        https://github.com/WebKit/WebKit/blob/109c8234854a0fa28955d81994bb98daa1fa14fe/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm#L2235#L2237
+
+        * accessibility/isolatedtree/AXIsolatedObject.cpp:
+        (WebCore::AXIsolatedObject::initializeAttributeData):
+
 2021-12-02  Alexey Shvayka  <ashva...@apple.com>
 
         Add a fast path for empty string to setInnerHTML()

Modified: trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp (286425 => 286426)


--- trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp	2021-12-02 15:21:12 UTC (rev 286425)
+++ trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp	2021-12-02 15:25:52 UTC (rev 286426)
@@ -425,9 +425,12 @@
         setProperty(AXPropertyName::SessionID, object.sessionID().isolatedCopy());
         setProperty(AXPropertyName::DocumentURI, object.documentURI().isolatedCopy());
         setProperty(AXPropertyName::DocumentEncoding, object.documentEncoding().isolatedCopy());
-        setObjectVectorProperty(AXPropertyName::DocumentLinks, object.documentLinks());
     }
 
+    // We only expose document links in web area objects.
+    if (object.isWebArea())
+        setObjectVectorProperty(AXPropertyName::DocumentLinks, object.documentLinks());
+
     if (object.isWidget())
         setProperty(AXPropertyName::IsWidget, true);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to