Skip to content

Commit

Permalink
UIA: Re-enable event tests
Browse files Browse the repository at this point in the history
A recent change to the AccessibilityTreeFormatter changed the filename
pattern for UIA test expectation files (from "-win-uia.txt" to
"-uia-win.txt").  However, the change didn't rename the expectation
files for *event* tests, so the event tests were inadvertantly disabled.

1. Renamed the event-test expectation files to match the new pattern.
-- Similarly, change any filter rules (@WIN-DENY, etc.) in the HTML
files to match the new pattern.

2. This exposed a crash in the AccessibilityTreeFormatter on Win7 since
we are now dumping some new trees.
-- We were requesting *all* properties, and UIA on Win7 was crashing
when requesting `LegacyIAccessibleSelection` (on a <SELECT> element).
-- The solution is to request only a subset of all properties.
-- The list currently contains *all* properties, except (1) properties
like `ProcessId` and `RuntimeId`, which are system specific and
shouldn't be in a dump file; and (2) the `LegacyIAccessible` properties,
which are proven problematic on Win7 and which we don't expose anyway.
-- Also removed were properties that are going to be dumped as part of
a pattern (see CL:1521468).

3. A few expectation files needed to be remastered, having diverged
slightly during the time the tests were disabled.

Bug: 928949
Change-Id: I1aa42a9b42882b368ef590035ea926b106c3712c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1518411
Commit-Queue: Ian Prest <iapres@microsoft.com>
Reviewed-by: Dominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#642120}
  • Loading branch information
ijprest authored and Commit Bot committed Mar 19, 2019
1 parent b7cc89d commit 4b5aca3
Show file tree
Hide file tree
Showing 21 changed files with 176 additions and 11 deletions.
167 changes: 164 additions & 3 deletions content/browser/accessibility/accessibility_tree_formatter_uia_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,167 @@ std::string UiaIdentifierToCondensedString(int32_t id) {

namespace content {

// This is the list of interesting properties to dump.
//
// Certain properties are skipped because they are known to cause crashes if the
// underlying pattern isn't implemented (e.g., LegacyIAccessibleSelection will
// crash on Win7 if the LegacyIAccessible pattern isn't implemented).
//
// Other properties aren't interesting in a tree-dump context (e.g., ProcessId).
//
// Finally, certain properties are dumped as part of a pattern, and don't need
// to be dumped a second time here (e.g., Grid*, GridItem*, RangeValue*, etc.).

// static
const long AccessibilityTreeFormatterUia::properties_[] = {
// UIA_RuntimeIdPropertyId // 30000
UIA_BoundingRectanglePropertyId, // 30001
// UIA_ProcessIdPropertyId // 30002
UIA_ControlTypePropertyId, // 30003
UIA_LocalizedControlTypePropertyId, // 30004
UIA_NamePropertyId, // 30005
UIA_AcceleratorKeyPropertyId, // 30006
UIA_AccessKeyPropertyId, // 30007
UIA_HasKeyboardFocusPropertyId, // 30008
UIA_IsKeyboardFocusablePropertyId, // 30009
UIA_IsEnabledPropertyId, // 30010
UIA_AutomationIdPropertyId, // 30011
UIA_ClassNamePropertyId, // 30012
UIA_HelpTextPropertyId, // 30013
UIA_ClickablePointPropertyId, // 30014
UIA_CulturePropertyId, // 30015
UIA_IsControlElementPropertyId, // 30016
UIA_IsContentElementPropertyId, // 30017
UIA_LabeledByPropertyId, // 30018
UIA_IsPasswordPropertyId, // 30019
// UIA_NativeWindowHandlePropertyId // 30020
UIA_ItemTypePropertyId, // 30021
UIA_IsOffscreenPropertyId, // 30022
UIA_OrientationPropertyId, // 30023
UIA_FrameworkIdPropertyId, // 30024
UIA_IsRequiredForFormPropertyId, // 30025
UIA_ItemStatusPropertyId, // 30026
UIA_IsDockPatternAvailablePropertyId, // 30027
UIA_IsExpandCollapsePatternAvailablePropertyId, // 30028
UIA_IsGridItemPatternAvailablePropertyId, // 30029
UIA_IsGridPatternAvailablePropertyId, // 30030
UIA_IsInvokePatternAvailablePropertyId, // 30031
UIA_IsMultipleViewPatternAvailablePropertyId, // 30032
UIA_IsRangeValuePatternAvailablePropertyId, // 30033
UIA_IsScrollPatternAvailablePropertyId, // 30034
UIA_IsScrollItemPatternAvailablePropertyId, // 30035
UIA_IsSelectionItemPatternAvailablePropertyId, // 30036
UIA_IsSelectionPatternAvailablePropertyId, // 30037
UIA_IsTablePatternAvailablePropertyId, // 30038
UIA_IsTableItemPatternAvailablePropertyId, // 30039
UIA_IsTextPatternAvailablePropertyId, // 30040
UIA_IsTogglePatternAvailablePropertyId, // 30041
UIA_IsTransformPatternAvailablePropertyId, // 30042
UIA_IsValuePatternAvailablePropertyId, // 30043
UIA_IsWindowPatternAvailablePropertyId, // 30044
// UIA_Value* // 30045-30046
// UIA_RangeValue* // 30047-30052
// UIA_Scroll* // 30053-30058
UIA_SelectionSelectionPropertyId, // 30059
// UIA_Selection* // 30060-30061
// UIA_Grid* // 30062-30068
UIA_DockDockPositionPropertyId, // 30069
UIA_ExpandCollapseExpandCollapseStatePropertyId, // 30070
UIA_MultipleViewCurrentViewPropertyId, // 30071
UIA_MultipleViewSupportedViewsPropertyId, // 30072
UIA_WindowCanMaximizePropertyId, // 30073
UIA_WindowCanMinimizePropertyId, // 30074
UIA_WindowWindowVisualStatePropertyId, // 30075
UIA_WindowWindowInteractionStatePropertyId, // 30076
// UIA_WindowIsModalPropertyId // 30077
UIA_WindowIsTopmostPropertyId, // 30078
// UIA_SelectionItem* // 30079-30080
UIA_TableRowHeadersPropertyId, // 30081
UIA_TableColumnHeadersPropertyId, // 30082
// UIA_TableRowOrColumnMajorPropertyId // 30083
UIA_TableItemRowHeaderItemsPropertyId, // 30084
UIA_TableItemColumnHeaderItemsPropertyId, // 30085
// UIA_ToggleToggleStatePropertyId // 30086
UIA_TransformCanMovePropertyId, // 30087
UIA_TransformCanResizePropertyId, // 30088
UIA_TransformCanRotatePropertyId, // 30089
UIA_IsLegacyIAccessiblePatternAvailablePropertyId, // 30090
// UIA_LegacyIAccessible* // 30091-30100
UIA_AriaRolePropertyId, // 30101
UIA_AriaPropertiesPropertyId, // 30102
UIA_IsDataValidForFormPropertyId, // 30103
UIA_ControllerForPropertyId, // 30104
UIA_DescribedByPropertyId, // 30105
UIA_FlowsToPropertyId, // 30106
// UIA_ProviderDescriptionPropertyId // 30107
UIA_IsItemContainerPatternAvailablePropertyId, // 30108
UIA_IsVirtualizedItemPatternAvailablePropertyId, // 30109
UIA_IsSynchronizedInputPatternAvailablePropertyId, // 30110
UIA_OptimizeForVisualContentPropertyId, // 30111
UIA_IsObjectModelPatternAvailablePropertyId, // 30112
UIA_AnnotationAnnotationTypeIdPropertyId, // 30113
UIA_AnnotationAnnotationTypeNamePropertyId, // 30114
UIA_AnnotationAuthorPropertyId, // 30115
UIA_AnnotationDateTimePropertyId, // 30116
UIA_AnnotationTargetPropertyId, // 30117
UIA_IsAnnotationPatternAvailablePropertyId, // 30118
UIA_IsTextPattern2AvailablePropertyId, // 30119
UIA_StylesStyleIdPropertyId, // 30120
UIA_StylesStyleNamePropertyId, // 30121
UIA_StylesFillColorPropertyId, // 30122
UIA_StylesFillPatternStylePropertyId, // 30123
UIA_StylesShapePropertyId, // 30124
UIA_StylesFillPatternColorPropertyId, // 30125
UIA_StylesExtendedPropertiesPropertyId, // 30126
UIA_IsStylesPatternAvailablePropertyId, // 30127
UIA_IsSpreadsheetPatternAvailablePropertyId, // 30128
UIA_SpreadsheetItemFormulaPropertyId, // 30129
UIA_SpreadsheetItemAnnotationObjectsPropertyId, // 30130
UIA_SpreadsheetItemAnnotationTypesPropertyId, // 30131
UIA_IsSpreadsheetItemPatternAvailablePropertyId, // 30132
UIA_Transform2CanZoomPropertyId, // 30133
UIA_IsTransformPattern2AvailablePropertyId, // 30134
UIA_LiveSettingPropertyId, // 30135
UIA_IsTextChildPatternAvailablePropertyId, // 30136
UIA_IsDragPatternAvailablePropertyId, // 30137
UIA_DragIsGrabbedPropertyId, // 30138
UIA_DragDropEffectPropertyId, // 30139
UIA_DragDropEffectsPropertyId, // 30140
UIA_IsDropTargetPatternAvailablePropertyId, // 30141
UIA_DropTargetDropTargetEffectPropertyId, // 30142
UIA_DropTargetDropTargetEffectsPropertyId, // 30143
UIA_DragGrabbedItemsPropertyId, // 30144
UIA_Transform2ZoomLevelPropertyId, // 30145
UIA_Transform2ZoomMinimumPropertyId, // 30146
UIA_Transform2ZoomMaximumPropertyId, // 30147
UIA_FlowsFromPropertyId, // 30148
UIA_IsTextEditPatternAvailablePropertyId, // 30149
UIA_IsPeripheralPropertyId, // 30150
UIA_IsCustomNavigationPatternAvailablePropertyId, // 30151
UIA_PositionInSetPropertyId, // 30152
UIA_SizeOfSetPropertyId, // 30153
UIA_LevelPropertyId, // 30154
UIA_AnnotationTypesPropertyId, // 30155
UIA_AnnotationObjectsPropertyId, // 30156
UIA_LandmarkTypePropertyId, // 30157
UIA_LocalizedLandmarkTypePropertyId, // 30158
UIA_FullDescriptionPropertyId, // 30159
UIA_FillColorPropertyId, // 30160
UIA_OutlineColorPropertyId, // 30161
UIA_FillTypePropertyId, // 30162
UIA_VisualEffectsPropertyId, // 30163
UIA_OutlineThicknessPropertyId, // 30164
UIA_CenterPointPropertyId, // 30165
UIA_RotationPropertyId, // 30166
UIA_SizePropertyId, // 30167
UIA_IsSelectionPattern2AvailablePropertyId, // 30168
UIA_Selection2FirstSelectedItemPropertyId, // 30169
UIA_Selection2LastSelectedItemPropertyId, // 30170
UIA_Selection2CurrentSelectedItemPropertyId, // 30171
UIA_Selection2ItemCountPropertyId, // 30172
UIA_HeadingLevelPropertyId, // 30173
};

// static
std::unique_ptr<AccessibilityTreeFormatter>
AccessibilityTreeFormatterUia::CreateUia() {
Expand Down Expand Up @@ -167,7 +328,7 @@ void AccessibilityTreeFormatterUia::AddProperties(
uncached_node->BuildUpdatedCache(element_cache_request_.Get(), &node);

// Get all properties that may be on this node.
for (long i = min_property_id_; i <= max_property_id_; ++i) {
for (long i : properties_) {
base::win::ScopedVariant variant;
if (SUCCEEDED(node->GetCachedPropertyValue(i, variant.Receive()))) {
WriteProperty(i, variant, dict);
Expand Down Expand Up @@ -343,7 +504,7 @@ void AccessibilityTreeFormatterUia::BuildCacheRequests() {
// the process boundary for each call.

// Cache all properties.
for (long i = min_property_id_; i <= max_property_id_; ++i) {
for (long i : properties_) {
element_cache_request_->AddProperty(i);
}
}
Expand All @@ -364,7 +525,7 @@ base::string16 AccessibilityTreeFormatterUia::ProcessTreeForOutput(
UiaIdentifierToStringUTF8(UIA_AriaRolePropertyId), role_value);
}

for (long i = min_property_id_; i <= max_property_id_; ++i) {
for (long i : properties_) {
const std::string attribute_name = UiaIdentifierToCondensedString(i);
const base::Value* value;
if (!dict.Get(attribute_name, &value))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ class AccessibilityTreeFormatterUia : public AccessibilityTreeFormatter {
const base::StringPiece& pattern) override;

private:
const long min_property_id_ = UIA_RuntimeIdPropertyId;
const long max_property_id_ = UIA_HeadingLevelPropertyId;
static const long properties_[];
void RecursiveBuildAccessibilityTree(IUIAutomationElement* node,
base::DictionaryValue* dict);
void BuildCacheRequests();
Expand Down
3 changes: 2 additions & 1 deletion content/test/data/accessibility/event/add-alert.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<!--
@WIN-DENY:*
@WIN-ALLOW:EVENT_SYSTEM_ALERT*
@WIN-ALLOW:SystemAlert*
@UIA-WIN-DENY:*
@UIA-WIN-ALLOW:SystemAlert*
-->
<!DOCTYPE html>
<html>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
AutomationFocusChanged on role=option, name=Apple
SelectionItem_ElementSelected on role=option, name=Apple

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
AutomationFocusChanged on role=option, name=Banana
SelectionItem_ElementSelected on role=option, name=Banana

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
AutomationFocusChanged on role=option, name=Orange
SelectionItem_ElementSelected on role=option, name=Orange

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ EVENT_OBJECT_SELECTION on <option> role=ROLE_SYSTEM_LISTITEM name="Orange" SELEC
EVENT_OBJECT_SELECTIONWITHIN on <select> role=ROLE_SYSTEM_LIST FOCUSABLE IA2_STATE_VERTICAL SetSize=3
EVENT_OBJECT_STATECHANGE on <option> role=ROLE_SYSTEM_LISTITEM name="Apple" FOCUSABLE,SELECTABLE PosInSet=1 SetSize=3
EVENT_OBJECT_STATECHANGE on <option> role=ROLE_SYSTEM_LISTITEM name="Orange" SELECTED,FOCUSED,FOCUSABLE,SELECTABLE PosInSet=2 SetSize=3
IA2_EVENT_ACTIVE_DESCENDANT_CHANGED on <select> role=ROLE_SYSTEM_LIST FOCUSABLE IA2_STATE_VERTICAL SetSize=3
IA2_EVENT_ACTIVE_DESCENDANT_CHANGED on <select> role=ROLE_SYSTEM_LIST FOCUSABLE IA2_STATE_VERTICAL SetSize=3
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
@WIN-ALLOW:EVENT_OBJECT_FOCUS*
@WIN-ALLOW:EVENT_SYSTEM_ALERT*
@WIN-ALLOW:EVENT_OBJECT_LIVE*
@WIN-ALLOW:AutomationFocusChanged*
@UIA-WIN-DENY:*
@UIA-WIN-ALLOW:AutomationFocusChanged*
@MAC-DENY:*
@MAC-ALLOW:AXFocusedUIElementChanged*
@MAC-ALLOW:AXFocusedUIElementChanged*
Expand Down

0 comments on commit 4b5aca3

Please sign in to comment.