OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/accessibility/dump_accessibility_browsertest_base.h" | 5 #include "content/browser/accessibility/dump_accessibility_browsertest_base.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 const char kMarkEndOfFile[] = "<-- End-of-file -->"; | 48 const char kMarkEndOfFile[] = "<-- End-of-file -->"; |
49 const char kSignalDiff[] = "*"; | 49 const char kSignalDiff[] = "*"; |
50 | 50 |
51 // Searches recursively and returns true if an accessibility node is found | 51 // Searches recursively and returns true if an accessibility node is found |
52 // that represents a fully loaded web document with the given url. | 52 // that represents a fully loaded web document with the given url. |
53 bool AccessibilityTreeContainsLoadedDocWithUrl(BrowserAccessibility* node, | 53 bool AccessibilityTreeContainsLoadedDocWithUrl(BrowserAccessibility* node, |
54 const std::string& url) { | 54 const std::string& url) { |
55 if ((node->GetRole() == ui::AX_ROLE_WEB_AREA || | 55 if ((node->GetRole() == ui::AX_ROLE_WEB_AREA || |
56 node->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA) && | 56 node->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA) && |
57 node->GetStringAttribute(ui::AX_ATTR_URL) == url) { | 57 node->GetStringAttribute(ui::AX_ATTR_URL) == url) { |
58 // If possible, ensure the doc has finished loading. That's currently | 58 // Ensure the doc has finished loading. |
59 // not possible with same-process iframes until https://crbug.com/532249 | 59 return node->manager()->GetTreeData().loaded; |
60 // is fixed. | |
61 return (node->manager()->GetTreeData().url != url || | |
62 node->manager()->GetTreeData().loaded); | |
63 } | 60 } |
64 | 61 |
65 for (unsigned i = 0; i < node->PlatformChildCount(); i++) { | 62 for (unsigned i = 0; i < node->PlatformChildCount(); i++) { |
66 if (AccessibilityTreeContainsLoadedDocWithUrl( | 63 if (AccessibilityTreeContainsLoadedDocWithUrl( |
67 node->PlatformGetChild(i), url)) { | 64 node->PlatformGetChild(i), url)) { |
68 return true; | 65 return true; |
69 } | 66 } |
70 } | 67 } |
71 return false; | 68 return false; |
72 } | 69 } |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 for (FrameTreeNode* node : frame_tree->Nodes()) { | 260 for (FrameTreeNode* node : frame_tree->Nodes()) { |
264 // Ignore about:blank urls because of the case where a parent frame A | 261 // Ignore about:blank urls because of the case where a parent frame A |
265 // has a child iframe B and it writes to the document using | 262 // has a child iframe B and it writes to the document using |
266 // contentDocument.open() on the child frame B. | 263 // contentDocument.open() on the child frame B. |
267 // | 264 // |
268 // In this scenario, B's contentWindow.location.href matches A's url, | 265 // In this scenario, B's contentWindow.location.href matches A's url, |
269 // but B's url in the browser frame tree is still "about:blank". | 266 // but B's url in the browser frame tree is still "about:blank". |
270 std::string url = node->current_url().spec(); | 267 std::string url = node->current_url().spec(); |
271 if (url != url::kAboutBlankURL) | 268 if (url != url::kAboutBlankURL) |
272 all_frame_urls.push_back(url); | 269 all_frame_urls.push_back(url); |
273 | |
274 // We won't get the correct coordinate transformations for | |
275 // out-of-process iframes until each frame's surface is ready. | |
276 RenderFrameHostImpl* current_frame_host = node->current_frame_host(); | |
277 if (!current_frame_host || !current_frame_host->is_local_root()) | |
278 continue; | |
279 RenderWidgetHostViewBase* rwhv = | |
280 static_cast<RenderWidgetHostViewBase*>(current_frame_host->GetView()); | |
281 if (rwhv && rwhv->IsChildFrameForTesting()) { | |
282 SurfaceHitTestReadyNotifier notifier( | |
283 static_cast<RenderWidgetHostViewChildFrame*>(rwhv)); | |
284 notifier.WaitForSurfaceReady(); | |
285 } | |
286 } | 270 } |
287 | 271 |
288 // Wait for the accessibility tree to fully load for all frames, | 272 // Wait for the accessibility tree to fully load for all frames, |
289 // by searching for the WEB_AREA node in the accessibility tree | 273 // by searching for the WEB_AREA node in the accessibility tree |
290 // with the url of each frame in our frame tree. Note that this | 274 // with the url of each frame in our frame tree. Note that this |
291 // doesn't support cases where there are two iframes with the | 275 // doesn't support cases where there are two iframes with the |
292 // exact same url. If all frames haven't loaded yet, set up a | 276 // exact same url. If all frames haven't loaded yet, set up a |
293 // listener for accessibility events on any frame and block | 277 // listener for accessibility events on any frame and block |
294 // until the next one is received. | 278 // until the next one is received. |
295 // | 279 // |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 expected_file, actual_contents.c_str(), actual_contents.size())); | 376 expected_file, actual_contents.c_str(), actual_contents.size())); |
393 LOG(INFO) << "Wrote expectations to: " | 377 LOG(INFO) << "Wrote expectations to: " |
394 << expected_file.LossyDisplayName(); | 378 << expected_file.LossyDisplayName(); |
395 } | 379 } |
396 } else { | 380 } else { |
397 LOG(INFO) << "Test output matches expectations."; | 381 LOG(INFO) << "Test output matches expectations."; |
398 } | 382 } |
399 } | 383 } |
400 | 384 |
401 } // namespace content | 385 } // namespace content |
OLD | NEW |