| OLD | NEW |
| 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/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 EXPECT_TRUE(controller.GetPendingEntry()); | 158 EXPECT_TRUE(controller.GetPendingEntry()); |
| 159 // TODO(darin): maybe this should really be true? | 159 // TODO(darin): maybe this should really be true? |
| 160 EXPECT_FALSE(controller.CanGoBack()); | 160 EXPECT_FALSE(controller.CanGoBack()); |
| 161 EXPECT_FALSE(controller.CanGoForward()); | 161 EXPECT_FALSE(controller.CanGoForward()); |
| 162 EXPECT_EQ(contents()->GetMaxPageID(), 0); | 162 EXPECT_EQ(contents()->GetMaxPageID(), 0); |
| 163 | 163 |
| 164 // Simulate the beforeunload ack for the cross-site transition, and then the | 164 // Simulate the beforeunload ack for the cross-site transition, and then the |
| 165 // commit. | 165 // commit. |
| 166 test_rvh()->SendShouldCloseACK(true); | 166 test_rvh()->SendShouldCloseACK(true); |
| 167 static_cast<TestRenderViewHost*>( | 167 static_cast<TestRenderViewHost*>( |
| 168 contents()->pending_rvh())->SendNavigate(1, url2); | 168 contents()->GetPendingRvh())->SendNavigate(1, url2); |
| 169 EXPECT_TRUE(notifications.Check1AndReset( | 169 EXPECT_TRUE(notifications.Check1AndReset( |
| 170 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 170 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
| 171 | 171 |
| 172 // The load should now be committed. | 172 // The load should now be committed. |
| 173 EXPECT_EQ(controller.GetEntryCount(), 2); | 173 EXPECT_EQ(controller.GetEntryCount(), 2); |
| 174 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); | 174 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1); |
| 175 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 175 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
| 176 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 176 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
| 177 EXPECT_FALSE(controller.GetPendingEntry()); | 177 EXPECT_FALSE(controller.GetPendingEntry()); |
| 178 EXPECT_TRUE(controller.CanGoBack()); | 178 EXPECT_TRUE(controller.CanGoBack()); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 // Make a pending entry to somewhere new. | 294 // Make a pending entry to somewhere new. |
| 295 const GURL kExistingURL2("http://bee"); | 295 const GURL kExistingURL2("http://bee"); |
| 296 controller.LoadURL(kExistingURL2, content::Referrer(), | 296 controller.LoadURL(kExistingURL2, content::Referrer(), |
| 297 content::PAGE_TRANSITION_TYPED, std::string()); | 297 content::PAGE_TRANSITION_TYPED, std::string()); |
| 298 EXPECT_EQ(0U, notifications.size()); | 298 EXPECT_EQ(0U, notifications.size()); |
| 299 | 299 |
| 300 // After the beforeunload but before it commits, do a new navigation. | 300 // After the beforeunload but before it commits, do a new navigation. |
| 301 test_rvh()->SendShouldCloseACK(true); | 301 test_rvh()->SendShouldCloseACK(true); |
| 302 const GURL kNewURL("http://see"); | 302 const GURL kNewURL("http://see"); |
| 303 static_cast<TestRenderViewHost*>( | 303 static_cast<TestRenderViewHost*>( |
| 304 contents()->pending_rvh())->SendNavigate(3, kNewURL); | 304 contents()->GetPendingRvh())->SendNavigate(3, kNewURL); |
| 305 | 305 |
| 306 // There should no longer be any pending entry, and the third navigation we | 306 // There should no longer be any pending entry, and the third navigation we |
| 307 // just made should be committed. | 307 // just made should be committed. |
| 308 EXPECT_TRUE(notifications.Check1AndReset( | 308 EXPECT_TRUE(notifications.Check1AndReset( |
| 309 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); | 309 content::NOTIFICATION_NAV_ENTRY_COMMITTED)); |
| 310 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 310 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
| 311 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 311 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 312 EXPECT_EQ(kNewURL, controller.GetActiveEntry()->GetURL()); | 312 EXPECT_EQ(kNewURL, controller.GetActiveEntry()->GetURL()); |
| 313 } | 313 } |
| 314 | 314 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 | 468 |
| 469 // It may abort before committing, if it's a download or due to a stop or | 469 // It may abort before committing, if it's a download or due to a stop or |
| 470 // a new navigation from the user. | 470 // a new navigation from the user. |
| 471 ViewHostMsg_DidFailProvisionalLoadWithError_Params params; | 471 ViewHostMsg_DidFailProvisionalLoadWithError_Params params; |
| 472 params.frame_id = 1; | 472 params.frame_id = 1; |
| 473 params.is_main_frame = true; | 473 params.is_main_frame = true; |
| 474 params.error_code = net::ERR_ABORTED; | 474 params.error_code = net::ERR_ABORTED; |
| 475 params.error_description = string16(); | 475 params.error_description = string16(); |
| 476 params.url = kNewURL; | 476 params.url = kNewURL; |
| 477 params.showing_repost_interstitial = false; | 477 params.showing_repost_interstitial = false; |
| 478 test_rvh()->TestOnMessageReceived( | 478 test_rvh()->OnMessageReceived( |
| 479 ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id | 479 ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id |
| 480 params)); | 480 params)); |
| 481 | 481 |
| 482 // This should clear the pending entry and notify of a navigation state | 482 // This should clear the pending entry and notify of a navigation state |
| 483 // change, so that we do not keep displaying kNewURL. | 483 // change, so that we do not keep displaying kNewURL. |
| 484 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 484 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
| 485 EXPECT_FALSE(controller.GetPendingEntry()); | 485 EXPECT_FALSE(controller.GetPendingEntry()); |
| 486 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); | 486 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); |
| 487 EXPECT_EQ(2, delegate->navigation_state_change_count()); | 487 EXPECT_EQ(2, delegate->navigation_state_change_count()); |
| 488 | 488 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 510 kNewURL, content::Referrer(), content::PAGE_TRANSITION_TYPED, | 510 kNewURL, content::Referrer(), content::PAGE_TRANSITION_TYPED, |
| 511 std::string()); | 511 std::string()); |
| 512 EXPECT_EQ(0U, notifications.size()); | 512 EXPECT_EQ(0U, notifications.size()); |
| 513 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 513 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
| 514 EXPECT_TRUE(controller.GetPendingEntry()); | 514 EXPECT_TRUE(controller.GetPendingEntry()); |
| 515 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); | 515 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); |
| 516 EXPECT_EQ(1, delegate->navigation_state_change_count()); | 516 EXPECT_EQ(1, delegate->navigation_state_change_count()); |
| 517 | 517 |
| 518 // Now the navigation redirects. | 518 // Now the navigation redirects. |
| 519 const GURL kRedirectURL("http://bee"); | 519 const GURL kRedirectURL("http://bee"); |
| 520 test_rvh()->TestOnMessageReceived( | 520 test_rvh()->OnMessageReceived( |
| 521 ViewHostMsg_DidRedirectProvisionalLoad(0, // routing_id | 521 ViewHostMsg_DidRedirectProvisionalLoad(0, // routing_id |
| 522 -1, // pending page_id | 522 -1, // pending page_id |
| 523 GURL(), // opener | 523 GURL(), // opener |
| 524 kNewURL, // old url | 524 kNewURL, // old url |
| 525 kRedirectURL)); // new url | 525 kRedirectURL)); // new url |
| 526 | 526 |
| 527 // We don't want to change the NavigationEntry's url, in case it cancels. | 527 // We don't want to change the NavigationEntry's url, in case it cancels. |
| 528 // Prevents regression of http://crbug.com/77786. | 528 // Prevents regression of http://crbug.com/77786. |
| 529 EXPECT_EQ(kNewURL, controller.GetPendingEntry()->GetURL()); | 529 EXPECT_EQ(kNewURL, controller.GetPendingEntry()->GetURL()); |
| 530 | 530 |
| 531 // It may abort before committing, if it's a download or due to a stop or | 531 // It may abort before committing, if it's a download or due to a stop or |
| 532 // a new navigation from the user. | 532 // a new navigation from the user. |
| 533 ViewHostMsg_DidFailProvisionalLoadWithError_Params params; | 533 ViewHostMsg_DidFailProvisionalLoadWithError_Params params; |
| 534 params.frame_id = 1; | 534 params.frame_id = 1; |
| 535 params.is_main_frame = true; | 535 params.is_main_frame = true; |
| 536 params.error_code = net::ERR_ABORTED; | 536 params.error_code = net::ERR_ABORTED; |
| 537 params.error_description = string16(); | 537 params.error_description = string16(); |
| 538 params.url = kRedirectURL; | 538 params.url = kRedirectURL; |
| 539 params.showing_repost_interstitial = false; | 539 params.showing_repost_interstitial = false; |
| 540 test_rvh()->TestOnMessageReceived( | 540 test_rvh()->OnMessageReceived( |
| 541 ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id | 541 ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id |
| 542 params)); | 542 params)); |
| 543 | 543 |
| 544 // This should clear the pending entry and notify of a navigation state | 544 // This should clear the pending entry and notify of a navigation state |
| 545 // change, so that we do not keep displaying kNewURL. | 545 // change, so that we do not keep displaying kNewURL. |
| 546 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 546 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
| 547 EXPECT_FALSE(controller.GetPendingEntry()); | 547 EXPECT_FALSE(controller.GetPendingEntry()); |
| 548 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); | 548 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); |
| 549 EXPECT_EQ(2, delegate->navigation_state_change_count()); | 549 EXPECT_EQ(2, delegate->navigation_state_change_count()); |
| 550 | 550 |
| (...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1639 // which causes the pending entry to be cleared. | 1639 // which causes the pending entry to be cleared. |
| 1640 TestRenderViewHost* rvh = | 1640 TestRenderViewHost* rvh = |
| 1641 static_cast<TestRenderViewHost*>(our_contents.GetRenderViewHost()); | 1641 static_cast<TestRenderViewHost*>(our_contents.GetRenderViewHost()); |
| 1642 ViewHostMsg_DidFailProvisionalLoadWithError_Params fail_load_params; | 1642 ViewHostMsg_DidFailProvisionalLoadWithError_Params fail_load_params; |
| 1643 fail_load_params.frame_id = 1; | 1643 fail_load_params.frame_id = 1; |
| 1644 fail_load_params.is_main_frame = true; | 1644 fail_load_params.is_main_frame = true; |
| 1645 fail_load_params.error_code = net::ERR_ABORTED; | 1645 fail_load_params.error_code = net::ERR_ABORTED; |
| 1646 fail_load_params.error_description = string16(); | 1646 fail_load_params.error_description = string16(); |
| 1647 fail_load_params.url = url; | 1647 fail_load_params.url = url; |
| 1648 fail_load_params.showing_repost_interstitial = false; | 1648 fail_load_params.showing_repost_interstitial = false; |
| 1649 rvh->TestOnMessageReceived( | 1649 rvh->OnMessageReceived( |
| 1650 ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id | 1650 ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id |
| 1651 fail_load_params)); | 1651 fail_load_params)); |
| 1652 | 1652 |
| 1653 // Now the pending restored entry commits. | 1653 // Now the pending restored entry commits. |
| 1654 ViewHostMsg_FrameNavigate_Params params; | 1654 ViewHostMsg_FrameNavigate_Params params; |
| 1655 params.page_id = 0; | 1655 params.page_id = 0; |
| 1656 params.url = url; | 1656 params.url = url; |
| 1657 params.transition = content::PAGE_TRANSITION_LINK; | 1657 params.transition = content::PAGE_TRANSITION_LINK; |
| 1658 params.should_update_history = false; | 1658 params.should_update_history = false; |
| 1659 params.gesture = NavigationGestureUser; | 1659 params.gesture = NavigationGestureUser; |
| 1660 params.is_post = false; | 1660 params.is_post = false; |
| 1661 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url)); | 1661 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url)); |
| (...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2582 TabNavigation nav(0, url0, GURL(), string16(), | 2582 TabNavigation nav(0, url0, GURL(), string16(), |
| 2583 webkit_glue::CreateHistoryStateForURL(url0), | 2583 webkit_glue::CreateHistoryStateForURL(url0), |
| 2584 content::PAGE_TRANSITION_LINK); | 2584 content::PAGE_TRANSITION_LINK); |
| 2585 session_helper_.AssertNavigationEquals(nav, | 2585 session_helper_.AssertNavigationEquals(nav, |
| 2586 windows_[0]->tabs[0]->navigations[0]); | 2586 windows_[0]->tabs[0]->navigations[0]); |
| 2587 nav.set_url(url2); | 2587 nav.set_url(url2); |
| 2588 session_helper_.AssertNavigationEquals(nav, | 2588 session_helper_.AssertNavigationEquals(nav, |
| 2589 windows_[0]->tabs[0]->navigations[1]); | 2589 windows_[0]->tabs[0]->navigations[1]); |
| 2590 } | 2590 } |
| 2591 */ | 2591 */ |
| OLD | NEW |