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

Side by Side Diff: content/browser/web_contents/web_contents_impl_unittest.cc

Issue 1202593002: Move browser-to-renderer opener plumbing to frame routing IDs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@opener-create-opener-render-views
Patch Set: Remove suppress_opener Created 5 years, 5 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
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | content/common/view_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "content/browser/frame_host/cross_site_transferring_request.h" 8 #include "content/browser/frame_host/cross_site_transferring_request.h"
9 #include "content/browser/frame_host/interstitial_page_impl.h" 9 #include "content/browser/frame_host/interstitial_page_impl.h"
10 #include "content/browser/frame_host/navigation_entry_impl.h" 10 #include "content/browser/frame_host/navigation_entry_impl.h"
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 orig_rfh->PrepareForCommit(); 905 orig_rfh->PrepareForCommit();
906 contents()->TestDidNavigate(orig_rfh, 1, entry_id, true, url, 906 contents()->TestDidNavigate(orig_rfh, 1, entry_id, true, url,
907 ui::PAGE_TRANSITION_TYPED); 907 ui::PAGE_TRANSITION_TYPED);
908 908
909 // Start to navigate first tab to a new site, so that it has a pending RVH. 909 // Start to navigate first tab to a new site, so that it has a pending RVH.
910 const GURL url2("http://www.yahoo.com"); 910 const GURL url2("http://www.yahoo.com");
911 controller().LoadURL( 911 controller().LoadURL(
912 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); 912 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
913 orig_rfh->PrepareForCommit(); 913 orig_rfh->PrepareForCommit();
914 TestRenderFrameHost* pending_rfh = contents()->GetPendingMainFrame(); 914 TestRenderFrameHost* pending_rfh = contents()->GetPendingMainFrame();
915 SiteInstance* instance = pending_rfh->GetSiteInstance();
915 916
916 // While it is still pending, simulate opening a new tab with the first tab 917 // While it is still pending, simulate opening a new tab with the first tab
917 // as its opener. This will call CreateOpenerProxies on the opener to ensure 918 // as its opener. This will call CreateOpenerProxies on the opener to ensure
918 // that an RVH exists. 919 // that an RVH exists.
919 int opener_routing_id = contents()->GetRenderManager()->CreateOpenerProxies( 920 scoped_ptr<TestWebContents> popup(
920 pending_rfh->GetSiteInstance()); 921 TestWebContents::Create(browser_context(), instance));
922 popup->SetOpener(contents());
923 contents()->GetRenderManager()->CreateOpenerProxies(instance);
921 924
922 // We should find the pending RVH and not create a new one. 925 // If swapped out is allowed, we should find the pending RFH and not create a
923 EXPECT_EQ(pending_rfh->GetRenderViewHost()->GetRoutingID(), 926 // new one. Otherwise, a new proxy should be created for the opener in
924 opener_routing_id); 927 // |instance|, and we should ensure that its routing ID is returned here.
928 //
929 // TODO(alexmos): Add the latter check once CreateOpenerProxies is fixed to
930 // create a proxy in this case.
931 if (!RenderFrameHostManager::IsSwappedOutStateForbidden()) {
932 int opener_frame_routing_id =
933 popup->GetRenderManager()->GetOpenerRoutingID(instance);
934 EXPECT_EQ(pending_rfh->GetRoutingID(), opener_frame_routing_id);
935 }
925 } 936 }
926 937
927 // Tests that WebContentsImpl uses the current URL, not the SiteInstance's site, 938 // Tests that WebContentsImpl uses the current URL, not the SiteInstance's site,
928 // to determine whether a navigation is cross-site. 939 // to determine whether a navigation is cross-site.
929 TEST_F(WebContentsImplTest, CrossSiteComparesAgainstCurrentPage) { 940 TEST_F(WebContentsImplTest, CrossSiteComparesAgainstCurrentPage) {
930 TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); 941 TestRenderFrameHost* orig_rfh = contents()->GetMainFrame();
931 SiteInstance* instance1 = contents()->GetSiteInstance(); 942 SiteInstance* instance1 = contents()->GetSiteInstance();
932 943
933 // Navigate to URL. 944 // Navigate to URL.
934 const GURL url("http://www.google.com"); 945 const GURL url("http://www.google.com");
(...skipping 2248 matching lines...) Expand 10 before | Expand all | Expand 10 after
3183 // Additional changes made by the web contents should propagate as well. 3194 // Additional changes made by the web contents should propagate as well.
3184 RenderViewHostTester::TestOnMessageReceived( 3195 RenderViewHostTester::TestOnMessageReceived(
3185 test_rvh(), 3196 test_rvh(),
3186 FrameHostMsg_DidChangeThemeColor(rfh->GetRoutingID(), SK_ColorGREEN)); 3197 FrameHostMsg_DidChangeThemeColor(rfh->GetRoutingID(), SK_ColorGREEN));
3187 3198
3188 EXPECT_EQ(SK_ColorGREEN, contents()->GetThemeColor()); 3199 EXPECT_EQ(SK_ColorGREEN, contents()->GetThemeColor());
3189 EXPECT_EQ(SK_ColorGREEN, observer.last_theme_color()); 3200 EXPECT_EQ(SK_ColorGREEN, observer.last_theme_color());
3190 } 3201 }
3191 3202
3192 } // namespace content 3203 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | content/common/view_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698