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

Changeset 285874 in webkit


Ignore:
Timestamp:
Nov 16, 2021, 11:26:36 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

AX: Simplify tests changed in https://bugs.webkit.org/show_bug.cgi?id=233085
https://bugs.webkit.org/show_bug.cgi?id=233167

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

In https://bugs.webkit.org/show_bug.cgi?id=233085 and https://bugs.webkit.org/show_bug.cgi?id=233017,
we made some tests async so that they passed in --release --accessibility-isolated-tree mode. However,
we can make these tests simpler and still pass — i.e., only wait for elements and expressions asynchronously
when it's absolutely necessary.

  • accessibility/color-well.html:
  • accessibility/mac/header-expected.txt:
  • accessibility/mac/header.html:
  • accessibility/mac/scrollbars.html:
  • accessibility/placeholder.html:
  • accessibility/progressbar.html:
  • accessibility/range-alter-by-percent-expected.txt:
  • accessibility/range-alter-by-percent.html:
  • accessibility/range-alter-by-step-expected.txt:
  • accessibility/range-alter-by-step.html:
  • accessibility/spinbutton-value-expected.txt:
  • accessibility/spinbutton-value.html:

Simplify these tests by only use async waiting when
necessary (i.e. dynamic mutation via JS)

  • resources/accessibility-helper.js:

(async expectAsyncExpression):
(async waitForExpression): Renamed to expectAsyncExpression.

Location:
trunk/LayoutTests
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r285857 r285874  
     12021-11-16  Tyler Wilcock  <tyler_w@apple.com>
     2
     3        AX: Simplify tests changed in https://bugs.webkit.org/show_bug.cgi?id=233085
     4        https://bugs.webkit.org/show_bug.cgi?id=233167
     5
     6        Reviewed by Andres Gonzalez.
     7
     8        In https://bugs.webkit.org/show_bug.cgi?id=233085 and https://bugs.webkit.org/show_bug.cgi?id=233017,
     9        we made some tests async so that they passed in --release --accessibility-isolated-tree mode. However,
     10        we can make these tests simpler and still pass — i.e., only wait for elements and expressions asynchronously
     11        when it's absolutely necessary.
     12
     13        * accessibility/color-well.html:
     14        * accessibility/mac/header-expected.txt:
     15        * accessibility/mac/header.html:
     16        * accessibility/mac/scrollbars.html:
     17        * accessibility/placeholder.html:
     18        * accessibility/progressbar.html:
     19        * accessibility/range-alter-by-percent-expected.txt:
     20        * accessibility/range-alter-by-percent.html:
     21        * accessibility/range-alter-by-step-expected.txt:
     22        * accessibility/range-alter-by-step.html:
     23        * accessibility/spinbutton-value-expected.txt:
     24        * accessibility/spinbutton-value.html:
     25        Simplify these tests by only use async waiting when
     26        necessary (i.e. dynamic mutation via JS)
     27
     28        * resources/accessibility-helper.js:
     29        (async expectAsyncExpression):
     30        (async waitForExpression): Renamed to expectAsyncExpression.
     31
    1322021-11-16  Commit Queue  <commit-queue@webkit.org>
    233
  • trunk/LayoutTests/accessibility/color-well.html

    r285778 r285874  
    1515
    1616    if (window.accessibilityController) {
    17         window.jsTestIsAsync = true;
     17        let axColorwell = accessibilityController.accessibleElementById("empty_colorwell");
     18        debug("Role of input type=color is: " + axColorwell.role);
     19        debug("Value of empty color well: " + axColorwell.stringValue);
    1820
    19         setTimeout(async function() {
    20             let axColorwell = await waitForElementById("empty_colorwell");
    21             debug("Role of input type=color is: " + axColorwell.role);
    22             debug("Value of empty color well: " + axColorwell.stringValue);
     21        axColorwell = accessibilityController.accessibleElementById("good_colorwell");
     22        debug("Value of good color well: " + axColorwell.stringValue);
    2323
    24             axColorwell = await waitForElementById("good_colorwell");
    25             debug("Value of good color well: " + axColorwell.stringValue);
    26 
    27             axColorwell = await waitForElementById("bad_colorwell");
    28             debug("Value of bad color well: " + axColorwell.stringValue);
    29 
    30             finishJSTest();
    31         }, 0);
     24        axColorwell = accessibilityController.accessibleElementById("bad_colorwell");
     25        debug("Value of bad color well: " + axColorwell.stringValue);
    3226    }
    3327</script>
  • trunk/LayoutTests/accessibility/mac/header-expected.txt

    r285776 r285874  
    1 PASS accessibilityController.focusedElement.role is "AXRole: AXGroup"
    2 PASS accessibilityController.focusedElement.roleDescription is "AXRoleDescription: banner"
    3 PASS accessibilityController.focusedElement.role is "AXRole: AXGroup"
    4 PASS accessibilityController.focusedElement.roleDescription is "AXRoleDescription: group"
    5 PASS accessibilityController.focusedElement.role is "AXRole: AXGroup"
    6 PASS accessibilityController.focusedElement.roleDescription is "AXRoleDescription: group"
     1PASS accessibilityController.accessibleElementById("header01").role is "AXRole: AXGroup"
     2PASS accessibilityController.accessibleElementById("header01").roleDescription is "AXRoleDescription: banner"
     3PASS accessibilityController.accessibleElementById("header02").role is "AXRole: AXGroup"
     4PASS accessibilityController.accessibleElementById("header02").roleDescription is "AXRoleDescription: group"
     5PASS accessibilityController.accessibleElementById("header03").role is "AXRole: AXGroup"
     6PASS accessibilityController.accessibleElementById("header03").roleDescription is "AXRoleDescription: group"
    77PASS successfullyParsed is true
    88
  • trunk/LayoutTests/accessibility/mac/header.html

    r285776 r285874  
    1616
    1717<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);
     18    function expectRole(expectedRole, expectedDescription, id) {
     19        shouldBeEqualToString(`accessibilityController.accessibleElementById("${id}").role`, `AXRole: ${expectedRole}`);
     20        shouldBeEqualToString(`accessibilityController.accessibleElementById("${id}").roleDescription`, `AXRoleDescription: ${expectedDescription}`);
    2821    }
    2922
    3023    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);
     24        expectRole("AXGroup", "banner", "header01");
     25        expectRole("AXGroup", "group", "header02");
     26        expectRole("AXGroup", "group", "header03");
    4027    }
    4128</script>
  • trunk/LayoutTests/accessibility/mac/scrollbars.html

    r285778 r285874  
    2121        setTimeout(async function() {
    2222            // Iterate up from the body AX element to the scrollarea AX element.
    23             let maybeScrollArea = (await waitForElementById("body")).parentElement();
     23            let maybeScrollArea = scrollArea = accessibilityController.accessibleElementById("body");
     24            while (maybeScrollArea) {
     25                if (maybeScrollArea.role === "AXRole: AXScrollArea") {
     26                    scrollArea = maybeScrollArea;
     27                    break;
     28                }
     29                maybeScrollArea = maybeScrollArea.parentElement();
     30            }
     31
     32            // Wait for scrollbar to be created.
    2433            await waitFor(() => {
    25                 if (maybeScrollArea && maybeScrollArea.role === "AXRole: AXScrollArea") {
    26                     scrollArea = maybeScrollArea;
    27                     return true;
    28                 }
    29 
    30                 maybeScrollArea = maybeScrollArea.parentElement();
    31                 return false;
     34                return scrollArea.verticalScrollbar;
    3235            });
    3336
  • trunk/LayoutTests/accessibility/placeholder.html

    r285778 r285874  
    1919    description("This test makes sure that the placeholder is returned as the correct attribute");
    2020
    21     var fieldElement, passwordElement, searchElement, textInput;
    2221    if (window.accessibilityController) {
    23         window.jsTestIsAsync = true;
     22        var fieldElement = accessibilityController.accessibleElementById("searchterm");
     23        shouldBe("fieldElement.stringAttributeValue('AXPlaceholderValue')", "'search'");
    2424
    25         setTimeout(async function() {
    26             fieldElement = await waitForElementById("searchterm");
    27             shouldBe("fieldElement.stringAttributeValue('AXPlaceholderValue')", "'search'");
     25        var passwordElement = accessibilityController.accessibleElementById("password");
     26        shouldBe("passwordElement.stringAttributeValue('AXPlaceholderValue')", "'Password'");
    2827
    29             passwordElement = await waitForElementById("password");
    30             shouldBe("passwordElement.stringAttributeValue('AXPlaceholderValue')", "'Password'");
    31            
    32             searchElement = await waitForElementById("search");
    33             shouldBe("searchElement.stringAttributeValue('AXPlaceholderValue')", "'MM-DD-YYYY'");
    34            
    35             // When the placeholder and aria-placeholder attributes are both present, use the placeholder
    36             // attribute's value.
    37             textInput = await waitForElementById("input");
    38             shouldBe("textInput.stringAttributeValue('AXPlaceholderValue')", "'Fill in the blank'");
     28        var searchElement = accessibilityController.accessibleElementById("search");
     29        shouldBe("searchElement.stringAttributeValue('AXPlaceholderValue')", "'MM-DD-YYYY'");
    3930
    40             finishJSTest();
    41         }, 0);
     31        // When the placeholder and aria-placeholder attributes are both present, use the placeholder attribute's value.
     32        var textInput = accessibilityController.accessibleElementById("input");
     33        shouldBe("textInput.stringAttributeValue('AXPlaceholderValue')", "'Fill in the blank'");
    4234    }
    4335</script>
  • trunk/LayoutTests/accessibility/progressbar.html

    r285778 r285874  
    1818    var progressbar1, progressbar2, progressbar3, progressbar4;
    1919    if (window.accessibilityController) {
    20         window.jsTestIsAsync = true;
     20        // ARIA determinate progressbar
     21        progressbar1 = accessibilityController.accessibleElementById("progressbar1");
     22        shouldBe("progressbar1.intValue", "7");
    2123
    22         setTimeout(async function() {
    23             // ARIA determinate progressbar
    24             progressbar1 = await waitForElementById("progressbar1");
    25             await waitForExpression(progressbar1, "intValue", 7);
    26             shouldBe("progressbar1.intValue", "7");
     24        // ARIA indeterminate progressbar
     25        progressbar2 = accessibilityController.accessibleElementById("progressbar2");
     26        shouldBe("progressbar2.intValue", "5");
    2727
    28             // ARIA indeterminate progressbar
    29             progressbar2 = await waitForElementById("progressbar2");
    30             await waitForExpression(progressbar2, "intValue", 5);
    31             shouldBe("progressbar2.intValue", "5");
     28        // Determinate progress element
     29        progressbar3 = accessibilityController.accessibleElementById("progressbar3");
     30        shouldBe("progressbar3.intValue", "7");
     31        shouldBe("progressbar3.role", "'AXRole: AXProgressIndicator'");
    3232
    33             // Determinate progress element
    34             progressbar3 = await waitForElementById("progressbar3");
    35             await waitForExpression(progressbar3, "intValue", 7);
    36             shouldBe("progressbar3.intValue", "7");
    37             shouldBe("progressbar3.role", "'AXRole: AXProgressIndicator'");
    38 
    39             // Indeterminate progress element
    40             progressbar4 = await waitForElementById("progressbar4");
    41             await waitForExpression(progressbar4, "intValue", 0);
    42             shouldBe("progressbar4.intValue", "0");
    43             shouldBe("progressbar4.role", "'AXRole: AXProgressIndicator'");
    44 
    45             finishJSTest();
    46         }, 0);
     33        // Indeterminate progress element
     34        progressbar4 = accessibilityController.accessibleElementById("progressbar4");
     35        shouldBe("progressbar4.intValue", "0");
     36        shouldBe("progressbar4.role", "'AXRole: AXProgressIndicator'");
    4737    }
    4838</script>
  • trunk/LayoutTests/accessibility/range-alter-by-percent-expected.txt

    r285778 r285874  
    55
    66PASS largeRange.intValue is 50
    7 PASS largeRange.intValue is 55
    8 PASS largeRange.intValue is 60
    9 PASS largeRange.intValue is 55
    10 PASS largeRange.intValue is 50
     7PASS largeRange.intValue === 55
     8PASS largeRange.intValue === 60
     9PASS largeRange.intValue === 55
     10PASS largeRange.intValue === 50
    1111PASS smallRange.intValue is 5
    12 PASS smallRange.intValue is 6
    13 PASS smallRange.intValue is 7
    14 PASS smallRange.intValue is 6
    15 PASS smallRange.intValue is 5
     12PASS smallRange.intValue === 6
     13PASS smallRange.intValue === 7
     14PASS smallRange.intValue === 6
     15PASS smallRange.intValue === 5
    1616PASS successfullyParsed is true
    1717
  • trunk/LayoutTests/accessibility/range-alter-by-percent.html

    r285778 r285874  
    2424
    2525        setTimeout(async function() {
    26             largeRange = await waitForElementById("largeRange");
    27             await waitForExpression(largeRange, "intValue", 50);
    28             shouldBe("largeRange.intValue", "50");
    29             largeRange.increment();
    30             await waitForExpression(largeRange, "intValue", 55);
    31             shouldBe("largeRange.intValue", "55");
    32             largeRange.increment();
    33             await waitForExpression(largeRange, "intValue", 60);
    34             shouldBe("largeRange.intValue", "60");
    35             largeRange.decrement();
    36             await waitForExpression(largeRange, "intValue", 55);
    37             shouldBe("largeRange.intValue", "55");
    38             largeRange.decrement();
    39             await waitForExpression(largeRange, "intValue", 50);
     26            largeRange = accessibilityController.accessibleElementById("largeRange");
    4027            shouldBe("largeRange.intValue", "50");
    4128
    42             smallRange = await waitForElementById("smallRange");
    43             await waitForExpression(smallRange, "intValue", 5);
     29            largeRange.increment();
     30            await expectAsyncExpression("largeRange.intValue", 55);
     31
     32            largeRange.increment();
     33            await expectAsyncExpression("largeRange.intValue", 60);
     34
     35            largeRange.decrement();
     36            await expectAsyncExpression("largeRange.intValue", 55);
     37
     38            largeRange.decrement();
     39            await expectAsyncExpression("largeRange.intValue", 50);
     40
     41            smallRange = accessibilityController.accessibleElementById("smallRange");
    4442            shouldBe("smallRange.intValue", "5");
     43
    4544            smallRange.increment();
    46             await waitForExpression(smallRange, "intValue", 6);
    47             shouldBe("smallRange.intValue", "6");
     45            await expectAsyncExpression("smallRange.intValue", 6);
     46
    4847            smallRange.increment();
    49             await waitForExpression(smallRange, "intValue", 7);
    50             shouldBe("smallRange.intValue", "7");
     48            await expectAsyncExpression("smallRange.intValue", 7);
     49
    5150            smallRange.decrement();
    52             await waitForExpression(smallRange, "intValue", 6);
    53             shouldBe("smallRange.intValue", "6");
     51            await expectAsyncExpression("smallRange.intValue", 6);
     52
    5453            smallRange.decrement();
    55             await waitForExpression(smallRange, "intValue", 5);
    56             shouldBe("smallRange.intValue", "5");
     54            await expectAsyncExpression("smallRange.intValue", 5);
    5755
    5856            finishJSTest();
  • trunk/LayoutTests/accessibility/range-alter-by-step-expected.txt

    r285778 r285874  
    55
    66PASS rangeInput.intValue is 25
    7 PASS rangeInput.intValue is 50
    8 PASS rangeInput.intValue is 75
    9 PASS rangeInput.intValue is 100
    10 PASS rangeInput.intValue is 100
    11 PASS rangeInput.intValue is 75
    12 PASS rangeInput.intValue is 50
    13 PASS rangeInput.intValue is 25
    14 PASS rangeInput.intValue is 0
    15 PASS rangeInput.intValue is 0
     7PASS rangeInput.intValue === 50
     8PASS rangeInput.intValue === 75
     9PASS rangeInput.intValue === 100
     10PASS rangeInput.intValue === 100
     11PASS rangeInput.intValue === 75
     12PASS rangeInput.intValue === 50
     13PASS rangeInput.intValue === 25
     14PASS rangeInput.intValue === 0
     15PASS rangeInput.intValue === 0
    1616PASS successfullyParsed is true
    1717
  • trunk/LayoutTests/accessibility/range-alter-by-step.html

    r285778 r285874  
    1313
    1414    var rangeInput;
    15     async function waitForAndExpectIntValue(expectedIntValue) {
    16         await waitForExpression(rangeInput, "intValue", expectedIntValue);
    17         shouldBe("rangeInput.intValue", `${expectedIntValue}`)
    18     }
    19 
    2015    if (window.accessibilityController) {
    2116        window.jsTestIsAsync = true;
     
    2419            // ARIA determinate progressbar
    2520            rangeInput = await waitForElementById("rangeInput");
    26             await waitForAndExpectIntValue(25);
     21            shouldBe("rangeInput.intValue", "25");
    2722
    2823            rangeInput.increment();
    29             await waitForAndExpectIntValue(50);
     24            await expectAsyncExpression("rangeInput.intValue", 50);
    3025
    3126            rangeInput.increment();
    32             await waitForAndExpectIntValue(75);
     27            await expectAsyncExpression("rangeInput.intValue", 75);
    3328
    3429            rangeInput.increment();
    35             await waitForAndExpectIntValue(100);
     30            await expectAsyncExpression("rangeInput.intValue", 100);
    3631
    3732            rangeInput.increment();
    38             await waitForAndExpectIntValue(100);
     33            await expectAsyncExpression("rangeInput.intValue", 100);
    3934
    4035            rangeInput.decrement();
    41             await waitForAndExpectIntValue(75);
     36            await expectAsyncExpression("rangeInput.intValue", 75);
    4237
    4338            rangeInput.decrement();
    44             await waitForAndExpectIntValue(50);
     39            await expectAsyncExpression("rangeInput.intValue", 50);
    4540
    4641            rangeInput.decrement();
    47             await waitForAndExpectIntValue(25);
     42            await expectAsyncExpression("rangeInput.intValue", 25);
    4843
    4944            rangeInput.decrement();
    50             await waitForAndExpectIntValue(0);
     45            await expectAsyncExpression("rangeInput.intValue", 0);
    5146
    5247            rangeInput.decrement();
    53             await waitForAndExpectIntValue(0);
     48            await expectAsyncExpression("rangeInput.intValue", 0);
    5449
    5550            finishJSTest();
  • trunk/LayoutTests/accessibility/spinbutton-value-expected.txt

    r285778 r285874  
    44
    55
     6PASS spinbutton.intValue is 5
    67PASS endsWith(spinbutton.intValue, '5') is true
    78PASS endsWith(spinbutton.minValue, '1') is true
  • trunk/LayoutTests/accessibility/spinbutton-value.html

    r285778 r285874  
    2727    var spinbutton, untitledButton;
    2828    if (window.accessibilityController) {
    29         window.jsTestIsAsync = true;
     29        untitledButton = accessibilityController.accessibleElementById("untitledButton");
     30        spinbutton = accessibilityController.accessibleElementById("spinbutton");
     31        shouldBe("spinbutton.intValue", "5");
    3032
    31         setTimeout(async function() {
    32             untitledButton = await waitForElementById("untitledButton");
    33             spinbutton = await waitForElementById("spinbutton");
    34             await waitForExpression(spinbutton, "intValue", 5);
     33        // Test range value attributes.
     34        shouldBe("endsWith(spinbutton.intValue, '5')", "true");
     35        shouldBe("endsWith(spinbutton.minValue, '1')", "true");
     36        shouldBe("endsWith(spinbutton.maxValue, '9')", "true");
     37        shouldBe("endsWith(spinbutton.valueDescription, '5 of 9')", "true");
    3538
    36             // Test range value attributes.
    37             shouldBe("endsWith(spinbutton.intValue, '5')", "true");
    38             shouldBe("endsWith(spinbutton.minValue, '1')", "true");
    39             shouldBe("endsWith(spinbutton.maxValue, '9')", "true");
    40             shouldBe("endsWith(spinbutton.valueDescription, '5 of 9')", "true");
    41 
    42             // Make sure the title doesn't come from the inner text. It should just be empty if
    43             // not otherwise specified.
    44             shouldBe("spinbutton.title", "untitledButton.title");
    45 
    46             finishJSTest();
    47         }, 0);
     39        // Make sure the title doesn't come from the inner text. It should just be empty if
     40        // not otherwise specified.
     41        shouldBe("spinbutton.title", "untitledButton.title");
    4842    }
    4943</script>
  • trunk/LayoutTests/resources/accessibility-helper.js

    r285778 r285874  
    121121}
    122122
    123 async function waitForExpression(element, expression, expectedValue) {
     123async function expectAsyncExpression(expression, expectedValue) {
    124124    if (typeof expression !== "string")
    125125        debug("WARN: The expression arg in waitForExpression() should be a string.");
    126126
     127    const evalExpression = `${expression} === ${expectedValue}`;
    127128    await waitFor(() => {
    128         return eval(`element.${expression} === ${expectedValue}`);
     129        return eval(evalExpression);
    129130    });
     131    debug(`PASS ${evalExpression}`);
    130132}
    131133
Note: See TracChangeset for help on using the changeset viewer.