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

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: More cleanup 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
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 // We should find the pending RFH and not create a new one.
nasko 2015/07/07 16:26:21 This is only valid in regular chrome, not with --s
alexmos 2015/07/08 04:42:18 Done - see my earlier discussion.
nasko 2015/07/08 09:35:19 Acknowledged.
923 EXPECT_EQ(pending_rfh->GetRenderViewHost()->GetRoutingID(), 926 int opener_frame_routing_id =
924 opener_routing_id); 927 popup->GetRenderManager()->GetOpenerRoutingID(instance);
928 EXPECT_EQ(pending_rfh->GetRoutingID(), opener_frame_routing_id);
925 } 929 }
926 930
927 // Tests that WebContentsImpl uses the current URL, not the SiteInstance's site, 931 // Tests that WebContentsImpl uses the current URL, not the SiteInstance's site,
928 // to determine whether a navigation is cross-site. 932 // to determine whether a navigation is cross-site.
929 TEST_F(WebContentsImplTest, CrossSiteComparesAgainstCurrentPage) { 933 TEST_F(WebContentsImplTest, CrossSiteComparesAgainstCurrentPage) {
930 TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); 934 TestRenderFrameHost* orig_rfh = contents()->GetMainFrame();
931 SiteInstance* instance1 = contents()->GetSiteInstance(); 935 SiteInstance* instance1 = contents()->GetSiteInstance();
932 936
933 // Navigate to URL. 937 // Navigate to URL.
934 const GURL url("http://www.google.com"); 938 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. 3187 // Additional changes made by the web contents should propagate as well.
3184 RenderViewHostTester::TestOnMessageReceived( 3188 RenderViewHostTester::TestOnMessageReceived(
3185 test_rvh(), 3189 test_rvh(),
3186 FrameHostMsg_DidChangeThemeColor(rfh->GetRoutingID(), SK_ColorGREEN)); 3190 FrameHostMsg_DidChangeThemeColor(rfh->GetRoutingID(), SK_ColorGREEN));
3187 3191
3188 EXPECT_EQ(SK_ColorGREEN, contents()->GetThemeColor()); 3192 EXPECT_EQ(SK_ColorGREEN, contents()->GetThemeColor());
3189 EXPECT_EQ(SK_ColorGREEN, observer.last_theme_color()); 3193 EXPECT_EQ(SK_ColorGREEN, observer.last_theme_color());
3190 } 3194 }
3191 3195
3192 } // namespace content 3196 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698