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 "chrome/browser/browser_url_handler.h" | 5 #include "chrome/browser/browser_url_handler.h" |
6 #include "chrome/test/test_notification_tracker.h" | 6 #include "chrome/test/test_notification_tracker.h" |
7 #include "chrome/test/testing_profile.h" | 7 #include "chrome/test/testing_profile.h" |
8 #include "content/browser/browser_thread.h" | 8 #include "content/browser/browser_thread.h" |
9 #include "content/browser/renderer_host/test_render_view_host.h" | 9 #include "content/browser/renderer_host/test_render_view_host.h" |
10 #include "content/browser/site_instance.h" | 10 #include "content/browser/site_instance.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 // Navigate our first tab to the new tab page and then to the destination. | 65 // Navigate our first tab to the new tab page and then to the destination. |
66 NavigateActiveAndCommit(kNtpUrl); | 66 NavigateActiveAndCommit(kNtpUrl); |
67 NavigateActiveAndCommit(kDestUrl); | 67 NavigateActiveAndCommit(kDestUrl); |
68 | 68 |
69 // Make a second tab. | 69 // Make a second tab. |
70 TestTabContents contents2(profile_.get(), NULL); | 70 TestTabContents contents2(profile_.get(), NULL); |
71 | 71 |
72 // Load the two URLs in the second tab. Note that the first navigation creates | 72 // Load the two URLs in the second tab. Note that the first navigation creates |
73 // a RVH that's not pending (since there is no cross-site transition), so | 73 // a RVH that's not pending (since there is no cross-site transition), so |
74 // we use the committed one, but the second one is the opposite. | 74 // we use the committed one. |
75 contents2.controller().LoadURL(kNtpUrl, GURL(), PageTransition::LINK); | 75 contents2.controller().LoadURL(kNtpUrl, GURL(), PageTransition::LINK); |
76 TestRenderViewHost* ntp_rvh2 = static_cast<TestRenderViewHost*>( | 76 TestRenderViewHost* ntp_rvh2 = static_cast<TestRenderViewHost*>( |
77 contents2.render_manager()->current_host()); | 77 contents2.render_manager()->current_host()); |
| 78 EXPECT_FALSE(contents2.cross_navigation_pending()); |
78 ntp_rvh2->SendNavigate(100, kNtpUrl); | 79 ntp_rvh2->SendNavigate(100, kNtpUrl); |
| 80 |
| 81 // The second one is the opposite, creating a cross-site transition and |
| 82 // requiring a beforeunload ack. |
79 contents2.controller().LoadURL(kDestUrl, GURL(), PageTransition::LINK); | 83 contents2.controller().LoadURL(kDestUrl, GURL(), PageTransition::LINK); |
80 TestRenderViewHost* dest_rvh2 = static_cast<TestRenderViewHost*>( | 84 TestRenderViewHost* dest_rvh2 = static_cast<TestRenderViewHost*>( |
81 contents2.render_manager()->pending_render_view_host()); | 85 contents2.render_manager()->pending_render_view_host()); |
| 86 EXPECT_TRUE(contents2.cross_navigation_pending()); |
| 87 ntp_rvh2->SendShouldCloseACK(true); |
82 dest_rvh2->SendNavigate(101, kDestUrl); | 88 dest_rvh2->SendNavigate(101, kDestUrl); |
83 ntp_rvh2->OnSwapOutACK(); | 89 ntp_rvh2->OnSwapOutACK(); |
84 | 90 |
85 // The two RVH's should be different in every way. | 91 // The two RVH's should be different in every way. |
86 EXPECT_NE(active_rvh()->process(), dest_rvh2->process()); | 92 EXPECT_NE(active_rvh()->process(), dest_rvh2->process()); |
87 EXPECT_NE(active_rvh()->site_instance(), dest_rvh2->site_instance()); | 93 EXPECT_NE(active_rvh()->site_instance(), dest_rvh2->site_instance()); |
88 EXPECT_NE(active_rvh()->site_instance()->browsing_instance(), | 94 EXPECT_NE(active_rvh()->site_instance()->browsing_instance(), |
89 dest_rvh2->site_instance()->browsing_instance()); | 95 dest_rvh2->site_instance()->browsing_instance()); |
90 | 96 |
91 // Navigate both to the new tab page, and verify that they share a | 97 // Navigate both to the new tab page, and verify that they share a |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 // That should have cancelled the pending RVH, and the evil RVH should be the | 359 // That should have cancelled the pending RVH, and the evil RVH should be the |
354 // current one. | 360 // current one. |
355 EXPECT_TRUE(contents()->render_manager()->pending_render_view_host() == NULL); | 361 EXPECT_TRUE(contents()->render_manager()->pending_render_view_host() == NULL); |
356 EXPECT_EQ(evil_rvh, contents()->render_manager()->current_host()); | 362 EXPECT_EQ(evil_rvh, contents()->render_manager()->current_host()); |
357 | 363 |
358 // Also we should not have a pending navigation entry. | 364 // Also we should not have a pending navigation entry. |
359 NavigationEntry* entry = contents()->controller().GetActiveEntry(); | 365 NavigationEntry* entry = contents()->controller().GetActiveEntry(); |
360 ASSERT_TRUE(entry != NULL); | 366 ASSERT_TRUE(entry != NULL); |
361 EXPECT_EQ(kUrl2, entry->url()); | 367 EXPECT_EQ(kUrl2, entry->url()); |
362 } | 368 } |
OLD | NEW |