Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "core/html/HTMLBodyElement.h" | |
| 6 #include "modules/accessibility/AXObjectCacheImpl.h" | |
| 7 #include "web/tests/sim/SimRequest.h" | |
| 8 #include "web/tests/sim/SimTest.h" | |
| 9 | |
| 10 namespace blink { | |
| 11 | |
| 12 namespace { | |
| 13 | |
| 14 class AccessibilityObjectModelTest : public SimTest { | |
|
aboxhall
2017/04/18 05:43:16
If this is ported, what was the original?
dmazzoni
2017/04/18 15:44:00
The three tests here just duplicate existing tests
| |
| 15 public: | |
| 16 AccessibilityObjectModelTest() { | |
| 17 RuntimeEnabledFeatures::setAccessibilityObjectModelEnabled(true); | |
| 18 } | |
| 19 | |
| 20 protected: | |
| 21 AXObjectCacheImpl* AXObjectCache() { | |
| 22 GetDocument().GetSettings()->SetAccessibilityEnabled(true); | |
| 23 return static_cast<AXObjectCacheImpl*>(GetDocument().AxObjectCache()); | |
| 24 } | |
| 25 }; | |
| 26 | |
| 27 TEST_F(AccessibilityObjectModelTest, DOMElementsHaveAnAccessibleNode) { | |
| 28 SimRequest main_resource("https://example.com/", "text/html"); | |
| 29 LoadURL("https://example.com/"); | |
| 30 main_resource.Complete("<button id=\"button\">Click me</button>"); | |
|
esprehn
2017/04/20 19:54:06
id=button, no quotes are needed and it avoids the
dmazzoni
2017/04/21 00:07:35
Done.
| |
| 31 RuntimeEnabledFeatures::setAccessibilityObjectModelEnabled(true); | |
|
bokan
2017/04/20 14:58:33
You already set this to true in the constructor, r
dmazzoni
2017/04/21 00:07:34
Done.
| |
| 32 | |
| 33 String result = ExecuteJavaScript( | |
|
esprehn
2017/04/20 19:54:06
Just do this in C++,
auto* button = GetDocument()
dmazzoni
2017/04/21 00:07:34
Done.
| |
| 34 "String(document.getElementById('button').accessibleNode)"); | |
| 35 EXPECT_EQ("[object AccessibleNode]", result); | |
| 36 } | |
| 37 | |
| 38 TEST_F(AccessibilityObjectModelTest, DOMTextNodesDoNotHaveAnAccessibleNode) { | |
| 39 SimRequest main_resource("https://example.com/", "text/html"); | |
| 40 LoadURL("https://example.com/"); | |
| 41 main_resource.Complete("<button id=\"button\">Click me</button>"); | |
|
esprehn
2017/04/20 19:54:06
the button is not needed, just do "Text node" ?
dmazzoni
2017/04/21 00:07:34
Done.
| |
| 42 RuntimeEnabledFeatures::setAccessibilityObjectModelEnabled(true); | |
|
esprehn
2017/04/20 19:54:06
not needed
dmazzoni
2017/04/21 00:07:35
Done.
| |
| 43 | |
| 44 String result = ExecuteJavaScript( | |
|
esprehn
2017/04/20 19:54:06
Is there a reason not to just do
auto* text = Get
dmazzoni
2017/04/21 00:07:35
Because accessibleNode is not even defined on Node
| |
| 45 "String(document.getElementById('button').firstChild.accessibleNode)"); | |
| 46 EXPECT_EQ("undefined", result); | |
| 47 } | |
| 48 | |
| 49 TEST_F(AccessibilityObjectModelTest, SetAccessibleNodeRole) { | |
| 50 SimRequest main_resource("https://example.com/", "text/html"); | |
| 51 LoadURL("https://example.com/"); | |
| 52 main_resource.Complete("<button id=\"button\">Click me</button>"); | |
| 53 RuntimeEnabledFeatures::setAccessibilityObjectModelEnabled(true); | |
| 54 | |
| 55 ExecuteJavaScript( | |
| 56 "document.getElementById('button').accessibleNode.role = 'slider';"); | |
|
esprehn
2017/04/20 19:54:06
auto* button = GetDocument().getElementById("butto
dmazzoni
2017/04/21 00:07:35
Done.
| |
| 57 | |
| 58 Element* button = GetDocument().GetElementById("button"); | |
| 59 EXPECT_TRUE(button); | |
|
esprehn
2017/04/20 19:54:06
ASSERT_NE(nullptr, button)
the code would crash i
dmazzoni
2017/04/21 00:07:35
Done.
| |
| 60 auto* cache = AXObjectCache(); | |
| 61 EXPECT_TRUE(cache); | |
| 62 | |
| 63 auto* axButton = cache->GetOrCreate(button); | |
| 64 EXPECT_EQ(kSliderRole, axButton->RoleValue()); | |
| 65 } | |
| 66 | |
| 67 } // namespace | |
| 68 | |
| 69 } // namespace blink | |
| OLD | NEW |