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 // Make sure accessibility is off initially. |
253 AccessibilityModeComplete, | 255 BrowserAccessibilityStateImpl::GetInstance()->DisableAccessibility(); |
254 ui::AX_EVENT_LOAD_COMPLETE); | 256 |
255 NavigateToURL(shell(), url); | 257 if (enable_accessibility_after_navigating_) { |
256 accessibility_waiter.WaitForNotification(); | 258 // Load the url, then enable accessibility. |
| 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 } |
257 | 275 |
258 // Get the url of every frame in the frame tree. | 276 // Get the url of every frame in the frame tree. |
259 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( | 277 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( |
260 shell()->web_contents()); | 278 shell()->web_contents()); |
261 FrameTree* frame_tree = web_contents->GetFrameTree(); | 279 FrameTree* frame_tree = web_contents->GetFrameTree(); |
262 std::vector<std::string> all_frame_urls; | 280 std::vector<std::string> all_frame_urls; |
263 for (FrameTreeNode* node : frame_tree->Nodes()) { | 281 for (FrameTreeNode* node : frame_tree->Nodes()) { |
264 // Ignore about:blank urls because of the case where a parent frame A | 282 // 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 | 283 // has a child iframe B and it writes to the document using |
266 // contentDocument.open() on the child frame B. | 284 // 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())); | 410 expected_file, actual_contents.c_str(), actual_contents.size())); |
393 LOG(INFO) << "Wrote expectations to: " | 411 LOG(INFO) << "Wrote expectations to: " |
394 << expected_file.LossyDisplayName(); | 412 << expected_file.LossyDisplayName(); |
395 } | 413 } |
396 } else { | 414 } else { |
397 LOG(INFO) << "Test output matches expectations."; | 415 LOG(INFO) << "Test output matches expectations."; |
398 } | 416 } |
399 } | 417 } |
400 | 418 |
401 } // namespace content | 419 } // namespace content |
OLD | NEW |