OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser_thread_impl.h" | 5 #include "content/browser/browser_thread_impl.h" |
6 #include "content/browser/browser_url_handler.h" | 6 #include "content/browser/browser_url_handler.h" |
7 #include "content/browser/mock_content_browser_client.h" | 7 #include "content/browser/mock_content_browser_client.h" |
8 #include "content/browser/renderer_host/test_render_view_host.h" | 8 #include "content/browser/renderer_host/test_render_view_host.h" |
9 #include "content/browser/site_instance.h" | 9 #include "content/browser/site_instance.h" |
10 #include "content/browser/tab_contents/navigation_controller.h" | 10 #include "content/browser/tab_contents/navigation_controller.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 void set_should_create_webui(bool should_create_webui) { | 108 void set_should_create_webui(bool should_create_webui) { |
109 browser_client_.set_should_create_webui(should_create_webui); | 109 browser_client_.set_should_create_webui(should_create_webui); |
110 } | 110 } |
111 | 111 |
112 void NavigateActiveAndCommit(const GURL& url) { | 112 void NavigateActiveAndCommit(const GURL& url) { |
113 // Note: we navigate the active RenderViewHost because previous navigations | 113 // Note: we navigate the active RenderViewHost because previous navigations |
114 // won't have committed yet, so NavigateAndCommit does the wrong thing | 114 // won't have committed yet, so NavigateAndCommit does the wrong thing |
115 // for us. | 115 // for us. |
116 controller().LoadURL( | 116 controller().LoadURL( |
117 url, GURL(), content::PAGE_TRANSITION_LINK, std::string()); | 117 url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); |
118 TestRenderViewHost* old_rvh = rvh(); | 118 TestRenderViewHost* old_rvh = rvh(); |
119 | 119 |
120 // Simulate the ShouldClose_ACK that is received from the current renderer | 120 // Simulate the ShouldClose_ACK that is received from the current renderer |
121 // for a cross-site navigation. | 121 // for a cross-site navigation. |
122 if (old_rvh != active_rvh()) | 122 if (old_rvh != active_rvh()) |
123 old_rvh->SendShouldCloseACK(true); | 123 old_rvh->SendShouldCloseACK(true); |
124 | 124 |
125 // Commit the navigation. | 125 // Commit the navigation. |
126 active_rvh()->SendNavigate( | 126 active_rvh()->SendNavigate( |
127 static_cast<MockRenderProcessHost*>(active_rvh()->process())-> | 127 static_cast<MockRenderProcessHost*>(active_rvh()->process())-> |
(...skipping 30 matching lines...) Expand all Loading... |
158 NavigateActiveAndCommit(kNtpUrl); | 158 NavigateActiveAndCommit(kNtpUrl); |
159 NavigateActiveAndCommit(kDestUrl); | 159 NavigateActiveAndCommit(kDestUrl); |
160 | 160 |
161 // Make a second tab. | 161 // Make a second tab. |
162 TestTabContents contents2(browser_context(), NULL); | 162 TestTabContents contents2(browser_context(), NULL); |
163 | 163 |
164 // Load the two URLs in the second tab. Note that the first navigation creates | 164 // Load the two URLs in the second tab. Note that the first navigation creates |
165 // a RVH that's not pending (since there is no cross-site transition), so | 165 // a RVH that's not pending (since there is no cross-site transition), so |
166 // we use the committed one. | 166 // we use the committed one. |
167 contents2.controller().LoadURL( | 167 contents2.controller().LoadURL( |
168 kNtpUrl, GURL(), content::PAGE_TRANSITION_LINK, std::string()); | 168 kNtpUrl, content::Referrer(), content::PAGE_TRANSITION_LINK, |
| 169 std::string()); |
169 TestRenderViewHost* ntp_rvh2 = static_cast<TestRenderViewHost*>( | 170 TestRenderViewHost* ntp_rvh2 = static_cast<TestRenderViewHost*>( |
170 contents2.render_manager_for_testing()->current_host()); | 171 contents2.render_manager_for_testing()->current_host()); |
171 EXPECT_FALSE(contents2.cross_navigation_pending()); | 172 EXPECT_FALSE(contents2.cross_navigation_pending()); |
172 ntp_rvh2->SendNavigate(100, kNtpUrl); | 173 ntp_rvh2->SendNavigate(100, kNtpUrl); |
173 | 174 |
174 // The second one is the opposite, creating a cross-site transition and | 175 // The second one is the opposite, creating a cross-site transition and |
175 // requiring a beforeunload ack. | 176 // requiring a beforeunload ack. |
176 contents2.controller().LoadURL( | 177 contents2.controller().LoadURL( |
177 kDestUrl, GURL(), content::PAGE_TRANSITION_LINK, std::string()); | 178 kDestUrl, content::Referrer(), content::PAGE_TRANSITION_LINK, |
| 179 std::string()); |
178 EXPECT_TRUE(contents2.cross_navigation_pending()); | 180 EXPECT_TRUE(contents2.cross_navigation_pending()); |
179 TestRenderViewHost* dest_rvh2 = static_cast<TestRenderViewHost*>( | 181 TestRenderViewHost* dest_rvh2 = static_cast<TestRenderViewHost*>( |
180 contents2.render_manager_for_testing()->pending_render_view_host()); | 182 contents2.render_manager_for_testing()->pending_render_view_host()); |
181 ASSERT_TRUE(dest_rvh2); | 183 ASSERT_TRUE(dest_rvh2); |
182 ntp_rvh2->SendShouldCloseACK(true); | 184 ntp_rvh2->SendShouldCloseACK(true); |
183 dest_rvh2->SendNavigate(101, kDestUrl); | 185 dest_rvh2->SendNavigate(101, kDestUrl); |
184 ntp_rvh2->OnSwapOutACK(); | 186 ntp_rvh2->OnSwapOutACK(); |
185 | 187 |
186 // The two RVH's should be different in every way. | 188 // The two RVH's should be different in every way. |
187 EXPECT_NE(active_rvh()->process(), dest_rvh2->process()); | 189 EXPECT_NE(active_rvh()->process(), dest_rvh2->process()); |
188 EXPECT_NE(active_rvh()->site_instance(), dest_rvh2->site_instance()); | 190 EXPECT_NE(active_rvh()->site_instance(), dest_rvh2->site_instance()); |
189 EXPECT_NE(active_rvh()->site_instance()->browsing_instance(), | 191 EXPECT_NE(active_rvh()->site_instance()->browsing_instance(), |
190 dest_rvh2->site_instance()->browsing_instance()); | 192 dest_rvh2->site_instance()->browsing_instance()); |
191 | 193 |
192 // Navigate both to the new tab page, and verify that they share a | 194 // Navigate both to the new tab page, and verify that they share a |
193 // SiteInstance. | 195 // SiteInstance. |
194 NavigateActiveAndCommit(kNtpUrl); | 196 NavigateActiveAndCommit(kNtpUrl); |
195 | 197 |
196 contents2.controller().LoadURL( | 198 contents2.controller().LoadURL( |
197 kNtpUrl, GURL(), content::PAGE_TRANSITION_LINK, std::string()); | 199 kNtpUrl, content::Referrer(), content::PAGE_TRANSITION_LINK, |
| 200 std::string()); |
198 dest_rvh2->SendShouldCloseACK(true); | 201 dest_rvh2->SendShouldCloseACK(true); |
199 static_cast<TestRenderViewHost*>(contents2.render_manager_for_testing()-> | 202 static_cast<TestRenderViewHost*>(contents2.render_manager_for_testing()-> |
200 pending_render_view_host())->SendNavigate(102, kNtpUrl); | 203 pending_render_view_host())->SendNavigate(102, kNtpUrl); |
201 dest_rvh2->OnSwapOutACK(); | 204 dest_rvh2->OnSwapOutACK(); |
202 | 205 |
203 EXPECT_EQ(active_rvh()->site_instance(), | 206 EXPECT_EQ(active_rvh()->site_instance(), |
204 contents2.render_view_host()->site_instance()); | 207 contents2.render_view_host()->site_instance()); |
205 } | 208 } |
206 | 209 |
207 // When there is an error with the specified page, renderer exits view-source | 210 // When there is an error with the specified page, renderer exits view-source |
208 // mode. See WebFrameImpl::DidFail(). We check by this test that | 211 // mode. See WebFrameImpl::DidFail(). We check by this test that |
209 // EnableViewSourceMode message is sent on every navigation regardless | 212 // EnableViewSourceMode message is sent on every navigation regardless |
210 // RenderView is being newly created or reused. | 213 // RenderView is being newly created or reused. |
211 TEST_F(RenderViewHostManagerTest, AlwaysSendEnableViewSourceMode) { | 214 TEST_F(RenderViewHostManagerTest, AlwaysSendEnableViewSourceMode) { |
212 BrowserThreadImpl ui_thread(BrowserThread::UI, MessageLoop::current()); | 215 BrowserThreadImpl ui_thread(BrowserThread::UI, MessageLoop::current()); |
213 const GURL kNtpUrl(chrome::kTestNewTabURL); | 216 const GURL kNtpUrl(chrome::kTestNewTabURL); |
214 const GURL kUrl("view-source:http://foo"); | 217 const GURL kUrl("view-source:http://foo"); |
215 | 218 |
216 // We have to navigate to some page at first since without this, the first | 219 // We have to navigate to some page at first since without this, the first |
217 // navigation will reuse the SiteInstance created by Init(), and the second | 220 // navigation will reuse the SiteInstance created by Init(), and the second |
218 // one will create a new SiteInstance. Because current_instance and | 221 // one will create a new SiteInstance. Because current_instance and |
219 // new_instance will be different, a new RenderViewHost will be created for | 222 // new_instance will be different, a new RenderViewHost will be created for |
220 // the second navigation. We have to avoid this in order to exercise the | 223 // the second navigation. We have to avoid this in order to exercise the |
221 // target code patch. | 224 // target code patch. |
222 NavigateActiveAndCommit(kNtpUrl); | 225 NavigateActiveAndCommit(kNtpUrl); |
223 | 226 |
224 // Navigate. | 227 // Navigate. |
225 controller().LoadURL( | 228 controller().LoadURL( |
226 kUrl, GURL(), content::PAGE_TRANSITION_TYPED, std::string()); | 229 kUrl, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
227 // Simulate response from RenderView for FirePageBeforeUnload. | 230 // Simulate response from RenderView for FirePageBeforeUnload. |
228 rvh()->TestOnMessageReceived( | 231 rvh()->TestOnMessageReceived( |
229 ViewHostMsg_ShouldClose_ACK(rvh()->routing_id(), true)); | 232 ViewHostMsg_ShouldClose_ACK(rvh()->routing_id(), true)); |
230 ASSERT_TRUE(pending_rvh()); // New pending RenderViewHost will be created. | 233 ASSERT_TRUE(pending_rvh()); // New pending RenderViewHost will be created. |
231 RenderViewHost* last_rvh = pending_rvh(); | 234 RenderViewHost* last_rvh = pending_rvh(); |
232 int new_id = static_cast<MockRenderProcessHost*>(pending_rvh()->process())-> | 235 int new_id = static_cast<MockRenderProcessHost*>(pending_rvh()->process())-> |
233 max_page_id() + 1; | 236 max_page_id() + 1; |
234 pending_rvh()->SendNavigate(new_id, kUrl); | 237 pending_rvh()->SendNavigate(new_id, kUrl); |
235 EXPECT_EQ(controller().last_committed_entry_index(), 1); | 238 EXPECT_EQ(controller().last_committed_entry_index(), 1); |
236 ASSERT_TRUE(controller().GetLastCommittedEntry()); | 239 ASSERT_TRUE(controller().GetLastCommittedEntry()); |
237 EXPECT_TRUE(kUrl == controller().GetLastCommittedEntry()->url()); | 240 EXPECT_TRUE(kUrl == controller().GetLastCommittedEntry()->url()); |
238 EXPECT_FALSE(controller().pending_entry()); | 241 EXPECT_FALSE(controller().pending_entry()); |
239 // Because we're using TestTabContents and TestRenderViewHost in this | 242 // Because we're using TestTabContents and TestRenderViewHost in this |
240 // unittest, no one calls TabContents::RenderViewCreated(). So, we see no | 243 // unittest, no one calls TabContents::RenderViewCreated(). So, we see no |
241 // EnableViewSourceMode message, here. | 244 // EnableViewSourceMode message, here. |
242 | 245 |
243 // Clear queued messages before load. | 246 // Clear queued messages before load. |
244 process()->sink().ClearMessages(); | 247 process()->sink().ClearMessages(); |
245 // Navigate, again. | 248 // Navigate, again. |
246 controller().LoadURL( | 249 controller().LoadURL( |
247 kUrl, GURL(), content::PAGE_TRANSITION_TYPED, std::string()); | 250 kUrl, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
248 // The same RenderViewHost should be reused. | 251 // The same RenderViewHost should be reused. |
249 EXPECT_FALSE(pending_rvh()); | 252 EXPECT_FALSE(pending_rvh()); |
250 EXPECT_TRUE(last_rvh == rvh()); | 253 EXPECT_TRUE(last_rvh == rvh()); |
251 rvh()->SendNavigate(new_id, kUrl); // The same page_id returned. | 254 rvh()->SendNavigate(new_id, kUrl); // The same page_id returned. |
252 EXPECT_EQ(controller().last_committed_entry_index(), 1); | 255 EXPECT_EQ(controller().last_committed_entry_index(), 1); |
253 EXPECT_FALSE(controller().pending_entry()); | 256 EXPECT_FALSE(controller().pending_entry()); |
254 // New message should be sent out to make sure to enter view-source mode. | 257 // New message should be sent out to make sure to enter view-source mode. |
255 EXPECT_TRUE(process()->sink().GetUniqueMessageMatching( | 258 EXPECT_TRUE(process()->sink().GetUniqueMessageMatching( |
256 ViewMsg_EnableViewSourceMode::ID)); | 259 ViewMsg_EnableViewSourceMode::ID)); |
257 } | 260 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 // Create. | 293 // Create. |
291 RenderViewHostManager manager(&tab_contents, &tab_contents); | 294 RenderViewHostManager manager(&tab_contents, &tab_contents); |
292 | 295 |
293 manager.Init(browser_context(), instance, MSG_ROUTING_NONE); | 296 manager.Init(browser_context(), instance, MSG_ROUTING_NONE); |
294 | 297 |
295 RenderViewHost* host; | 298 RenderViewHost* host; |
296 | 299 |
297 // 1) The first navigation. -------------------------- | 300 // 1) The first navigation. -------------------------- |
298 const GURL kUrl1("http://www.google.com/"); | 301 const GURL kUrl1("http://www.google.com/"); |
299 NavigationEntry entry1(NULL /* instance */, -1 /* page_id */, kUrl1, | 302 NavigationEntry entry1(NULL /* instance */, -1 /* page_id */, kUrl1, |
300 GURL() /* referrer */, string16() /* title */, | 303 content::Referrer(), string16() /* title */, |
301 content::PAGE_TRANSITION_TYPED, | 304 content::PAGE_TRANSITION_TYPED, |
302 false /* is_renderer_init */); | 305 false /* is_renderer_init */); |
303 host = manager.Navigate(entry1); | 306 host = manager.Navigate(entry1); |
304 | 307 |
305 // The RenderViewHost created in Init will be reused. | 308 // The RenderViewHost created in Init will be reused. |
306 EXPECT_TRUE(host == manager.current_host()); | 309 EXPECT_TRUE(host == manager.current_host()); |
307 EXPECT_FALSE(manager.pending_render_view_host()); | 310 EXPECT_FALSE(manager.pending_render_view_host()); |
308 | 311 |
309 // Commit. | 312 // Commit. |
310 manager.DidNavigateMainFrame(host); | 313 manager.DidNavigateMainFrame(host); |
311 // Commit to SiteInstance should be delayed until RenderView commit. | 314 // Commit to SiteInstance should be delayed until RenderView commit. |
312 EXPECT_TRUE(host == manager.current_host()); | 315 EXPECT_TRUE(host == manager.current_host()); |
313 ASSERT_TRUE(host); | 316 ASSERT_TRUE(host); |
314 EXPECT_FALSE(host->site_instance()->has_site()); | 317 EXPECT_FALSE(host->site_instance()->has_site()); |
315 host->site_instance()->SetSite(kUrl1); | 318 host->site_instance()->SetSite(kUrl1); |
316 | 319 |
317 // 2) Navigate to next site. ------------------------- | 320 // 2) Navigate to next site. ------------------------- |
318 const GURL kUrl2("http://www.google.com/foo"); | 321 const GURL kUrl2("http://www.google.com/foo"); |
319 NavigationEntry entry2(NULL /* instance */, -1 /* page_id */, kUrl2, | 322 NavigationEntry entry2( |
320 kUrl1 /* referrer */, string16() /* title */, | 323 NULL /* instance */, -1 /* page_id */, kUrl2, |
321 content::PAGE_TRANSITION_LINK, | 324 content::Referrer(kUrl1, WebKit::WebReferrerPolicyDefault), |
322 true /* is_renderer_init */); | 325 string16() /* title */, content::PAGE_TRANSITION_LINK, |
| 326 true /* is_renderer_init */); |
323 host = manager.Navigate(entry2); | 327 host = manager.Navigate(entry2); |
324 | 328 |
325 // The RenderViewHost created in Init will be reused. | 329 // The RenderViewHost created in Init will be reused. |
326 EXPECT_TRUE(host == manager.current_host()); | 330 EXPECT_TRUE(host == manager.current_host()); |
327 EXPECT_FALSE(manager.pending_render_view_host()); | 331 EXPECT_FALSE(manager.pending_render_view_host()); |
328 | 332 |
329 // Commit. | 333 // Commit. |
330 manager.DidNavigateMainFrame(host); | 334 manager.DidNavigateMainFrame(host); |
331 EXPECT_TRUE(host == manager.current_host()); | 335 EXPECT_TRUE(host == manager.current_host()); |
332 ASSERT_TRUE(host); | 336 ASSERT_TRUE(host); |
333 EXPECT_TRUE(host->site_instance()->has_site()); | 337 EXPECT_TRUE(host->site_instance()->has_site()); |
334 | 338 |
335 // 3) Cross-site navigate to next site. -------------- | 339 // 3) Cross-site navigate to next site. -------------- |
336 const GURL kUrl3("http://webkit.org/"); | 340 const GURL kUrl3("http://webkit.org/"); |
337 NavigationEntry entry3(NULL /* instance */, -1 /* page_id */, kUrl3, | 341 NavigationEntry entry3( |
338 kUrl2 /* referrer */, string16() /* title */, | 342 NULL /* instance */, -1 /* page_id */, kUrl3, |
339 content::PAGE_TRANSITION_LINK, | 343 content::Referrer(kUrl2, WebKit::WebReferrerPolicyDefault), |
340 false /* is_renderer_init */); | 344 string16() /* title */, content::PAGE_TRANSITION_LINK, |
| 345 false /* is_renderer_init */); |
341 host = manager.Navigate(entry3); | 346 host = manager.Navigate(entry3); |
342 | 347 |
343 // A new RenderViewHost should be created. | 348 // A new RenderViewHost should be created. |
344 EXPECT_TRUE(manager.pending_render_view_host()); | 349 EXPECT_TRUE(manager.pending_render_view_host()); |
345 ASSERT_EQ(host, manager.pending_render_view_host()); | 350 ASSERT_EQ(host, manager.pending_render_view_host()); |
346 | 351 |
347 notifications.Reset(); | 352 notifications.Reset(); |
348 | 353 |
349 // Commit. | 354 // Commit. |
350 manager.DidNavigateMainFrame(manager.pending_render_view_host()); | 355 manager.DidNavigateMainFrame(manager.pending_render_view_host()); |
(...skipping 23 matching lines...) Expand all Loading... |
374 content::Source<NavigationController>(&tab_contents.controller())); | 379 content::Source<NavigationController>(&tab_contents.controller())); |
375 | 380 |
376 // Create. | 381 // Create. |
377 RenderViewHostManager manager(&tab_contents, &tab_contents); | 382 RenderViewHostManager manager(&tab_contents, &tab_contents); |
378 | 383 |
379 manager.Init(browser_context(), instance, MSG_ROUTING_NONE); | 384 manager.Init(browser_context(), instance, MSG_ROUTING_NONE); |
380 | 385 |
381 // 1) The first navigation. -------------------------- | 386 // 1) The first navigation. -------------------------- |
382 const GURL kUrl1("http://www.google.com/"); | 387 const GURL kUrl1("http://www.google.com/"); |
383 NavigationEntry entry1(NULL /* instance */, -1 /* page_id */, kUrl1, | 388 NavigationEntry entry1(NULL /* instance */, -1 /* page_id */, kUrl1, |
384 GURL() /* referrer */, string16() /* title */, | 389 content::Referrer(), string16() /* title */, |
385 content::PAGE_TRANSITION_TYPED, | 390 content::PAGE_TRANSITION_TYPED, |
386 false /* is_renderer_init */); | 391 false /* is_renderer_init */); |
387 RenderViewHost* host = manager.Navigate(entry1); | 392 RenderViewHost* host = manager.Navigate(entry1); |
388 | 393 |
389 // The RenderViewHost created in Init will be reused. | 394 // The RenderViewHost created in Init will be reused. |
390 EXPECT_TRUE(host == manager.current_host()); | 395 EXPECT_TRUE(host == manager.current_host()); |
391 EXPECT_FALSE(manager.pending_render_view_host()); | 396 EXPECT_FALSE(manager.pending_render_view_host()); |
392 | 397 |
393 // We should observe a notification. | 398 // We should observe a notification. |
394 EXPECT_TRUE(notifications.Check1AndReset( | 399 EXPECT_TRUE(notifications.Check1AndReset( |
395 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED)); | 400 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED)); |
396 notifications.Reset(); | 401 notifications.Reset(); |
397 | 402 |
398 // Commit. | 403 // Commit. |
399 manager.DidNavigateMainFrame(host); | 404 manager.DidNavigateMainFrame(host); |
400 | 405 |
401 // Commit to SiteInstance should be delayed until RenderView commit. | 406 // Commit to SiteInstance should be delayed until RenderView commit. |
402 EXPECT_TRUE(host == manager.current_host()); | 407 EXPECT_TRUE(host == manager.current_host()); |
403 ASSERT_TRUE(host); | 408 ASSERT_TRUE(host); |
404 EXPECT_FALSE(host->site_instance()->has_site()); | 409 EXPECT_FALSE(host->site_instance()->has_site()); |
405 host->site_instance()->SetSite(kUrl1); | 410 host->site_instance()->SetSite(kUrl1); |
406 | 411 |
407 // 2) Cross-site navigate to next site. ------------------------- | 412 // 2) Cross-site navigate to next site. ------------------------- |
408 const GURL kUrl2("http://www.example.com"); | 413 const GURL kUrl2("http://www.example.com"); |
409 NavigationEntry entry2(NULL /* instance */, -1 /* page_id */, kUrl2, | 414 NavigationEntry entry2(NULL /* instance */, -1 /* page_id */, kUrl2, |
410 GURL() /* referrer */, string16() /* title */, | 415 content::Referrer(), string16() /* title */, |
411 content::PAGE_TRANSITION_TYPED, | 416 content::PAGE_TRANSITION_TYPED, |
412 false /* is_renderer_init */); | 417 false /* is_renderer_init */); |
413 RenderViewHost* host2 = manager.Navigate(entry2); | 418 RenderViewHost* host2 = manager.Navigate(entry2); |
414 | 419 |
415 // A new RenderViewHost should be created. | 420 // A new RenderViewHost should be created. |
416 EXPECT_TRUE(manager.pending_render_view_host()); | 421 EXPECT_TRUE(manager.pending_render_view_host()); |
417 ASSERT_EQ(host2, manager.pending_render_view_host()); | 422 ASSERT_EQ(host2, manager.pending_render_view_host()); |
418 | 423 |
419 // Check that the navigation is still suspended because the old RVH | 424 // Check that the navigation is still suspended because the old RVH |
420 // is not swapped out, yet. | 425 // is not swapped out, yet. |
(...skipping 27 matching lines...) Expand all Loading... |
448 EXPECT_EQ(host, manager.current_host()); | 453 EXPECT_EQ(host, manager.current_host()); |
449 EXPECT_TRUE(manager.current_host()->is_swapped_out()); | 454 EXPECT_TRUE(manager.current_host()->is_swapped_out()); |
450 EXPECT_EQ(host2, manager.pending_render_view_host()); | 455 EXPECT_EQ(host2, manager.pending_render_view_host()); |
451 // There should be still no navigation messages being sent. | 456 // There should be still no navigation messages being sent. |
452 EXPECT_FALSE(test_process_host2->sink().GetUniqueMessageMatching( | 457 EXPECT_FALSE(test_process_host2->sink().GetUniqueMessageMatching( |
453 ViewMsg_Navigate::ID)); | 458 ViewMsg_Navigate::ID)); |
454 | 459 |
455 // 3) Cross-site navigate to next site before 2) has committed. -------------- | 460 // 3) Cross-site navigate to next site before 2) has committed. -------------- |
456 const GURL kUrl3("http://webkit.org/"); | 461 const GURL kUrl3("http://webkit.org/"); |
457 NavigationEntry entry3(NULL /* instance */, -1 /* page_id */, kUrl3, | 462 NavigationEntry entry3(NULL /* instance */, -1 /* page_id */, kUrl3, |
458 GURL() /* referrer */, string16() /* title */, | 463 content::Referrer(), string16() /* title */, |
459 content::PAGE_TRANSITION_TYPED, | 464 content::PAGE_TRANSITION_TYPED, |
460 false /* is_renderer_init */); | 465 false /* is_renderer_init */); |
461 RenderViewHost* host3 = manager.Navigate(entry3); | 466 RenderViewHost* host3 = manager.Navigate(entry3); |
462 | 467 |
463 // A new RenderViewHost should be created. | 468 // A new RenderViewHost should be created. |
464 EXPECT_TRUE(manager.pending_render_view_host()); | 469 EXPECT_TRUE(manager.pending_render_view_host()); |
465 ASSERT_EQ(host3, manager.pending_render_view_host()); | 470 ASSERT_EQ(host3, manager.pending_render_view_host()); |
466 | 471 |
467 EXPECT_EQ(host, manager.current_host()); | 472 EXPECT_EQ(host, manager.current_host()); |
468 EXPECT_TRUE(manager.current_host()->is_swapped_out()); | 473 EXPECT_TRUE(manager.current_host()->is_swapped_out()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 BrowserThreadImpl ui_thread(BrowserThread::UI, MessageLoop::current()); | 505 BrowserThreadImpl ui_thread(BrowserThread::UI, MessageLoop::current()); |
501 SiteInstance* instance = SiteInstance::CreateSiteInstance(browser_context()); | 506 SiteInstance* instance = SiteInstance::CreateSiteInstance(browser_context()); |
502 | 507 |
503 TestTabContents tab_contents(browser_context(), instance); | 508 TestTabContents tab_contents(browser_context(), instance); |
504 RenderViewHostManager manager(&tab_contents, &tab_contents); | 509 RenderViewHostManager manager(&tab_contents, &tab_contents); |
505 | 510 |
506 manager.Init(browser_context(), instance, MSG_ROUTING_NONE); | 511 manager.Init(browser_context(), instance, MSG_ROUTING_NONE); |
507 | 512 |
508 const GURL kUrl(chrome::kTestNewTabURL); | 513 const GURL kUrl(chrome::kTestNewTabURL); |
509 NavigationEntry entry(NULL /* instance */, -1 /* page_id */, kUrl, | 514 NavigationEntry entry(NULL /* instance */, -1 /* page_id */, kUrl, |
510 GURL() /* referrer */, string16() /* title */, | 515 content::Referrer(), string16() /* title */, |
511 content::PAGE_TRANSITION_TYPED, | 516 content::PAGE_TRANSITION_TYPED, |
512 false /* is_renderer_init */); | 517 false /* is_renderer_init */); |
513 RenderViewHost* host = manager.Navigate(entry); | 518 RenderViewHost* host = manager.Navigate(entry); |
514 | 519 |
515 EXPECT_TRUE(host); | 520 EXPECT_TRUE(host); |
516 EXPECT_TRUE(host == manager.current_host()); | 521 EXPECT_TRUE(host == manager.current_host()); |
517 EXPECT_FALSE(manager.pending_render_view_host()); | 522 EXPECT_FALSE(manager.pending_render_view_host()); |
518 | 523 |
519 // It's important that the site instance get set on the Web UI page as soon | 524 // It's important that the site instance get set on the Web UI page as soon |
520 // as the navigation starts, rather than lazily after it commits, so we don't | 525 // as the navigation starts, rather than lazily after it commits, so we don't |
(...skipping 18 matching lines...) Expand all Loading... |
539 TEST_F(RenderViewHostManagerTest, NonWebUIChromeURLs) { | 544 TEST_F(RenderViewHostManagerTest, NonWebUIChromeURLs) { |
540 BrowserThreadImpl thread(BrowserThread::UI, &message_loop_); | 545 BrowserThreadImpl thread(BrowserThread::UI, &message_loop_); |
541 SiteInstance* instance = SiteInstance::CreateSiteInstance(browser_context()); | 546 SiteInstance* instance = SiteInstance::CreateSiteInstance(browser_context()); |
542 TestTabContents tab_contents(browser_context(), instance); | 547 TestTabContents tab_contents(browser_context(), instance); |
543 RenderViewHostManager manager(&tab_contents, &tab_contents); | 548 RenderViewHostManager manager(&tab_contents, &tab_contents); |
544 manager.Init(browser_context(), instance, MSG_ROUTING_NONE); | 549 manager.Init(browser_context(), instance, MSG_ROUTING_NONE); |
545 | 550 |
546 // NTP is a Web UI page. | 551 // NTP is a Web UI page. |
547 const GURL kNtpUrl(chrome::kTestNewTabURL); | 552 const GURL kNtpUrl(chrome::kTestNewTabURL); |
548 NavigationEntry ntp_entry(NULL /* instance */, -1 /* page_id */, kNtpUrl, | 553 NavigationEntry ntp_entry(NULL /* instance */, -1 /* page_id */, kNtpUrl, |
549 GURL() /* referrer */, string16() /* title */, | 554 content::Referrer(), string16() /* title */, |
550 content::PAGE_TRANSITION_TYPED, | 555 content::PAGE_TRANSITION_TYPED, |
551 false /* is_renderer_init */); | 556 false /* is_renderer_init */); |
552 | 557 |
553 // A URL with the Chrome UI scheme, that isn't handled by Web UI. | 558 // A URL with the Chrome UI scheme, that isn't handled by Web UI. |
554 GURL about_url(kChromeUISchemeButNotWebUIURL); | 559 GURL about_url(kChromeUISchemeButNotWebUIURL); |
555 NavigationEntry about_entry(NULL /* instance */, -1 /* page_id */, about_url, | 560 NavigationEntry about_entry(NULL /* instance */, -1 /* page_id */, about_url, |
556 GURL() /* referrer */, string16() /* title */, | 561 content::Referrer(), string16() /* title */, |
557 content::PAGE_TRANSITION_TYPED, | 562 content::PAGE_TRANSITION_TYPED, |
558 false /* is_renderer_init */); | 563 false /* is_renderer_init */); |
559 | 564 |
560 EXPECT_TRUE(ShouldSwapProcesses(&manager, &ntp_entry, &about_entry)); | 565 EXPECT_TRUE(ShouldSwapProcesses(&manager, &ntp_entry, &about_entry)); |
561 } | 566 } |
562 | 567 |
563 // Tests that we don't end up in an inconsistent state if a page does a back and | 568 // Tests that we don't end up in an inconsistent state if a page does a back and |
564 // then reload. http://crbug.com/51680 | 569 // then reload. http://crbug.com/51680 |
565 TEST_F(RenderViewHostManagerTest, PageDoesBackAndReload) { | 570 TEST_F(RenderViewHostManagerTest, PageDoesBackAndReload) { |
566 const GURL kUrl1("http://www.google.com/"); | 571 const GURL kUrl1("http://www.google.com/"); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 // current one. | 603 // current one. |
599 EXPECT_TRUE(contents()->render_manager_for_testing()-> | 604 EXPECT_TRUE(contents()->render_manager_for_testing()-> |
600 pending_render_view_host() == NULL); | 605 pending_render_view_host() == NULL); |
601 EXPECT_EQ(evil_rvh, contents()->render_manager_for_testing()->current_host()); | 606 EXPECT_EQ(evil_rvh, contents()->render_manager_for_testing()->current_host()); |
602 | 607 |
603 // Also we should not have a pending navigation entry. | 608 // Also we should not have a pending navigation entry. |
604 NavigationEntry* entry = contents()->controller().GetActiveEntry(); | 609 NavigationEntry* entry = contents()->controller().GetActiveEntry(); |
605 ASSERT_TRUE(entry != NULL); | 610 ASSERT_TRUE(entry != NULL); |
606 EXPECT_EQ(kUrl2, entry->url()); | 611 EXPECT_EQ(kUrl2, entry->url()); |
607 } | 612 } |
OLD | NEW |