OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "base/test/histogram_tester.h" | 8 #include "base/test/histogram_tester.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "content/browser/frame_host/cross_site_transferring_request.h" | 10 #include "content/browser/frame_host/cross_site_transferring_request.h" |
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 NULL /* instance */, -1 /* page_id */, kUrl1, Referrer(), | 894 NULL /* instance */, -1 /* page_id */, kUrl1, Referrer(), |
895 base::string16() /* title */, ui::PAGE_TRANSITION_TYPED, | 895 base::string16() /* title */, ui::PAGE_TRANSITION_TYPED, |
896 false /* is_renderer_init */); | 896 false /* is_renderer_init */); |
897 host = manager->Navigate(entry1); | 897 host = manager->Navigate(entry1); |
898 | 898 |
899 // The RenderFrameHost created in Init will be reused. | 899 // The RenderFrameHost created in Init will be reused. |
900 EXPECT_TRUE(host == manager->current_frame_host()); | 900 EXPECT_TRUE(host == manager->current_frame_host()); |
901 EXPECT_FALSE(manager->pending_frame_host()); | 901 EXPECT_FALSE(manager->pending_frame_host()); |
902 | 902 |
903 // Commit. | 903 // Commit. |
904 manager->DidNavigateFrame(host); | 904 manager->DidNavigateFrame(host, true); |
905 // Commit to SiteInstance should be delayed until RenderView commit. | 905 // Commit to SiteInstance should be delayed until RenderView commit. |
906 EXPECT_TRUE(host == manager->current_frame_host()); | 906 EXPECT_TRUE(host == manager->current_frame_host()); |
907 ASSERT_TRUE(host); | 907 ASSERT_TRUE(host); |
908 EXPECT_FALSE(host->GetSiteInstance()->HasSite()); | 908 EXPECT_FALSE(host->GetSiteInstance()->HasSite()); |
909 host->GetSiteInstance()->SetSite(kUrl1); | 909 host->GetSiteInstance()->SetSite(kUrl1); |
910 | 910 |
911 // 2) Navigate to next site. ------------------------- | 911 // 2) Navigate to next site. ------------------------- |
912 const GURL kUrl2("http://www.google.com/foo"); | 912 const GURL kUrl2("http://www.google.com/foo"); |
913 NavigationEntryImpl entry2( | 913 NavigationEntryImpl entry2( |
914 NULL /* instance */, -1 /* page_id */, kUrl2, | 914 NULL /* instance */, -1 /* page_id */, kUrl2, |
915 Referrer(kUrl1, blink::WebReferrerPolicyDefault), | 915 Referrer(kUrl1, blink::WebReferrerPolicyDefault), |
916 base::string16() /* title */, ui::PAGE_TRANSITION_LINK, | 916 base::string16() /* title */, ui::PAGE_TRANSITION_LINK, |
917 true /* is_renderer_init */); | 917 true /* is_renderer_init */); |
918 host = manager->Navigate(entry2); | 918 host = manager->Navigate(entry2); |
919 | 919 |
920 // The RenderFrameHost created in Init will be reused. | 920 // The RenderFrameHost created in Init will be reused. |
921 EXPECT_TRUE(host == manager->current_frame_host()); | 921 EXPECT_TRUE(host == manager->current_frame_host()); |
922 EXPECT_FALSE(manager->pending_frame_host()); | 922 EXPECT_FALSE(manager->pending_frame_host()); |
923 | 923 |
924 // Commit. | 924 // Commit. |
925 manager->DidNavigateFrame(host); | 925 manager->DidNavigateFrame(host, true); |
926 EXPECT_TRUE(host == manager->current_frame_host()); | 926 EXPECT_TRUE(host == manager->current_frame_host()); |
927 ASSERT_TRUE(host); | 927 ASSERT_TRUE(host); |
928 EXPECT_TRUE(host->GetSiteInstance()->HasSite()); | 928 EXPECT_TRUE(host->GetSiteInstance()->HasSite()); |
929 | 929 |
930 // 3) Cross-site navigate to next site. -------------- | 930 // 3) Cross-site navigate to next site. -------------- |
931 const GURL kUrl3("http://webkit.org/"); | 931 const GURL kUrl3("http://webkit.org/"); |
932 NavigationEntryImpl entry3( | 932 NavigationEntryImpl entry3( |
933 NULL /* instance */, -1 /* page_id */, kUrl3, | 933 NULL /* instance */, -1 /* page_id */, kUrl3, |
934 Referrer(kUrl2, blink::WebReferrerPolicyDefault), | 934 Referrer(kUrl2, blink::WebReferrerPolicyDefault), |
935 base::string16() /* title */, ui::PAGE_TRANSITION_LINK, | 935 base::string16() /* title */, ui::PAGE_TRANSITION_LINK, |
936 false /* is_renderer_init */); | 936 false /* is_renderer_init */); |
937 host = manager->Navigate(entry3); | 937 host = manager->Navigate(entry3); |
938 | 938 |
939 // A new RenderFrameHost should be created. | 939 // A new RenderFrameHost should be created. |
940 EXPECT_TRUE(manager->pending_frame_host()); | 940 EXPECT_TRUE(manager->pending_frame_host()); |
941 ASSERT_EQ(host, manager->pending_frame_host()); | 941 ASSERT_EQ(host, manager->pending_frame_host()); |
942 | 942 |
943 notifications.Reset(); | 943 notifications.Reset(); |
944 | 944 |
945 // Commit. | 945 // Commit. |
946 manager->DidNavigateFrame(manager->pending_frame_host()); | 946 manager->DidNavigateFrame(manager->pending_frame_host(), true); |
947 EXPECT_TRUE(host == manager->current_frame_host()); | 947 EXPECT_TRUE(host == manager->current_frame_host()); |
948 ASSERT_TRUE(host); | 948 ASSERT_TRUE(host); |
949 EXPECT_TRUE(host->GetSiteInstance()->HasSite()); | 949 EXPECT_TRUE(host->GetSiteInstance()->HasSite()); |
950 // Check the pending RenderFrameHost has been committed. | 950 // Check the pending RenderFrameHost has been committed. |
951 EXPECT_FALSE(manager->pending_frame_host()); | 951 EXPECT_FALSE(manager->pending_frame_host()); |
952 | 952 |
953 // We should observe a notification. | 953 // We should observe a notification. |
954 EXPECT_TRUE( | 954 EXPECT_TRUE( |
955 notifications.Check1AndReset(NOTIFICATION_RENDER_VIEW_HOST_CHANGED)); | 955 notifications.Check1AndReset(NOTIFICATION_RENDER_VIEW_HOST_CHANGED)); |
956 } | 956 } |
(...skipping 29 matching lines...) Expand all Loading... |
986 // get loaded in between. | 986 // get loaded in between. |
987 EXPECT_TRUE(host->GetSiteInstance()->HasSite()); | 987 EXPECT_TRUE(host->GetSiteInstance()->HasSite()); |
988 EXPECT_EQ(kUrl, host->GetSiteInstance()->GetSiteURL()); | 988 EXPECT_EQ(kUrl, host->GetSiteInstance()->GetSiteURL()); |
989 | 989 |
990 // The Web UI is committed immediately because the RenderViewHost has not been | 990 // The Web UI is committed immediately because the RenderViewHost has not been |
991 // used yet. UpdateStateForNavigate() took the short cut path. | 991 // used yet. UpdateStateForNavigate() took the short cut path. |
992 EXPECT_FALSE(manager->pending_web_ui()); | 992 EXPECT_FALSE(manager->pending_web_ui()); |
993 EXPECT_TRUE(manager->web_ui()); | 993 EXPECT_TRUE(manager->web_ui()); |
994 | 994 |
995 // Commit. | 995 // Commit. |
996 manager->DidNavigateFrame(host); | 996 manager->DidNavigateFrame(host, true); |
997 EXPECT_TRUE( | 997 EXPECT_TRUE( |
998 host->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); | 998 host->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); |
999 } | 999 } |
1000 | 1000 |
1001 // Tests that we can open a WebUI link in a new tab from a WebUI page and still | 1001 // Tests that we can open a WebUI link in a new tab from a WebUI page and still |
1002 // grant the correct bindings. http://crbug.com/189101. | 1002 // grant the correct bindings. http://crbug.com/189101. |
1003 TEST_F(RenderFrameHostManagerTest, WebUIInNewTab) { | 1003 TEST_F(RenderFrameHostManagerTest, WebUIInNewTab) { |
1004 set_should_create_webui(true); | 1004 set_should_create_webui(true); |
1005 SiteInstance* blank_instance = SiteInstance::Create(browser_context()); | 1005 SiteInstance* blank_instance = SiteInstance::Create(browser_context()); |
1006 | 1006 |
(...skipping 17 matching lines...) Expand all Loading... |
1024 RenderFrameHostImpl* host1 = manager1->Navigate(entry1); | 1024 RenderFrameHostImpl* host1 = manager1->Navigate(entry1); |
1025 | 1025 |
1026 // We should have a pending navigation to the WebUI RenderViewHost. | 1026 // We should have a pending navigation to the WebUI RenderViewHost. |
1027 // It should already have bindings. | 1027 // It should already have bindings. |
1028 EXPECT_EQ(host1, manager1->pending_frame_host()); | 1028 EXPECT_EQ(host1, manager1->pending_frame_host()); |
1029 EXPECT_NE(host1, manager1->current_frame_host()); | 1029 EXPECT_NE(host1, manager1->current_frame_host()); |
1030 EXPECT_TRUE( | 1030 EXPECT_TRUE( |
1031 host1->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); | 1031 host1->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); |
1032 | 1032 |
1033 // Commit and ensure we still have bindings. | 1033 // Commit and ensure we still have bindings. |
1034 manager1->DidNavigateFrame(host1); | 1034 manager1->DidNavigateFrame(host1, true); |
1035 SiteInstance* webui_instance = host1->GetSiteInstance(); | 1035 SiteInstance* webui_instance = host1->GetSiteInstance(); |
1036 EXPECT_EQ(host1, manager1->current_frame_host()); | 1036 EXPECT_EQ(host1, manager1->current_frame_host()); |
1037 EXPECT_TRUE( | 1037 EXPECT_TRUE( |
1038 host1->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); | 1038 host1->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); |
1039 | 1039 |
1040 // Now simulate clicking a link that opens in a new tab. | 1040 // Now simulate clicking a link that opens in a new tab. |
1041 scoped_ptr<TestWebContents> web_contents2( | 1041 scoped_ptr<TestWebContents> web_contents2( |
1042 TestWebContents::Create(browser_context(), webui_instance)); | 1042 TestWebContents::Create(browser_context(), webui_instance)); |
1043 RenderFrameHostManager* manager2 = | 1043 RenderFrameHostManager* manager2 = |
1044 web_contents2->GetRenderManagerForTesting(); | 1044 web_contents2->GetRenderManagerForTesting(); |
1045 // Make sure the new RVH is considered live. This is usually done in | 1045 // Make sure the new RVH is considered live. This is usually done in |
1046 // RenderWidgetHost::Init when opening a new tab from a link. | 1046 // RenderWidgetHost::Init when opening a new tab from a link. |
1047 manager2->current_host()->CreateRenderView( | 1047 manager2->current_host()->CreateRenderView( |
1048 base::string16(), -1, MSG_ROUTING_NONE, -1, false); | 1048 base::string16(), -1, MSG_ROUTING_NONE, -1, false); |
1049 | 1049 |
1050 const GURL kUrl2("chrome://foo/bar"); | 1050 const GURL kUrl2("chrome://foo/bar"); |
1051 NavigationEntryImpl entry2(NULL /* instance */, -1 /* page_id */, kUrl2, | 1051 NavigationEntryImpl entry2(NULL /* instance */, -1 /* page_id */, kUrl2, |
1052 Referrer(), base::string16() /* title */, | 1052 Referrer(), base::string16() /* title */, |
1053 ui::PAGE_TRANSITION_LINK, | 1053 ui::PAGE_TRANSITION_LINK, |
1054 true /* is_renderer_init */); | 1054 true /* is_renderer_init */); |
1055 RenderFrameHostImpl* host2 = manager2->Navigate(entry2); | 1055 RenderFrameHostImpl* host2 = manager2->Navigate(entry2); |
1056 | 1056 |
1057 // No cross-process transition happens because we are already in the right | 1057 // No cross-process transition happens because we are already in the right |
1058 // SiteInstance. We should grant bindings immediately. | 1058 // SiteInstance. We should grant bindings immediately. |
1059 EXPECT_EQ(host2, manager2->current_frame_host()); | 1059 EXPECT_EQ(host2, manager2->current_frame_host()); |
1060 EXPECT_TRUE( | 1060 EXPECT_TRUE( |
1061 host2->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); | 1061 host2->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); |
1062 | 1062 |
1063 manager2->DidNavigateFrame(host2); | 1063 manager2->DidNavigateFrame(host2, true); |
1064 } | 1064 } |
1065 | 1065 |
1066 // Tests that we don't end up in an inconsistent state if a page does a back and | 1066 // Tests that we don't end up in an inconsistent state if a page does a back and |
1067 // then reload. http://crbug.com/51680 | 1067 // then reload. http://crbug.com/51680 |
| 1068 // Also tests that only user-gesture navigations can interrupt cross-process |
| 1069 // navigations. http://crbug.com/75195 |
1068 TEST_F(RenderFrameHostManagerTest, PageDoesBackAndReload) { | 1070 TEST_F(RenderFrameHostManagerTest, PageDoesBackAndReload) { |
1069 const GURL kUrl1("http://www.google.com/"); | 1071 const GURL kUrl1("http://www.google.com/"); |
1070 const GURL kUrl2("http://www.evil-site.com/"); | 1072 const GURL kUrl2("http://www.evil-site.com/"); |
1071 | 1073 |
1072 // Navigate to a safe site, then an evil site. | 1074 // Navigate to a safe site, then an evil site. |
1073 // This will switch RenderFrameHosts. We cannot assert that the first and | 1075 // This will switch RenderFrameHosts. We cannot assert that the first and |
1074 // second RFHs are different, though, because the first one may be promptly | 1076 // second RFHs are different, though, because the first one may be promptly |
1075 // deleted. | 1077 // deleted. |
1076 contents()->NavigateAndCommit(kUrl1); | 1078 contents()->NavigateAndCommit(kUrl1); |
1077 contents()->NavigateAndCommit(kUrl2); | 1079 contents()->NavigateAndCommit(kUrl2); |
(...skipping 15 matching lines...) Expand all Loading... |
1093 params.transition = ui::PAGE_TRANSITION_CLIENT_REDIRECT; | 1095 params.transition = ui::PAGE_TRANSITION_CLIENT_REDIRECT; |
1094 params.should_update_history = false; | 1096 params.should_update_history = false; |
1095 params.gesture = NavigationGestureAuto; | 1097 params.gesture = NavigationGestureAuto; |
1096 params.was_within_same_page = false; | 1098 params.was_within_same_page = false; |
1097 params.is_post = false; | 1099 params.is_post = false; |
1098 params.page_state = PageState::CreateFromURL(kUrl2); | 1100 params.page_state = PageState::CreateFromURL(kUrl2); |
1099 | 1101 |
1100 contents()->GetFrameTree()->root()->navigator()->DidNavigate(evil_rfh, | 1102 contents()->GetFrameTree()->root()->navigator()->DidNavigate(evil_rfh, |
1101 params); | 1103 params); |
1102 | 1104 |
1103 // That should have cancelled the pending RFH, and the evil RFH should be the | 1105 // That should NOT have cancelled the pending RFH, because the reload did |
1104 // current one. | 1106 // not have a user gesture. Thus, the pending back navigation will still |
| 1107 // eventually commit. |
| 1108 EXPECT_TRUE(contents()->GetRenderManagerForTesting()-> |
| 1109 pending_render_view_host() != NULL); |
| 1110 EXPECT_TRUE(contents()->GetRenderManagerForTesting()->pending_frame_host() != |
| 1111 NULL); |
| 1112 EXPECT_EQ(evil_rfh, |
| 1113 contents()->GetRenderManagerForTesting()->current_frame_host()); |
| 1114 EXPECT_EQ(evil_rfh->GetRenderViewHost(), |
| 1115 contents()->GetRenderManagerForTesting()->current_host()); |
| 1116 |
| 1117 // Also we should not have a pending navigation entry. |
| 1118 EXPECT_TRUE(contents()->GetController().GetPendingEntry() == NULL); |
| 1119 NavigationEntry* entry = contents()->GetController().GetVisibleEntry(); |
| 1120 ASSERT_TRUE(entry != NULL); |
| 1121 EXPECT_EQ(kUrl2, entry->GetURL()); |
| 1122 |
| 1123 // Now do the same but as a user gesture. |
| 1124 params.gesture = NavigationGestureUser; |
| 1125 contents()->GetFrameTree()->root()->navigator()->DidNavigate(evil_rfh, |
| 1126 params); |
| 1127 |
| 1128 // User navigation should have cancelled the pending RFH. |
1105 EXPECT_TRUE(contents()->GetRenderManagerForTesting()-> | 1129 EXPECT_TRUE(contents()->GetRenderManagerForTesting()-> |
1106 pending_render_view_host() == NULL); | 1130 pending_render_view_host() == NULL); |
1107 EXPECT_TRUE(contents()->GetRenderManagerForTesting()->pending_frame_host() == | 1131 EXPECT_TRUE(contents()->GetRenderManagerForTesting()->pending_frame_host() == |
1108 NULL); | 1132 NULL); |
1109 EXPECT_EQ(evil_rfh, | 1133 EXPECT_EQ(evil_rfh, |
1110 contents()->GetRenderManagerForTesting()->current_frame_host()); | 1134 contents()->GetRenderManagerForTesting()->current_frame_host()); |
1111 EXPECT_EQ(evil_rfh->GetRenderViewHost(), | 1135 EXPECT_EQ(evil_rfh->GetRenderViewHost(), |
1112 contents()->GetRenderManagerForTesting()->current_host()); | 1136 contents()->GetRenderManagerForTesting()->current_host()); |
1113 | 1137 |
1114 // Also we should not have a pending navigation entry. | 1138 // Also we should not have a pending navigation entry. |
1115 EXPECT_TRUE(contents()->GetController().GetPendingEntry() == NULL); | 1139 EXPECT_TRUE(contents()->GetController().GetPendingEntry() == NULL); |
1116 NavigationEntry* entry = contents()->GetController().GetVisibleEntry(); | 1140 entry = contents()->GetController().GetVisibleEntry(); |
1117 ASSERT_TRUE(entry != NULL); | 1141 ASSERT_TRUE(entry != NULL); |
1118 EXPECT_EQ(kUrl2, entry->GetURL()); | 1142 EXPECT_EQ(kUrl2, entry->GetURL()); |
1119 } | 1143 } |
1120 | 1144 |
1121 // Ensure that we can go back and forward even if a SwapOut ACK isn't received. | 1145 // Ensure that we can go back and forward even if a SwapOut ACK isn't received. |
1122 // See http://crbug.com/93427. | 1146 // See http://crbug.com/93427. |
1123 TEST_F(RenderFrameHostManagerTest, NavigateAfterMissingSwapOutACK) { | 1147 TEST_F(RenderFrameHostManagerTest, NavigateAfterMissingSwapOutACK) { |
1124 const GURL kUrl1("http://www.google.com/"); | 1148 const GURL kUrl1("http://www.google.com/"); |
1125 const GURL kUrl2("http://www.chromium.org/"); | 1149 const GURL kUrl2("http://www.chromium.org/"); |
1126 | 1150 |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1493 base::string16() /* title */, ui::PAGE_TRANSITION_TYPED, | 1517 base::string16() /* title */, ui::PAGE_TRANSITION_TYPED, |
1494 false /* is_renderer_init */); | 1518 false /* is_renderer_init */); |
1495 host = manager->Navigate(entry1); | 1519 host = manager->Navigate(entry1); |
1496 | 1520 |
1497 // The RenderFrameHost created in Init will be reused. | 1521 // The RenderFrameHost created in Init will be reused. |
1498 EXPECT_TRUE(host == manager->current_frame_host()); | 1522 EXPECT_TRUE(host == manager->current_frame_host()); |
1499 EXPECT_FALSE(manager->pending_frame_host()); | 1523 EXPECT_FALSE(manager->pending_frame_host()); |
1500 EXPECT_EQ(manager->current_frame_host()->GetSiteInstance(), instance); | 1524 EXPECT_EQ(manager->current_frame_host()->GetSiteInstance(), instance); |
1501 | 1525 |
1502 // Commit. | 1526 // Commit. |
1503 manager->DidNavigateFrame(host); | 1527 manager->DidNavigateFrame(host, true); |
1504 // Commit to SiteInstance should be delayed until RenderView commit. | 1528 // Commit to SiteInstance should be delayed until RenderView commit. |
1505 EXPECT_EQ(host, manager->current_frame_host()); | 1529 EXPECT_EQ(host, manager->current_frame_host()); |
1506 ASSERT_TRUE(host); | 1530 ASSERT_TRUE(host); |
1507 EXPECT_TRUE(host->GetSiteInstance()->HasSite()); | 1531 EXPECT_TRUE(host->GetSiteInstance()->HasSite()); |
1508 | 1532 |
1509 // 2) Navigate to a different domain. ------------------------- | 1533 // 2) Navigate to a different domain. ------------------------- |
1510 // Guests stay in the same process on navigation. | 1534 // Guests stay in the same process on navigation. |
1511 const GURL kUrl2("http://www.chromium.org"); | 1535 const GURL kUrl2("http://www.chromium.org"); |
1512 NavigationEntryImpl entry2( | 1536 NavigationEntryImpl entry2( |
1513 NULL /* instance */, -1 /* page_id */, kUrl2, | 1537 NULL /* instance */, -1 /* page_id */, kUrl2, |
1514 Referrer(kUrl1, blink::WebReferrerPolicyDefault), | 1538 Referrer(kUrl1, blink::WebReferrerPolicyDefault), |
1515 base::string16() /* title */, ui::PAGE_TRANSITION_LINK, | 1539 base::string16() /* title */, ui::PAGE_TRANSITION_LINK, |
1516 true /* is_renderer_init */); | 1540 true /* is_renderer_init */); |
1517 host = manager->Navigate(entry2); | 1541 host = manager->Navigate(entry2); |
1518 | 1542 |
1519 // The RenderFrameHost created in Init will be reused. | 1543 // The RenderFrameHost created in Init will be reused. |
1520 EXPECT_EQ(host, manager->current_frame_host()); | 1544 EXPECT_EQ(host, manager->current_frame_host()); |
1521 EXPECT_FALSE(manager->pending_frame_host()); | 1545 EXPECT_FALSE(manager->pending_frame_host()); |
1522 | 1546 |
1523 // Commit. | 1547 // Commit. |
1524 manager->DidNavigateFrame(host); | 1548 manager->DidNavigateFrame(host, true); |
1525 EXPECT_EQ(host, manager->current_frame_host()); | 1549 EXPECT_EQ(host, manager->current_frame_host()); |
1526 ASSERT_TRUE(host); | 1550 ASSERT_TRUE(host); |
1527 EXPECT_EQ(host->GetSiteInstance(), instance); | 1551 EXPECT_EQ(host->GetSiteInstance(), instance); |
1528 } | 1552 } |
1529 | 1553 |
1530 // Test that we cancel a pending RVH if we close the tab while it's pending. | 1554 // Test that we cancel a pending RVH if we close the tab while it's pending. |
1531 // http://crbug.com/294697. | 1555 // http://crbug.com/294697. |
1532 TEST_F(RenderFrameHostManagerTest, NavigateWithEarlyClose) { | 1556 TEST_F(RenderFrameHostManagerTest, NavigateWithEarlyClose) { |
1533 TestNotificationTracker notifications; | 1557 TestNotificationTracker notifications; |
1534 | 1558 |
(...skipping 19 matching lines...) Expand all Loading... |
1554 // The RenderFrameHost created in Init will be reused. | 1578 // The RenderFrameHost created in Init will be reused. |
1555 EXPECT_EQ(host, manager->current_frame_host()); | 1579 EXPECT_EQ(host, manager->current_frame_host()); |
1556 EXPECT_FALSE(manager->pending_frame_host()); | 1580 EXPECT_FALSE(manager->pending_frame_host()); |
1557 | 1581 |
1558 // We should observe a notification. | 1582 // We should observe a notification. |
1559 EXPECT_TRUE( | 1583 EXPECT_TRUE( |
1560 notifications.Check1AndReset(NOTIFICATION_RENDER_VIEW_HOST_CHANGED)); | 1584 notifications.Check1AndReset(NOTIFICATION_RENDER_VIEW_HOST_CHANGED)); |
1561 notifications.Reset(); | 1585 notifications.Reset(); |
1562 | 1586 |
1563 // Commit. | 1587 // Commit. |
1564 manager->DidNavigateFrame(host); | 1588 manager->DidNavigateFrame(host, true); |
1565 | 1589 |
1566 // Commit to SiteInstance should be delayed until RenderFrame commits. | 1590 // Commit to SiteInstance should be delayed until RenderFrame commits. |
1567 EXPECT_EQ(host, manager->current_frame_host()); | 1591 EXPECT_EQ(host, manager->current_frame_host()); |
1568 EXPECT_FALSE(host->GetSiteInstance()->HasSite()); | 1592 EXPECT_FALSE(host->GetSiteInstance()->HasSite()); |
1569 host->GetSiteInstance()->SetSite(kUrl1); | 1593 host->GetSiteInstance()->SetSite(kUrl1); |
1570 | 1594 |
1571 // 2) Cross-site navigate to next site. ------------------------- | 1595 // 2) Cross-site navigate to next site. ------------------------- |
1572 const GURL kUrl2("http://www.example.com"); | 1596 const GURL kUrl2("http://www.example.com"); |
1573 NavigationEntryImpl entry2( | 1597 NavigationEntryImpl entry2( |
1574 NULL /* instance */, -1 /* page_id */, kUrl2, Referrer(), | 1598 NULL /* instance */, -1 /* page_id */, kUrl2, Referrer(), |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1798 pending_rfh->GetSiteInstance()->increment_active_frame_count(); | 1822 pending_rfh->GetSiteInstance()->increment_active_frame_count(); |
1799 | 1823 |
1800 contents()->GetMainFrame()->OnMessageReceived( | 1824 contents()->GetMainFrame()->OnMessageReceived( |
1801 FrameHostMsg_BeforeUnload_ACK(0, false, now, now)); | 1825 FrameHostMsg_BeforeUnload_ACK(0, false, now, now)); |
1802 EXPECT_FALSE(contents()->cross_navigation_pending()); | 1826 EXPECT_FALSE(contents()->cross_navigation_pending()); |
1803 EXPECT_FALSE(rfh_deleted_observer.deleted()); | 1827 EXPECT_FALSE(rfh_deleted_observer.deleted()); |
1804 } | 1828 } |
1805 } | 1829 } |
1806 | 1830 |
1807 } // namespace content | 1831 } // namespace content |
OLD | NEW |