Title: [187595] trunk/LayoutTests
Revision
187595
Author
commit-qu...@webkit.org
Date
2015-07-30 11:39:42 -0700 (Thu, 30 Jul 2015)

Log Message

aria-liveregions-notifications tests are very flaky
https://bugs.webkit.org/show_bug.cgi?id=147299
<rdar://problem/21998675>

Patch by Nan Wang <n_w...@apple.com> on 2015-07-30
Reviewed by Chris Fleizach.

These tests were flaky because they relied on timer notification callbacks.
Fixed these tests by using different objects to capture the notifications instead.

* platform/mac/TestExpectations:
* platform/mac/accessibility/aria-liveregions-notifications-always-sent-expected.txt:
* platform/mac/accessibility/aria-liveregions-notifications-always-sent.html:
* platform/mac/accessibility/aria-liveregions-notifications-expected.txt:
* platform/mac/accessibility/aria-liveregions-notifications.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (187594 => 187595)


--- trunk/LayoutTests/ChangeLog	2015-07-30 18:36:59 UTC (rev 187594)
+++ trunk/LayoutTests/ChangeLog	2015-07-30 18:39:42 UTC (rev 187595)
@@ -1,3 +1,20 @@
+2015-07-30  Nan Wang  <n_w...@apple.com>
+
+        aria-liveregions-notifications tests are very flaky
+        https://bugs.webkit.org/show_bug.cgi?id=147299
+        <rdar://problem/21998675>
+
+        Reviewed by Chris Fleizach.
+
+        These tests were flaky because they relied on timer notification callbacks.
+        Fixed these tests by using different objects to capture the notifications instead.
+
+        * platform/mac/TestExpectations:
+        * platform/mac/accessibility/aria-liveregions-notifications-always-sent-expected.txt:
+        * platform/mac/accessibility/aria-liveregions-notifications-always-sent.html:
+        * platform/mac/accessibility/aria-liveregions-notifications-expected.txt:
+        * platform/mac/accessibility/aria-liveregions-notifications.html:
+
 2015-07-30  Simon Fraser  <simon.fra...@apple.com>
 
         Selecting in an iframe can cause main page scrolling

Modified: trunk/LayoutTests/platform/mac/TestExpectations (187594 => 187595)


--- trunk/LayoutTests/platform/mac/TestExpectations	2015-07-30 18:36:59 UTC (rev 187594)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2015-07-30 18:39:42 UTC (rev 187595)
@@ -1302,9 +1302,6 @@
 # <rdar://problem/21857102>
 [ ElCapitan+ ] fast/canvas/canvas-too-large-to-draw.html [ Crash ]
 
-webkit.org/b/147299 platform/mac/accessibility/aria-liveregions-notifications-always-sent.html [ Pass Failure ]
-webkit.org/b/147299 platform/mac/accessibility/aria-liveregions-notifications.html [ Pass Failure ]
-
 # rdar://problem/22014672
 [ ElCapitan+ ] imported/w3c/canvas/2d.composite.uncovered.fill.destination-atop.html [ Pass Failure ]
 [ ElCapitan+ ] imported/w3c/canvas/2d.composite.uncovered.fill.destination-in.html [ Pass Failure ]

Modified: trunk/LayoutTests/platform/mac/accessibility/aria-liveregions-notifications-always-sent-expected.txt (187594 => 187595)


--- trunk/LayoutTests/platform/mac/accessibility/aria-liveregions-notifications-always-sent-expected.txt	2015-07-30 18:36:59 UTC (rev 187594)
+++ trunk/LayoutTests/platform/mac/accessibility/aria-liveregions-notifications-always-sent-expected.txt	2015-07-30 18:39:42 UTC (rev 187595)
@@ -1,11 +1,12 @@
-Test test0test1test2
+Test test1
+test2
 This tests that ARIA live region notifications are sent even when an assistive technology is not accessing them directly on each update.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS addedNotification is true
-PASS liveRegionChangeCount == 3 is true
+PASS addedNotification1 is true
+PASS addedNotification2 is true
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/platform/mac/accessibility/aria-liveregions-notifications-always-sent.html (187594 => 187595)


--- trunk/LayoutTests/platform/mac/accessibility/aria-liveregions-notifications-always-sent.html	2015-07-30 18:36:59 UTC (rev 187594)
+++ trunk/LayoutTests/platform/mac/accessibility/aria-liveregions-notifications-always-sent.html	2015-07-30 18:39:42 UTC (rev 187595)
@@ -5,9 +5,10 @@
 </head>
 <body id="body">
 
-<div role="group" tabindex=0 id="liveregion" aria-live="polite" aria-relevant="additions">
+<div role="group" tabindex=0 id="liveregion1" aria-live="polite" aria-relevant="additions">
 Test
 </div>
+<div role="group" tabindex=0 id="liveregion2" aria-live="polite" aria-relevant="additions"></div>
 
 <p id="description"></p>
 <div id="console"></div>
@@ -19,44 +20,43 @@
 
     if (window.accessibilityController) {
 
-        liveRegion = accessibilityController.accessibleElementById("liveregion");
+        var liveRegion1 = accessibilityController.accessibleElementById("liveregion1");
+        var liveRegion2 = accessibilityController.accessibleElementById("liveregion2");
 
-        var liveRegionChangeCount = 0;
-        function ariaCallback(notification) {
+        var liveRegion1Changed = false;
+        var liveRegion2Changed = false;
+        function ariaCallback1(notification) {
            if (notification == "AXLiveRegionChanged") {
-               liveRegionChangeCount++;
+               liveRegion1Changed = true;
+               finishTest();
            }
         }
-        var addedNotification = liveRegion.addNotificationListener(ariaCallback);
-        shouldBe("addedNotification", "true");
+        function ariaCallback2(notification) {
+           if (notification == "AXLiveRegionChanged") {
+               liveRegion2Changed = true;
+               finishTest();
+           }
+        }
 
+        addedNotification1 = liveRegion1.addNotificationListener(ariaCallback1);
+        shouldBe("addedNotification1", "true");
+        addedNotification2 = liveRegion2.addNotificationListener(ariaCallback2);
+        shouldBe("addedNotification2", "true");
+
         // this should trigger our live region callback for a new element.
-        for (var k = 0; k < 3; k++) {
-            // AXLiveRegionsChanged notifications are sent after a delay, so in order to ensure we 
-            // get an notification for each operation we should avoid coalescing which can occur
-            doSetTimeout(k);
+        for (var k = 1; k < 3; k++) {
+            var textNode = document.createTextNode("test" + k);
+            document.getElementById("liveregion" + k).appendChild(textNode);
         }
-
-        // add a short delay to check after all the operations if we have exactly three notificaitons
-        setTimeout("finishTest()", 200);
     }
 
-    function doSetTimeout(k) {
-        setTimeout(function() {
-            operation(k);
-        }, k * 30);
-    }
-
-    function operation(k) {
-        var textNode = document.createTextNode("test" + k);
-        document.getElementById("liveregion").appendChild(textNode);
-    }
-    
     function finishTest() {
-        // We should get a total of three live region changes.
-        liveRegion.removeNotificationListener();
-        shouldBeTrue("liveRegionChangeCount == 3");
-        finishJSTest();
+        // We should get a total of two live region changes.
+        if (liveRegion1Changed && liveRegion2Changed) {
+            liveRegion1.removeNotificationListener();
+            liveRegion2.removeNotificationListener();
+            finishJSTest();
+        }        
     }
 
 </script>

Modified: trunk/LayoutTests/platform/mac/accessibility/aria-liveregions-notifications-expected.txt (187594 => 187595)


--- trunk/LayoutTests/platform/mac/accessibility/aria-liveregions-notifications-expected.txt	2015-07-30 18:36:59 UTC (rev 187594)
+++ trunk/LayoutTests/platform/mac/accessibility/aria-liveregions-notifications-expected.txt	2015-07-30 18:39:42 UTC (rev 187595)
@@ -1,11 +1,16 @@
- new text element
+changed text
+
+new text element
+
 This tests that ARIA live regions are sending out the correct notifications. We perform four operations (add, remove, change text, change alt tag), each one should trigger a live region notification
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS addedNotification is true
-PASS liveRegionChangeCount == 4 is true
+PASS addedNotification1 is true
+PASS addedNotification2 is true
+PASS addedNotification3 is true
+PASS addedNotification4 is true
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/platform/mac/accessibility/aria-liveregions-notifications.html (187594 => 187595)


--- trunk/LayoutTests/platform/mac/accessibility/aria-liveregions-notifications.html	2015-07-30 18:36:59 UTC (rev 187594)
+++ trunk/LayoutTests/platform/mac/accessibility/aria-liveregions-notifications.html	2015-07-30 18:39:42 UTC (rev 187595)
@@ -5,11 +5,21 @@
 </head>
 <body id="body">
 
-<div role="group" tabindex=0 id="liveregion" aria-live="polite" aria-relevant="additions">
-<h3 id="innerlive">text</h3>
+<div role="group" tabindex=0 id="liveregion1" aria-live="polite" aria-relevant="additions">
+<h3 id="innerlive1">text</h3>
+</div>
+
+<div role="group" tabindex=0 id="liveregion2" aria-live="polite" aria-relevant="additions"></div>
+
+<div role="group" tabindex=0 id="liveregion3" aria-live="polite" aria-relevant="additions">
 <img src="" width=100 height=100 alt="alt text" tabindex=0 id="image">
 </div>
 
+<div role="group" tabindex=0 id="liveregion4" aria-live="polite" aria-relevant="additions">
+<h3 id="innerlive2">text</h3>
+</div>
+
+
 <p id="description"></p>
 <div id="console"></div>
 
@@ -18,63 +28,93 @@
 
     description("This tests that ARIA live regions are sending out the correct notifications. We perform four operations (add, remove, change text, change alt tag), each one should trigger a live region notification");
 
-    var liveRegion = 0;
-    var liveRegionChangeCount = 0;
-    function ariaCallback(notification) {
+    var receivedTextChangeNotification = false;
+    var receivedNewElementNotification = false;
+    var receivedAlternativeChangeNotification = false;
+    var receivedRemoveElementNotification = false;
+    
+    // notification callbacks
+    function textChangeCallback(notification) {
         if (notification == "AXLiveRegionChanged") {
-            liveRegionChangeCount++;
+            receivedTextChangeNotification = true;
+            finishTest();
         }
     }
+    function newElementCallback(notification) {
+        if (notification == "AXLiveRegionChanged") {
+            receivedNewElementNotification = true;
+            finishTest();
+        }
+    }
+    function alternativeChangeCallback(notification) {
+        if (notification == "AXLiveRegionChanged") {
+            receivedAlternativeChangeNotification = true;
+            finishTest();
+        }
+    }
+    function removeElementCallback(notification) {
+        if (notification == "AXLiveRegionChanged") {
+            receivedRemoveElementNotification = true;
+            finishTest();
+        }
+    }
 
+    function finishTest() {
+        // We should get a total of four live region changes.
+        if(receivedTextChangeNotification
+           && receivedNewElementNotification
+           && receivedAlternativeChangeNotification
+           && receivedRemoveElementNotification) {
+            liveRegion1.removeNotificationListener();
+            liveRegion2.removeNotificationListener();
+            liveRegion3.removeNotificationListener();
+            liveRegion4.removeNotificationListener();
+            finishJSTest();
+        }
+    }
+
     if (window.accessibilityController) {
 
-        liveRegion = accessibilityController.accessibleElementById("liveregion");
+        liveRegion1 = accessibilityController.accessibleElementById("liveregion1");
+        liveRegion2 = accessibilityController.accessibleElementById("liveregion2");
+        liveRegion3 = accessibilityController.accessibleElementById("liveregion3");
+        liveRegion4 = accessibilityController.accessibleElementById("liveregion4");
 
-        var addedNotification = liveRegion.addNotificationListener(ariaCallback);
-        shouldBe("addedNotification", "true");
+        var addedNotification1 = liveRegion1.addNotificationListener(textChangeCallback);
+        shouldBe("addedNotification1", "true");
+        var addedNotification2 = liveRegion2.addNotificationListener(newElementCallback);
+        shouldBe("addedNotification2", "true");
+        var addedNotification3 = liveRegion3.addNotificationListener(alternativeChangeCallback);
+        shouldBe("addedNotification3", "true");
+        var addedNotification4 = liveRegion4.addNotificationListener(removeElementCallback);
+        shouldBe("addedNotification4", "true");
 
-        // AXLiveRegionsChanged notifications are sent after a delay, so in order to ensure we 
-        // get an notification for each operation we should avoid coalescing which can occur
-        setTimeout("textChangeOperation()", 0);
-        setTimeout("newElementOperation()", 30);
-        setTimeout("alternativeChangeOperation()", 60);
-        setTimeout("removeElementOperation()", 90);
-
-        // add a short delay to check after all the operations if we have exactly four notificaitons
-        setTimeout("finishTest()", 200);
+        textChangeOperation();
+        newElementOperation();
+        alternativeChangeOperation();
+        removeElementOperation();
     }
 
     function textChangeOperation() {
         // this should trigger our live region callback for a text change.
-        document.getElementById("liveregion").childNodes[0].innerText = "changed text";
+        document.getElementById("innerlive1").innerText = "changed text";
     }
 
     function newElementOperation() {
         // this should trigger our live region callback for a new element.
-        document.getElementById("liveregion").innerHTML += "new text element";
+        document.getElementById("liveregion2").innerHTML += "new text element";
     }
 
     function alternativeChangeOperation() {
         // this should also trigger our live region change because its a text alternative change. 
         document.getElementById("image").setAttribute('alt', "new image text");
-
-        // Access the accessibility tree here because AX won't post the live region change
-        // notification twice when the children have already been marked as dirty.
-        liveRegion.childAtIndex(0);
     }
 
     function removeElementOperation() {
         // this should trigger our live region callback for a removed element.
-        document.getElementById("liveregion").removeChild(document.getElementById("innerlive")); 
+        document.getElementById("liveregion4").removeChild(document.getElementById("innerlive2")); 
     }
 
-    function finishTest() {
-        // We should get a total of four live region changes.
-        liveRegion.removeNotificationListener();
-        shouldBeTrue("liveRegionChangeCount == 4");
-        finishJSTest();
-    }
-
 </script>
 
 <script src=""
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to