OLD | NEW |
---|---|
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 ASSERT_TRUE(observer->did_defer_response()); |
117 } | 118 } |
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 NavigationController::LoadURLParams params(GURL(url::kAboutBlankURL)); | |
137 transition_web_contents->GetController().LoadURLWithParams(params); | |
138 transition_web_contents->Focus(); | |
139 | |
140 WaitForLoadStop(transition_web_contents.get()); | |
141 | |
142 int transition_process_id = | |
143 transition_web_contents->GetRenderProcessHost()->GetID(); | |
144 | |
145 ASSERT_EQ(outgoing_process_id, transition_process_id); | |
Charlie Reis
2014/07/25 17:31:22
nit: Use EXPECT_* for things we're testing (so tha
shatch
2014/07/25 20:57:06
Done.
| |
146 } | |
147 | |
119 } // namespace content | 148 } // namespace content |
OLD | NEW |