⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 285776 in webkit


Ignore:
Timestamp:
Nov 13, 2021, 10:38:12 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

AX: Make accessibility/mac/header.html test async to fix it for isolated tree mode
https://bugs.webkit.org/show_bug.cgi?id=233017

Patch by Tyler Wilcock <Tyler Wilcock> on 2021-11-13
Reviewed by Andres Gonzalez.

Tools:

This patch implements the domIdentifier attribute for DumpRenderTree
elements. When making this test async, I wanted to use this attribute,
hence the implementation in this patch.

  • DumpRenderTree/AccessibilityUIElement.cpp:

(domIdentifierCallback): Added.
(AccessibilityUIElement::getJSClass):
Add "domIdentifer" entry to staticValues[].

  • DumpRenderTree/AccessibilityUIElement.h:

Add AccessibilityUIElement::domIdentifier const definition.

  • DumpRenderTree/mac/AccessibilityUIElementMac.mm:

(AccessibilityUIElement::domIdentifier const): Added.

  • DumpRenderTree/ios/AccessibilityUIElementIOS.mm:

(AccessibilityUIElement::domIdentifier const): Added.

  • DumpRenderTree/win/AccessibilityUIElementWin.cpp:

(AccessibilityUIElement::domIdentifier const):Added.

LayoutTests:

This test needs to be made async, as we need to wait for
accessibilityController.focusedElement to be synced with the DOM
focused element before running our expectations. This fixes the
test in isolated tree mode.

  • accessibility/mac/header-expected.txt:

Remove extra newline at end of the file.

  • accessibility/mac/header.html:

Make test async.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r285769 r285776  
     12021-11-13  Tyler Wilcock  <tyler_w@apple.com>
     2
     3        AX: Make accessibility/mac/header.html test async to fix it for isolated tree mode
     4        https://bugs.webkit.org/show_bug.cgi?id=233017
     5
     6        Reviewed by Andres Gonzalez.
     7
     8        This test needs to be made async, as we need to wait for
     9        accessibilityController.focusedElement to be synced with the DOM
     10        focused element before running our expectations. This fixes the
     11        test in isolated tree mode.
     12
     13        * accessibility/mac/header-expected.txt:
     14        Remove extra newline at end of the file.
     15        * accessibility/mac/header.html:
     16        Make test async.
     17
    1182021-11-12  Said Abou-Hallawa  <said@apple.com>
    219
  • trunk/LayoutTests/accessibility/mac/header-expected.txt

    r187799 r285776  
    1111Header inside an article.
    1212Header inside a section.
    13 
  • trunk/LayoutTests/accessibility/mac/header.html

    r187799 r285776  
    1 <html>
     1<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
    22<html>
    33<head>
    4 <script src='../../resources/js-test-pre.js'></script>
     4<script src="../../resources/js-test.js"></script>
     5<script src="../../resources/accessibility-helper.js"></script>
    56</head>
    6 <body id='body'>
    7     <header tabindex='0' id='header01'>Header outside section and article elements.</header>
    8     <article>
    9         <header tabindex='0' id='header02'>Header inside an article.</header>
    10     </article>
    11     <section>
    12         <header tabindex='0' id='header03'>Header inside a section.</header>
    13     </section>
    14     <pre id='result'></pre>
    15     <script>
    16         function log(str) {
    17             var result = document.querySelector('#result');
    18             result.appendChild(document.createTextNode(str));
    19         }
     7<body>
    208
    21         function expectRole(expectedRole, expectedDescription, id) {
    22             if (!window.accessibilityController)
    23                 return;
    24             var el = document.querySelector(id);
    25             el.focus();
    26             shouldBeEqualToString('accessibilityController.focusedElement.role', "AXRole: " + expectedRole);
    27             shouldBeEqualToString('accessibilityController.focusedElement.roleDescription', "AXRoleDescription: " + expectedDescription);
    28         }
     9<header tabindex="0" id="header01">Header outside section and article elements.</header>
     10<article>
     11    <header tabindex="0" id="header02">Header inside an article.</header>
     12</article>
     13<section>
     14    <header tabindex="0" id="header03">Header inside a section.</header>
     15</section>
    2916
    30         expectRole('AXGroup', 'banner', '#header01');
    31         expectRole('AXGroup', 'group', '#header02');
    32         expectRole('AXGroup', 'group', '#header03');
    33     </script>
    34 <script src='../../resources/js-test-post.js'></script>
     17<script>
     18    async function expectRole(expectedRole, expectedDescription, id) {
     19        document.getElementById(id).focus();
     20
     21        await waitFor(() => {
     22            const focusedElement = accessibilityController.focusedElement;
     23            return focusedElement && focusedElement.domIdentifier === id;
     24        });
     25
     26        shouldBeEqualToString("accessibilityController.focusedElement.role", "AXRole: " + expectedRole);
     27        shouldBeEqualToString("accessibilityController.focusedElement.roleDescription", "AXRoleDescription: " + expectedDescription);
     28    }
     29
     30    if (window.accessibilityController) {
     31        window.jsTestIsAsync = true;
     32
     33        setTimeout(async function() {
     34            await expectRole("AXGroup", "banner", "header01");
     35            await expectRole("AXGroup", "group", "header02");
     36            await expectRole("AXGroup", "group", "header03");
     37
     38            finishJSTest();
     39        }, 0);
     40    }
     41</script>
     42
    3543</body>
    3644</html>
     45
  • trunk/Tools/ChangeLog

    r285772 r285776  
     12021-11-13  Tyler Wilcock  <tyler_w@apple.com>
     2
     3        AX: Make accessibility/mac/header.html test async to fix it for isolated tree mode
     4        https://bugs.webkit.org/show_bug.cgi?id=233017
     5
     6        Reviewed by Andres Gonzalez.
     7
     8        This patch implements the `domIdentifier` attribute for DumpRenderTree
     9        elements. When making this test async, I wanted to use this attribute,
     10        hence the implementation in this patch.
     11
     12        * DumpRenderTree/AccessibilityUIElement.cpp:
     13        (domIdentifierCallback): Added.
     14        (AccessibilityUIElement::getJSClass):
     15        Add "domIdentifer" entry to `staticValues[]`.
     16
     17        * DumpRenderTree/AccessibilityUIElement.h:
     18        Add AccessibilityUIElement::domIdentifier const definition.
     19        * DumpRenderTree/mac/AccessibilityUIElementMac.mm:
     20        (AccessibilityUIElement::domIdentifier const): Added.
     21        * DumpRenderTree/ios/AccessibilityUIElementIOS.mm:
     22        (AccessibilityUIElement::domIdentifier const): Added.
     23        * DumpRenderTree/win/AccessibilityUIElementWin.cpp:
     24        (AccessibilityUIElement::domIdentifier const):Added.
     25
    1262021-11-12  Jonathan Bedard  <jbedard@apple.com>
    227
  • trunk/Tools/DumpRenderTree/AccessibilityUIElement.cpp

    r285589 r285776  
    11671167    auto classList = toAXElement(thisObject)->classList();
    11681168    return JSValueMakeString(context, classList.get());
     1169}
     1170
     1171static JSValueRef domIdentifierCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
     1172{
     1173    auto domIdentifier = toAXElement(thisObject)->domIdentifier();
     1174    return JSValueMakeString(context, domIdentifier.get());
    11691175}
    11701176
     
    19461952        { "ariaDropEffects", getARIADropEffectsCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    19471953        { "classList", getClassListCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     1954        { "domIdentifier", domIdentifierCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    19481955        { "isIgnored", isIgnoredCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    19491956        { "speakAs", speakAsCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
  • trunk/Tools/DumpRenderTree/AccessibilityUIElement.h

    r285589 r285776  
    176176    JSRetainPtr<JSStringRef> url();
    177177    JSRetainPtr<JSStringRef> classList() const;
     178    JSRetainPtr<JSStringRef> domIdentifier() const;
    178179
    179180    // CSS3-speech properties.
  • trunk/Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm

    r285589 r285776  
    9595- (NSString *)_accessibilityPhotoDescription;
    9696- (BOOL)accessibilityPerformEscape;
     97- (NSString *)accessibilityDOMIdentifier;
    9798
    9899// TextMarker related
     
    12271228}
    12281229
     1230JSRetainPtr<JSStringRef> AccessibilityUIElement::domIdentifier() const
     1231{
     1232    return [[m_element accessibilityDOMIdentifier] createJSStringRef];
     1233}
     1234
    12291235void AccessibilityUIElement::uiElementArrayAttributeValue(JSStringRef, Vector<AccessibilityUIElement>&) const
    12301236{
  • trunk/Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm

    r285589 r285776  
    3939#import <wtf/cocoa/VectorCocoa.h>
    4040
     41#ifndef NSAccessibilityDOMIdentifierAttribute
     42#define NSAccessibilityDOMIdentifierAttribute @"AXDOMIdentifier"
     43#endif
     44
    4145#ifndef NSAccessibilityOwnsAttribute
    4246#define NSAccessibilityOwnsAttribute @"AXOwns"
     
    656660    id description = descriptionOfValue([m_element accessibilityAttributeValue:NSAccessibilityDescriptionAttribute], m_element.get());
    657661    return concatenateAttributeAndValue(@"AXDescription", description);
     662    END_AX_OBJC_EXCEPTIONS
     663
     664    return nullptr;
     665}
     666
     667JSRetainPtr<JSStringRef> AccessibilityUIElement::domIdentifier() const
     668{
     669    BEGIN_AX_OBJC_EXCEPTIONS
     670    id value = [m_element accessibilityAttributeValue:NSAccessibilityDOMIdentifierAttribute];
     671    if ([value isKindOfClass:[NSString class]])
     672        return [value createJSStringRef];
    658673    END_AX_OBJC_EXCEPTIONS
    659674
  • trunk/Tools/DumpRenderTree/win/AccessibilityUIElementWin.cpp

    r285589 r285776  
    991991}
    992992
     993JSRetainPtr<JSStringRef> AccessibilityUIElement::domIdentifier() const
     994{
     995    // FIXME: implement
     996    return 0;
     997}
     998
    993999unsigned AccessibilityUIElement::selectedChildrenCount() const
    9941000{
Note: See TracChangeset for help on using the changeset viewer.