OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 #include <tuple> | 7 #include <tuple> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 return result; | 197 return result; |
198 } | 198 } |
199 | 199 |
200 // Returns CommonNavigationParams for a normal navigation to a data: url, with | 200 // Returns CommonNavigationParams for a normal navigation to a data: url, with |
201 // navigation_start set to Now() plus the given offset. | 201 // navigation_start set to Now() plus the given offset. |
202 CommonNavigationParams MakeCommonNavigationParams( | 202 CommonNavigationParams MakeCommonNavigationParams( |
203 TimeDelta navigation_start_offset) { | 203 TimeDelta navigation_start_offset) { |
204 CommonNavigationParams params; | 204 CommonNavigationParams params; |
205 params.url = GURL("data:text/html,<div>Page</div>"); | 205 params.url = GURL("data:text/html,<div>Page</div>"); |
206 params.navigation_start = base::TimeTicks::Now() + navigation_start_offset; | 206 params.navigation_start = base::TimeTicks::Now() + navigation_start_offset; |
207 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 207 params.navigation_type = FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT; |
208 params.transition = ui::PAGE_TRANSITION_TYPED; | 208 params.transition = ui::PAGE_TRANSITION_TYPED; |
209 return params; | 209 return params; |
210 } | 210 } |
211 | 211 |
212 } // namespace | 212 } // namespace |
213 | 213 |
214 class RenderViewImplTest : public RenderViewTest { | 214 class RenderViewImplTest : public RenderViewTest { |
215 public: | 215 public: |
216 RenderViewImplTest() { | 216 RenderViewImplTest() { |
217 // Attach a pseudo keyboard device to this object. | 217 // Attach a pseudo keyboard device to this object. |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching( | 593 EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching( |
594 FrameHostMsg_UpdateState::ID)); | 594 FrameHostMsg_UpdateState::ID)); |
595 } | 595 } |
596 | 596 |
597 TEST_F(RenderViewImplTest, OnNavigationHttpPost) { | 597 TEST_F(RenderViewImplTest, OnNavigationHttpPost) { |
598 // An http url will trigger a resource load so cannot be used here. | 598 // An http url will trigger a resource load so cannot be used here. |
599 CommonNavigationParams common_params; | 599 CommonNavigationParams common_params; |
600 StartNavigationParams start_params; | 600 StartNavigationParams start_params; |
601 RequestNavigationParams request_params; | 601 RequestNavigationParams request_params; |
602 common_params.url = GURL("data:text/html,<div>Page</div>"); | 602 common_params.url = GURL("data:text/html,<div>Page</div>"); |
603 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 603 common_params.navigation_type = FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT; |
604 common_params.transition = ui::PAGE_TRANSITION_TYPED; | 604 common_params.transition = ui::PAGE_TRANSITION_TYPED; |
605 common_params.method = "POST"; | 605 common_params.method = "POST"; |
606 | 606 |
607 // Set up post data. | 607 // Set up post data. |
608 const char raw_data[] = "post \0\ndata"; | 608 const char raw_data[] = "post \0\ndata"; |
609 const size_t length = arraysize(raw_data); | 609 const size_t length = arraysize(raw_data); |
610 scoped_refptr<ResourceRequestBodyImpl> post_data(new ResourceRequestBodyImpl); | 610 scoped_refptr<ResourceRequestBodyImpl> post_data(new ResourceRequestBodyImpl); |
611 post_data->AppendBytes(raw_data, length); | 611 post_data->AppendBytes(raw_data, length); |
612 common_params.post_data = post_data; | 612 common_params.post_data = post_data; |
613 | 613 |
(...skipping 20 matching lines...) Expand all Loading... |
634 EXPECT_TRUE(successful); | 634 EXPECT_TRUE(successful); |
635 EXPECT_EQ(blink::WebHTTPBody::Element::TypeData, element.type); | 635 EXPECT_EQ(blink::WebHTTPBody::Element::TypeData, element.type); |
636 EXPECT_EQ(length, element.data.size()); | 636 EXPECT_EQ(length, element.data.size()); |
637 EXPECT_EQ(0, memcmp(raw_data, element.data.data(), length)); | 637 EXPECT_EQ(0, memcmp(raw_data, element.data.data(), length)); |
638 } | 638 } |
639 | 639 |
640 #if defined(OS_ANDROID) | 640 #if defined(OS_ANDROID) |
641 TEST_F(RenderViewImplTest, OnNavigationLoadDataWithBaseURL) { | 641 TEST_F(RenderViewImplTest, OnNavigationLoadDataWithBaseURL) { |
642 CommonNavigationParams common_params; | 642 CommonNavigationParams common_params; |
643 common_params.url = GURL("data:text/html,"); | 643 common_params.url = GURL("data:text/html,"); |
644 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 644 common_params.navigation_type = FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT; |
645 common_params.transition = ui::PAGE_TRANSITION_TYPED; | 645 common_params.transition = ui::PAGE_TRANSITION_TYPED; |
646 common_params.base_url_for_data_url = GURL("about:blank"); | 646 common_params.base_url_for_data_url = GURL("about:blank"); |
647 common_params.history_url_for_data_url = GURL("about:blank"); | 647 common_params.history_url_for_data_url = GURL("about:blank"); |
648 RequestNavigationParams request_params; | 648 RequestNavigationParams request_params; |
649 request_params.data_url_as_string = | 649 request_params.data_url_as_string = |
650 "data:text/html,<html><head><title>Data page</title></head></html>"; | 650 "data:text/html,<html><head><title>Data page</title></head></html>"; |
651 | 651 |
652 frame()->Navigate(common_params, StartNavigationParams(), | 652 frame()->Navigate(common_params, StartNavigationParams(), |
653 request_params); | 653 request_params); |
654 const IPC::Message* frame_title_msg = nullptr; | 654 const IPC::Message* frame_title_msg = nullptr; |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
961 FrameHostMsg_UpdateState::ID); | 961 FrameHostMsg_UpdateState::ID); |
962 ASSERT_TRUE(msg_C); | 962 ASSERT_TRUE(msg_C); |
963 FrameHostMsg_UpdateState::Read(msg_C, ¶m); | 963 FrameHostMsg_UpdateState::Read(msg_C, ¶m); |
964 PageState state_C = std::get<0>(param); | 964 PageState state_C = std::get<0>(param); |
965 EXPECT_NE(state_B, state_C); | 965 EXPECT_NE(state_B, state_C); |
966 render_thread_->sink().ClearMessages(); | 966 render_thread_->sink().ClearMessages(); |
967 | 967 |
968 // Go back to C and commit, preparing for our real test. | 968 // Go back to C and commit, preparing for our real test. |
969 CommonNavigationParams common_params_C; | 969 CommonNavigationParams common_params_C; |
970 RequestNavigationParams request_params_C; | 970 RequestNavigationParams request_params_C; |
971 common_params_C.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 971 common_params_C.navigation_type = |
| 972 FrameMsg_Navigate_Type::HISTORY_DIFFERENT_DOCUMENT; |
972 common_params_C.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 973 common_params_C.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
973 request_params_C.current_history_list_length = 4; | 974 request_params_C.current_history_list_length = 4; |
974 request_params_C.current_history_list_offset = 3; | 975 request_params_C.current_history_list_offset = 3; |
975 request_params_C.pending_history_list_offset = 2; | 976 request_params_C.pending_history_list_offset = 2; |
976 request_params_C.nav_entry_id = 3; | 977 request_params_C.nav_entry_id = 3; |
977 request_params_C.page_state = state_C; | 978 request_params_C.page_state = state_C; |
978 frame()->Navigate(common_params_C, StartNavigationParams(), request_params_C); | 979 frame()->Navigate(common_params_C, StartNavigationParams(), request_params_C); |
979 ProcessPendingMessages(); | 980 ProcessPendingMessages(); |
980 render_thread_->sink().ClearMessages(); | 981 render_thread_->sink().ClearMessages(); |
981 | 982 |
982 // Go back twice quickly, such that page B does not have a chance to commit. | 983 // Go back twice quickly, such that page B does not have a chance to commit. |
983 // This leads to two changes to the back/forward list but only one change to | 984 // This leads to two changes to the back/forward list but only one change to |
984 // the RenderView's page ID. | 985 // the RenderView's page ID. |
985 | 986 |
986 // Back to page B without committing. | 987 // Back to page B without committing. |
987 CommonNavigationParams common_params_B; | 988 CommonNavigationParams common_params_B; |
988 RequestNavigationParams request_params_B; | 989 RequestNavigationParams request_params_B; |
989 common_params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 990 common_params_B.navigation_type = |
| 991 FrameMsg_Navigate_Type::HISTORY_DIFFERENT_DOCUMENT; |
990 common_params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 992 common_params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
991 request_params_B.current_history_list_length = 4; | 993 request_params_B.current_history_list_length = 4; |
992 request_params_B.current_history_list_offset = 2; | 994 request_params_B.current_history_list_offset = 2; |
993 request_params_B.pending_history_list_offset = 1; | 995 request_params_B.pending_history_list_offset = 1; |
994 request_params_B.nav_entry_id = 2; | 996 request_params_B.nav_entry_id = 2; |
995 request_params_B.page_state = state_B; | 997 request_params_B.page_state = state_B; |
996 frame()->Navigate(common_params_B, StartNavigationParams(), request_params_B); | 998 frame()->Navigate(common_params_B, StartNavigationParams(), request_params_B); |
997 | 999 |
998 // Back to page A and commit. | 1000 // Back to page A and commit. |
999 CommonNavigationParams common_params; | 1001 CommonNavigationParams common_params; |
1000 RequestNavigationParams request_params; | 1002 RequestNavigationParams request_params; |
1001 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 1003 common_params.navigation_type = |
| 1004 FrameMsg_Navigate_Type::HISTORY_DIFFERENT_DOCUMENT; |
1002 common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 1005 common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
1003 request_params.current_history_list_length = 4; | 1006 request_params.current_history_list_length = 4; |
1004 request_params.current_history_list_offset = 2; | 1007 request_params.current_history_list_offset = 2; |
1005 request_params.pending_history_list_offset = 0; | 1008 request_params.pending_history_list_offset = 0; |
1006 request_params.nav_entry_id = 1; | 1009 request_params.nav_entry_id = 1; |
1007 request_params.page_state = state_A; | 1010 request_params.page_state = state_A; |
1008 frame()->Navigate(common_params, StartNavigationParams(), request_params); | 1011 frame()->Navigate(common_params, StartNavigationParams(), request_params); |
1009 ProcessPendingMessages(); | 1012 ProcessPendingMessages(); |
1010 | 1013 |
1011 // Now ensure that the UpdateState message we receive is consistent | 1014 // Now ensure that the UpdateState message we receive is consistent |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1334 GetMainFrame()->enableViewSourceMode(true); | 1337 GetMainFrame()->enableViewSourceMode(true); |
1335 WebURLError error; | 1338 WebURLError error; |
1336 error.domain = WebString::fromUTF8(net::kErrorDomain); | 1339 error.domain = WebString::fromUTF8(net::kErrorDomain); |
1337 error.reason = net::ERR_FILE_NOT_FOUND; | 1340 error.reason = net::ERR_FILE_NOT_FOUND; |
1338 error.unreachableURL = GURL("http://foo"); | 1341 error.unreachableURL = GURL("http://foo"); |
1339 WebLocalFrame* web_frame = GetMainFrame(); | 1342 WebLocalFrame* web_frame = GetMainFrame(); |
1340 | 1343 |
1341 // Start a load that will reach provisional state synchronously, | 1344 // Start a load that will reach provisional state synchronously, |
1342 // but won't complete synchronously. | 1345 // but won't complete synchronously. |
1343 CommonNavigationParams common_params; | 1346 CommonNavigationParams common_params; |
1344 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 1347 common_params.navigation_type = FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT; |
1345 common_params.url = GURL("data:text/html,test data"); | 1348 common_params.url = GURL("data:text/html,test data"); |
1346 frame()->Navigate(common_params, StartNavigationParams(), | 1349 frame()->Navigate(common_params, StartNavigationParams(), |
1347 RequestNavigationParams()); | 1350 RequestNavigationParams()); |
1348 | 1351 |
1349 // An error occurred. | 1352 // An error occurred. |
1350 view()->GetMainRenderFrame()->didFailProvisionalLoad( | 1353 view()->GetMainRenderFrame()->didFailProvisionalLoad( |
1351 web_frame, error, blink::WebStandardCommit); | 1354 web_frame, error, blink::WebStandardCommit); |
1352 // Frame should exit view-source mode. | 1355 // Frame should exit view-source mode. |
1353 EXPECT_FALSE(web_frame->isViewSourceModeEnabled()); | 1356 EXPECT_FALSE(web_frame->isViewSourceModeEnabled()); |
1354 } | 1357 } |
1355 | 1358 |
1356 TEST_F(RenderViewImplTest, DidFailProvisionalLoadWithErrorForCancellation) { | 1359 TEST_F(RenderViewImplTest, DidFailProvisionalLoadWithErrorForCancellation) { |
1357 GetMainFrame()->enableViewSourceMode(true); | 1360 GetMainFrame()->enableViewSourceMode(true); |
1358 WebURLError error; | 1361 WebURLError error; |
1359 error.domain = WebString::fromUTF8(net::kErrorDomain); | 1362 error.domain = WebString::fromUTF8(net::kErrorDomain); |
1360 error.reason = net::ERR_ABORTED; | 1363 error.reason = net::ERR_ABORTED; |
1361 error.unreachableURL = GURL("http://foo"); | 1364 error.unreachableURL = GURL("http://foo"); |
1362 WebLocalFrame* web_frame = GetMainFrame(); | 1365 WebLocalFrame* web_frame = GetMainFrame(); |
1363 | 1366 |
1364 // Start a load that will reach provisional state synchronously, | 1367 // Start a load that will reach provisional state synchronously, |
1365 // but won't complete synchronously. | 1368 // but won't complete synchronously. |
1366 CommonNavigationParams common_params; | 1369 CommonNavigationParams common_params; |
1367 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 1370 common_params.navigation_type = FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT; |
1368 common_params.url = GURL("data:text/html,test data"); | 1371 common_params.url = GURL("data:text/html,test data"); |
1369 frame()->Navigate(common_params, StartNavigationParams(), | 1372 frame()->Navigate(common_params, StartNavigationParams(), |
1370 RequestNavigationParams()); | 1373 RequestNavigationParams()); |
1371 | 1374 |
1372 // A cancellation occurred. | 1375 // A cancellation occurred. |
1373 view()->GetMainRenderFrame()->didFailProvisionalLoad( | 1376 view()->GetMainRenderFrame()->didFailProvisionalLoad( |
1374 web_frame, error, blink::WebStandardCommit); | 1377 web_frame, error, blink::WebStandardCommit); |
1375 // Frame should stay in view-source mode. | 1378 // Frame should stay in view-source mode. |
1376 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); | 1379 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); |
1377 } | 1380 } |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1669 | 1672 |
1670 // Test that the navigating specific frames works correctly. | 1673 // Test that the navigating specific frames works correctly. |
1671 TEST_F(RenderViewImplTest, NavigateSubframe) { | 1674 TEST_F(RenderViewImplTest, NavigateSubframe) { |
1672 // Load page A. | 1675 // Load page A. |
1673 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>"); | 1676 LoadHTML("hello <iframe srcdoc='fail' name='frame'></iframe>"); |
1674 | 1677 |
1675 // Navigate the frame only. | 1678 // Navigate the frame only. |
1676 CommonNavigationParams common_params; | 1679 CommonNavigationParams common_params; |
1677 RequestNavigationParams request_params; | 1680 RequestNavigationParams request_params; |
1678 common_params.url = GURL("data:text/html,world"); | 1681 common_params.url = GURL("data:text/html,world"); |
1679 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 1682 common_params.navigation_type = FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT; |
1680 common_params.transition = ui::PAGE_TRANSITION_TYPED; | 1683 common_params.transition = ui::PAGE_TRANSITION_TYPED; |
1681 common_params.navigation_start = base::TimeTicks::FromInternalValue(1); | 1684 common_params.navigation_start = base::TimeTicks::FromInternalValue(1); |
1682 request_params.current_history_list_length = 1; | 1685 request_params.current_history_list_length = 1; |
1683 request_params.current_history_list_offset = 0; | 1686 request_params.current_history_list_offset = 0; |
1684 request_params.pending_history_list_offset = 1; | 1687 request_params.pending_history_list_offset = 1; |
1685 | 1688 |
1686 TestRenderFrame* subframe = | 1689 TestRenderFrame* subframe = |
1687 static_cast<TestRenderFrame*>(RenderFrameImpl::FromWebFrame( | 1690 static_cast<TestRenderFrame*>(RenderFrameImpl::FromWebFrame( |
1688 view()->webview()->findFrameByName("frame"))); | 1691 view()->webview()->findFrameByName("frame"))); |
1689 subframe->Navigate(common_params, StartNavigationParams(), request_params); | 1692 subframe->Navigate(common_params, StartNavigationParams(), request_params); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1781 TEST_F(RendererErrorPageTest, MAYBE_Suppresses) { | 1784 TEST_F(RendererErrorPageTest, MAYBE_Suppresses) { |
1782 WebURLError error; | 1785 WebURLError error; |
1783 error.domain = WebString::fromUTF8(net::kErrorDomain); | 1786 error.domain = WebString::fromUTF8(net::kErrorDomain); |
1784 error.reason = net::ERR_FILE_NOT_FOUND; | 1787 error.reason = net::ERR_FILE_NOT_FOUND; |
1785 error.unreachableURL = GURL("http://example.com/suppress"); | 1788 error.unreachableURL = GURL("http://example.com/suppress"); |
1786 WebLocalFrame* web_frame = GetMainFrame(); | 1789 WebLocalFrame* web_frame = GetMainFrame(); |
1787 | 1790 |
1788 // Start a load that will reach provisional state synchronously, | 1791 // Start a load that will reach provisional state synchronously, |
1789 // but won't complete synchronously. | 1792 // but won't complete synchronously. |
1790 CommonNavigationParams common_params; | 1793 CommonNavigationParams common_params; |
1791 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 1794 common_params.navigation_type = FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT; |
1792 common_params.url = GURL("data:text/html,test data"); | 1795 common_params.url = GURL("data:text/html,test data"); |
1793 TestRenderFrame* main_frame = static_cast<TestRenderFrame*>(frame()); | 1796 TestRenderFrame* main_frame = static_cast<TestRenderFrame*>(frame()); |
1794 main_frame->Navigate(common_params, StartNavigationParams(), | 1797 main_frame->Navigate(common_params, StartNavigationParams(), |
1795 RequestNavigationParams()); | 1798 RequestNavigationParams()); |
1796 | 1799 |
1797 // An error occurred. | 1800 // An error occurred. |
1798 main_frame->didFailProvisionalLoad(web_frame, error, | 1801 main_frame->didFailProvisionalLoad(web_frame, error, |
1799 blink::WebStandardCommit); | 1802 blink::WebStandardCommit); |
1800 const int kMaxOutputCharacters = 22; | 1803 const int kMaxOutputCharacters = 22; |
1801 EXPECT_EQ("", WebFrameContentDumper::dumpWebViewAsText(view()->GetWebView(), | 1804 EXPECT_EQ("", WebFrameContentDumper::dumpWebViewAsText(view()->GetWebView(), |
(...skipping 11 matching lines...) Expand all Loading... |
1813 TEST_F(RendererErrorPageTest, MAYBE_DoesNotSuppress) { | 1816 TEST_F(RendererErrorPageTest, MAYBE_DoesNotSuppress) { |
1814 WebURLError error; | 1817 WebURLError error; |
1815 error.domain = WebString::fromUTF8(net::kErrorDomain); | 1818 error.domain = WebString::fromUTF8(net::kErrorDomain); |
1816 error.reason = net::ERR_FILE_NOT_FOUND; | 1819 error.reason = net::ERR_FILE_NOT_FOUND; |
1817 error.unreachableURL = GURL("http://example.com/dont-suppress"); | 1820 error.unreachableURL = GURL("http://example.com/dont-suppress"); |
1818 WebLocalFrame* web_frame = GetMainFrame(); | 1821 WebLocalFrame* web_frame = GetMainFrame(); |
1819 | 1822 |
1820 // Start a load that will reach provisional state synchronously, | 1823 // Start a load that will reach provisional state synchronously, |
1821 // but won't complete synchronously. | 1824 // but won't complete synchronously. |
1822 CommonNavigationParams common_params; | 1825 CommonNavigationParams common_params; |
1823 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 1826 common_params.navigation_type = FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT; |
1824 common_params.url = GURL("data:text/html,test data"); | 1827 common_params.url = GURL("data:text/html,test data"); |
1825 TestRenderFrame* main_frame = static_cast<TestRenderFrame*>(frame()); | 1828 TestRenderFrame* main_frame = static_cast<TestRenderFrame*>(frame()); |
1826 main_frame->Navigate(common_params, StartNavigationParams(), | 1829 main_frame->Navigate(common_params, StartNavigationParams(), |
1827 RequestNavigationParams()); | 1830 RequestNavigationParams()); |
1828 | 1831 |
1829 // An error occurred. | 1832 // An error occurred. |
1830 main_frame->didFailProvisionalLoad(web_frame, error, | 1833 main_frame->didFailProvisionalLoad(web_frame, error, |
1831 blink::WebStandardCommit); | 1834 blink::WebStandardCommit); |
1832 | 1835 |
1833 // The error page itself is loaded asynchronously. | 1836 // The error page itself is loaded asynchronously. |
(...skipping 13 matching lines...) Expand all Loading... |
1847 #define MAYBE_HttpStatusCodeErrorWithEmptyBody HttpStatusCodeErrorWithEmptyBody | 1850 #define MAYBE_HttpStatusCodeErrorWithEmptyBody HttpStatusCodeErrorWithEmptyBody |
1848 #endif | 1851 #endif |
1849 TEST_F(RendererErrorPageTest, MAYBE_HttpStatusCodeErrorWithEmptyBody) { | 1852 TEST_F(RendererErrorPageTest, MAYBE_HttpStatusCodeErrorWithEmptyBody) { |
1850 blink::WebURLResponse response; | 1853 blink::WebURLResponse response; |
1851 response.setHTTPStatusCode(503); | 1854 response.setHTTPStatusCode(503); |
1852 WebLocalFrame* web_frame = GetMainFrame(); | 1855 WebLocalFrame* web_frame = GetMainFrame(); |
1853 | 1856 |
1854 // Start a load that will reach provisional state synchronously, | 1857 // Start a load that will reach provisional state synchronously, |
1855 // but won't complete synchronously. | 1858 // but won't complete synchronously. |
1856 CommonNavigationParams common_params; | 1859 CommonNavigationParams common_params; |
1857 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 1860 common_params.navigation_type = FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT; |
1858 common_params.url = GURL("data:text/html,test data"); | 1861 common_params.url = GURL("data:text/html,test data"); |
1859 TestRenderFrame* main_frame = static_cast<TestRenderFrame*>(frame()); | 1862 TestRenderFrame* main_frame = static_cast<TestRenderFrame*>(frame()); |
1860 main_frame->Navigate(common_params, StartNavigationParams(), | 1863 main_frame->Navigate(common_params, StartNavigationParams(), |
1861 RequestNavigationParams()); | 1864 RequestNavigationParams()); |
1862 | 1865 |
1863 // Emulate a 4xx/5xx main resource response with an empty body. | 1866 // Emulate a 4xx/5xx main resource response with an empty body. |
1864 main_frame->didReceiveResponse(response); | 1867 main_frame->didReceiveResponse(response); |
1865 main_frame->didFinishDocumentLoad(web_frame); | 1868 main_frame->didFinishDocumentLoad(web_frame); |
1866 main_frame->runScriptsAtDocumentReady(web_frame, true); | 1869 main_frame->runScriptsAtDocumentReady(web_frame, true); |
1867 | 1870 |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2096 LoadHTML("<div id=pagename>Page C</div>"); | 2099 LoadHTML("<div id=pagename>Page C</div>"); |
2097 PageState forward_state = GetCurrentPageState(); | 2100 PageState forward_state = GetCurrentPageState(); |
2098 ProcessPendingMessages(); | 2101 ProcessPendingMessages(); |
2099 render_thread_->sink().ClearMessages(); | 2102 render_thread_->sink().ClearMessages(); |
2100 | 2103 |
2101 // Go back. | 2104 // Go back. |
2102 CommonNavigationParams common_params_back; | 2105 CommonNavigationParams common_params_back; |
2103 common_params_back.url = | 2106 common_params_back.url = |
2104 GURL("data:text/html;charset=utf-8,<div id=pagename>Page B</div>"); | 2107 GURL("data:text/html;charset=utf-8,<div id=pagename>Page B</div>"); |
2105 common_params_back.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 2108 common_params_back.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 2109 common_params_back.navigation_type = |
| 2110 FrameMsg_Navigate_Type::HISTORY_DIFFERENT_DOCUMENT; |
2106 GoToOffsetWithParams(-1, back_state, common_params_back, | 2111 GoToOffsetWithParams(-1, back_state, common_params_back, |
2107 StartNavigationParams(), RequestNavigationParams()); | 2112 StartNavigationParams(), RequestNavigationParams()); |
2108 FrameHostMsg_DidStartProvisionalLoad::Param host_nav_params = | 2113 FrameHostMsg_DidStartProvisionalLoad::Param host_nav_params = |
2109 ProcessAndReadIPC<FrameHostMsg_DidStartProvisionalLoad>(); | 2114 ProcessAndReadIPC<FrameHostMsg_DidStartProvisionalLoad>(); |
2110 if (!IsBrowserSideNavigationEnabled()) { | 2115 if (!IsBrowserSideNavigationEnabled()) { |
2111 // The browser navigation_start should not be used because beforeunload was | 2116 // The browser navigation_start should not be used because beforeunload was |
2112 // fired during GoToOffsetWithParams. | 2117 // fired during GoToOffsetWithParams. |
2113 EXPECT_PRED2(TimeTicksGT, std::get<2>(host_nav_params), | 2118 EXPECT_PRED2(TimeTicksGT, std::get<2>(host_nav_params), |
2114 common_params_back.navigation_start); | 2119 common_params_back.navigation_start); |
2115 } else { | 2120 } else { |
2116 // PlzNavigate: the browser navigation_start is always used. | 2121 // PlzNavigate: the browser navigation_start is always used. |
2117 EXPECT_EQ(common_params_back.navigation_start, | 2122 EXPECT_EQ(common_params_back.navigation_start, |
2118 std::get<2>(host_nav_params)); | 2123 std::get<2>(host_nav_params)); |
2119 } | 2124 } |
2120 render_thread_->sink().ClearMessages(); | 2125 render_thread_->sink().ClearMessages(); |
2121 | 2126 |
2122 // Go forward. | 2127 // Go forward. |
2123 CommonNavigationParams common_params_forward; | 2128 CommonNavigationParams common_params_forward; |
2124 common_params_forward.url = | 2129 common_params_forward.url = |
2125 GURL("data:text/html;charset=utf-8,<div id=pagename>Page C</div>"); | 2130 GURL("data:text/html;charset=utf-8,<div id=pagename>Page C</div>"); |
2126 common_params_forward.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 2131 common_params_forward.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 2132 common_params_forward.navigation_type = |
| 2133 FrameMsg_Navigate_Type::HISTORY_DIFFERENT_DOCUMENT; |
2127 GoToOffsetWithParams(1, forward_state, common_params_forward, | 2134 GoToOffsetWithParams(1, forward_state, common_params_forward, |
2128 StartNavigationParams(), RequestNavigationParams()); | 2135 StartNavigationParams(), RequestNavigationParams()); |
2129 FrameHostMsg_DidStartProvisionalLoad::Param host_nav_params2 = | 2136 FrameHostMsg_DidStartProvisionalLoad::Param host_nav_params2 = |
2130 ProcessAndReadIPC<FrameHostMsg_DidStartProvisionalLoad>(); | 2137 ProcessAndReadIPC<FrameHostMsg_DidStartProvisionalLoad>(); |
2131 if (!IsBrowserSideNavigationEnabled()) { | 2138 if (!IsBrowserSideNavigationEnabled()) { |
2132 EXPECT_PRED2(TimeTicksGT, std::get<2>(host_nav_params2), | 2139 EXPECT_PRED2(TimeTicksGT, std::get<2>(host_nav_params2), |
2133 common_params_forward.navigation_start); | 2140 common_params_forward.navigation_start); |
2134 } else { | 2141 } else { |
2135 EXPECT_EQ(common_params_forward.navigation_start, | 2142 EXPECT_EQ(common_params_forward.navigation_start, |
2136 std::get<2>(host_nav_params2)); | 2143 std::get<2>(host_nav_params2)); |
2137 } | 2144 } |
2138 } | 2145 } |
2139 | 2146 |
2140 TEST_F(RenderViewImplTest, NavigationStartForCrossProcessHistoryNavigation) { | 2147 TEST_F(RenderViewImplTest, NavigationStartForCrossProcessHistoryNavigation) { |
2141 auto common_params = MakeCommonNavigationParams(-TimeDelta::FromSeconds(1)); | 2148 auto common_params = MakeCommonNavigationParams(-TimeDelta::FromSeconds(1)); |
2142 common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 2149 common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 2150 common_params.navigation_type = |
| 2151 FrameMsg_Navigate_Type::HISTORY_DIFFERENT_DOCUMENT; |
2143 | 2152 |
2144 RequestNavigationParams request_params; | 2153 RequestNavigationParams request_params; |
2145 request_params.page_state = | 2154 request_params.page_state = |
2146 PageState::CreateForTesting(common_params.url, false, nullptr, nullptr); | 2155 PageState::CreateForTesting(common_params.url, false, nullptr, nullptr); |
2147 request_params.nav_entry_id = 42; | 2156 request_params.nav_entry_id = 42; |
2148 request_params.pending_history_list_offset = 1; | 2157 request_params.pending_history_list_offset = 1; |
2149 request_params.current_history_list_offset = 0; | 2158 request_params.current_history_list_offset = 0; |
2150 request_params.current_history_list_length = 1; | 2159 request_params.current_history_list_length = 1; |
2151 frame()->Navigate(common_params, StartNavigationParams(), request_params); | 2160 frame()->Navigate(common_params, StartNavigationParams(), request_params); |
2152 | 2161 |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2555 ExpectPauseAndResume(3); | 2564 ExpectPauseAndResume(3); |
2556 blink::WebScriptSource source2( | 2565 blink::WebScriptSource source2( |
2557 WebString::fromUTF8("function func2() { func1(); }; func2();")); | 2566 WebString::fromUTF8("function func2() { func1(); }; func2();")); |
2558 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1); | 2567 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1); |
2559 | 2568 |
2560 EXPECT_FALSE(IsPaused()); | 2569 EXPECT_FALSE(IsPaused()); |
2561 Detach(); | 2570 Detach(); |
2562 } | 2571 } |
2563 | 2572 |
2564 } // namespace content | 2573 } // namespace content |
OLD | NEW |