Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1914)

Side by Side Diff: content/browser/frame_host/render_frame_host_manager_unittest.cc

Issue 2738983004: Set an initial background for RenderFrameHosts during commit. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "content/browser/frame_host/render_frame_host_manager.h" 5 #include "content/browser/frame_host/render_frame_host_manager.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <tuple> 9 #include <tuple>
10 #include <utility> 10 #include <utility>
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 EXPECT_FALSE(GetPendingFrameHost(manager)); 927 EXPECT_FALSE(GetPendingFrameHost(manager));
928 928
929 // Commit. 929 // Commit.
930 manager->DidNavigateFrame(host, true); 930 manager->DidNavigateFrame(host, true);
931 // Commit to SiteInstance should be delayed until RenderFrame commit. 931 // Commit to SiteInstance should be delayed until RenderFrame commit.
932 EXPECT_TRUE(host == manager->current_frame_host()); 932 EXPECT_TRUE(host == manager->current_frame_host());
933 ASSERT_TRUE(host); 933 ASSERT_TRUE(host);
934 EXPECT_FALSE(host->GetSiteInstance()->HasSite()); 934 EXPECT_FALSE(host->GetSiteInstance()->HasSite());
935 host->GetSiteInstance()->SetSite(kUrl1); 935 host->GetSiteInstance()->SetSite(kUrl1);
936 936
937 manager->GetRenderWidgetHostView()->SetBackgroundColor(SK_ColorRED);
938
937 // 2) Navigate to next site. ------------------------- 939 // 2) Navigate to next site. -------------------------
938 const GURL kUrl2("http://www.google.com/foo"); 940 const GURL kUrl2("http://www.google.com/foo");
939 NavigationEntryImpl entry2( 941 NavigationEntryImpl entry2(
940 NULL /* instance */, kUrl2, 942 NULL /* instance */, kUrl2,
941 Referrer(kUrl1, blink::WebReferrerPolicyDefault), 943 Referrer(kUrl1, blink::WebReferrerPolicyDefault),
942 base::string16() /* title */, ui::PAGE_TRANSITION_LINK, 944 base::string16() /* title */, ui::PAGE_TRANSITION_LINK,
943 true /* is_renderer_init */); 945 true /* is_renderer_init */);
944 host = NavigateToEntry(manager, entry2); 946 host = NavigateToEntry(manager, entry2);
945 947
946 // The RenderFrameHost created in Init will be reused. 948 // The RenderFrameHost created in Init will be reused.
947 EXPECT_TRUE(host == manager->current_frame_host()); 949 EXPECT_TRUE(host == manager->current_frame_host());
948 EXPECT_FALSE(GetPendingFrameHost(manager)); 950 EXPECT_FALSE(GetPendingFrameHost(manager));
949 951
950 // Commit. 952 // Commit.
951 manager->DidNavigateFrame(host, true); 953 manager->DidNavigateFrame(host, true);
952 EXPECT_TRUE(host == manager->current_frame_host()); 954 EXPECT_TRUE(host == manager->current_frame_host());
953 ASSERT_TRUE(host); 955 ASSERT_TRUE(host);
954 EXPECT_TRUE(host->GetSiteInstance()->HasSite()); 956 EXPECT_TRUE(host->GetSiteInstance()->HasSite());
955 957
958 EXPECT_EQ(SK_ColorRED,
959 manager->GetRenderWidgetHostView()->background_color());
960
956 // 3) Cross-site navigate to next site. -------------- 961 // 3) Cross-site navigate to next site. --------------
957 const GURL kUrl3("http://webkit.org/"); 962 const GURL kUrl3("http://webkit.org/");
958 NavigationEntryImpl entry3( 963 NavigationEntryImpl entry3(
959 NULL /* instance */, kUrl3, 964 NULL /* instance */, kUrl3,
960 Referrer(kUrl2, blink::WebReferrerPolicyDefault), 965 Referrer(kUrl2, blink::WebReferrerPolicyDefault),
961 base::string16() /* title */, ui::PAGE_TRANSITION_LINK, 966 base::string16() /* title */, ui::PAGE_TRANSITION_LINK,
962 false /* is_renderer_init */); 967 false /* is_renderer_init */);
963 host = NavigateToEntry(manager, entry3); 968 host = NavigateToEntry(manager, entry3);
964 969
965 // A new RenderFrameHost should be created. 970 // A new RenderFrameHost should be created.
966 EXPECT_TRUE(GetPendingFrameHost(manager)); 971 EXPECT_TRUE(GetPendingFrameHost(manager));
967 ASSERT_EQ(host, GetPendingFrameHost(manager)); 972 ASSERT_EQ(host, GetPendingFrameHost(manager));
968 973
969 change_observer.Reset(); 974 change_observer.Reset();
970 975
971 // Commit. 976 // Commit.
972 manager->DidNavigateFrame(GetPendingFrameHost(manager), true); 977 manager->DidNavigateFrame(GetPendingFrameHost(manager), true);
973 EXPECT_TRUE(host == manager->current_frame_host()); 978 EXPECT_TRUE(host == manager->current_frame_host());
974 ASSERT_TRUE(host); 979 ASSERT_TRUE(host);
975 EXPECT_TRUE(host->GetSiteInstance()->HasSite()); 980 EXPECT_TRUE(host->GetSiteInstance()->HasSite());
976 // Check the pending RenderFrameHost has been committed. 981 // Check the pending RenderFrameHost has been committed.
977 EXPECT_FALSE(GetPendingFrameHost(manager)); 982 EXPECT_FALSE(GetPendingFrameHost(manager));
978 983
979 // We should observe RVH changed event. 984 // We should observe RVH changed event.
980 EXPECT_TRUE(change_observer.DidHostChange()); 985 EXPECT_TRUE(change_observer.DidHostChange());
986
987 EXPECT_EQ(SK_ColorRED,
988 manager->GetRenderWidgetHostView()->background_color());
981 } 989 }
982 990
983 // Tests WebUI creation. 991 // Tests WebUI creation.
984 TEST_F(RenderFrameHostManagerTest, WebUI) { 992 TEST_F(RenderFrameHostManagerTest, WebUI) {
985 set_should_create_webui(true); 993 set_should_create_webui(true);
986 scoped_refptr<SiteInstance> instance = 994 scoped_refptr<SiteInstance> instance =
987 SiteInstance::Create(browser_context()); 995 SiteInstance::Create(browser_context());
988 996
989 std::unique_ptr<TestWebContents> web_contents( 997 std::unique_ptr<TestWebContents> web_contents(
990 TestWebContents::Create(browser_context(), instance)); 998 TestWebContents::Create(browser_context(), instance));
(...skipping 2155 matching lines...) Expand 10 before | Expand all | Expand 10 after
3146 ASSERT_FALSE(delete_observer.deleted()); 3154 ASSERT_FALSE(delete_observer.deleted());
3147 EXPECT_FALSE(initial_rfh->is_active()); 3155 EXPECT_FALSE(initial_rfh->is_active());
3148 3156
3149 // The initial RFH receives a DidStartProvisionalLoad IPC. It should not 3157 // The initial RFH receives a DidStartProvisionalLoad IPC. It should not
3150 // create a NavigationHandle. 3158 // create a NavigationHandle.
3151 initial_rfh->SimulateNavigationStart(kUrl3); 3159 initial_rfh->SimulateNavigationStart(kUrl3);
3152 EXPECT_FALSE(initial_rfh->navigation_handle()); 3160 EXPECT_FALSE(initial_rfh->navigation_handle());
3153 } 3161 }
3154 3162
3155 } // namespace content 3163 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_manager.cc ('k') | content/browser/web_contents/web_contents_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698