| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 return true; | 65 return true; |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 return false; | 68 return false; |
| 69 } | 69 } |
| 70 | 70 |
| 71 } // namespace | 71 } // namespace |
| 72 | 72 |
| 73 typedef AccessibilityTreeFormatter::Filter Filter; | 73 typedef AccessibilityTreeFormatter::Filter Filter; |
| 74 | 74 |
| 75 DumpAccessibilityTestBase::DumpAccessibilityTestBase() { | 75 DumpAccessibilityTestBase::DumpAccessibilityTestBase() |
| 76 : is_blink_pass_(false), |
| 77 enable_accessibility_after_navigating_(false) { |
| 76 } | 78 } |
| 77 | 79 |
| 78 DumpAccessibilityTestBase::~DumpAccessibilityTestBase() { | 80 DumpAccessibilityTestBase::~DumpAccessibilityTestBase() { |
| 79 } | 81 } |
| 80 | 82 |
| 81 void DumpAccessibilityTestBase::SetUpCommandLine( | 83 void DumpAccessibilityTestBase::SetUpCommandLine( |
| 82 base::CommandLine* command_line) { | 84 base::CommandLine* command_line) { |
| 83 IsolateAllSitesForTesting(command_line); | 85 IsolateAllSitesForTesting(command_line); |
| 84 } | 86 } |
| 85 | 87 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 if (!expected_contents.compare(0, strlen(kMarkSkipFile), kMarkSkipFile)) { | 237 if (!expected_contents.compare(0, strlen(kMarkSkipFile), kMarkSkipFile)) { |
| 236 LOG(INFO) << "Skipping this test on this platform."; | 238 LOG(INFO) << "Skipping this test on this platform."; |
| 237 return; | 239 return; |
| 238 } | 240 } |
| 239 | 241 |
| 240 // Parse filters and other directives in the test file. | 242 // Parse filters and other directives in the test file. |
| 241 std::vector<std::string> wait_for; | 243 std::vector<std::string> wait_for; |
| 242 AddDefaultFilters(&filters_); | 244 AddDefaultFilters(&filters_); |
| 243 ParseHtmlForExtraDirectives(html_contents, &filters_, &wait_for); | 245 ParseHtmlForExtraDirectives(html_contents, &filters_, &wait_for); |
| 244 | 246 |
| 245 // Load the test html and wait for the "load complete" AX event. | 247 // Get the test URL. |
| 246 GURL url(embedded_test_server()->GetURL( | 248 GURL url(embedded_test_server()->GetURL( |
| 247 "/" + std::string(file_dir) + "/" + file_path.BaseName().MaybeAsASCII())); | 249 "/" + std::string(file_dir) + "/" + file_path.BaseName().MaybeAsASCII())); |
| 248 AccessibilityNotificationWaiter accessibility_waiter( | 250 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( |
| 249 shell()->web_contents(), | 251 shell()->web_contents()); |
| 250 AccessibilityModeComplete, | 252 |
| 251 ui::AX_EVENT_LOAD_COMPLETE); | 253 if (enable_accessibility_after_navigating_ && |
| 252 NavigateToURL(shell(), url); | 254 web_contents->GetAccessibilityMode() == AccessibilityModeOff) { |
| 253 accessibility_waiter.WaitForNotification(); | 255 // Load the url, then enable accessibility. |
| 256 NavigateToURL(shell(), url); |
| 257 AccessibilityNotificationWaiter accessibility_waiter( |
| 258 web_contents, |
| 259 AccessibilityModeComplete, |
| 260 ui::AX_EVENT_NONE); |
| 261 accessibility_waiter.WaitForNotification(); |
| 262 } else { |
| 263 // Enable accessibility, then load the test html and wait for the |
| 264 // "load complete" AX event. |
| 265 AccessibilityNotificationWaiter accessibility_waiter( |
| 266 web_contents, |
| 267 AccessibilityModeComplete, |
| 268 ui::AX_EVENT_LOAD_COMPLETE); |
| 269 NavigateToURL(shell(), url); |
| 270 accessibility_waiter.WaitForNotification(); |
| 271 } |
| 254 | 272 |
| 255 // Get the url of every frame in the frame tree. | 273 // Get the url of every frame in the frame tree. |
| 256 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( | |
| 257 shell()->web_contents()); | |
| 258 FrameTree* frame_tree = web_contents->GetFrameTree(); | 274 FrameTree* frame_tree = web_contents->GetFrameTree(); |
| 259 std::vector<std::string> all_frame_urls; | 275 std::vector<std::string> all_frame_urls; |
| 260 for (FrameTreeNode* node : frame_tree->Nodes()) { | 276 for (FrameTreeNode* node : frame_tree->Nodes()) { |
| 261 // Ignore about:blank urls because of the case where a parent frame A | 277 // Ignore about:blank urls because of the case where a parent frame A |
| 262 // has a child iframe B and it writes to the document using | 278 // has a child iframe B and it writes to the document using |
| 263 // contentDocument.open() on the child frame B. | 279 // contentDocument.open() on the child frame B. |
| 264 // | 280 // |
| 265 // In this scenario, B's contentWindow.location.href matches A's url, | 281 // In this scenario, B's contentWindow.location.href matches A's url, |
| 266 // but B's url in the browser frame tree is still "about:blank". | 282 // but B's url in the browser frame tree is still "about:blank". |
| 267 std::string url = node->current_url().spec(); | 283 std::string url = node->current_url().spec(); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 expected_file, actual_contents.c_str(), actual_contents.size())); | 392 expected_file, actual_contents.c_str(), actual_contents.size())); |
| 377 LOG(INFO) << "Wrote expectations to: " | 393 LOG(INFO) << "Wrote expectations to: " |
| 378 << expected_file.LossyDisplayName(); | 394 << expected_file.LossyDisplayName(); |
| 379 } | 395 } |
| 380 } else { | 396 } else { |
| 381 LOG(INFO) << "Test output matches expectations."; | 397 LOG(INFO) << "Test output matches expectations."; |
| 382 } | 398 } |
| 383 } | 399 } |
| 384 | 400 |
| 385 } // namespace content | 401 } // namespace content |
| OLD | NEW |