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