OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/dom/AccessibleNode.h" | 5 #include "core/dom/AccessibleNode.h" |
| 6 #include "core/dom/AccessibleNodeList.h" |
6 #include "core/html/HTMLBodyElement.h" | 7 #include "core/html/HTMLBodyElement.h" |
7 #include "core/testing/sim/SimRequest.h" | 8 #include "core/testing/sim/SimRequest.h" |
8 #include "core/testing/sim/SimTest.h" | 9 #include "core/testing/sim/SimTest.h" |
9 #include "modules/accessibility/AXObjectCacheImpl.h" | 10 #include "modules/accessibility/AXObjectCacheImpl.h" |
10 #include "modules/accessibility/AXTable.h" | 11 #include "modules/accessibility/AXTable.h" |
11 #include "modules/accessibility/AXTableCell.h" | 12 #include "modules/accessibility/AXTableCell.h" |
12 #include "modules/accessibility/AXTableRow.h" | 13 #include "modules/accessibility/AXTableRow.h" |
13 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" | 14 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
14 | 15 |
15 namespace blink { | 16 namespace blink { |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 ->RoleValue()); | 336 ->RoleValue()); |
336 ASSERT_EQ(kFormRole, sparse_attributes2 | 337 ASSERT_EQ(kFormRole, sparse_attributes2 |
337 .object_attributes[AXObjectAttribute::kAriaDetails] | 338 .object_attributes[AXObjectAttribute::kAriaDetails] |
338 ->RoleValue()); | 339 ->RoleValue()); |
339 ASSERT_EQ(kBannerRole, | 340 ASSERT_EQ(kBannerRole, |
340 sparse_attributes2 | 341 sparse_attributes2 |
341 .object_attributes[AXObjectAttribute::kAriaErrorMessage] | 342 .object_attributes[AXObjectAttribute::kAriaErrorMessage] |
342 ->RoleValue()); | 343 ->RoleValue()); |
343 } | 344 } |
344 | 345 |
| 346 TEST_F(AccessibilityObjectModelTest, LabeledBy) { |
| 347 SimRequest main_resource("https://example.com/", "text/html"); |
| 348 LoadURL("https://example.com/"); |
| 349 main_resource.Complete( |
| 350 "<input id=target aria-labelledby='l1 l2'>" |
| 351 "<label id=l1>Label 1</label>" |
| 352 "<label id=l2>Label 2</label>" |
| 353 "<label id=l3>Label 3</label>"); |
| 354 |
| 355 auto* target = GetDocument().getElementById("target"); |
| 356 auto* l1 = GetDocument().getElementById("l1"); |
| 357 auto* l2 = GetDocument().getElementById("l2"); |
| 358 auto* l3 = GetDocument().getElementById("l3"); |
| 359 |
| 360 HeapVector<Member<Element>> labeled_by; |
| 361 ASSERT_TRUE(AccessibleNode::GetPropertyOrARIAAttribute( |
| 362 target, AOMRelationListProperty::kLabeledBy, labeled_by)); |
| 363 ASSERT_EQ(2U, labeled_by.size()); |
| 364 ASSERT_EQ(l1, labeled_by[0]); |
| 365 ASSERT_EQ(l2, labeled_by[1]); |
| 366 |
| 367 AccessibleNodeList* node_list = target->accessibleNode()->labeledBy(); |
| 368 ASSERT_EQ(nullptr, node_list); |
| 369 |
| 370 node_list = new AccessibleNodeList(); |
| 371 node_list->add(l3->accessibleNode()); |
| 372 target->accessibleNode()->setLabeledBy(node_list); |
| 373 |
| 374 labeled_by.clear(); |
| 375 ASSERT_TRUE(AccessibleNode::GetPropertyOrARIAAttribute( |
| 376 target, AOMRelationListProperty::kLabeledBy, labeled_by)); |
| 377 ASSERT_EQ(1U, labeled_by.size()); |
| 378 ASSERT_EQ(l3, labeled_by[0]); |
| 379 } |
| 380 |
345 } // namespace | 381 } // namespace |
346 | 382 |
347 } // namespace blink | 383 } // namespace blink |
OLD | NEW |