Commit 703d577a authored by Mark Schillaci's avatar Mark Schillaci Committed by Chromium LUCI CQ

Remove LONG_CLICK action from a11y nodes on Android


This CL updates the AccessibilityNodeInfo object actions on Android.

With this CL we partially revert the work done here:

crrev.com/c/2341398

We will no longer add the LONG_CLICK action to all nodes in Android,
however we will continue to process LONG_CLICK's sent to performAction.


AX-Relnotes: Elements may not explicitly announce they are long clickable on Android
Change-Id: I115d29b5288df45de7a800523a9c074237b233b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2583142Reviewed-by: default avatarMark Schillaci <mschillaci@google.com>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: Mark Schillaci <mschillaci@google.com>
Cr-Commit-Position: refs/heads/master@{#835726}
parent 14dbc848
......@@ -1455,7 +1455,9 @@ public class WebContentsAccessibilityImpl extends AccessibilityNodeProvider
addAction(node, AccessibilityNodeInfo.ACTION_PREVIOUS_HTML_ELEMENT);
addAction(node, ACTION_SHOW_ON_SCREEN);
addAction(node, ACTION_CONTEXT_CLICK);
addAction(node, AccessibilityNodeInfo.ACTION_LONG_CLICK);
// We choose to not add ACTION_LONG_CLICK to nodes to prevent verbose utterances.
// addAction(node, AccessibilityNodeInfo.ACTION_LONG_CLICK);
if (hasNonEmptyInnerText) {
addAction(node, AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY);
......
......@@ -20,6 +20,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
import android.view.accessibility.AccessibilityNodeProvider;
import androidx.test.filters.LargeTest;
......@@ -53,6 +54,8 @@ public class WebContentsAccessibilityTest {
private static final String TIMEOUT_ERROR =
"TYPE_ANNOUNCEMENT event not received before timeout.";
private static final String COMBOBOX_ERROR = "expanded combobox announcement was incorrect.";
private static final String LONG_CLICK_ERROR =
"node should not have the ACTION_LONG_CLICK action as an available action";
private interface AccessibilityNodeInfoMatcher {
public boolean matches(AccessibilityNodeInfo node);
......@@ -440,6 +443,31 @@ public class WebContentsAccessibilityTest {
() -> mActivityTestRule.getWebContents().evaluateJavaScriptForTests(method, null));
}
/**
* Ensure we are not adding ACTION_LONG_CLICK to nodes due to verbose utterances issue.
*/
@Test
@MediumTest
public void testAccessibilityNodeInfo_noLongClickAction() {
// Build a simple web page with a node.
String data = "<p>Example paragraph</p>";
mActivityTestRule.launchContentShellWithUrl(UrlUtils.encodeHtmlDataUri(data));
mActivityTestRule.waitForActiveShellToBeDoneLoading();
mNodeProvider = enableAccessibilityAndWaitForNodeProvider();
int textNodeVirtualViewId = waitForNodeWithText(mNodeProvider, "Example paragraph");
mNodeInfo = mNodeProvider.createAccessibilityNodeInfo(textNodeVirtualViewId);
// Assert we have the correct node.
Assert.assertNotNull(mNodeInfo);
Assert.assertEquals("Example paragraph", mNodeInfo.getText().toString());
// Confirm the ACTION_LONG_CLICK action has not been added to the node.
Assert.assertFalse(LONG_CLICK_ERROR,
mNodeInfo.getActionList().contains(
new AccessibilityAction(AccessibilityNodeInfo.ACTION_LONG_CLICK, null)));
}
/**
* Ensure we send an announcement on combobox expansion.
*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment