| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
| 6 #include "content/common/accessibility_node_data.h" | 6 #include "content/common/accessibility_node_data.h" |
| 7 #include "content/common/view_messages.h" | 7 #include "content/common/view_messages.h" |
| 8 #include "content/public/test/render_view_test.h" | 8 #include "content/public/test/render_view_test.h" |
| 9 #include "content/renderer/accessibility/renderer_accessibility_complete.h" | 9 #include "content/renderer/accessibility/renderer_accessibility_complete.h" |
| 10 #include "content/renderer/render_view_impl.h" | 10 #include "content/renderer/render_view_impl.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "third_party/WebKit/public/platform/WebSize.h" | 12 #include "third_party/WebKit/public/platform/WebSize.h" |
| 13 #include "third_party/WebKit/public/web/WebAXObject.h" | 13 #include "third_party/WebKit/public/web/WebAXObject.h" |
| 14 #include "third_party/WebKit/public/web/WebDocument.h" | 14 #include "third_party/WebKit/public/web/WebDocument.h" |
| 15 #include "third_party/WebKit/public/web/WebView.h" | 15 #include "third_party/WebKit/public/web/WebView.h" |
| 16 | 16 |
| 17 using WebKit::WebAXObject; | 17 using blink::WebAXObject; |
| 18 using WebKit::WebDocument; | 18 using blink::WebDocument; |
| 19 | 19 |
| 20 namespace content { | 20 namespace content { |
| 21 | 21 |
| 22 class TestRendererAccessibilityComplete : public RendererAccessibilityComplete { | 22 class TestRendererAccessibilityComplete : public RendererAccessibilityComplete { |
| 23 public: | 23 public: |
| 24 explicit TestRendererAccessibilityComplete(RenderViewImpl* render_view) | 24 explicit TestRendererAccessibilityComplete(RenderViewImpl* render_view) |
| 25 : RendererAccessibilityComplete(render_view), | 25 : RendererAccessibilityComplete(render_view), |
| 26 browser_tree_node_count_(0) { | 26 browser_tree_node_count_(0) { |
| 27 } | 27 } |
| 28 | 28 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 TEST_F(RendererAccessibilityTest, EditableTextModeFocusEvents) { | 97 TEST_F(RendererAccessibilityTest, EditableTextModeFocusEvents) { |
| 98 // This is not a test of true web accessibility, it's a test of | 98 // This is not a test of true web accessibility, it's a test of |
| 99 // a mode used on Windows 8 in Metro mode where an extremely simplified | 99 // a mode used on Windows 8 in Metro mode where an extremely simplified |
| 100 // accessibility tree containing only the current focused node is | 100 // accessibility tree containing only the current focused node is |
| 101 // generated. | 101 // generated. |
| 102 SetMode(AccessibilityModeEditableTextOnly); | 102 SetMode(AccessibilityModeEditableTextOnly); |
| 103 | 103 |
| 104 // Set a minimum size and give focus so simulated events work. | 104 // Set a minimum size and give focus so simulated events work. |
| 105 view()->webwidget()->resize(WebKit::WebSize(500, 500)); | 105 view()->webwidget()->resize(blink::WebSize(500, 500)); |
| 106 view()->webwidget()->setFocus(true); | 106 view()->webwidget()->setFocus(true); |
| 107 | 107 |
| 108 std::string html = | 108 std::string html = |
| 109 "<body>" | 109 "<body>" |
| 110 " <input>" | 110 " <input>" |
| 111 " <textarea></textarea>" | 111 " <textarea></textarea>" |
| 112 " <p contentEditable>Editable</p>" | 112 " <p contentEditable>Editable</p>" |
| 113 " <div tabindex=0 role=textbox>Textbox</div>" | 113 " <div tabindex=0 role=textbox>Textbox</div>" |
| 114 " <button>Button</button>" | 114 " <button>Button</button>" |
| 115 " <a href=#>Link</a>" | 115 " <a href=#>Link</a>" |
| 116 "</body>"; | 116 "</body>"; |
| 117 | 117 |
| 118 // Load the test page. | 118 // Load the test page. |
| 119 LoadHTML(html.c_str()); | 119 LoadHTML(html.c_str()); |
| 120 | 120 |
| 121 // We should have sent a message to the browser with the initial focus | 121 // We should have sent a message to the browser with the initial focus |
| 122 // on the document. | 122 // on the document. |
| 123 { | 123 { |
| 124 SCOPED_TRACE("Initial focus on document"); | 124 SCOPED_TRACE("Initial focus on document"); |
| 125 AccessibilityHostMsg_EventParams event; | 125 AccessibilityHostMsg_EventParams event; |
| 126 GetLastAccEvent(&event); | 126 GetLastAccEvent(&event); |
| 127 EXPECT_EQ(event.event_type, | 127 EXPECT_EQ(event.event_type, |
| 128 WebKit::WebAXEventLayoutComplete); | 128 blink::WebAXEventLayoutComplete); |
| 129 EXPECT_EQ(event.id, 1); | 129 EXPECT_EQ(event.id, 1); |
| 130 EXPECT_EQ(event.nodes.size(), 2U); | 130 EXPECT_EQ(event.nodes.size(), 2U); |
| 131 EXPECT_EQ(event.nodes[0].id, 1); | 131 EXPECT_EQ(event.nodes[0].id, 1); |
| 132 EXPECT_EQ(event.nodes[0].role, | 132 EXPECT_EQ(event.nodes[0].role, |
| 133 WebKit::WebAXRoleRootWebArea); | 133 blink::WebAXRoleRootWebArea); |
| 134 EXPECT_EQ(event.nodes[0].state, | 134 EXPECT_EQ(event.nodes[0].state, |
| 135 (1U << WebKit::WebAXStateReadonly) | | 135 (1U << blink::WebAXStateReadonly) | |
| 136 (1U << WebKit::WebAXStateFocusable) | | 136 (1U << blink::WebAXStateFocusable) | |
| 137 (1U << WebKit::WebAXStateFocused)); | 137 (1U << blink::WebAXStateFocused)); |
| 138 EXPECT_EQ(event.nodes[0].child_ids.size(), 1U); | 138 EXPECT_EQ(event.nodes[0].child_ids.size(), 1U); |
| 139 } | 139 } |
| 140 | 140 |
| 141 // Now focus the input element, and check everything again. | 141 // Now focus the input element, and check everything again. |
| 142 { | 142 { |
| 143 SCOPED_TRACE("input"); | 143 SCOPED_TRACE("input"); |
| 144 sink_->ClearMessages(); | 144 sink_->ClearMessages(); |
| 145 ExecuteJavaScript("document.querySelector('input').focus();"); | 145 ExecuteJavaScript("document.querySelector('input').focus();"); |
| 146 AccessibilityHostMsg_EventParams event; | 146 AccessibilityHostMsg_EventParams event; |
| 147 GetLastAccEvent(&event); | 147 GetLastAccEvent(&event); |
| 148 EXPECT_EQ(event.event_type, | 148 EXPECT_EQ(event.event_type, |
| 149 WebKit::WebAXEventFocus); | 149 blink::WebAXEventFocus); |
| 150 EXPECT_EQ(event.id, 3); | 150 EXPECT_EQ(event.id, 3); |
| 151 EXPECT_EQ(event.nodes[0].id, 1); | 151 EXPECT_EQ(event.nodes[0].id, 1); |
| 152 EXPECT_EQ(event.nodes[0].role, | 152 EXPECT_EQ(event.nodes[0].role, |
| 153 WebKit::WebAXRoleRootWebArea); | 153 blink::WebAXRoleRootWebArea); |
| 154 EXPECT_EQ(event.nodes[0].state, | 154 EXPECT_EQ(event.nodes[0].state, |
| 155 (1U << WebKit::WebAXStateReadonly) | | 155 (1U << blink::WebAXStateReadonly) | |
| 156 (1U << WebKit::WebAXStateFocusable)); | 156 (1U << blink::WebAXStateFocusable)); |
| 157 EXPECT_EQ(event.nodes[0].child_ids.size(), 1U); | 157 EXPECT_EQ(event.nodes[0].child_ids.size(), 1U); |
| 158 EXPECT_EQ(event.nodes[1].id, 3); | 158 EXPECT_EQ(event.nodes[1].id, 3); |
| 159 EXPECT_EQ(event.nodes[1].role, | 159 EXPECT_EQ(event.nodes[1].role, |
| 160 WebKit::WebAXRoleGroup); | 160 blink::WebAXRoleGroup); |
| 161 EXPECT_EQ(event.nodes[1].state, | 161 EXPECT_EQ(event.nodes[1].state, |
| 162 (1U << WebKit::WebAXStateFocusable) | | 162 (1U << blink::WebAXStateFocusable) | |
| 163 (1U << WebKit::WebAXStateFocused)); | 163 (1U << blink::WebAXStateFocused)); |
| 164 } | 164 } |
| 165 | 165 |
| 166 // Check other editable text nodes. | 166 // Check other editable text nodes. |
| 167 { | 167 { |
| 168 SCOPED_TRACE("textarea"); | 168 SCOPED_TRACE("textarea"); |
| 169 sink_->ClearMessages(); | 169 sink_->ClearMessages(); |
| 170 ExecuteJavaScript("document.querySelector('textarea').focus();"); | 170 ExecuteJavaScript("document.querySelector('textarea').focus();"); |
| 171 AccessibilityHostMsg_EventParams event; | 171 AccessibilityHostMsg_EventParams event; |
| 172 GetLastAccEvent(&event); | 172 GetLastAccEvent(&event); |
| 173 EXPECT_EQ(event.id, 4); | 173 EXPECT_EQ(event.id, 4); |
| 174 EXPECT_EQ(event.nodes[1].state, | 174 EXPECT_EQ(event.nodes[1].state, |
| 175 (1U << WebKit::WebAXStateFocusable) | | 175 (1U << blink::WebAXStateFocusable) | |
| 176 (1U << WebKit::WebAXStateFocused)); | 176 (1U << blink::WebAXStateFocused)); |
| 177 } | 177 } |
| 178 | 178 |
| 179 { | 179 { |
| 180 SCOPED_TRACE("contentEditable"); | 180 SCOPED_TRACE("contentEditable"); |
| 181 sink_->ClearMessages(); | 181 sink_->ClearMessages(); |
| 182 ExecuteJavaScript("document.querySelector('p').focus();"); | 182 ExecuteJavaScript("document.querySelector('p').focus();"); |
| 183 AccessibilityHostMsg_EventParams event; | 183 AccessibilityHostMsg_EventParams event; |
| 184 GetLastAccEvent(&event); | 184 GetLastAccEvent(&event); |
| 185 EXPECT_EQ(event.id, 5); | 185 EXPECT_EQ(event.id, 5); |
| 186 EXPECT_EQ(event.nodes[1].state, | 186 EXPECT_EQ(event.nodes[1].state, |
| 187 (1U << WebKit::WebAXStateFocusable) | | 187 (1U << blink::WebAXStateFocusable) | |
| 188 (1U << WebKit::WebAXStateFocused)); | 188 (1U << blink::WebAXStateFocused)); |
| 189 } | 189 } |
| 190 | 190 |
| 191 { | 191 { |
| 192 SCOPED_TRACE("role=textarea"); | 192 SCOPED_TRACE("role=textarea"); |
| 193 sink_->ClearMessages(); | 193 sink_->ClearMessages(); |
| 194 ExecuteJavaScript("document.querySelector('div').focus();"); | 194 ExecuteJavaScript("document.querySelector('div').focus();"); |
| 195 AccessibilityHostMsg_EventParams event; | 195 AccessibilityHostMsg_EventParams event; |
| 196 GetLastAccEvent(&event); | 196 GetLastAccEvent(&event); |
| 197 EXPECT_EQ(event.id, 6); | 197 EXPECT_EQ(event.id, 6); |
| 198 EXPECT_EQ(event.nodes[1].state, | 198 EXPECT_EQ(event.nodes[1].state, |
| 199 (1U << WebKit::WebAXStateFocusable) | | 199 (1U << blink::WebAXStateFocusable) | |
| 200 (1U << WebKit::WebAXStateFocused)); | 200 (1U << blink::WebAXStateFocused)); |
| 201 } | 201 } |
| 202 | 202 |
| 203 // Try focusing things that aren't editable text. | 203 // Try focusing things that aren't editable text. |
| 204 { | 204 { |
| 205 SCOPED_TRACE("button"); | 205 SCOPED_TRACE("button"); |
| 206 sink_->ClearMessages(); | 206 sink_->ClearMessages(); |
| 207 ExecuteJavaScript("document.querySelector('button').focus();"); | 207 ExecuteJavaScript("document.querySelector('button').focus();"); |
| 208 AccessibilityHostMsg_EventParams event; | 208 AccessibilityHostMsg_EventParams event; |
| 209 GetLastAccEvent(&event); | 209 GetLastAccEvent(&event); |
| 210 EXPECT_EQ(event.id, 7); | 210 EXPECT_EQ(event.id, 7); |
| 211 EXPECT_EQ(event.nodes[1].state, | 211 EXPECT_EQ(event.nodes[1].state, |
| 212 (1U << WebKit::WebAXStateFocusable) | | 212 (1U << blink::WebAXStateFocusable) | |
| 213 (1U << WebKit::WebAXStateFocused) | | 213 (1U << blink::WebAXStateFocused) | |
| 214 (1U << WebKit::WebAXStateReadonly)); | 214 (1U << blink::WebAXStateReadonly)); |
| 215 } | 215 } |
| 216 | 216 |
| 217 { | 217 { |
| 218 SCOPED_TRACE("link"); | 218 SCOPED_TRACE("link"); |
| 219 sink_->ClearMessages(); | 219 sink_->ClearMessages(); |
| 220 ExecuteJavaScript("document.querySelector('a').focus();"); | 220 ExecuteJavaScript("document.querySelector('a').focus();"); |
| 221 AccessibilityHostMsg_EventParams event; | 221 AccessibilityHostMsg_EventParams event; |
| 222 GetLastAccEvent(&event); | 222 GetLastAccEvent(&event); |
| 223 EXPECT_EQ(event.id, 8); | 223 EXPECT_EQ(event.id, 8); |
| 224 EXPECT_EQ(event.nodes[1].state, | 224 EXPECT_EQ(event.nodes[1].state, |
| 225 (1U << WebKit::WebAXStateFocusable) | | 225 (1U << blink::WebAXStateFocusable) | |
| 226 (1U << WebKit::WebAXStateFocused) | | 226 (1U << blink::WebAXStateFocused) | |
| 227 (1U << WebKit::WebAXStateReadonly)); | 227 (1U << blink::WebAXStateReadonly)); |
| 228 } | 228 } |
| 229 | 229 |
| 230 // Clear focus. | 230 // Clear focus. |
| 231 { | 231 { |
| 232 SCOPED_TRACE("Back to document."); | 232 SCOPED_TRACE("Back to document."); |
| 233 sink_->ClearMessages(); | 233 sink_->ClearMessages(); |
| 234 ExecuteJavaScript("document.activeElement.blur()"); | 234 ExecuteJavaScript("document.activeElement.blur()"); |
| 235 AccessibilityHostMsg_EventParams event; | 235 AccessibilityHostMsg_EventParams event; |
| 236 GetLastAccEvent(&event); | 236 GetLastAccEvent(&event); |
| 237 EXPECT_EQ(event.id, 1); | 237 EXPECT_EQ(event.id, 1); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 262 EXPECT_EQ(4, accessibility->browser_tree_node_count()); | 262 EXPECT_EQ(4, accessibility->browser_tree_node_count()); |
| 263 EXPECT_EQ(4, CountAccessibilityNodesSentToBrowser()); | 263 EXPECT_EQ(4, CountAccessibilityNodesSentToBrowser()); |
| 264 | 264 |
| 265 // If we post another event but the tree doesn't change, | 265 // If we post another event but the tree doesn't change, |
| 266 // we should only send 1 node to the browser. | 266 // we should only send 1 node to the browser. |
| 267 sink_->ClearMessages(); | 267 sink_->ClearMessages(); |
| 268 WebDocument document = view()->GetWebView()->mainFrame()->document(); | 268 WebDocument document = view()->GetWebView()->mainFrame()->document(); |
| 269 WebAXObject root_obj = document.accessibilityObject(); | 269 WebAXObject root_obj = document.accessibilityObject(); |
| 270 accessibility->HandleWebAccessibilityEvent( | 270 accessibility->HandleWebAccessibilityEvent( |
| 271 root_obj, | 271 root_obj, |
| 272 WebKit::WebAXEventLayoutComplete); | 272 blink::WebAXEventLayoutComplete); |
| 273 accessibility->SendPendingAccessibilityEvents(); | 273 accessibility->SendPendingAccessibilityEvents(); |
| 274 EXPECT_EQ(4, accessibility->browser_tree_node_count()); | 274 EXPECT_EQ(4, accessibility->browser_tree_node_count()); |
| 275 EXPECT_EQ(1, CountAccessibilityNodesSentToBrowser()); | 275 EXPECT_EQ(1, CountAccessibilityNodesSentToBrowser()); |
| 276 { | 276 { |
| 277 // Make sure it's the root object that was updated. | 277 // Make sure it's the root object that was updated. |
| 278 AccessibilityHostMsg_EventParams event; | 278 AccessibilityHostMsg_EventParams event; |
| 279 GetLastAccEvent(&event); | 279 GetLastAccEvent(&event); |
| 280 EXPECT_EQ(root_obj.axID(), event.nodes[0].id); | 280 EXPECT_EQ(root_obj.axID(), event.nodes[0].id); |
| 281 } | 281 } |
| 282 | 282 |
| 283 // If we reload the page and send a event, we should send | 283 // If we reload the page and send a event, we should send |
| 284 // all 4 nodes to the browser. Also double-check that we didn't | 284 // all 4 nodes to the browser. Also double-check that we didn't |
| 285 // leak any of the old BrowserTreeNodes. | 285 // leak any of the old BrowserTreeNodes. |
| 286 LoadHTML(html.c_str()); | 286 LoadHTML(html.c_str()); |
| 287 document = view()->GetWebView()->mainFrame()->document(); | 287 document = view()->GetWebView()->mainFrame()->document(); |
| 288 root_obj = document.accessibilityObject(); | 288 root_obj = document.accessibilityObject(); |
| 289 sink_->ClearMessages(); | 289 sink_->ClearMessages(); |
| 290 accessibility->HandleWebAccessibilityEvent( | 290 accessibility->HandleWebAccessibilityEvent( |
| 291 root_obj, | 291 root_obj, |
| 292 WebKit::WebAXEventLayoutComplete); | 292 blink::WebAXEventLayoutComplete); |
| 293 accessibility->SendPendingAccessibilityEvents(); | 293 accessibility->SendPendingAccessibilityEvents(); |
| 294 EXPECT_EQ(4, accessibility->browser_tree_node_count()); | 294 EXPECT_EQ(4, accessibility->browser_tree_node_count()); |
| 295 EXPECT_EQ(4, CountAccessibilityNodesSentToBrowser()); | 295 EXPECT_EQ(4, CountAccessibilityNodesSentToBrowser()); |
| 296 | 296 |
| 297 // Even if the first event is sent on an element other than | 297 // Even if the first event is sent on an element other than |
| 298 // the root, the whole tree should be updated because we know | 298 // the root, the whole tree should be updated because we know |
| 299 // the browser doesn't have the root element. | 299 // the browser doesn't have the root element. |
| 300 LoadHTML(html.c_str()); | 300 LoadHTML(html.c_str()); |
| 301 document = view()->GetWebView()->mainFrame()->document(); | 301 document = view()->GetWebView()->mainFrame()->document(); |
| 302 root_obj = document.accessibilityObject(); | 302 root_obj = document.accessibilityObject(); |
| 303 sink_->ClearMessages(); | 303 sink_->ClearMessages(); |
| 304 const WebAXObject& first_child = root_obj.childAt(0); | 304 const WebAXObject& first_child = root_obj.childAt(0); |
| 305 accessibility->HandleWebAccessibilityEvent( | 305 accessibility->HandleWebAccessibilityEvent( |
| 306 first_child, | 306 first_child, |
| 307 WebKit::WebAXEventLiveRegionChanged); | 307 blink::WebAXEventLiveRegionChanged); |
| 308 accessibility->SendPendingAccessibilityEvents(); | 308 accessibility->SendPendingAccessibilityEvents(); |
| 309 EXPECT_EQ(4, accessibility->browser_tree_node_count()); | 309 EXPECT_EQ(4, accessibility->browser_tree_node_count()); |
| 310 EXPECT_EQ(4, CountAccessibilityNodesSentToBrowser()); | 310 EXPECT_EQ(4, CountAccessibilityNodesSentToBrowser()); |
| 311 } | 311 } |
| 312 | 312 |
| 313 // http://crbug.com/253537 | 313 // http://crbug.com/253537 |
| 314 #if defined(OS_ANDROID) | 314 #if defined(OS_ANDROID) |
| 315 #define MAYBE_AccessibilityMessagesQueueWhileSwappedOut \ | 315 #define MAYBE_AccessibilityMessagesQueueWhileSwappedOut \ |
| 316 DISABLED_AccessibilityMessagesQueueWhileSwappedOut | 316 DISABLED_AccessibilityMessagesQueueWhileSwappedOut |
| 317 #else | 317 #else |
| (...skipping 18 matching lines...) Expand all Loading... |
| 336 EXPECT_EQ(5, CountAccessibilityNodesSentToBrowser()); | 336 EXPECT_EQ(5, CountAccessibilityNodesSentToBrowser()); |
| 337 | 337 |
| 338 // Post a "value changed" event, but then swap out | 338 // Post a "value changed" event, but then swap out |
| 339 // before sending it. It shouldn't send the event while | 339 // before sending it. It shouldn't send the event while |
| 340 // swapped out. | 340 // swapped out. |
| 341 sink_->ClearMessages(); | 341 sink_->ClearMessages(); |
| 342 WebDocument document = view()->GetWebView()->mainFrame()->document(); | 342 WebDocument document = view()->GetWebView()->mainFrame()->document(); |
| 343 WebAXObject root_obj = document.accessibilityObject(); | 343 WebAXObject root_obj = document.accessibilityObject(); |
| 344 accessibility->HandleWebAccessibilityEvent( | 344 accessibility->HandleWebAccessibilityEvent( |
| 345 root_obj, | 345 root_obj, |
| 346 WebKit::WebAXEventValueChanged); | 346 blink::WebAXEventValueChanged); |
| 347 view()->OnSwapOut(); | 347 view()->OnSwapOut(); |
| 348 accessibility->SendPendingAccessibilityEvents(); | 348 accessibility->SendPendingAccessibilityEvents(); |
| 349 EXPECT_FALSE(sink_->GetUniqueMessageMatching( | 349 EXPECT_FALSE(sink_->GetUniqueMessageMatching( |
| 350 AccessibilityHostMsg_Events::ID)); | 350 AccessibilityHostMsg_Events::ID)); |
| 351 | 351 |
| 352 // Navigate, so we're not swapped out anymore. Now we should | 352 // Navigate, so we're not swapped out anymore. Now we should |
| 353 // send accessibility events again. Note that the | 353 // send accessibility events again. Note that the |
| 354 // message that was queued up before will be quickly discarded | 354 // message that was queued up before will be quickly discarded |
| 355 // because the element it was referring to no longer exists, | 355 // because the element it was referring to no longer exists, |
| 356 // so the event here is from loading this new page. | 356 // so the event here is from loading this new page. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 // Hide node 'B' ('C' stays visible). | 398 // Hide node 'B' ('C' stays visible). |
| 399 ExecuteJavaScript( | 399 ExecuteJavaScript( |
| 400 "document.getElementById('B').style.visibility = 'hidden';"); | 400 "document.getElementById('B').style.visibility = 'hidden';"); |
| 401 // Force layout now. | 401 // Force layout now. |
| 402 ExecuteJavaScript("document.getElementById('B').offsetLeft;"); | 402 ExecuteJavaScript("document.getElementById('B').offsetLeft;"); |
| 403 | 403 |
| 404 // Send a childrenChanged on 'A'. | 404 // Send a childrenChanged on 'A'. |
| 405 sink_->ClearMessages(); | 405 sink_->ClearMessages(); |
| 406 accessibility->HandleWebAccessibilityEvent( | 406 accessibility->HandleWebAccessibilityEvent( |
| 407 node_a, | 407 node_a, |
| 408 WebKit::WebAXEventChildrenChanged); | 408 blink::WebAXEventChildrenChanged); |
| 409 | 409 |
| 410 accessibility->SendPendingAccessibilityEvents(); | 410 accessibility->SendPendingAccessibilityEvents(); |
| 411 EXPECT_EQ(3, accessibility->browser_tree_node_count()); | 411 EXPECT_EQ(3, accessibility->browser_tree_node_count()); |
| 412 AccessibilityHostMsg_EventParams event; | 412 AccessibilityHostMsg_EventParams event; |
| 413 GetLastAccEvent(&event); | 413 GetLastAccEvent(&event); |
| 414 ASSERT_EQ(3U, event.nodes.size()); | 414 ASSERT_EQ(3U, event.nodes.size()); |
| 415 | 415 |
| 416 // RendererAccessibilityComplete notices that 'C' is being reparented, | 416 // RendererAccessibilityComplete notices that 'C' is being reparented, |
| 417 // so it updates 'B' first to remove 'C' as a child, then 'A' to add it, | 417 // so it updates 'B' first to remove 'C' as a child, then 'A' to add it, |
| 418 // and finally it updates 'C'. | 418 // and finally it updates 'C'. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 448 ExecuteJavaScript( | 448 ExecuteJavaScript( |
| 449 "document.getElementById('B').style.visibility = 'visible';"); | 449 "document.getElementById('B').style.visibility = 'visible';"); |
| 450 ExecuteJavaScript("document.getElementById('B').offsetLeft;"); | 450 ExecuteJavaScript("document.getElementById('B').offsetLeft;"); |
| 451 | 451 |
| 452 sink_->ClearMessages(); | 452 sink_->ClearMessages(); |
| 453 WebDocument document = view()->GetWebView()->mainFrame()->document(); | 453 WebDocument document = view()->GetWebView()->mainFrame()->document(); |
| 454 WebAXObject root_obj = document.accessibilityObject(); | 454 WebAXObject root_obj = document.accessibilityObject(); |
| 455 WebAXObject node_a = root_obj.childAt(0); | 455 WebAXObject node_a = root_obj.childAt(0); |
| 456 accessibility->HandleWebAccessibilityEvent( | 456 accessibility->HandleWebAccessibilityEvent( |
| 457 node_a, | 457 node_a, |
| 458 WebKit::WebAXEventChildrenChanged); | 458 blink::WebAXEventChildrenChanged); |
| 459 | 459 |
| 460 accessibility->SendPendingAccessibilityEvents(); | 460 accessibility->SendPendingAccessibilityEvents(); |
| 461 EXPECT_EQ(4, accessibility->browser_tree_node_count()); | 461 EXPECT_EQ(4, accessibility->browser_tree_node_count()); |
| 462 AccessibilityHostMsg_EventParams event; | 462 AccessibilityHostMsg_EventParams event; |
| 463 GetLastAccEvent(&event); | 463 GetLastAccEvent(&event); |
| 464 ASSERT_EQ(3U, event.nodes.size()); | 464 ASSERT_EQ(3U, event.nodes.size()); |
| 465 EXPECT_EQ(3, CountAccessibilityNodesSentToBrowser()); | 465 EXPECT_EQ(3, CountAccessibilityNodesSentToBrowser()); |
| 466 } | 466 } |
| 467 | 467 |
| 468 TEST_F(RendererAccessibilityTest, DetachAccessibilityObject) { | 468 TEST_F(RendererAccessibilityTest, DetachAccessibilityObject) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 // anonymous block to be destroyed. | 502 // anonymous block to be destroyed. |
| 503 ExecuteJavaScript( | 503 ExecuteJavaScript( |
| 504 "document.querySelectorAll('span')[1].style.display = 'inline';"); | 504 "document.querySelectorAll('span')[1].style.display = 'inline';"); |
| 505 // Force layout now. | 505 // Force layout now. |
| 506 ExecuteJavaScript("document.body.offsetLeft;"); | 506 ExecuteJavaScript("document.body.offsetLeft;"); |
| 507 | 507 |
| 508 // Send a childrenChanged on the body. | 508 // Send a childrenChanged on the body. |
| 509 sink_->ClearMessages(); | 509 sink_->ClearMessages(); |
| 510 accessibility->HandleWebAccessibilityEvent( | 510 accessibility->HandleWebAccessibilityEvent( |
| 511 body, | 511 body, |
| 512 WebKit::WebAXEventChildrenChanged); | 512 blink::WebAXEventChildrenChanged); |
| 513 | 513 |
| 514 accessibility->SendPendingAccessibilityEvents(); | 514 accessibility->SendPendingAccessibilityEvents(); |
| 515 | 515 |
| 516 // Afterwards, the accessibility tree looks like this: | 516 // Afterwards, the accessibility tree looks like this: |
| 517 // | 517 // |
| 518 // Document | 518 // Document |
| 519 // +--Body | 519 // +--Body |
| 520 // +--Static Text "1" | 520 // +--Static Text "1" |
| 521 // +--Inline Text Box "1" | 521 // +--Inline Text Box "1" |
| 522 // +--Static Text "2" | 522 // +--Static Text "2" |
| 523 // +--Inline Text Box "2" | 523 // +--Inline Text Box "2" |
| 524 // | 524 // |
| 525 // We just assert that there are now four nodes in the | 525 // We just assert that there are now four nodes in the |
| 526 // accessibility tree and that only three nodes needed | 526 // accessibility tree and that only three nodes needed |
| 527 // to be updated (the body, the static text 1, and | 527 // to be updated (the body, the static text 1, and |
| 528 // the static text 2). | 528 // the static text 2). |
| 529 EXPECT_EQ(6, accessibility->browser_tree_node_count()); | 529 EXPECT_EQ(6, accessibility->browser_tree_node_count()); |
| 530 | 530 |
| 531 AccessibilityHostMsg_EventParams event; | 531 AccessibilityHostMsg_EventParams event; |
| 532 GetLastAccEvent(&event); | 532 GetLastAccEvent(&event); |
| 533 ASSERT_EQ(5U, event.nodes.size()); | 533 ASSERT_EQ(5U, event.nodes.size()); |
| 534 | 534 |
| 535 EXPECT_EQ(body.axID(), event.nodes[0].id); | 535 EXPECT_EQ(body.axID(), event.nodes[0].id); |
| 536 EXPECT_EQ(text_1.axID(), event.nodes[1].id); | 536 EXPECT_EQ(text_1.axID(), event.nodes[1].id); |
| 537 // The third event is to update text_2, but its id changes | 537 // The third event is to update text_2, but its id changes |
| 538 // so we don't have a test expectation for it. | 538 // so we don't have a test expectation for it. |
| 539 } | 539 } |
| 540 | 540 |
| 541 } // namespace content | 541 } // namespace content |
| OLD | NEW |