Commit 7c7e0f8d authored by Victor Fei's avatar Victor Fei Committed by Commit Bot

UIA: Upon visibility change, fire UIA_AriaPropertiesPropertyId event

- Implemented firing property changed event for
  UIA_AriaPropertiesPropertyId - hidden upon visibility change
  introduced by aria-hidden and visibility:hidden, accompanied by
  associated browser dump tests.

- Documentation on UI Automation AriaProperties
(see the second table's last column for AriaProperties
properties):
https://docs.microsoft.com/en-us/windows/desktop/WinAuto/uiauto-ariaspecification

Bug: 928949
Change-Id: I7808ba8fe352d515a054027217afc34892b38732
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1659970
Commit-Queue: Victor Fei <vicfei@microsoft.com>
Reviewed-by: default avatarKatie Dektar <katie@chromium.org>
Reviewed-by: default avatarIan Prest <iapres@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#675876}
parent 9636ef3e
...@@ -252,6 +252,7 @@ void BrowserAccessibilityManagerWin::FireGeneratedEvent( ...@@ -252,6 +252,7 @@ void BrowserAccessibilityManagerWin::FireGeneratedEvent(
FireWinAccessibilityEvent(EVENT_OBJECT_SHOW, node); FireWinAccessibilityEvent(EVENT_OBJECT_SHOW, node);
FireUiaStructureChangedEvent(StructureChangeType_ChildAdded, node); FireUiaStructureChangedEvent(StructureChangeType_ChildAdded, node);
} }
aria_properties_events_.insert(node);
break; break;
case ui::AXEventGenerator::Event::IMAGE_ANNOTATION_CHANGED: case ui::AXEventGenerator::Event::IMAGE_ANNOTATION_CHANGED:
FireWinAccessibilityEvent(EVENT_OBJECT_NAMECHANGE, node); FireWinAccessibilityEvent(EVENT_OBJECT_NAMECHANGE, node);
...@@ -463,10 +464,16 @@ void BrowserAccessibilityManagerWin::FireUiaPropertyChangedEvent( ...@@ -463,10 +464,16 @@ void BrowserAccessibilityManagerWin::FireUiaPropertyChangedEvent(
return; return;
if (!ShouldFireEventForNode(node)) if (!ShouldFireEventForNode(node))
return; return;
// Suppress events when |IGNORED_CHANGED|
// Suppress events when |IGNORED_CHANGED| with the exception for firing
// UIA_AriaPropertiesPropertyId-hidden event on non-text node marked as
// ignored.
if (node->HasState(ax::mojom::State::kIgnored) || if (node->HasState(ax::mojom::State::kIgnored) ||
base::Contains(ignored_changed_nodes_, node)) base::Contains(ignored_changed_nodes_, node)) {
return; if (uia_property != UIA_AriaPropertiesPropertyId ||
node->IsTextOnlyObject())
return;
}
// The old value is not used by the system // The old value is not used by the system
VARIANT old_value = {}; VARIANT old_value = {};
......
...@@ -282,6 +282,11 @@ IN_PROC_BROWSER_TEST_P(DumpAccessibilityEventsTest, ...@@ -282,6 +282,11 @@ IN_PROC_BROWSER_TEST_P(DumpAccessibilityEventsTest,
RunEventTest(FILE_PATH_LITERAL("aria-haspopup-changed.html")); RunEventTest(FILE_PATH_LITERAL("aria-haspopup-changed.html"));
} }
IN_PROC_BROWSER_TEST_P(DumpAccessibilityEventsTest,
AccessibilityEventsAriaHiddenChanged) {
RunEventTest(FILE_PATH_LITERAL("aria-hidden-changed.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityEventsTest, IN_PROC_BROWSER_TEST_P(DumpAccessibilityEventsTest,
AccessibilityEventsAriaInvalidChanged) { AccessibilityEventsAriaInvalidChanged) {
RunEventTest(FILE_PATH_LITERAL("aria-invalid-changed.html")); RunEventTest(FILE_PATH_LITERAL("aria-invalid-changed.html"));
...@@ -721,6 +726,11 @@ IN_PROC_BROWSER_TEST_P(DumpAccessibilityEventsTest, ...@@ -721,6 +726,11 @@ IN_PROC_BROWSER_TEST_P(DumpAccessibilityEventsTest,
RunEventTest(FILE_PATH_LITERAL("tbody-focus.html")); RunEventTest(FILE_PATH_LITERAL("tbody-focus.html"));
} }
IN_PROC_BROWSER_TEST_P(DumpAccessibilityEventsTest,
AccessibilityEventsVisibilityHiddenChanged) {
RunEventTest(FILE_PATH_LITERAL("visibility-hidden-changed.html"));
}
// Even with the deflaking in WaitForAccessibilityTreeToContainNodeWithName, // Even with the deflaking in WaitForAccessibilityTreeToContainNodeWithName,
// this test is still flaky on Windows. // this test is still flaky on Windows.
// TODO(aboxhall, dmazzoni, meredithl): re-enable with better fix for above. // TODO(aboxhall, dmazzoni, meredithl): re-enable with better fix for above.
......
EVENT_OBJECT_FOCUS on <li#op1> role=ROLE_SYSTEM_LISTITEM name="Apple" SELECTED,FOCUSED,FOCUSABLE,SELECTABLE PosInSet=1 SetSize=1 EVENT_OBJECT_FOCUS on <li#op1> role=ROLE_SYSTEM_LISTITEM name="Apple" SELECTED,FOCUSED,FOCUSABLE,SELECTABLE PosInSet=1 SetSize=1
EVENT_OBJECT_HIDE on <body> role=BODY EVENT_OBJECT_HIDE on <body> role=BODY INVISIBLE
IA2_EVENT_ACTIVE_DESCENDANT_CHANGED on <input> role=ROLE_SYSTEM_COMBOBOX EXPANDED,FOCUSABLE,HASPOPUP IA2_STATE_EDITABLE,IA2_STATE_SELECTABLE_TEXT,IA2_STATE_SINGLE_LINE,IA2_STATE_SUPPORTS_AUTOCOMPLETION IA2_EVENT_ACTIVE_DESCENDANT_CHANGED on <input> role=ROLE_SYSTEM_COMBOBOX EXPANDED,FOCUSABLE,HASPOPUP IA2_STATE_EDITABLE,IA2_STATE_SELECTABLE_TEXT,IA2_STATE_SINGLE_LINE,IA2_STATE_SUPPORTS_AUTOCOMPLETION
IA2_EVENT_TEXT_INSERTED on <#document> role=ROLE_SYSTEM_DOCUMENT value~=[doc-url] FOCUSABLE new_text={'<obj><obj>' start=0 end=2} IA2_EVENT_TEXT_INSERTED on <#document> role=ROLE_SYSTEM_DOCUMENT value~=[doc-url] FOCUSABLE new_text={'<obj><obj>' start=0 end=2}
IA2_EVENT_TEXT_REMOVED on <#document> role=ROLE_SYSTEM_DOCUMENT value~=[doc-url] FOCUSABLE old_text={'<obj>' start=0 end=1} IA2_EVENT_TEXT_REMOVED on <#document> role=ROLE_SYSTEM_DOCUMENT value~=[doc-url] FOCUSABLE old_text={'<obj>' start=0 end=1}
AriaProperties changed on role=heading, name=Item2
AriaProperties changed on role=heading, name=Item3
AriaProperties changed on role=heading, name=Item4
<!--
@UIA-WIN-DENY:*
@UIA-WIN-ALLOW:AriaProperties*
-->
<!DOCTYPE html>
<html>
<body>
<h4 id="d1">Item1</h4>
<h4 id="d2" aria-hidden="true">Item2</h4>
<h4 id="d3" aria-hidden="false">Item3</h4>
<h4 id="d4" aria-hidden="true">Item4</h4>
<script>
function go() {
// Set aria-hidden from [removed]->false; should not fire an event.
document.getElementById('d1').setAttribute('aria-hidden', 'false');
// Set aria-hidden from true->false; should fire an event.
document.getElementById('d2').setAttribute('aria-hidden', 'false');
// Set aria-hidden from false->true; should fire an event.
document.getElementById('d3').setAttribute('aria-hidden', 'true');
// Set aria-hidden from true->[removed]; should fire an event.
document.getElementById('d4').removeAttribute('aria-hidden');
}
</script>
</body>
</html>
EVENT_OBJECT_HIDE on <div.a> role=DIV level=2 EVENT_OBJECT_HIDE on <div.a> role=DIV INVISIBLE level=2
EVENT_OBJECT_REORDER on <div> role=ROLE_SYSTEM_TOOLBAR IA2_STATE_HORIZONTAL EVENT_OBJECT_REORDER on <div> role=ROLE_SYSTEM_TOOLBAR IA2_STATE_HORIZONTAL
EVENT_OBJECT_SHOW on <div.b> role=ROLE_SYSTEM_GROUPING name="Banner" EVENT_OBJECT_SHOW on <div.b> role=ROLE_SYSTEM_GROUPING name="Banner"
IA2_EVENT_TEXT_INSERTED on <div> role=ROLE_SYSTEM_TOOLBAR IA2_STATE_HORIZONTAL new_text={'<obj>' start=0 end=1} IA2_EVENT_TEXT_INSERTED on <div> role=ROLE_SYSTEM_TOOLBAR IA2_STATE_HORIZONTAL new_text={'<obj>' start=0 end=1}
......
AriaProperties changed on role=link, name=Toggle AriaProperties changed on role=link, name=Toggle
AriaProperties changed on role=list
AriaProperties changed on role=listitem
AriaProperties changed on role=listitem
AriaProperties changed on role=listitem
AriaProperties changed on role=listitem
ExpandCollapseExpandCollapseState changed on role=link, name=Toggle ExpandCollapseExpandCollapseState changed on role=link, name=Toggle
AriaProperties changed on role=heading
AriaProperties changed on role=heading
AriaProperties changed on role=heading, name=Item2
AriaProperties changed on role=heading, name=Item4
<!--
@UIA-WIN-DENY:*
@UIA-WIN-ALLOW:AriaProperties*
-->
<!DOCTYPE html>
<html>
<body>
<h4 id="d1">Item1</h4>
<h4 id="d2" style="visibility: hidden">Item2</h4>
<h4 id="d3" style="visibility: visible">Item3</h4>
<h4 id="d4" style="visibility: hidden">Item4</h4>
<script>
function go() {
// Set style from [none]->visibility: hidden; should fire an event.
document.getElementById('d1').setAttribute('style', 'visibility: hidden');
// Set style from visibility: hidden->visibility: visible; should fire an event.
document.getElementById('d2').setAttribute('style', 'visibility: visible');
// Set style from visibility: visible->visibility: hidden; should fire an event.
document.getElementById('d3').setAttribute('style', 'visibility: hidden');
// Remove style visibility; should fire an event.
document.getElementById('d4').removeAttribute('style');
}
</script>
</body>
</html>
...@@ -733,6 +733,7 @@ bool AXPlatformNodeBase::IsChildOfLeaf() const { ...@@ -733,6 +733,7 @@ bool AXPlatformNodeBase::IsChildOfLeaf() const {
bool AXPlatformNodeBase::IsInvisibleOrIgnored() const { bool AXPlatformNodeBase::IsInvisibleOrIgnored() const {
const AXNodeData& data = GetData(); const AXNodeData& data = GetData();
return data.HasState(ax::mojom::State::kInvisible) || return data.HasState(ax::mojom::State::kInvisible) ||
data.HasState(ax::mojom::State::kIgnored) ||
data.role == ax::mojom::Role::kIgnored; data.role == ax::mojom::Role::kIgnored;
} }
......
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