| 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 1601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1612 Reset(); | 1612 Reset(); |
| 1613 } | 1613 } |
| 1614 | 1614 |
| 1615 void TestRunner::WorkQueue::ProcessWorkSoon() { | 1615 void TestRunner::WorkQueue::ProcessWorkSoon() { |
| 1616 if (controller_->topLoadingFrame()) | 1616 if (controller_->topLoadingFrame()) |
| 1617 return; | 1617 return; |
| 1618 | 1618 |
| 1619 if (!queue_.empty()) { | 1619 if (!queue_.empty()) { |
| 1620 // We delay processing queued work to avoid recursion problems. | 1620 // We delay processing queued work to avoid recursion problems. |
| 1621 controller_->delegate_->PostTask(new WorkQueueTask(this)); | 1621 controller_->delegate_->PostTask(new WorkQueueTask(this)); |
| 1622 } else if (!controller_->wait_until_done_) { | 1622 } else if (!controller_->layout_dump_flags_.wait_until_done()) { |
| 1623 controller_->delegate_->TestFinished(); | 1623 controller_->delegate_->TestFinished(); |
| 1624 } | 1624 } |
| 1625 } | 1625 } |
| 1626 | 1626 |
| 1627 void TestRunner::WorkQueue::Reset() { | 1627 void TestRunner::WorkQueue::Reset() { |
| 1628 frozen_ = false; | 1628 frozen_ = false; |
| 1629 while (!queue_.empty()) { | 1629 while (!queue_.empty()) { |
| 1630 delete queue_.front(); | 1630 delete queue_.front(); |
| 1631 queue_.pop_front(); | 1631 queue_.pop_front(); |
| 1632 } | 1632 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1644 // Quit doing work once a load is in progress. | 1644 // Quit doing work once a load is in progress. |
| 1645 while (!queue_.empty()) { | 1645 while (!queue_.empty()) { |
| 1646 bool startedLoad = queue_.front()->Run(controller_->delegate_, | 1646 bool startedLoad = queue_.front()->Run(controller_->delegate_, |
| 1647 controller_->web_view_); | 1647 controller_->web_view_); |
| 1648 delete queue_.front(); | 1648 delete queue_.front(); |
| 1649 queue_.pop_front(); | 1649 queue_.pop_front(); |
| 1650 if (startedLoad) | 1650 if (startedLoad) |
| 1651 return; | 1651 return; |
| 1652 } | 1652 } |
| 1653 | 1653 |
| 1654 if (!controller_->wait_until_done_ && !controller_->topLoadingFrame()) | 1654 if (!controller_->layout_dump_flags_.wait_until_done() && |
| 1655 !controller_->topLoadingFrame()) |
| 1655 controller_->delegate_->TestFinished(); | 1656 controller_->delegate_->TestFinished(); |
| 1656 } | 1657 } |
| 1657 | 1658 |
| 1658 void TestRunner::WorkQueue::WorkQueueTask::RunIfValid() { | 1659 void TestRunner::WorkQueue::WorkQueueTask::RunIfValid() { |
| 1659 object_->ProcessWork(); | 1660 object_->ProcessWork(); |
| 1660 } | 1661 } |
| 1661 | 1662 |
| 1662 TestRunner::TestRunner(TestInterfaces* interfaces) | 1663 TestRunner::TestRunner(TestInterfaces* interfaces) |
| 1663 : test_is_running_(false), | 1664 : test_is_running_(false), |
| 1664 close_remaining_windows_(false), | 1665 close_remaining_windows_(false), |
| 1665 work_queue_(this), | 1666 work_queue_(this), |
| 1666 disable_notify_done_(false), | 1667 disable_notify_done_(false), |
| 1667 web_history_item_count_(0), | 1668 web_history_item_count_(0), |
| 1668 intercept_post_message_(false), | 1669 intercept_post_message_(false), |
| 1669 layout_dump_flags_( | |
| 1670 false, // dump_as_text | |
| 1671 false, // dump_child_frames_as_text | |
| 1672 false, // dump_as_markup | |
| 1673 false, // dump_child_frames_as_markup | |
| 1674 false, // dump_child_frame_scroll_positions | |
| 1675 false), // is_printing | |
| 1676 test_interfaces_(interfaces), | 1670 test_interfaces_(interfaces), |
| 1677 delegate_(nullptr), | 1671 delegate_(nullptr), |
| 1678 web_view_(nullptr), | 1672 web_view_(nullptr), |
| 1679 web_content_settings_(new WebContentSettings()), | 1673 web_content_settings_(new WebContentSettings()), |
| 1680 weak_factory_(this) {} | 1674 weak_factory_(this) {} |
| 1681 | 1675 |
| 1682 TestRunner::~TestRunner() {} | 1676 TestRunner::~TestRunner() {} |
| 1683 | 1677 |
| 1684 void TestRunner::Install(WebFrame* frame) { | 1678 void TestRunner::Install(WebFrame* frame) { |
| 1685 TestRunnerBindings::Install(weak_factory_.GetWeakPtr(), frame); | 1679 TestRunnerBindings::Install(weak_factory_.GetWeakPtr(), frame); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1706 web_view_->setSelectionColors( | 1700 web_view_->setSelectionColors( |
| 1707 0xff1e90ff, 0xff000000, 0xffc8c8c8, 0xff323232); | 1701 0xff1e90ff, 0xff000000, 0xffc8c8c8, 0xff323232); |
| 1708 #endif | 1702 #endif |
| 1709 web_view_->setVisibilityState(WebPageVisibilityStateVisible, true); | 1703 web_view_->setVisibilityState(WebPageVisibilityStateVisible, true); |
| 1710 web_view_->mainFrame()->enableViewSourceMode(false); | 1704 web_view_->mainFrame()->enableViewSourceMode(false); |
| 1711 | 1705 |
| 1712 web_view_->setPageOverlayColor(SK_ColorTRANSPARENT); | 1706 web_view_->setPageOverlayColor(SK_ColorTRANSPARENT); |
| 1713 } | 1707 } |
| 1714 | 1708 |
| 1715 top_loading_frame_ = nullptr; | 1709 top_loading_frame_ = nullptr; |
| 1716 wait_until_done_ = false; | 1710 layout_dump_flags_.Reset(); |
| 1717 wait_until_external_url_load_ = false; | 1711 wait_until_external_url_load_ = false; |
| 1718 policy_delegate_enabled_ = false; | 1712 policy_delegate_enabled_ = false; |
| 1719 policy_delegate_is_permissive_ = false; | 1713 policy_delegate_is_permissive_ = false; |
| 1720 policy_delegate_should_notify_done_ = false; | 1714 policy_delegate_should_notify_done_ = false; |
| 1721 | 1715 |
| 1722 WebSecurityPolicy::resetOriginAccessWhitelists(); | 1716 WebSecurityPolicy::resetOriginAccessWhitelists(); |
| 1723 #if defined(__linux__) || defined(ANDROID) | 1717 #if defined(__linux__) || defined(ANDROID) |
| 1724 WebFontRendering::setSubpixelPositioning(false); | 1718 WebFontRendering::setSubpixelPositioning(false); |
| 1725 #endif | 1719 #endif |
| 1726 | 1720 |
| 1727 if (delegate_) { | 1721 if (delegate_) { |
| 1728 // Reset the default quota for each origin to 5MB | 1722 // Reset the default quota for each origin to 5MB |
| 1729 delegate_->SetDatabaseQuota(5 * 1024 * 1024); | 1723 delegate_->SetDatabaseQuota(5 * 1024 * 1024); |
| 1730 delegate_->SetDeviceColorProfile("reset"); | 1724 delegate_->SetDeviceColorProfile("reset"); |
| 1731 delegate_->SetDeviceScaleFactor(GetDefaultDeviceScaleFactor()); | 1725 delegate_->SetDeviceScaleFactor(GetDefaultDeviceScaleFactor()); |
| 1732 delegate_->SetAcceptAllCookies(false); | 1726 delegate_->SetAcceptAllCookies(false); |
| 1733 delegate_->SetLocale(""); | 1727 delegate_->SetLocale(""); |
| 1734 delegate_->UseUnfortunateSynchronousResizeMode(false); | 1728 delegate_->UseUnfortunateSynchronousResizeMode(false); |
| 1735 delegate_->DisableAutoResizeMode(WebSize()); | 1729 delegate_->DisableAutoResizeMode(WebSize()); |
| 1736 delegate_->DeleteAllCookies(); | 1730 delegate_->DeleteAllCookies(); |
| 1737 delegate_->ResetScreenOrientation(); | 1731 delegate_->ResetScreenOrientation(); |
| 1738 delegate_->SetBluetoothMockDataSet(""); | 1732 delegate_->SetBluetoothMockDataSet(""); |
| 1739 delegate_->ClearGeofencingMockProvider(); | 1733 delegate_->ClearGeofencingMockProvider(); |
| 1740 delegate_->ResetPermissions(); | 1734 delegate_->ResetPermissions(); |
| 1741 ResetDeviceLight(); | 1735 ResetDeviceLight(); |
| 1742 } | 1736 } |
| 1743 | 1737 |
| 1744 dump_editting_callbacks_ = false; | 1738 dump_editting_callbacks_ = false; |
| 1745 layout_dump_flags_.dump_as_text = false; | |
| 1746 layout_dump_flags_.dump_as_markup = false; | |
| 1747 generate_pixel_results_ = true; | |
| 1748 layout_dump_flags_.dump_child_frame_scroll_positions = false; | |
| 1749 layout_dump_flags_.dump_child_frames_as_text = false; | |
| 1750 layout_dump_flags_.dump_child_frames_as_markup = false; | |
| 1751 dump_icon_changes_ = false; | 1739 dump_icon_changes_ = false; |
| 1752 dump_as_audio_ = false; | 1740 dump_as_audio_ = false; |
| 1753 dump_frame_load_callbacks_ = false; | 1741 dump_frame_load_callbacks_ = false; |
| 1754 dump_ping_loader_callbacks_ = false; | 1742 dump_ping_loader_callbacks_ = false; |
| 1755 dump_user_gesture_in_frame_load_callbacks_ = false; | 1743 dump_user_gesture_in_frame_load_callbacks_ = false; |
| 1756 dump_title_changes_ = false; | 1744 dump_title_changes_ = false; |
| 1757 dump_create_view_ = false; | 1745 dump_create_view_ = false; |
| 1758 can_open_windows_ = false; | 1746 can_open_windows_ = false; |
| 1759 dump_resource_load_callbacks_ = false; | 1747 dump_resource_load_callbacks_ = false; |
| 1760 dump_resource_request_callbacks_ = false; | 1748 dump_resource_request_callbacks_ = false; |
| 1761 dump_resource_response_mime_types_ = false; | 1749 dump_resource_response_mime_types_ = false; |
| 1762 dump_window_status_changes_ = false; | 1750 dump_window_status_changes_ = false; |
| 1763 dump_spell_check_callbacks_ = false; | 1751 dump_spell_check_callbacks_ = false; |
| 1764 dump_back_forward_list_ = false; | 1752 dump_back_forward_list_ = false; |
| 1765 dump_selection_rect_ = false; | 1753 dump_selection_rect_ = false; |
| 1766 dump_drag_image_ = false; | 1754 dump_drag_image_ = false; |
| 1767 dump_navigation_policy_ = false; | 1755 dump_navigation_policy_ = false; |
| 1768 test_repaint_ = false; | 1756 test_repaint_ = false; |
| 1769 sweep_horizontally_ = false; | 1757 sweep_horizontally_ = false; |
| 1770 layout_dump_flags_.is_printing = false; | |
| 1771 midi_accessor_result_ = true; | 1758 midi_accessor_result_ = true; |
| 1772 should_stay_on_page_after_handling_before_unload_ = false; | 1759 should_stay_on_page_after_handling_before_unload_ = false; |
| 1773 should_dump_resource_priorities_ = false; | 1760 should_dump_resource_priorities_ = false; |
| 1774 has_custom_text_output_ = false; | 1761 has_custom_text_output_ = false; |
| 1775 custom_text_output_.clear(); | 1762 custom_text_output_.clear(); |
| 1776 | 1763 |
| 1777 http_headers_to_clear_.clear(); | 1764 http_headers_to_clear_.clear(); |
| 1778 | 1765 |
| 1779 platform_name_ = "chromium"; | 1766 platform_name_ = "chromium"; |
| 1780 tooltip_text_ = std::string(); | 1767 tooltip_text_ = std::string(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1804 | 1791 |
| 1805 void TestRunner::InvokeCallback(scoped_ptr<InvokeCallbackTask> task) { | 1792 void TestRunner::InvokeCallback(scoped_ptr<InvokeCallbackTask> task) { |
| 1806 delegate_->PostTask(task.release()); | 1793 delegate_->PostTask(task.release()); |
| 1807 } | 1794 } |
| 1808 | 1795 |
| 1809 bool TestRunner::shouldDumpEditingCallbacks() const { | 1796 bool TestRunner::shouldDumpEditingCallbacks() const { |
| 1810 return dump_editting_callbacks_; | 1797 return dump_editting_callbacks_; |
| 1811 } | 1798 } |
| 1812 | 1799 |
| 1813 void TestRunner::setShouldDumpAsText(bool value) { | 1800 void TestRunner::setShouldDumpAsText(bool value) { |
| 1814 layout_dump_flags_.dump_as_text = value; | 1801 layout_dump_flags_.set_dump_as_text(value); |
| 1802 OnLayoutDumpFlagsChanged(); |
| 1815 } | 1803 } |
| 1816 | 1804 |
| 1817 void TestRunner::setShouldDumpAsMarkup(bool value) { | 1805 void TestRunner::setShouldDumpAsMarkup(bool value) { |
| 1818 layout_dump_flags_.dump_as_markup = value; | 1806 layout_dump_flags_.set_dump_as_markup(value); |
| 1807 OnLayoutDumpFlagsChanged(); |
| 1819 } | 1808 } |
| 1820 | 1809 |
| 1821 bool TestRunner::shouldDumpAsCustomText() const { | 1810 bool TestRunner::shouldDumpAsCustomText() const { |
| 1822 return has_custom_text_output_; | 1811 return has_custom_text_output_; |
| 1823 } | 1812 } |
| 1824 | 1813 |
| 1825 std::string TestRunner::customDumpText() const { | 1814 std::string TestRunner::customDumpText() const { |
| 1826 return custom_text_output_; | 1815 return custom_text_output_; |
| 1827 } | 1816 } |
| 1828 | 1817 |
| 1829 void TestRunner::setCustomTextOutput(const std::string& text) { | 1818 void TestRunner::setCustomTextOutput(const std::string& text) { |
| 1830 custom_text_output_ = text; | 1819 custom_text_output_ = text; |
| 1831 has_custom_text_output_ = true; | 1820 has_custom_text_output_ = true; |
| 1832 } | 1821 } |
| 1833 | 1822 |
| 1834 bool TestRunner::ShouldGeneratePixelResults() { | 1823 bool TestRunner::ShouldGeneratePixelResults() { |
| 1835 CheckResponseMimeType(); | 1824 CheckResponseMimeType(); |
| 1836 return generate_pixel_results_; | 1825 return layout_dump_flags_.generate_pixel_results(); |
| 1837 } | 1826 } |
| 1838 | 1827 |
| 1839 bool TestRunner::ShouldStayOnPageAfterHandlingBeforeUnload() const { | 1828 bool TestRunner::ShouldStayOnPageAfterHandlingBeforeUnload() const { |
| 1840 return should_stay_on_page_after_handling_before_unload_; | 1829 return should_stay_on_page_after_handling_before_unload_; |
| 1841 } | 1830 } |
| 1842 | 1831 |
| 1843 | 1832 |
| 1844 void TestRunner::setShouldGeneratePixelResults(bool value) { | 1833 void TestRunner::setShouldGeneratePixelResults(bool value) { |
| 1845 generate_pixel_results_ = value; | 1834 layout_dump_flags_.set_generate_pixel_results(value); |
| 1835 OnLayoutDumpFlagsChanged(); |
| 1846 } | 1836 } |
| 1847 | 1837 |
| 1848 bool TestRunner::ShouldDumpAsAudio() const { | 1838 bool TestRunner::ShouldDumpAsAudio() const { |
| 1849 return dump_as_audio_; | 1839 return dump_as_audio_; |
| 1850 } | 1840 } |
| 1851 | 1841 |
| 1852 void TestRunner::GetAudioData(std::vector<unsigned char>* buffer_view) const { | 1842 void TestRunner::GetAudioData(std::vector<unsigned char>* buffer_view) const { |
| 1853 *buffer_view = audio_data_; | 1843 *buffer_view = audio_data_; |
| 1854 } | 1844 } |
| 1855 | 1845 |
| 1856 const LayoutDumpFlags& TestRunner::GetLayoutDumpFlags() { | 1846 const LayoutDumpFlags& TestRunner::GetLayoutDumpFlags() { |
| 1857 CheckResponseMimeType(); | 1847 CheckResponseMimeType(); |
| 1858 return layout_dump_flags_; | 1848 return layout_dump_flags_; |
| 1859 } | 1849 } |
| 1860 | 1850 |
| 1851 void TestRunner::ReplicateLayoutDumpFlagsChanges( |
| 1852 const base::DictionaryValue& changed_values) { |
| 1853 layout_dump_flags_.tracked_dictionary().ApplyUntrackedChanges(changed_values); |
| 1854 } |
| 1855 |
| 1861 bool TestRunner::HasCustomTextDump(std::string* custom_text_dump) const { | 1856 bool TestRunner::HasCustomTextDump(std::string* custom_text_dump) const { |
| 1862 if (shouldDumpAsCustomText()) { | 1857 if (shouldDumpAsCustomText()) { |
| 1863 *custom_text_dump = customDumpText(); | 1858 *custom_text_dump = customDumpText(); |
| 1864 return true; | 1859 return true; |
| 1865 } | 1860 } |
| 1866 | 1861 |
| 1867 return false; | 1862 return false; |
| 1868 } | 1863 } |
| 1869 | 1864 |
| 1870 bool TestRunner::shouldDumpFrameLoadCallbacks() const { | 1865 bool TestRunner::shouldDumpFrameLoadCallbacks() const { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1933 | 1928 |
| 1934 bool TestRunner::ShouldDumpBackForwardList() const { | 1929 bool TestRunner::ShouldDumpBackForwardList() const { |
| 1935 return dump_back_forward_list_; | 1930 return dump_back_forward_list_; |
| 1936 } | 1931 } |
| 1937 | 1932 |
| 1938 bool TestRunner::shouldDumpSelectionRect() const { | 1933 bool TestRunner::shouldDumpSelectionRect() const { |
| 1939 return dump_selection_rect_; | 1934 return dump_selection_rect_; |
| 1940 } | 1935 } |
| 1941 | 1936 |
| 1942 bool TestRunner::isPrinting() const { | 1937 bool TestRunner::isPrinting() const { |
| 1943 return layout_dump_flags_.is_printing; | 1938 return layout_dump_flags_.is_printing(); |
| 1944 } | 1939 } |
| 1945 | 1940 |
| 1946 bool TestRunner::shouldWaitUntilExternalURLLoad() const { | 1941 bool TestRunner::shouldWaitUntilExternalURLLoad() const { |
| 1947 return wait_until_external_url_load_; | 1942 return wait_until_external_url_load_; |
| 1948 } | 1943 } |
| 1949 | 1944 |
| 1950 const std::set<std::string>* TestRunner::httpHeadersToClear() const { | 1945 const std::set<std::string>* TestRunner::httpHeadersToClear() const { |
| 1951 return &http_headers_to_clear_; | 1946 return &http_headers_to_clear_; |
| 1952 } | 1947 } |
| 1953 | 1948 |
| 1954 void TestRunner::setTopLoadingFrame(WebFrame* frame, bool clear) { | 1949 void TestRunner::setTopLoadingFrame(WebFrame* frame, bool clear) { |
| 1955 if (frame->top()->view() != web_view_) | 1950 if (frame->top()->view() != web_view_) |
| 1956 return; | 1951 return; |
| 1957 if (!test_is_running_) | 1952 if (!test_is_running_) |
| 1958 return; | 1953 return; |
| 1959 if (clear) { | 1954 if (clear) { |
| 1960 top_loading_frame_ = nullptr; | 1955 top_loading_frame_ = nullptr; |
| 1961 LocationChangeDone(); | 1956 LocationChangeDone(); |
| 1962 } else if (!top_loading_frame_) { | 1957 } else if (!top_loading_frame_) { |
| 1963 top_loading_frame_ = frame; | 1958 top_loading_frame_ = frame; |
| 1964 } | 1959 } |
| 1965 } | 1960 } |
| 1966 | 1961 |
| 1967 WebFrame* TestRunner::topLoadingFrame() const { | 1962 WebFrame* TestRunner::topLoadingFrame() const { |
| 1968 return top_loading_frame_; | 1963 return top_loading_frame_; |
| 1969 } | 1964 } |
| 1970 | 1965 |
| 1971 void TestRunner::policyDelegateDone() { | 1966 void TestRunner::policyDelegateDone() { |
| 1972 DCHECK(wait_until_done_); | 1967 DCHECK(layout_dump_flags_.wait_until_done()); |
| 1973 delegate_->TestFinished(); | 1968 delegate_->TestFinished(); |
| 1974 wait_until_done_ = false; | 1969 layout_dump_flags_.set_wait_until_done(false); |
| 1970 OnLayoutDumpFlagsChanged(); |
| 1975 } | 1971 } |
| 1976 | 1972 |
| 1977 bool TestRunner::policyDelegateEnabled() const { | 1973 bool TestRunner::policyDelegateEnabled() const { |
| 1978 return policy_delegate_enabled_; | 1974 return policy_delegate_enabled_; |
| 1979 } | 1975 } |
| 1980 | 1976 |
| 1981 bool TestRunner::policyDelegateIsPermissive() const { | 1977 bool TestRunner::policyDelegateIsPermissive() const { |
| 1982 return policy_delegate_is_permissive_; | 1978 return policy_delegate_is_permissive_; |
| 1983 } | 1979 } |
| 1984 | 1980 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2064 if (disable_notify_done_) | 2060 if (disable_notify_done_) |
| 2065 return; | 2061 return; |
| 2066 | 2062 |
| 2067 // Test didn't timeout. Kill the timeout timer. | 2063 // Test didn't timeout. Kill the timeout timer. |
| 2068 task_list_.RevokeAll(); | 2064 task_list_.RevokeAll(); |
| 2069 | 2065 |
| 2070 CompleteNotifyDone(); | 2066 CompleteNotifyDone(); |
| 2071 } | 2067 } |
| 2072 | 2068 |
| 2073 void TestRunner::WaitUntilDone() { | 2069 void TestRunner::WaitUntilDone() { |
| 2074 wait_until_done_ = true; | 2070 layout_dump_flags_.set_wait_until_done(true); |
| 2071 OnLayoutDumpFlagsChanged(); |
| 2075 } | 2072 } |
| 2076 | 2073 |
| 2077 void TestRunner::QueueBackNavigation(int how_far_back) { | 2074 void TestRunner::QueueBackNavigation(int how_far_back) { |
| 2078 work_queue_.AddWork(new WorkItemBackForward(-how_far_back)); | 2075 work_queue_.AddWork(new WorkItemBackForward(-how_far_back)); |
| 2079 } | 2076 } |
| 2080 | 2077 |
| 2081 void TestRunner::QueueForwardNavigation(int how_far_forward) { | 2078 void TestRunner::QueueForwardNavigation(int how_far_forward) { |
| 2082 work_queue_.AddWork(new WorkItemBackForward(how_far_forward)); | 2079 work_queue_.AddWork(new WorkItemBackForward(how_far_forward)); |
| 2083 } | 2080 } |
| 2084 | 2081 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2197 | 2194 |
| 2198 void TestRunner::SetCustomPolicyDelegate(gin::Arguments* args) { | 2195 void TestRunner::SetCustomPolicyDelegate(gin::Arguments* args) { |
| 2199 args->GetNext(&policy_delegate_enabled_); | 2196 args->GetNext(&policy_delegate_enabled_); |
| 2200 if (!args->PeekNext().IsEmpty() && args->PeekNext()->IsBoolean()) | 2197 if (!args->PeekNext().IsEmpty() && args->PeekNext()->IsBoolean()) |
| 2201 args->GetNext(&policy_delegate_is_permissive_); | 2198 args->GetNext(&policy_delegate_is_permissive_); |
| 2202 } | 2199 } |
| 2203 | 2200 |
| 2204 void TestRunner::WaitForPolicyDelegate() { | 2201 void TestRunner::WaitForPolicyDelegate() { |
| 2205 policy_delegate_enabled_ = true; | 2202 policy_delegate_enabled_ = true; |
| 2206 policy_delegate_should_notify_done_ = true; | 2203 policy_delegate_should_notify_done_ = true; |
| 2207 wait_until_done_ = true; | 2204 layout_dump_flags_.set_wait_until_done(true); |
| 2205 OnLayoutDumpFlagsChanged(); |
| 2208 } | 2206 } |
| 2209 | 2207 |
| 2210 int TestRunner::WindowCount() { | 2208 int TestRunner::WindowCount() { |
| 2211 return test_interfaces_->GetWindowList().size(); | 2209 return test_interfaces_->GetWindowList().size(); |
| 2212 } | 2210 } |
| 2213 | 2211 |
| 2214 void TestRunner::SetCloseRemainingWindowsWhenComplete( | 2212 void TestRunner::SetCloseRemainingWindowsWhenComplete( |
| 2215 bool close_remaining_windows) { | 2213 bool close_remaining_windows) { |
| 2216 close_remaining_windows_ = close_remaining_windows; | 2214 close_remaining_windows_ = close_remaining_windows; |
| 2217 } | 2215 } |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2642 | 2640 |
| 2643 bool TestRunner::AnimationScheduled() { | 2641 bool TestRunner::AnimationScheduled() { |
| 2644 return proxy_->AnimationScheduled(); | 2642 return proxy_->AnimationScheduled(); |
| 2645 } | 2643 } |
| 2646 | 2644 |
| 2647 void TestRunner::DumpEditingCallbacks() { | 2645 void TestRunner::DumpEditingCallbacks() { |
| 2648 dump_editting_callbacks_ = true; | 2646 dump_editting_callbacks_ = true; |
| 2649 } | 2647 } |
| 2650 | 2648 |
| 2651 void TestRunner::DumpAsMarkup() { | 2649 void TestRunner::DumpAsMarkup() { |
| 2652 layout_dump_flags_.dump_as_markup = true; | 2650 layout_dump_flags_.set_dump_as_markup(true); |
| 2653 generate_pixel_results_ = false; | 2651 layout_dump_flags_.set_generate_pixel_results(false); |
| 2652 OnLayoutDumpFlagsChanged(); |
| 2654 } | 2653 } |
| 2655 | 2654 |
| 2656 void TestRunner::DumpAsText() { | 2655 void TestRunner::DumpAsText() { |
| 2657 layout_dump_flags_.dump_as_text = true; | 2656 layout_dump_flags_.set_dump_as_text(true); |
| 2658 generate_pixel_results_ = false; | 2657 layout_dump_flags_.set_generate_pixel_results(false); |
| 2658 OnLayoutDumpFlagsChanged(); |
| 2659 } | 2659 } |
| 2660 | 2660 |
| 2661 void TestRunner::DumpAsTextWithPixelResults() { | 2661 void TestRunner::DumpAsTextWithPixelResults() { |
| 2662 layout_dump_flags_.dump_as_text = true; | 2662 layout_dump_flags_.set_dump_as_text(true); |
| 2663 generate_pixel_results_ = true; | 2663 layout_dump_flags_.set_generate_pixel_results(true); |
| 2664 OnLayoutDumpFlagsChanged(); |
| 2664 } | 2665 } |
| 2665 | 2666 |
| 2666 void TestRunner::DumpChildFrameScrollPositions() { | 2667 void TestRunner::DumpChildFrameScrollPositions() { |
| 2667 layout_dump_flags_.dump_child_frame_scroll_positions = true; | 2668 layout_dump_flags_.set_dump_child_frame_scroll_positions(true); |
| 2669 OnLayoutDumpFlagsChanged(); |
| 2668 } | 2670 } |
| 2669 | 2671 |
| 2670 void TestRunner::DumpChildFramesAsMarkup() { | 2672 void TestRunner::DumpChildFramesAsMarkup() { |
| 2671 layout_dump_flags_.dump_child_frames_as_markup = true; | 2673 layout_dump_flags_.set_dump_child_frames_as_markup(true); |
| 2674 OnLayoutDumpFlagsChanged(); |
| 2672 } | 2675 } |
| 2673 | 2676 |
| 2674 void TestRunner::DumpChildFramesAsText() { | 2677 void TestRunner::DumpChildFramesAsText() { |
| 2675 layout_dump_flags_.dump_child_frames_as_text = true; | 2678 layout_dump_flags_.set_dump_child_frames_as_text(true); |
| 2679 OnLayoutDumpFlagsChanged(); |
| 2676 } | 2680 } |
| 2677 | 2681 |
| 2678 void TestRunner::DumpIconChanges() { | 2682 void TestRunner::DumpIconChanges() { |
| 2679 dump_icon_changes_ = true; | 2683 dump_icon_changes_ = true; |
| 2680 } | 2684 } |
| 2681 | 2685 |
| 2682 void TestRunner::SetAudioData(const gin::ArrayBufferView& view) { | 2686 void TestRunner::SetAudioData(const gin::ArrayBufferView& view) { |
| 2683 unsigned char* bytes = static_cast<unsigned char*>(view.bytes()); | 2687 unsigned char* bytes = static_cast<unsigned char*>(view.bytes()); |
| 2684 audio_data_.resize(view.num_bytes()); | 2688 audio_data_.resize(view.num_bytes()); |
| 2685 std::copy(bytes, bytes + view.num_bytes(), audio_data_.begin()); | 2689 std::copy(bytes, bytes + view.num_bytes(), audio_data_.begin()); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2764 | 2768 |
| 2765 void TestRunner::DumpBackForwardList() { | 2769 void TestRunner::DumpBackForwardList() { |
| 2766 dump_back_forward_list_ = true; | 2770 dump_back_forward_list_ = true; |
| 2767 } | 2771 } |
| 2768 | 2772 |
| 2769 void TestRunner::DumpSelectionRect() { | 2773 void TestRunner::DumpSelectionRect() { |
| 2770 dump_selection_rect_ = true; | 2774 dump_selection_rect_ = true; |
| 2771 } | 2775 } |
| 2772 | 2776 |
| 2773 void TestRunner::SetPrinting() { | 2777 void TestRunner::SetPrinting() { |
| 2774 layout_dump_flags_.is_printing = true; | 2778 layout_dump_flags_.set_is_printing(true); |
| 2779 OnLayoutDumpFlagsChanged(); |
| 2775 } | 2780 } |
| 2776 | 2781 |
| 2777 void TestRunner::ClearPrinting() { | 2782 void TestRunner::ClearPrinting() { |
| 2778 layout_dump_flags_.is_printing = false; | 2783 layout_dump_flags_.set_is_printing(false); |
| 2784 OnLayoutDumpFlagsChanged(); |
| 2779 } | 2785 } |
| 2780 | 2786 |
| 2781 void TestRunner::SetShouldStayOnPageAfterHandlingBeforeUnload(bool value) { | 2787 void TestRunner::SetShouldStayOnPageAfterHandlingBeforeUnload(bool value) { |
| 2782 should_stay_on_page_after_handling_before_unload_ = value; | 2788 should_stay_on_page_after_handling_before_unload_ = value; |
| 2783 } | 2789 } |
| 2784 | 2790 |
| 2785 void TestRunner::SetWillSendRequestClearHeader(const std::string& header) { | 2791 void TestRunner::SetWillSendRequestClearHeader(const std::string& header) { |
| 2786 if (!header.empty()) | 2792 if (!header.empty()) |
| 2787 http_headers_to_clear_.insert(header); | 2793 http_headers_to_clear_.insert(header); |
| 2788 } | 2794 } |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3026 } | 3032 } |
| 3027 | 3033 |
| 3028 void TestRunner::CapturePixelsAsyncThen(v8::Local<v8::Function> callback) { | 3034 void TestRunner::CapturePixelsAsyncThen(v8::Local<v8::Function> callback) { |
| 3029 scoped_ptr<InvokeCallbackTask> task( | 3035 scoped_ptr<InvokeCallbackTask> task( |
| 3030 new InvokeCallbackTask(this, callback)); | 3036 new InvokeCallbackTask(this, callback)); |
| 3031 proxy_->CapturePixelsAsync(base::Bind(&TestRunner::CapturePixelsCallback, | 3037 proxy_->CapturePixelsAsync(base::Bind(&TestRunner::CapturePixelsCallback, |
| 3032 weak_factory_.GetWeakPtr(), | 3038 weak_factory_.GetWeakPtr(), |
| 3033 base::Passed(&task))); | 3039 base::Passed(&task))); |
| 3034 } | 3040 } |
| 3035 | 3041 |
| 3042 void TestRunner::OnLayoutDumpFlagsChanged() { |
| 3043 if (layout_dump_flags_.tracked_dictionary().changed_values().empty()) |
| 3044 return; |
| 3045 |
| 3046 delegate_->OnLayoutDumpFlagsChanged( |
| 3047 layout_dump_flags_.tracked_dictionary().changed_values()); |
| 3048 layout_dump_flags_.tracked_dictionary().ResetChangeTracking(); |
| 3049 } |
| 3050 |
| 3036 void TestRunner::ForceNextWebGLContextCreationToFail() { | 3051 void TestRunner::ForceNextWebGLContextCreationToFail() { |
| 3037 if (web_view_) | 3052 if (web_view_) |
| 3038 web_view_->forceNextWebGLContextCreationToFail(); | 3053 web_view_->forceNextWebGLContextCreationToFail(); |
| 3039 } | 3054 } |
| 3040 | 3055 |
| 3041 void TestRunner::ForceNextDrawingBufferCreationToFail() { | 3056 void TestRunner::ForceNextDrawingBufferCreationToFail() { |
| 3042 if (web_view_) | 3057 if (web_view_) |
| 3043 web_view_->forceNextDrawingBufferCreationToFail(); | 3058 web_view_->forceNextDrawingBufferCreationToFail(); |
| 3044 } | 3059 } |
| 3045 | 3060 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3143 task->SetArguments(1, arg); | 3158 task->SetArguments(1, arg); |
| 3144 InvokeCallback(std::move(task)); | 3159 InvokeCallback(std::move(task)); |
| 3145 } | 3160 } |
| 3146 | 3161 |
| 3147 void TestRunner::LocationChangeDone() { | 3162 void TestRunner::LocationChangeDone() { |
| 3148 web_history_item_count_ = delegate_->NavigationEntryCount(); | 3163 web_history_item_count_ = delegate_->NavigationEntryCount(); |
| 3149 | 3164 |
| 3150 // No more new work after the first complete load. | 3165 // No more new work after the first complete load. |
| 3151 work_queue_.set_frozen(true); | 3166 work_queue_.set_frozen(true); |
| 3152 | 3167 |
| 3153 if (!wait_until_done_) | 3168 if (!layout_dump_flags_.wait_until_done()) |
| 3154 work_queue_.ProcessWorkSoon(); | 3169 work_queue_.ProcessWorkSoon(); |
| 3155 } | 3170 } |
| 3156 | 3171 |
| 3157 void TestRunner::CheckResponseMimeType() { | 3172 void TestRunner::CheckResponseMimeType() { |
| 3158 // Text output: the test page can request different types of output which we | 3173 // Text output: the test page can request different types of output which we |
| 3159 // handle here. | 3174 // handle here. |
| 3160 if (!layout_dump_flags_.dump_as_text) { | 3175 |
| 3161 std::string mimeType = | 3176 if (layout_dump_flags_.dump_as_text()) |
| 3162 web_view_->mainFrame()->dataSource()->response().mimeType().utf8(); | 3177 return; |
| 3163 if (mimeType == "text/plain") { | 3178 |
| 3164 layout_dump_flags_.dump_as_text = true; | 3179 WebDataSource* data_source = web_view_->mainFrame()->dataSource(); |
| 3165 generate_pixel_results_ = false; | 3180 if (!data_source) |
| 3166 } | 3181 return; |
| 3167 } | 3182 |
| 3183 std::string mimeType = data_source->response().mimeType().utf8(); |
| 3184 if (mimeType != "text/plain") |
| 3185 return; |
| 3186 |
| 3187 layout_dump_flags_.set_dump_as_text(true); |
| 3188 layout_dump_flags_.set_generate_pixel_results(false); |
| 3189 OnLayoutDumpFlagsChanged(); |
| 3168 } | 3190 } |
| 3169 | 3191 |
| 3170 void TestRunner::CompleteNotifyDone() { | 3192 void TestRunner::CompleteNotifyDone() { |
| 3171 if (wait_until_done_ && !topLoadingFrame() && work_queue_.is_empty()) | 3193 if (layout_dump_flags_.wait_until_done() && !topLoadingFrame() && |
| 3194 work_queue_.is_empty()) |
| 3172 delegate_->TestFinished(); | 3195 delegate_->TestFinished(); |
| 3173 wait_until_done_ = false; | 3196 layout_dump_flags_.set_wait_until_done(false); |
| 3197 OnLayoutDumpFlagsChanged(); |
| 3174 } | 3198 } |
| 3175 | 3199 |
| 3176 void TestRunner::DidAcquirePointerLockInternal() { | 3200 void TestRunner::DidAcquirePointerLockInternal() { |
| 3177 pointer_locked_ = true; | 3201 pointer_locked_ = true; |
| 3178 web_view_->didAcquirePointerLock(); | 3202 web_view_->didAcquirePointerLock(); |
| 3179 | 3203 |
| 3180 // Reset planned result to default. | 3204 // Reset planned result to default. |
| 3181 pointer_lock_planned_result_ = PointerLockWillSucceed; | 3205 pointer_lock_planned_result_ = PointerLockWillSucceed; |
| 3182 } | 3206 } |
| 3183 | 3207 |
| 3184 void TestRunner::DidNotAcquirePointerLockInternal() { | 3208 void TestRunner::DidNotAcquirePointerLockInternal() { |
| 3185 DCHECK(!pointer_locked_); | 3209 DCHECK(!pointer_locked_); |
| 3186 pointer_locked_ = false; | 3210 pointer_locked_ = false; |
| 3187 web_view_->didNotAcquirePointerLock(); | 3211 web_view_->didNotAcquirePointerLock(); |
| 3188 | 3212 |
| 3189 // Reset planned result to default. | 3213 // Reset planned result to default. |
| 3190 pointer_lock_planned_result_ = PointerLockWillSucceed; | 3214 pointer_lock_planned_result_ = PointerLockWillSucceed; |
| 3191 } | 3215 } |
| 3192 | 3216 |
| 3193 void TestRunner::DidLosePointerLockInternal() { | 3217 void TestRunner::DidLosePointerLockInternal() { |
| 3194 bool was_locked = pointer_locked_; | 3218 bool was_locked = pointer_locked_; |
| 3195 pointer_locked_ = false; | 3219 pointer_locked_ = false; |
| 3196 if (was_locked) | 3220 if (was_locked) |
| 3197 web_view_->didLosePointerLock(); | 3221 web_view_->didLosePointerLock(); |
| 3198 } | 3222 } |
| 3199 | 3223 |
| 3200 } // namespace test_runner | 3224 } // namespace test_runner |
| OLD | NEW |