Source/WebCore:
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Feb 2019 08:37:26 +0000 (08:37 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Feb 2019 08:37:26 +0000 (08:37 +0000)
When performing AXPress, check to see if the menu list is disabled.
https://bugs.webkit.org/show_bug.cgi?id=193878

Patch by Eric Liang <ericliang@apple.com> on 2019-02-08
Reviewed by Chris Fleizach.

Test: accessibility/mac/press-not-work-for-disabled-menu-list.html

* accessibility/AXObjectCache.h:
* accessibility/AccessibilityMenuList.cpp:
(WebCore::AccessibilityMenuList::press):
* accessibility/mac/AXObjectCacheMac.mm:
(WebCore::AXObjectCache::postPlatformNotification):

LayoutTests:
Check if receive AXPressDidFail notification when performing AXPress action on disabled MenuList.
https://bugs.webkit.org/show_bug.cgi?id=193878

Patch by Eric Liang <ericliang@apple.com> on 2019-02-08
Reviewed by Chris Fleizach.

* accessibility/mac/press-not-work-for-disabled-menu-list.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241190 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/accessibility/mac/press-not-work-for-disabled-menu-list-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/mac/press-not-work-for-disabled-menu-list.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AXObjectCache.h
Source/WebCore/accessibility/AccessibilityMenuList.cpp
Source/WebCore/accessibility/mac/AXObjectCacheMac.mm

index 0fe4df3..03f3244 100644 (file)
@@ -1,3 +1,12 @@
+2019-02-08  Eric Liang  <ericliang@apple.com>
+
+        Check if receive AXPressDidFail notification when performing AXPress action on disabled MenuList.
+        https://bugs.webkit.org/show_bug.cgi?id=193878
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/mac/press-not-work-for-disabled-menu-list.html: Added.
+
 2019-02-07  Devin Rousso  <drousso@apple.com>
 
         PseudoElement created for any ::before/::after selector regardless of whether a content property exists
diff --git a/LayoutTests/accessibility/mac/press-not-work-for-disabled-menu-list-expected.txt b/LayoutTests/accessibility/mac/press-not-work-for-disabled-menu-list-expected.txt
new file mode 100644 (file)
index 0000000..c273ff4
--- /dev/null
@@ -0,0 +1,13 @@
+    
+This tests that menu lists that are disabled will not be triggered by AXPress actions.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Got notification: AXPressDidFail
+Got notification: AXPressDidFail
+Got notification: AXPressDidFail
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/mac/press-not-work-for-disabled-menu-list.html b/LayoutTests/accessibility/mac/press-not-work-for-disabled-menu-list.html
new file mode 100644 (file)
index 0000000..db44d39
--- /dev/null
@@ -0,0 +1,78 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+<div id="content">
+
+<select id="test0" disabled>
+     <option value="1">Cork</option>
+     <option value="2">Cupertino</option>
+     <option value="3">London</option>
+     <option value="4">New York</option>
+     <option value="5">Singapore</option>
+     <option value="6">Tokyo</option>
+</select>
+
+<select id="test1" disabled aria-disabled="false">
+    <option value="1">Cork</option>
+    <option value="2">Cupertino</option>
+    <option value="3">London</option>
+    <option value="4">New York</option>
+    <option value="5">Singapore</option>
+    <option value="6">Tokyo</option>
+</select>
+
+<select id="test2" disabled aria-disabled="true">
+    <option value="1">Cork</option>
+    <option value="2">Cupertino</option>
+    <option value="3">London</option>
+    <option value="4">New York</option>
+    <option value="5">Singapore</option>
+    <option value="6">Tokyo</option>
+</select>
+
+<p id="description"></p>
+<div id="console"></div>
+
+</div>
+
+<script>
+    description("This tests that menu lists that are disabled will not be triggered by AXPress actions.");
+
+    // We don't test for enabled controls because opening menu lists waits on the UI process to display the menu.
+    var numOfTests = 3, notificationCount = 0;
+    var lists = [null, null, null];
+    if (window.accessibilityController) {
+        jsTestIsAsync = true;
+        pressNext(0);
+    }
+
+    function pressNext(testId) {
+        if (testId > numOfTests)
+            return;
+        var menulist = accessibilityController.accessibleElementById("test" + testId);
+        menulist.addNotificationListener(pressListener);
+        menulist.press();
+        lists[testId] = menulist;
+        window.setTimeout(function() {
+            pressNext(testId + 1);
+        }, 0);
+    }
+
+    function pressListener(notification) {
+        if (notification == "AXPressDidFail" || notification == "AXPressDidSucceed")
+            notificationCount++;
+
+        debug("Got notification: " + notification);
+        lists[notificationCount-1].removeNotificationListener(pressListener);
+        if (notificationCount == numOfTests) {
+            finishJSTest();
+        }
+    }
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
index 699d0da..da8d037 100644 (file)
@@ -1,3 +1,18 @@
+2019-02-08  Eric Liang  <ericliang@apple.com>
+
+        When performing AXPress, check to see if the menu list is disabled.
+        https://bugs.webkit.org/show_bug.cgi?id=193878
+
+        Reviewed by Chris Fleizach.
+
+        Test: accessibility/mac/press-not-work-for-disabled-menu-list.html
+
+        * accessibility/AXObjectCache.h:
+        * accessibility/AccessibilityMenuList.cpp:
+        (WebCore::AccessibilityMenuList::press):
+        * accessibility/mac/AXObjectCacheMac.mm:
+        (WebCore::AXObjectCache::postPlatformNotification):
+
 2019-02-07  Devin Rousso  <drousso@apple.com>
 
         PseudoElement created for any ::before/::after selector regardless of whether a content property exists
index d6e7eff..c8afafb 100644 (file)
@@ -291,6 +291,8 @@ public:
         AXRowExpanded,
         AXExpandedChanged,
         AXInvalidStatusChanged,
+        AXPressDidSucceed,
+        AXPressDidFail,
         AXPressedStateChanged,
         AXReadOnlyStatusChanged,
         AXRequiredStatusChanged,
index 6de8673..ef1377b 100644 (file)
@@ -45,15 +45,21 @@ Ref<AccessibilityMenuList> AccessibilityMenuList::create(RenderMenuList* rendere
 bool AccessibilityMenuList::press()
 {
 #if !PLATFORM(IOS_FAMILY)
-    RenderMenuList* menuList = static_cast<RenderMenuList*>(renderer());
-    if (menuList->popupIsVisible())
-        menuList->hidePopup();
-    else
-        menuList->showPopup();
+    auto element = this->element();
+    AXObjectCache::AXNotification notification = AXObjectCache::AXPressDidFail;
+    if (element && !element->isDisabledFormControl() && is<RenderMenuList>(renderer())) {
+        RenderMenuList* menuList = downcast<RenderMenuList>(renderer());
+        if (menuList->popupIsVisible())
+            menuList->hidePopup();
+        else
+            menuList->showPopup();
+        notification = AXObjectCache::AXPressDidSucceed;
+    }
+    if (auto cache = axObjectCache())
+        cache->postNotification(element, notification);
     return true;
-#else
-    return false;
 #endif
+    return false;
 }
 
 void AccessibilityMenuList::addChildren()
index d075550..f652db3 100644 (file)
@@ -346,6 +346,12 @@ void AXObjectCache::postPlatformNotification(AccessibilityObject* obj, AXNotific
         case AXMenuListItemSelected:
             macNotification = (id)kAXMenuItemSelectedNotification;
             break;
+        case AXPressDidSucceed:
+            macNotification = @"AXPressDidSucceed";
+            break;
+        case AXPressDidFail:
+            macNotification = @"AXPressDidFail";
+            break;
         case AXMenuOpened:
             macNotification = (id)kAXMenuOpenedNotification;
             break;