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 "components/test_runner/test_runner.h" | 5 #include "components/test_runner/test_runner.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <limits> | 8 #include <limits> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 1537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1548 TestRunner::TestRunner(TestInterfaces* interfaces) | 1548 TestRunner::TestRunner(TestInterfaces* interfaces) |
1549 : test_is_running_(false), | 1549 : test_is_running_(false), |
1550 close_remaining_windows_(false), | 1550 close_remaining_windows_(false), |
1551 work_queue_(this), | 1551 work_queue_(this), |
1552 web_history_item_count_(0), | 1552 web_history_item_count_(0), |
1553 test_interfaces_(interfaces), | 1553 test_interfaces_(interfaces), |
1554 delegate_(nullptr), | 1554 delegate_(nullptr), |
1555 main_view_(nullptr), | 1555 main_view_(nullptr), |
1556 mock_content_settings_client_( | 1556 mock_content_settings_client_( |
1557 new MockContentSettingsClient(&layout_test_runtime_flags_)), | 1557 new MockContentSettingsClient(&layout_test_runtime_flags_)), |
| 1558 will_navigate_(false), |
1558 credential_manager_client_(new MockCredentialManagerClient), | 1559 credential_manager_client_(new MockCredentialManagerClient), |
1559 mock_screen_orientation_client_(new MockScreenOrientationClient), | 1560 mock_screen_orientation_client_(new MockScreenOrientationClient), |
1560 spellcheck_(new SpellCheckClient(this)), | 1561 spellcheck_(new SpellCheckClient(this)), |
1561 chooser_count_(0), | 1562 chooser_count_(0), |
1562 previously_focused_view_(nullptr), | 1563 previously_focused_view_(nullptr), |
1563 is_web_platform_tests_mode_(false), | 1564 is_web_platform_tests_mode_(false), |
1564 weak_factory_(this) {} | 1565 weak_factory_(this) {} |
1565 | 1566 |
1566 TestRunner::~TestRunner() {} | 1567 TestRunner::~TestRunner() {} |
1567 | 1568 |
(...skipping 11 matching lines...) Expand all Loading... |
1579 if (speech_recognizer_) | 1580 if (speech_recognizer_) |
1580 speech_recognizer_->SetDelegate(delegate); | 1581 speech_recognizer_->SetDelegate(delegate); |
1581 } | 1582 } |
1582 | 1583 |
1583 void TestRunner::SetMainView(WebView* web_view) { | 1584 void TestRunner::SetMainView(WebView* web_view) { |
1584 main_view_ = web_view; | 1585 main_view_ = web_view; |
1585 } | 1586 } |
1586 | 1587 |
1587 void TestRunner::Reset() { | 1588 void TestRunner::Reset() { |
1588 is_web_platform_tests_mode_ = false; | 1589 is_web_platform_tests_mode_ = false; |
| 1590 will_navigate_ = false; |
1589 top_loading_frame_ = nullptr; | 1591 top_loading_frame_ = nullptr; |
1590 layout_test_runtime_flags_.Reset(); | 1592 layout_test_runtime_flags_.Reset(); |
1591 mock_screen_orientation_client_->ResetData(); | 1593 mock_screen_orientation_client_->ResetData(); |
1592 drag_image_.reset(); | 1594 drag_image_.reset(); |
1593 widgets_with_scheduled_animations_.clear(); | 1595 widgets_with_scheduled_animations_.clear(); |
1594 | 1596 |
1595 WebSecurityPolicy::resetOriginAccessWhitelists(); | 1597 WebSecurityPolicy::resetOriginAccessWhitelists(); |
1596 #if defined(__linux__) || defined(ANDROID) | 1598 #if defined(__linux__) || defined(ANDROID) |
1597 WebFontRendering::setSubpixelPositioning(false); | 1599 WebFontRendering::setSubpixelPositioning(false); |
1598 #endif | 1600 #endif |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1829 } | 1831 } |
1830 | 1832 |
1831 const std::set<std::string>* TestRunner::httpHeadersToClear() const { | 1833 const std::set<std::string>* TestRunner::httpHeadersToClear() const { |
1832 return &http_headers_to_clear_; | 1834 return &http_headers_to_clear_; |
1833 } | 1835 } |
1834 | 1836 |
1835 bool TestRunner::IsFramePartOfMainTestWindow(blink::WebFrame* frame) const { | 1837 bool TestRunner::IsFramePartOfMainTestWindow(blink::WebFrame* frame) const { |
1836 return test_is_running_ && frame->top()->view() == main_view_; | 1838 return test_is_running_ && frame->top()->view() == main_view_; |
1837 } | 1839 } |
1838 | 1840 |
| 1841 void TestRunner::OnNavigationBegin(WebFrame* frame) { |
| 1842 if (IsFramePartOfMainTestWindow(frame)) |
| 1843 will_navigate_ = true; |
| 1844 } |
| 1845 |
1839 bool TestRunner::tryToSetTopLoadingFrame(WebFrame* frame) { | 1846 bool TestRunner::tryToSetTopLoadingFrame(WebFrame* frame) { |
| 1847 will_navigate_ = false; |
1840 if (!IsFramePartOfMainTestWindow(frame)) | 1848 if (!IsFramePartOfMainTestWindow(frame)) |
1841 return false; | 1849 return false; |
1842 | 1850 |
1843 if (top_loading_frame_ || layout_test_runtime_flags_.have_top_loading_frame()) | 1851 if (top_loading_frame_ || layout_test_runtime_flags_.have_top_loading_frame()) |
1844 return false; | 1852 return false; |
1845 | 1853 |
1846 top_loading_frame_ = frame; | 1854 top_loading_frame_ = frame; |
1847 layout_test_runtime_flags_.set_have_top_loading_frame(true); | 1855 layout_test_runtime_flags_.set_have_top_loading_frame(true); |
1848 OnLayoutTestRuntimeFlagsChanged(); | 1856 OnLayoutTestRuntimeFlagsChanged(); |
1849 return true; | 1857 return true; |
1850 } | 1858 } |
1851 | 1859 |
1852 bool TestRunner::tryToClearTopLoadingFrame(WebFrame* frame) { | 1860 bool TestRunner::tryToClearTopLoadingFrame(WebFrame* frame) { |
| 1861 will_navigate_ = false; |
1853 if (!IsFramePartOfMainTestWindow(frame)) | 1862 if (!IsFramePartOfMainTestWindow(frame)) |
1854 return false; | 1863 return false; |
1855 | 1864 |
1856 if (frame != top_loading_frame_) | 1865 if (frame != top_loading_frame_) |
1857 return false; | 1866 return false; |
1858 | 1867 |
1859 top_loading_frame_ = nullptr; | 1868 top_loading_frame_ = nullptr; |
1860 DCHECK(layout_test_runtime_flags_.have_top_loading_frame()); | 1869 DCHECK(layout_test_runtime_flags_.have_top_loading_frame()); |
1861 layout_test_runtime_flags_.set_have_top_loading_frame(false); | 1870 layout_test_runtime_flags_.set_have_top_loading_frame(false); |
1862 OnLayoutTestRuntimeFlagsChanged(); | 1871 OnLayoutTestRuntimeFlagsChanged(); |
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2728 if (mimeType != "text/plain") | 2737 if (mimeType != "text/plain") |
2729 return; | 2738 return; |
2730 | 2739 |
2731 layout_test_runtime_flags_.set_dump_as_text(true); | 2740 layout_test_runtime_flags_.set_dump_as_text(true); |
2732 layout_test_runtime_flags_.set_generate_pixel_results(false); | 2741 layout_test_runtime_flags_.set_generate_pixel_results(false); |
2733 OnLayoutTestRuntimeFlagsChanged(); | 2742 OnLayoutTestRuntimeFlagsChanged(); |
2734 } | 2743 } |
2735 | 2744 |
2736 void TestRunner::NotifyDone() { | 2745 void TestRunner::NotifyDone() { |
2737 if (layout_test_runtime_flags_.wait_until_done() && !topLoadingFrame() && | 2746 if (layout_test_runtime_flags_.wait_until_done() && !topLoadingFrame() && |
2738 work_queue_.is_empty()) | 2747 !will_navigate_ && work_queue_.is_empty()) |
2739 delegate_->TestFinished(); | 2748 delegate_->TestFinished(); |
2740 layout_test_runtime_flags_.set_wait_until_done(false); | 2749 layout_test_runtime_flags_.set_wait_until_done(false); |
2741 OnLayoutTestRuntimeFlagsChanged(); | 2750 OnLayoutTestRuntimeFlagsChanged(); |
2742 } | 2751 } |
2743 | 2752 |
2744 } // namespace test_runner | 2753 } // namespace test_runner |
OLD | NEW |