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

Side by Side Diff: content/browser/transition_browsertest.cc

Issue 378743002: Navigation transitions: Place transition page in same process as destination page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix clang build. Created 6 years, 4 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/site_instance_impl_unittest.cc ('k') | content/public/browser/site_instance.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/bind.h" 5 #include "base/bind.h"
6 #include "content/browser/loader/cross_site_resource_handler.h" 6 #include "content/browser/loader/cross_site_resource_handler.h"
7 #include "content/browser/loader/resource_dispatcher_host_impl.h" 7 #include "content/browser/loader/resource_dispatcher_host_impl.h"
8 #include "content/browser/loader/resource_request_info_impl.h" 8 #include "content/browser/loader/resource_request_info_impl.h"
9 #include "content/browser/transition_request_manager.h" 9 #include "content/browser/transition_request_manager.h"
10 #include "content/browser/web_contents/web_contents_impl.h" 10 #include "content/browser/web_contents/web_contents_impl.h"
11 #include "content/public/browser/web_contents_observer.h" 11 #include "content/public/browser/web_contents_observer.h"
12 #include "content/public/test/browser_test_utils.h"
12 #include "content/public/test/content_browser_test.h" 13 #include "content/public/test/content_browser_test.h"
13 #include "content/public/test/content_browser_test_utils.h" 14 #include "content/public/test/content_browser_test_utils.h"
14 #include "content/public/test/test_utils.h" 15 #include "content/public/test/test_utils.h"
15 #include "content/shell/browser/shell.h" 16 #include "content/shell/browser/shell.h"
16 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h" 17 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h"
17 #include "net/test/embedded_test_server/embedded_test_server.h" 18 #include "net/test/embedded_test_server/embedded_test_server.h"
18 #include "net/url_request/url_request.h" 19 #include "net/url_request/url_request.h"
19 20
20 namespace content { 21 namespace content {
21 22
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 IN_PROC_BROWSER_TEST_F(TransitionBrowserTest, 91 IN_PROC_BROWSER_TEST_F(TransitionBrowserTest,
91 NormalNavigationNotDeferred) { 92 NormalNavigationNotDeferred) {
92 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 93 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
93 scoped_ptr<TransitionBrowserTestObserver> observer( 94 scoped_ptr<TransitionBrowserTestObserver> observer(
94 new TransitionBrowserTestObserver(shell()->web_contents())); 95 new TransitionBrowserTestObserver(shell()->web_contents()));
95 96
96 ResourceDispatcherHost::Get()->SetDelegate(observer.get()); 97 ResourceDispatcherHost::Get()->SetDelegate(observer.get());
97 98
98 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")); 99 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html"));
99 100
100 ASSERT_FALSE(observer->did_defer_response()); 101 EXPECT_FALSE(observer->did_defer_response());
101 } 102 }
102 103
103 // This tests that when a navigation transition is detected, the response is 104 // This tests that when a navigation transition is detected, the response is
104 // deferred. 105 // deferred.
105 IN_PROC_BROWSER_TEST_F(TransitionBrowserTest, 106 IN_PROC_BROWSER_TEST_F(TransitionBrowserTest,
106 TransitionNavigationIsDeferred) { 107 TransitionNavigationIsDeferred) {
107 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 108 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
108 scoped_ptr<TransitionBrowserTestObserver> observer( 109 scoped_ptr<TransitionBrowserTestObserver> observer(
109 new TransitionBrowserTestObserver(shell()->web_contents())); 110 new TransitionBrowserTestObserver(shell()->web_contents()));
110 111
111 ResourceDispatcherHost::Get()->SetDelegate(observer.get()); 112 ResourceDispatcherHost::Get()->SetDelegate(observer.get());
112 observer->set_pending_transition_request(true); 113 observer->set_pending_transition_request(true);
113 114
114 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")); 115 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html"));
115 116
116 ASSERT_TRUE(observer->did_defer_response()); 117 EXPECT_TRUE(observer->did_defer_response());
118 }
119
120 // This tests that the renderer is reused between the outgoing and transition.
121 IN_PROC_BROWSER_TEST_F(TransitionBrowserTest,
122 TransitionNavigationSharesRenderer) {
123 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
124
125 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html"));
126
127 int outgoing_process_id =
128 shell()->web_contents()->GetRenderProcessHost()->GetID();
129
130 WebContents::CreateParams create_params(
131 shell()->web_contents()->GetBrowserContext(),
132 shell()->web_contents()->GetSiteInstance());
133 scoped_ptr<WebContents> transition_web_contents(
134 WebContents::Create(create_params));
135
136 GURL about_blank(url::kAboutBlankURL);
137 NavigationController::LoadURLParams params(about_blank);
138 transition_web_contents->GetController().LoadURLWithParams(params);
139 transition_web_contents->Focus();
140
141 WaitForLoadStop(transition_web_contents.get());
142
143 int transition_process_id =
144 transition_web_contents->GetRenderProcessHost()->GetID();
145
146 EXPECT_EQ(outgoing_process_id, transition_process_id);
117 } 147 }
118 148
119 } // namespace content 149 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/site_instance_impl_unittest.cc ('k') | content/public/browser/site_instance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698