Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1190)

Unified Diff: third_party/WebKit/Source/web/tests/AccessibilityObjectModelTest.cpp

Issue 2805493002: Boolean properties for Accessibility Object Model Phase 1 (Closed)
Patch Set: Back to previous patchset, ready to land Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/accessibility/AXSlider.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/tests/AccessibilityObjectModelTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/AccessibilityObjectModelTest.cpp b/third_party/WebKit/Source/web/tests/AccessibilityObjectModelTest.cpp
index 4e1a3600225dd2fd2290cc142f58ed808b8a05d5..cee1987b9679349e1a4a98122dec9da3d32a2675 100644
--- a/third_party/WebKit/Source/web/tests/AccessibilityObjectModelTest.cpp
+++ b/third_party/WebKit/Source/web/tests/AccessibilityObjectModelTest.cpp
@@ -58,6 +58,79 @@ TEST_F(AccessibilityObjectModelTest, SetAccessibleNodeRole) {
EXPECT_EQ(kSliderRole, axButton->RoleValue());
}
+TEST_F(AccessibilityObjectModelTest, AOMDoesNotReflectARIA) {
+ SimRequest main_resource("https://example.com/", "text/html");
+ LoadURL("https://example.com/");
+ main_resource.Complete("<input id=textbox>");
+
+ // Set ARIA attributes.
+ auto* textbox = GetDocument().getElementById("textbox");
+ ASSERT_NE(nullptr, textbox);
+ textbox->setAttribute("role", "combobox");
+ textbox->setAttribute("aria-label", "Combo");
+ textbox->setAttribute("aria-disabled", "true");
+
+ // Assert that the ARIA attributes affect the AX object.
+ auto* cache = AXObjectCache();
+ ASSERT_NE(nullptr, cache);
+ auto* axTextBox = cache->GetOrCreate(textbox);
+ EXPECT_EQ(kComboBoxRole, axTextBox->RoleValue());
+ AXNameFrom name_from;
+ AXObjectImpl::AXObjectVector name_objects;
+ EXPECT_EQ("Combo", axTextBox->GetName(name_from, &name_objects));
+ EXPECT_FALSE(axTextBox->IsEnabled());
+
+ // The AOM properties should still all be null.
+ EXPECT_EQ(nullptr, textbox->accessibleNode()->role());
+ EXPECT_EQ(nullptr, textbox->accessibleNode()->label());
+ bool is_null = false;
+ EXPECT_FALSE(textbox->accessibleNode()->disabled(is_null));
+ EXPECT_TRUE(is_null);
+}
+
+TEST_F(AccessibilityObjectModelTest, AOMPropertiesCanBeCleared) {
+ SimRequest main_resource("https://example.com/", "text/html");
+ LoadURL("https://example.com/");
+ main_resource.Complete("<input type=button id=button>");
+
+ // Set ARIA attributes.
+ auto* button = GetDocument().getElementById("button");
+ ASSERT_NE(nullptr, button);
+ button->setAttribute("role", "checkbox");
+ button->setAttribute("aria-label", "Check");
+ button->setAttribute("aria-disabled", "true");
+
+ // Assert that the AX object was affected by ARIA attributes.
+ auto* cache = AXObjectCache();
+ ASSERT_NE(nullptr, cache);
+ auto* axButton = cache->GetOrCreate(button);
+ EXPECT_EQ(kCheckBoxRole, axButton->RoleValue());
+ AXNameFrom name_from;
+ AXObjectImpl::AXObjectVector name_objects;
+ EXPECT_EQ("Check", axButton->GetName(name_from, &name_objects));
+ EXPECT_FALSE(axButton->IsEnabled());
+
+ // Now set the AOM properties to override.
+ button->accessibleNode()->setRole("radio");
+ button->accessibleNode()->setLabel("Radio");
+ button->accessibleNode()->setDisabled(false, false);
+
+ // Assert that the AX object was affected by AOM properties.
+ EXPECT_EQ(kRadioButtonRole, axButton->RoleValue());
+ EXPECT_EQ("Radio", axButton->GetName(name_from, &name_objects));
+ EXPECT_TRUE(axButton->IsEnabled());
+
+ // Null the AOM properties.
+ button->accessibleNode()->setRole(g_null_atom);
+ button->accessibleNode()->setLabel(g_null_atom);
+ button->accessibleNode()->setDisabled(false, true);
+
+ // The AX Object should now revert to ARIA.
+ EXPECT_EQ(kCheckBoxRole, axButton->RoleValue());
+ EXPECT_EQ("Check", axButton->GetName(name_from, &name_objects));
+ EXPECT_FALSE(axButton->IsEnabled());
+}
+
} // namespace
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/modules/accessibility/AXSlider.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698