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