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 1592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1603 Reset(); | 1603 Reset(); |
1604 } | 1604 } |
1605 | 1605 |
1606 void TestRunner::WorkQueue::ProcessWorkSoon() { | 1606 void TestRunner::WorkQueue::ProcessWorkSoon() { |
1607 if (controller_->topLoadingFrame()) | 1607 if (controller_->topLoadingFrame()) |
1608 return; | 1608 return; |
1609 | 1609 |
1610 if (!queue_.empty()) { | 1610 if (!queue_.empty()) { |
1611 // We delay processing queued work to avoid recursion problems. | 1611 // We delay processing queued work to avoid recursion problems. |
1612 controller_->delegate_->PostTask(new WorkQueueTask(this)); | 1612 controller_->delegate_->PostTask(new WorkQueueTask(this)); |
1613 } else if (!controller_->wait_until_done_) { | 1613 } else if (!controller_->layout_dump_flags_.wait_until_done()) { |
1614 controller_->delegate_->TestFinished(); | 1614 controller_->delegate_->TestFinished(); |
1615 } | 1615 } |
1616 } | 1616 } |
1617 | 1617 |
1618 void TestRunner::WorkQueue::Reset() { | 1618 void TestRunner::WorkQueue::Reset() { |
1619 frozen_ = false; | 1619 frozen_ = false; |
1620 while (!queue_.empty()) { | 1620 while (!queue_.empty()) { |
1621 delete queue_.front(); | 1621 delete queue_.front(); |
1622 queue_.pop_front(); | 1622 queue_.pop_front(); |
1623 } | 1623 } |
(...skipping 11 matching lines...) Expand all Loading... | |
1635 // Quit doing work once a load is in progress. | 1635 // Quit doing work once a load is in progress. |
1636 while (!queue_.empty()) { | 1636 while (!queue_.empty()) { |
1637 bool startedLoad = queue_.front()->Run(controller_->delegate_, | 1637 bool startedLoad = queue_.front()->Run(controller_->delegate_, |
1638 controller_->web_view_); | 1638 controller_->web_view_); |
1639 delete queue_.front(); | 1639 delete queue_.front(); |
1640 queue_.pop_front(); | 1640 queue_.pop_front(); |
1641 if (startedLoad) | 1641 if (startedLoad) |
1642 return; | 1642 return; |
1643 } | 1643 } |
1644 | 1644 |
1645 if (!controller_->wait_until_done_ && !controller_->topLoadingFrame()) | 1645 if (!controller_->layout_dump_flags_.wait_until_done() && |
1646 !controller_->topLoadingFrame()) | |
1646 controller_->delegate_->TestFinished(); | 1647 controller_->delegate_->TestFinished(); |
1647 } | 1648 } |
1648 | 1649 |
1649 void TestRunner::WorkQueue::WorkQueueTask::RunIfValid() { | 1650 void TestRunner::WorkQueue::WorkQueueTask::RunIfValid() { |
1650 object_->ProcessWork(); | 1651 object_->ProcessWork(); |
1651 } | 1652 } |
1652 | 1653 |
1653 TestRunner::TestRunner(TestInterfaces* interfaces) | 1654 TestRunner::TestRunner(TestInterfaces* interfaces) |
1654 : test_is_running_(false), | 1655 : test_is_running_(false), |
1655 close_remaining_windows_(false), | 1656 close_remaining_windows_(false), |
1656 work_queue_(this), | 1657 work_queue_(this), |
1657 disable_notify_done_(false), | 1658 disable_notify_done_(false), |
1658 web_history_item_count_(0), | 1659 web_history_item_count_(0), |
1659 intercept_post_message_(false), | 1660 intercept_post_message_(false), |
1660 layout_dump_flags_( | |
1661 false, // dump_as_text | |
1662 false, // dump_child_frames_as_text | |
1663 false, // dump_as_markup | |
1664 false, // dump_child_frames_as_markup | |
1665 false, // dump_child_frame_scroll_positions | |
1666 false), // is_printing | |
1667 test_interfaces_(interfaces), | 1661 test_interfaces_(interfaces), |
1668 delegate_(nullptr), | 1662 delegate_(nullptr), |
1669 web_view_(nullptr), | 1663 web_view_(nullptr), |
1670 web_content_settings_(new WebContentSettings()), | 1664 web_content_settings_(new WebContentSettings()), |
1671 weak_factory_(this) {} | 1665 weak_factory_(this) {} |
1672 | 1666 |
1673 TestRunner::~TestRunner() {} | 1667 TestRunner::~TestRunner() {} |
1674 | 1668 |
1675 void TestRunner::Install(WebFrame* frame) { | 1669 void TestRunner::Install(WebFrame* frame) { |
1676 TestRunnerBindings::Install(weak_factory_.GetWeakPtr(), frame); | 1670 TestRunnerBindings::Install(weak_factory_.GetWeakPtr(), frame); |
(...skipping 20 matching lines...) Expand all Loading... | |
1697 web_view_->setSelectionColors( | 1691 web_view_->setSelectionColors( |
1698 0xff1e90ff, 0xff000000, 0xffc8c8c8, 0xff323232); | 1692 0xff1e90ff, 0xff000000, 0xffc8c8c8, 0xff323232); |
1699 #endif | 1693 #endif |
1700 web_view_->setVisibilityState(WebPageVisibilityStateVisible, true); | 1694 web_view_->setVisibilityState(WebPageVisibilityStateVisible, true); |
1701 web_view_->mainFrame()->enableViewSourceMode(false); | 1695 web_view_->mainFrame()->enableViewSourceMode(false); |
1702 | 1696 |
1703 web_view_->setPageOverlayColor(SK_ColorTRANSPARENT); | 1697 web_view_->setPageOverlayColor(SK_ColorTRANSPARENT); |
1704 } | 1698 } |
1705 | 1699 |
1706 top_loading_frame_ = nullptr; | 1700 top_loading_frame_ = nullptr; |
1707 wait_until_done_ = false; | 1701 layout_dump_flags_.Reset(); |
1708 wait_until_external_url_load_ = false; | 1702 wait_until_external_url_load_ = false; |
1709 policy_delegate_enabled_ = false; | 1703 policy_delegate_enabled_ = false; |
1710 policy_delegate_is_permissive_ = false; | 1704 policy_delegate_is_permissive_ = false; |
1711 policy_delegate_should_notify_done_ = false; | 1705 policy_delegate_should_notify_done_ = false; |
1712 | 1706 |
1713 WebSecurityPolicy::resetOriginAccessWhitelists(); | 1707 WebSecurityPolicy::resetOriginAccessWhitelists(); |
1714 #if defined(__linux__) || defined(ANDROID) | 1708 #if defined(__linux__) || defined(ANDROID) |
1715 WebFontRendering::setSubpixelPositioning(false); | 1709 WebFontRendering::setSubpixelPositioning(false); |
1716 #endif | 1710 #endif |
1717 | 1711 |
1718 if (delegate_) { | 1712 if (delegate_) { |
1719 // Reset the default quota for each origin to 5MB | 1713 // Reset the default quota for each origin to 5MB |
1720 delegate_->SetDatabaseQuota(5 * 1024 * 1024); | 1714 delegate_->SetDatabaseQuota(5 * 1024 * 1024); |
1721 delegate_->SetDeviceColorProfile("reset"); | 1715 delegate_->SetDeviceColorProfile("reset"); |
1722 delegate_->SetDeviceScaleFactor(GetDefaultDeviceScaleFactor()); | 1716 delegate_->SetDeviceScaleFactor(GetDefaultDeviceScaleFactor()); |
1723 delegate_->SetAcceptAllCookies(false); | 1717 delegate_->SetAcceptAllCookies(false); |
1724 delegate_->SetLocale(""); | 1718 delegate_->SetLocale(""); |
1725 delegate_->UseUnfortunateSynchronousResizeMode(false); | 1719 delegate_->UseUnfortunateSynchronousResizeMode(false); |
1726 delegate_->DisableAutoResizeMode(WebSize()); | 1720 delegate_->DisableAutoResizeMode(WebSize()); |
1727 delegate_->DeleteAllCookies(); | 1721 delegate_->DeleteAllCookies(); |
1728 delegate_->ResetScreenOrientation(); | 1722 delegate_->ResetScreenOrientation(); |
1729 delegate_->SetBluetoothMockDataSet(""); | 1723 delegate_->SetBluetoothMockDataSet(""); |
1730 delegate_->ClearGeofencingMockProvider(); | 1724 delegate_->ClearGeofencingMockProvider(); |
1731 delegate_->ResetPermissions(); | 1725 delegate_->ResetPermissions(); |
1732 ResetDeviceLight(); | 1726 ResetDeviceLight(); |
1733 } | 1727 } |
1734 | 1728 |
1735 dump_editting_callbacks_ = false; | 1729 dump_editting_callbacks_ = false; |
1736 layout_dump_flags_.dump_as_text = false; | |
1737 layout_dump_flags_.dump_as_markup = false; | |
1738 generate_pixel_results_ = true; | |
1739 layout_dump_flags_.dump_child_frame_scroll_positions = false; | |
1740 layout_dump_flags_.dump_child_frames_as_text = false; | |
1741 layout_dump_flags_.dump_child_frames_as_markup = false; | |
1742 dump_icon_changes_ = false; | 1730 dump_icon_changes_ = false; |
1743 dump_as_audio_ = false; | 1731 dump_as_audio_ = false; |
1744 dump_frame_load_callbacks_ = false; | 1732 dump_frame_load_callbacks_ = false; |
1745 dump_ping_loader_callbacks_ = false; | 1733 dump_ping_loader_callbacks_ = false; |
1746 dump_user_gesture_in_frame_load_callbacks_ = false; | 1734 dump_user_gesture_in_frame_load_callbacks_ = false; |
1747 dump_title_changes_ = false; | 1735 dump_title_changes_ = false; |
1748 dump_create_view_ = false; | 1736 dump_create_view_ = false; |
1749 can_open_windows_ = false; | 1737 can_open_windows_ = false; |
1750 dump_resource_load_callbacks_ = false; | 1738 dump_resource_load_callbacks_ = false; |
1751 dump_resource_request_callbacks_ = false; | 1739 dump_resource_request_callbacks_ = false; |
1752 dump_resource_response_mime_types_ = false; | 1740 dump_resource_response_mime_types_ = false; |
1753 dump_window_status_changes_ = false; | 1741 dump_window_status_changes_ = false; |
1754 dump_spell_check_callbacks_ = false; | 1742 dump_spell_check_callbacks_ = false; |
1755 dump_back_forward_list_ = false; | 1743 dump_back_forward_list_ = false; |
1756 dump_selection_rect_ = false; | 1744 dump_selection_rect_ = false; |
1757 dump_drag_image_ = false; | 1745 dump_drag_image_ = false; |
1758 dump_navigation_policy_ = false; | 1746 dump_navigation_policy_ = false; |
1759 test_repaint_ = false; | 1747 test_repaint_ = false; |
1760 sweep_horizontally_ = false; | 1748 sweep_horizontally_ = false; |
1761 layout_dump_flags_.is_printing = false; | |
1762 midi_accessor_result_ = true; | 1749 midi_accessor_result_ = true; |
1763 should_stay_on_page_after_handling_before_unload_ = false; | 1750 should_stay_on_page_after_handling_before_unload_ = false; |
1764 should_dump_resource_priorities_ = false; | 1751 should_dump_resource_priorities_ = false; |
1765 has_custom_text_output_ = false; | 1752 has_custom_text_output_ = false; |
1766 custom_text_output_.clear(); | 1753 custom_text_output_.clear(); |
1767 | 1754 |
1768 http_headers_to_clear_.clear(); | 1755 http_headers_to_clear_.clear(); |
1769 | 1756 |
1770 platform_name_ = "chromium"; | 1757 platform_name_ = "chromium"; |
1771 tooltip_text_ = std::string(); | 1758 tooltip_text_ = std::string(); |
(...skipping 23 matching lines...) Expand all Loading... | |
1795 | 1782 |
1796 void TestRunner::InvokeCallback(scoped_ptr<InvokeCallbackTask> task) { | 1783 void TestRunner::InvokeCallback(scoped_ptr<InvokeCallbackTask> task) { |
1797 delegate_->PostTask(task.release()); | 1784 delegate_->PostTask(task.release()); |
1798 } | 1785 } |
1799 | 1786 |
1800 bool TestRunner::shouldDumpEditingCallbacks() const { | 1787 bool TestRunner::shouldDumpEditingCallbacks() const { |
1801 return dump_editting_callbacks_; | 1788 return dump_editting_callbacks_; |
1802 } | 1789 } |
1803 | 1790 |
1804 void TestRunner::setShouldDumpAsText(bool value) { | 1791 void TestRunner::setShouldDumpAsText(bool value) { |
1805 layout_dump_flags_.dump_as_text = value; | 1792 layout_dump_flags_.set_dump_as_text(value); |
1793 OnLayoutDumpFlagsChanged(); | |
1806 } | 1794 } |
1807 | 1795 |
1808 void TestRunner::setShouldDumpAsMarkup(bool value) { | 1796 void TestRunner::setShouldDumpAsMarkup(bool value) { |
1809 layout_dump_flags_.dump_as_markup = value; | 1797 layout_dump_flags_.set_dump_as_markup(value); |
1798 OnLayoutDumpFlagsChanged(); | |
1810 } | 1799 } |
1811 | 1800 |
1812 bool TestRunner::shouldDumpAsCustomText() const { | 1801 bool TestRunner::shouldDumpAsCustomText() const { |
1813 return has_custom_text_output_; | 1802 return has_custom_text_output_; |
1814 } | 1803 } |
1815 | 1804 |
1816 std::string TestRunner::customDumpText() const { | 1805 std::string TestRunner::customDumpText() const { |
1817 return custom_text_output_; | 1806 return custom_text_output_; |
1818 } | 1807 } |
1819 | 1808 |
1820 void TestRunner::setCustomTextOutput(const std::string& text) { | 1809 void TestRunner::setCustomTextOutput(const std::string& text) { |
1821 custom_text_output_ = text; | 1810 custom_text_output_ = text; |
1822 has_custom_text_output_ = true; | 1811 has_custom_text_output_ = true; |
1823 } | 1812 } |
1824 | 1813 |
1825 bool TestRunner::ShouldGeneratePixelResults() { | 1814 bool TestRunner::ShouldGeneratePixelResults() { |
1826 CheckResponseMimeType(); | 1815 CheckResponseMimeType(); |
1827 return generate_pixel_results_; | 1816 return layout_dump_flags_.generate_pixel_results(); |
1828 } | 1817 } |
1829 | 1818 |
1830 bool TestRunner::ShouldStayOnPageAfterHandlingBeforeUnload() const { | 1819 bool TestRunner::ShouldStayOnPageAfterHandlingBeforeUnload() const { |
1831 return should_stay_on_page_after_handling_before_unload_; | 1820 return should_stay_on_page_after_handling_before_unload_; |
1832 } | 1821 } |
1833 | 1822 |
1834 | 1823 |
1835 void TestRunner::setShouldGeneratePixelResults(bool value) { | 1824 void TestRunner::setShouldGeneratePixelResults(bool value) { |
1836 generate_pixel_results_ = value; | 1825 layout_dump_flags_.set_generate_pixel_results(value); |
1826 OnLayoutDumpFlagsChanged(); | |
1837 } | 1827 } |
1838 | 1828 |
1839 bool TestRunner::ShouldDumpAsAudio() const { | 1829 bool TestRunner::ShouldDumpAsAudio() const { |
1840 return dump_as_audio_; | 1830 return dump_as_audio_; |
1841 } | 1831 } |
1842 | 1832 |
1843 void TestRunner::GetAudioData(std::vector<unsigned char>* buffer_view) const { | 1833 void TestRunner::GetAudioData(std::vector<unsigned char>* buffer_view) const { |
1844 *buffer_view = audio_data_; | 1834 *buffer_view = audio_data_; |
1845 } | 1835 } |
1846 | 1836 |
1847 const LayoutDumpFlags& TestRunner::GetLayoutDumpFlags() { | 1837 const LayoutDumpFlags& TestRunner::GetLayoutDumpFlags() { |
1848 CheckResponseMimeType(); | 1838 CheckResponseMimeType(); |
1849 return layout_dump_flags_; | 1839 return layout_dump_flags_; |
1850 } | 1840 } |
1851 | 1841 |
1842 void TestRunner::ReplicateLayoutDumpFlagsChanges( | |
1843 const base::DictionaryValue& changed_values) { | |
1844 layout_dump_flags_.tracked_dictionary().ApplyUntrackedChanges(changed_values); | |
1845 } | |
1846 | |
1852 bool TestRunner::HasCustomTextDump(std::string* custom_text_dump) const { | 1847 bool TestRunner::HasCustomTextDump(std::string* custom_text_dump) const { |
1853 if (shouldDumpAsCustomText()) { | 1848 if (shouldDumpAsCustomText()) { |
1854 *custom_text_dump = customDumpText(); | 1849 *custom_text_dump = customDumpText(); |
1855 return true; | 1850 return true; |
1856 } | 1851 } |
1857 | 1852 |
1858 return false; | 1853 return false; |
1859 } | 1854 } |
1860 | 1855 |
1861 bool TestRunner::shouldDumpFrameLoadCallbacks() const { | 1856 bool TestRunner::shouldDumpFrameLoadCallbacks() const { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1924 | 1919 |
1925 bool TestRunner::ShouldDumpBackForwardList() const { | 1920 bool TestRunner::ShouldDumpBackForwardList() const { |
1926 return dump_back_forward_list_; | 1921 return dump_back_forward_list_; |
1927 } | 1922 } |
1928 | 1923 |
1929 bool TestRunner::shouldDumpSelectionRect() const { | 1924 bool TestRunner::shouldDumpSelectionRect() const { |
1930 return dump_selection_rect_; | 1925 return dump_selection_rect_; |
1931 } | 1926 } |
1932 | 1927 |
1933 bool TestRunner::isPrinting() const { | 1928 bool TestRunner::isPrinting() const { |
1934 return layout_dump_flags_.is_printing; | 1929 return layout_dump_flags_.is_printing(); |
1935 } | 1930 } |
1936 | 1931 |
1937 bool TestRunner::shouldWaitUntilExternalURLLoad() const { | 1932 bool TestRunner::shouldWaitUntilExternalURLLoad() const { |
1938 return wait_until_external_url_load_; | 1933 return wait_until_external_url_load_; |
1939 } | 1934 } |
1940 | 1935 |
1941 const std::set<std::string>* TestRunner::httpHeadersToClear() const { | 1936 const std::set<std::string>* TestRunner::httpHeadersToClear() const { |
1942 return &http_headers_to_clear_; | 1937 return &http_headers_to_clear_; |
1943 } | 1938 } |
1944 | 1939 |
1945 void TestRunner::setTopLoadingFrame(WebFrame* frame, bool clear) { | 1940 void TestRunner::setTopLoadingFrame(WebFrame* frame, bool clear) { |
1946 if (frame->top()->view() != web_view_) | 1941 if (frame->top()->view() != web_view_) |
1947 return; | 1942 return; |
1948 if (!test_is_running_) | 1943 if (!test_is_running_) |
1949 return; | 1944 return; |
1950 if (clear) { | 1945 if (clear) { |
1951 top_loading_frame_ = nullptr; | 1946 top_loading_frame_ = nullptr; |
1952 LocationChangeDone(); | 1947 LocationChangeDone(); |
1953 } else if (!top_loading_frame_) { | 1948 } else if (!top_loading_frame_) { |
1954 top_loading_frame_ = frame; | 1949 top_loading_frame_ = frame; |
1955 } | 1950 } |
1956 } | 1951 } |
1957 | 1952 |
1958 WebFrame* TestRunner::topLoadingFrame() const { | 1953 WebFrame* TestRunner::topLoadingFrame() const { |
1959 return top_loading_frame_; | 1954 return top_loading_frame_; |
1960 } | 1955 } |
1961 | 1956 |
1962 void TestRunner::policyDelegateDone() { | 1957 void TestRunner::policyDelegateDone() { |
1963 DCHECK(wait_until_done_); | 1958 DCHECK(layout_dump_flags_.wait_until_done()); |
1964 delegate_->TestFinished(); | 1959 delegate_->TestFinished(); |
1965 wait_until_done_ = false; | 1960 layout_dump_flags_.set_wait_until_done(false); |
1961 OnLayoutDumpFlagsChanged(); | |
1966 } | 1962 } |
1967 | 1963 |
1968 bool TestRunner::policyDelegateEnabled() const { | 1964 bool TestRunner::policyDelegateEnabled() const { |
1969 return policy_delegate_enabled_; | 1965 return policy_delegate_enabled_; |
1970 } | 1966 } |
1971 | 1967 |
1972 bool TestRunner::policyDelegateIsPermissive() const { | 1968 bool TestRunner::policyDelegateIsPermissive() const { |
1973 return policy_delegate_is_permissive_; | 1969 return policy_delegate_is_permissive_; |
1974 } | 1970 } |
1975 | 1971 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2055 if (disable_notify_done_) | 2051 if (disable_notify_done_) |
2056 return; | 2052 return; |
2057 | 2053 |
2058 // Test didn't timeout. Kill the timeout timer. | 2054 // Test didn't timeout. Kill the timeout timer. |
2059 task_list_.RevokeAll(); | 2055 task_list_.RevokeAll(); |
2060 | 2056 |
2061 CompleteNotifyDone(); | 2057 CompleteNotifyDone(); |
2062 } | 2058 } |
2063 | 2059 |
2064 void TestRunner::WaitUntilDone() { | 2060 void TestRunner::WaitUntilDone() { |
2065 wait_until_done_ = true; | 2061 layout_dump_flags_.set_wait_until_done(true); |
2062 OnLayoutDumpFlagsChanged(); | |
2066 } | 2063 } |
2067 | 2064 |
2068 void TestRunner::QueueBackNavigation(int how_far_back) { | 2065 void TestRunner::QueueBackNavigation(int how_far_back) { |
2069 work_queue_.AddWork(new WorkItemBackForward(-how_far_back)); | 2066 work_queue_.AddWork(new WorkItemBackForward(-how_far_back)); |
2070 } | 2067 } |
2071 | 2068 |
2072 void TestRunner::QueueForwardNavigation(int how_far_forward) { | 2069 void TestRunner::QueueForwardNavigation(int how_far_forward) { |
2073 work_queue_.AddWork(new WorkItemBackForward(how_far_forward)); | 2070 work_queue_.AddWork(new WorkItemBackForward(how_far_forward)); |
2074 } | 2071 } |
2075 | 2072 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2188 | 2185 |
2189 void TestRunner::SetCustomPolicyDelegate(gin::Arguments* args) { | 2186 void TestRunner::SetCustomPolicyDelegate(gin::Arguments* args) { |
2190 args->GetNext(&policy_delegate_enabled_); | 2187 args->GetNext(&policy_delegate_enabled_); |
2191 if (!args->PeekNext().IsEmpty() && args->PeekNext()->IsBoolean()) | 2188 if (!args->PeekNext().IsEmpty() && args->PeekNext()->IsBoolean()) |
2192 args->GetNext(&policy_delegate_is_permissive_); | 2189 args->GetNext(&policy_delegate_is_permissive_); |
2193 } | 2190 } |
2194 | 2191 |
2195 void TestRunner::WaitForPolicyDelegate() { | 2192 void TestRunner::WaitForPolicyDelegate() { |
2196 policy_delegate_enabled_ = true; | 2193 policy_delegate_enabled_ = true; |
2197 policy_delegate_should_notify_done_ = true; | 2194 policy_delegate_should_notify_done_ = true; |
2198 wait_until_done_ = true; | 2195 layout_dump_flags_.set_wait_until_done(true); |
2196 OnLayoutDumpFlagsChanged(); | |
2199 } | 2197 } |
2200 | 2198 |
2201 int TestRunner::WindowCount() { | 2199 int TestRunner::WindowCount() { |
2202 return test_interfaces_->GetWindowList().size(); | 2200 return test_interfaces_->GetWindowList().size(); |
2203 } | 2201 } |
2204 | 2202 |
2205 void TestRunner::SetCloseRemainingWindowsWhenComplete( | 2203 void TestRunner::SetCloseRemainingWindowsWhenComplete( |
2206 bool close_remaining_windows) { | 2204 bool close_remaining_windows) { |
2207 close_remaining_windows_ = close_remaining_windows; | 2205 close_remaining_windows_ = close_remaining_windows; |
2208 } | 2206 } |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2633 | 2631 |
2634 bool TestRunner::AnimationScheduled() { | 2632 bool TestRunner::AnimationScheduled() { |
2635 return proxy_->AnimationScheduled(); | 2633 return proxy_->AnimationScheduled(); |
2636 } | 2634 } |
2637 | 2635 |
2638 void TestRunner::DumpEditingCallbacks() { | 2636 void TestRunner::DumpEditingCallbacks() { |
2639 dump_editting_callbacks_ = true; | 2637 dump_editting_callbacks_ = true; |
2640 } | 2638 } |
2641 | 2639 |
2642 void TestRunner::DumpAsMarkup() { | 2640 void TestRunner::DumpAsMarkup() { |
2643 layout_dump_flags_.dump_as_markup = true; | 2641 layout_dump_flags_.set_dump_as_markup(true); |
2644 generate_pixel_results_ = false; | 2642 layout_dump_flags_.set_generate_pixel_results(false); |
2643 OnLayoutDumpFlagsChanged(); | |
2645 } | 2644 } |
2646 | 2645 |
2647 void TestRunner::DumpAsText() { | 2646 void TestRunner::DumpAsText() { |
2648 layout_dump_flags_.dump_as_text = true; | 2647 layout_dump_flags_.set_dump_as_text(true); |
2649 generate_pixel_results_ = false; | 2648 layout_dump_flags_.set_generate_pixel_results(false); |
2649 OnLayoutDumpFlagsChanged(); | |
2650 } | 2650 } |
2651 | 2651 |
2652 void TestRunner::DumpAsTextWithPixelResults() { | 2652 void TestRunner::DumpAsTextWithPixelResults() { |
2653 layout_dump_flags_.dump_as_text = true; | 2653 layout_dump_flags_.set_dump_as_text(true); |
2654 generate_pixel_results_ = true; | 2654 layout_dump_flags_.set_generate_pixel_results(true); |
2655 OnLayoutDumpFlagsChanged(); | |
2655 } | 2656 } |
2656 | 2657 |
2657 void TestRunner::DumpChildFrameScrollPositions() { | 2658 void TestRunner::DumpChildFrameScrollPositions() { |
2658 layout_dump_flags_.dump_child_frame_scroll_positions = true; | 2659 layout_dump_flags_.set_dump_child_frame_scroll_positions(true); |
2660 OnLayoutDumpFlagsChanged(); | |
2659 } | 2661 } |
2660 | 2662 |
2661 void TestRunner::DumpChildFramesAsMarkup() { | 2663 void TestRunner::DumpChildFramesAsMarkup() { |
2662 layout_dump_flags_.dump_child_frames_as_markup = true; | 2664 layout_dump_flags_.set_dump_child_frames_as_markup(true); |
2665 OnLayoutDumpFlagsChanged(); | |
2663 } | 2666 } |
2664 | 2667 |
2665 void TestRunner::DumpChildFramesAsText() { | 2668 void TestRunner::DumpChildFramesAsText() { |
2666 layout_dump_flags_.dump_child_frames_as_text = true; | 2669 layout_dump_flags_.set_dump_child_frames_as_text(true); |
2670 OnLayoutDumpFlagsChanged(); | |
2667 } | 2671 } |
2668 | 2672 |
2669 void TestRunner::DumpIconChanges() { | 2673 void TestRunner::DumpIconChanges() { |
2670 dump_icon_changes_ = true; | 2674 dump_icon_changes_ = true; |
2671 } | 2675 } |
2672 | 2676 |
2673 void TestRunner::SetAudioData(const gin::ArrayBufferView& view) { | 2677 void TestRunner::SetAudioData(const gin::ArrayBufferView& view) { |
2674 unsigned char* bytes = static_cast<unsigned char*>(view.bytes()); | 2678 unsigned char* bytes = static_cast<unsigned char*>(view.bytes()); |
2675 audio_data_.resize(view.num_bytes()); | 2679 audio_data_.resize(view.num_bytes()); |
2676 std::copy(bytes, bytes + view.num_bytes(), audio_data_.begin()); | 2680 std::copy(bytes, bytes + view.num_bytes(), audio_data_.begin()); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2755 | 2759 |
2756 void TestRunner::DumpBackForwardList() { | 2760 void TestRunner::DumpBackForwardList() { |
2757 dump_back_forward_list_ = true; | 2761 dump_back_forward_list_ = true; |
2758 } | 2762 } |
2759 | 2763 |
2760 void TestRunner::DumpSelectionRect() { | 2764 void TestRunner::DumpSelectionRect() { |
2761 dump_selection_rect_ = true; | 2765 dump_selection_rect_ = true; |
2762 } | 2766 } |
2763 | 2767 |
2764 void TestRunner::SetPrinting() { | 2768 void TestRunner::SetPrinting() { |
2765 layout_dump_flags_.is_printing = true; | 2769 layout_dump_flags_.set_is_printing(true); |
2770 OnLayoutDumpFlagsChanged(); | |
2766 } | 2771 } |
2767 | 2772 |
2768 void TestRunner::ClearPrinting() { | 2773 void TestRunner::ClearPrinting() { |
2769 layout_dump_flags_.is_printing = false; | 2774 layout_dump_flags_.set_is_printing(false); |
2775 OnLayoutDumpFlagsChanged(); | |
2770 } | 2776 } |
2771 | 2777 |
2772 void TestRunner::SetShouldStayOnPageAfterHandlingBeforeUnload(bool value) { | 2778 void TestRunner::SetShouldStayOnPageAfterHandlingBeforeUnload(bool value) { |
2773 should_stay_on_page_after_handling_before_unload_ = value; | 2779 should_stay_on_page_after_handling_before_unload_ = value; |
2774 } | 2780 } |
2775 | 2781 |
2776 void TestRunner::SetWillSendRequestClearHeader(const std::string& header) { | 2782 void TestRunner::SetWillSendRequestClearHeader(const std::string& header) { |
2777 if (!header.empty()) | 2783 if (!header.empty()) |
2778 http_headers_to_clear_.insert(header); | 2784 http_headers_to_clear_.insert(header); |
2779 } | 2785 } |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3013 } | 3019 } |
3014 | 3020 |
3015 void TestRunner::CapturePixelsAsyncThen(v8::Local<v8::Function> callback) { | 3021 void TestRunner::CapturePixelsAsyncThen(v8::Local<v8::Function> callback) { |
3016 scoped_ptr<InvokeCallbackTask> task( | 3022 scoped_ptr<InvokeCallbackTask> task( |
3017 new InvokeCallbackTask(this, callback)); | 3023 new InvokeCallbackTask(this, callback)); |
3018 proxy_->CapturePixelsAsync(base::Bind(&TestRunner::CapturePixelsCallback, | 3024 proxy_->CapturePixelsAsync(base::Bind(&TestRunner::CapturePixelsCallback, |
3019 weak_factory_.GetWeakPtr(), | 3025 weak_factory_.GetWeakPtr(), |
3020 base::Passed(&task))); | 3026 base::Passed(&task))); |
3021 } | 3027 } |
3022 | 3028 |
3029 void TestRunner::OnLayoutDumpFlagsChanged() { | |
3030 if (layout_dump_flags_.tracked_dictionary().changed_values().size() == 0) | |
dcheng
2016/03/08 23:09:37
.empty()?
Łukasz Anforowicz
2016/03/10 22:24:21
Done.
| |
3031 return; | |
3032 | |
3033 delegate_->OnLayoutDumpFlagsChanged(&layout_dump_flags_); | |
dcheng
2016/03/08 23:09:37
Nit: pass a const ref, I don't see a place that ac
Łukasz Anforowicz
2016/03/10 22:24:21
Done. I've moved responsibility for deciding when
| |
3034 } | |
3035 | |
3023 void TestRunner::ForceNextWebGLContextCreationToFail() { | 3036 void TestRunner::ForceNextWebGLContextCreationToFail() { |
3024 if (web_view_) | 3037 if (web_view_) |
3025 web_view_->forceNextWebGLContextCreationToFail(); | 3038 web_view_->forceNextWebGLContextCreationToFail(); |
3026 } | 3039 } |
3027 | 3040 |
3028 void TestRunner::ForceNextDrawingBufferCreationToFail() { | 3041 void TestRunner::ForceNextDrawingBufferCreationToFail() { |
3029 if (web_view_) | 3042 if (web_view_) |
3030 web_view_->forceNextDrawingBufferCreationToFail(); | 3043 web_view_->forceNextDrawingBufferCreationToFail(); |
3031 } | 3044 } |
3032 | 3045 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3130 task->SetArguments(1, arg); | 3143 task->SetArguments(1, arg); |
3131 InvokeCallback(std::move(task)); | 3144 InvokeCallback(std::move(task)); |
3132 } | 3145 } |
3133 | 3146 |
3134 void TestRunner::LocationChangeDone() { | 3147 void TestRunner::LocationChangeDone() { |
3135 web_history_item_count_ = delegate_->NavigationEntryCount(); | 3148 web_history_item_count_ = delegate_->NavigationEntryCount(); |
3136 | 3149 |
3137 // No more new work after the first complete load. | 3150 // No more new work after the first complete load. |
3138 work_queue_.set_frozen(true); | 3151 work_queue_.set_frozen(true); |
3139 | 3152 |
3140 if (!wait_until_done_) | 3153 if (!layout_dump_flags_.wait_until_done()) |
3141 work_queue_.ProcessWorkSoon(); | 3154 work_queue_.ProcessWorkSoon(); |
3142 } | 3155 } |
3143 | 3156 |
3144 void TestRunner::CheckResponseMimeType() { | 3157 void TestRunner::CheckResponseMimeType() { |
3145 // Text output: the test page can request different types of output which we | 3158 // Text output: the test page can request different types of output which we |
3146 // handle here. | 3159 // handle here. |
3147 if (!layout_dump_flags_.dump_as_text) { | 3160 |
3148 std::string mimeType = | 3161 if (layout_dump_flags_.dump_as_text()) |
3149 web_view_->mainFrame()->dataSource()->response().mimeType().utf8(); | 3162 return; |
3150 if (mimeType == "text/plain") { | 3163 |
3151 layout_dump_flags_.dump_as_text = true; | 3164 WebDataSource* data_source = web_view_->mainFrame()->dataSource(); |
3152 generate_pixel_results_ = false; | 3165 if (!data_source) |
3153 } | 3166 return; |
3154 } | 3167 |
3168 std::string mimeType = data_source->response().mimeType().utf8(); | |
3169 if (mimeType != "text/plain") | |
3170 return; | |
3171 | |
3172 layout_dump_flags_.set_dump_as_text(true); | |
3173 layout_dump_flags_.set_generate_pixel_results(false); | |
3174 OnLayoutDumpFlagsChanged(); | |
3155 } | 3175 } |
3156 | 3176 |
3157 void TestRunner::CompleteNotifyDone() { | 3177 void TestRunner::CompleteNotifyDone() { |
3158 if (wait_until_done_ && !topLoadingFrame() && work_queue_.is_empty()) | 3178 if (layout_dump_flags_.wait_until_done() && !topLoadingFrame() && |
3179 work_queue_.is_empty()) | |
3159 delegate_->TestFinished(); | 3180 delegate_->TestFinished(); |
3160 wait_until_done_ = false; | 3181 layout_dump_flags_.set_wait_until_done(false); |
3182 OnLayoutDumpFlagsChanged(); | |
3161 } | 3183 } |
3162 | 3184 |
3163 void TestRunner::DidAcquirePointerLockInternal() { | 3185 void TestRunner::DidAcquirePointerLockInternal() { |
3164 pointer_locked_ = true; | 3186 pointer_locked_ = true; |
3165 web_view_->didAcquirePointerLock(); | 3187 web_view_->didAcquirePointerLock(); |
3166 | 3188 |
3167 // Reset planned result to default. | 3189 // Reset planned result to default. |
3168 pointer_lock_planned_result_ = PointerLockWillSucceed; | 3190 pointer_lock_planned_result_ = PointerLockWillSucceed; |
3169 } | 3191 } |
3170 | 3192 |
3171 void TestRunner::DidNotAcquirePointerLockInternal() { | 3193 void TestRunner::DidNotAcquirePointerLockInternal() { |
3172 DCHECK(!pointer_locked_); | 3194 DCHECK(!pointer_locked_); |
3173 pointer_locked_ = false; | 3195 pointer_locked_ = false; |
3174 web_view_->didNotAcquirePointerLock(); | 3196 web_view_->didNotAcquirePointerLock(); |
3175 | 3197 |
3176 // Reset planned result to default. | 3198 // Reset planned result to default. |
3177 pointer_lock_planned_result_ = PointerLockWillSucceed; | 3199 pointer_lock_planned_result_ = PointerLockWillSucceed; |
3178 } | 3200 } |
3179 | 3201 |
3180 void TestRunner::DidLosePointerLockInternal() { | 3202 void TestRunner::DidLosePointerLockInternal() { |
3181 bool was_locked = pointer_locked_; | 3203 bool was_locked = pointer_locked_; |
3182 pointer_locked_ = false; | 3204 pointer_locked_ = false; |
3183 if (was_locked) | 3205 if (was_locked) |
3184 web_view_->didLosePointerLock(); | 3206 web_view_->didLosePointerLock(); |
3185 } | 3207 } |
3186 | 3208 |
3187 } // namespace test_runner | 3209 } // namespace test_runner |
OLD | NEW |