| 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 "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 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 const GURL kNewURL("http://eh"); | 416 const GURL kNewURL("http://eh"); |
| 417 controller().LoadURL(kNewURL, GURL(), PageTransition::TYPED, std::string()); | 417 controller().LoadURL(kNewURL, GURL(), PageTransition::TYPED, std::string()); |
| 418 EXPECT_EQ(0U, notifications.size()); | 418 EXPECT_EQ(0U, notifications.size()); |
| 419 EXPECT_EQ(-1, controller().pending_entry_index()); | 419 EXPECT_EQ(-1, controller().pending_entry_index()); |
| 420 EXPECT_TRUE(controller().pending_entry()); | 420 EXPECT_TRUE(controller().pending_entry()); |
| 421 EXPECT_EQ(-1, controller().last_committed_entry_index()); | 421 EXPECT_EQ(-1, controller().last_committed_entry_index()); |
| 422 EXPECT_EQ(1, delegate->navigation_state_change_count()); | 422 EXPECT_EQ(1, delegate->navigation_state_change_count()); |
| 423 | 423 |
| 424 // It may abort before committing, if it's a download or due to a stop or | 424 // It may abort before committing, if it's a download or due to a stop or |
| 425 // a new navigation from the user. | 425 // a new navigation from the user. |
| 426 ViewHostMsg_DidFailProvisionalLoadWithError_Params params; |
| 427 params.frame_id = 1; |
| 428 params.is_main_frame = true; |
| 429 params.error_code = net::ERR_ABORTED; |
| 430 params.error_description = string16(); |
| 431 params.url = kNewURL; |
| 432 params.showing_repost_interstitial = false; |
| 426 rvh()->TestOnMessageReceived( | 433 rvh()->TestOnMessageReceived( |
| 427 ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id | 434 ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id |
| 428 1, // frame_id | 435 params)); |
| 429 true, // is_main_frame | |
| 430 net::ERR_ABORTED, // error | |
| 431 kNewURL, // url | |
| 432 false)); // repost | |
| 433 | 436 |
| 434 // This should clear the pending entry and notify of a navigation state | 437 // This should clear the pending entry and notify of a navigation state |
| 435 // change, so that we do not keep displaying kNewURL. | 438 // change, so that we do not keep displaying kNewURL. |
| 436 EXPECT_EQ(-1, controller().pending_entry_index()); | 439 EXPECT_EQ(-1, controller().pending_entry_index()); |
| 437 EXPECT_FALSE(controller().pending_entry()); | 440 EXPECT_FALSE(controller().pending_entry()); |
| 438 EXPECT_EQ(-1, controller().last_committed_entry_index()); | 441 EXPECT_EQ(-1, controller().last_committed_entry_index()); |
| 439 EXPECT_EQ(2, delegate->navigation_state_change_count()); | 442 EXPECT_EQ(2, delegate->navigation_state_change_count()); |
| 440 | 443 |
| 441 contents()->set_delegate(NULL); | 444 contents()->set_delegate(NULL); |
| 442 } | 445 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 472 false, // opener | 475 false, // opener |
| 473 kNewURL, // old url | 476 kNewURL, // old url |
| 474 kRedirectURL)); // new url | 477 kRedirectURL)); // new url |
| 475 | 478 |
| 476 // We don't want to change the NavigationEntry's url, in case it cancels. | 479 // We don't want to change the NavigationEntry's url, in case it cancels. |
| 477 // Prevents regression of http://crbug.com/77786. | 480 // Prevents regression of http://crbug.com/77786. |
| 478 EXPECT_EQ(kNewURL, controller().pending_entry()->url()); | 481 EXPECT_EQ(kNewURL, controller().pending_entry()->url()); |
| 479 | 482 |
| 480 // It may abort before committing, if it's a download or due to a stop or | 483 // It may abort before committing, if it's a download or due to a stop or |
| 481 // a new navigation from the user. | 484 // a new navigation from the user. |
| 485 ViewHostMsg_DidFailProvisionalLoadWithError_Params params; |
| 486 params.frame_id = 1; |
| 487 params.is_main_frame = true; |
| 488 params.error_code = net::ERR_ABORTED; |
| 489 params.error_description = string16(); |
| 490 params.url = kRedirectURL; |
| 491 params.showing_repost_interstitial = false; |
| 482 rvh()->TestOnMessageReceived( | 492 rvh()->TestOnMessageReceived( |
| 483 ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id | 493 ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id |
| 484 1, // frame_id | 494 params)); |
| 485 true, // is_main_frame | |
| 486 net::ERR_ABORTED, // error | |
| 487 kRedirectURL, // url | |
| 488 false)); // repost | |
| 489 | 495 |
| 490 // This should clear the pending entry and notify of a navigation state | 496 // This should clear the pending entry and notify of a navigation state |
| 491 // change, so that we do not keep displaying kNewURL. | 497 // change, so that we do not keep displaying kNewURL. |
| 492 EXPECT_EQ(-1, controller().pending_entry_index()); | 498 EXPECT_EQ(-1, controller().pending_entry_index()); |
| 493 EXPECT_FALSE(controller().pending_entry()); | 499 EXPECT_FALSE(controller().pending_entry()); |
| 494 EXPECT_EQ(-1, controller().last_committed_entry_index()); | 500 EXPECT_EQ(-1, controller().last_committed_entry_index()); |
| 495 EXPECT_EQ(2, delegate->navigation_state_change_count()); | 501 EXPECT_EQ(2, delegate->navigation_state_change_count()); |
| 496 | 502 |
| 497 contents()->set_delegate(NULL); | 503 contents()->set_delegate(NULL); |
| 498 } | 504 } |
| (...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1522 our_controller.pending_entry()); | 1528 our_controller.pending_entry()); |
| 1523 EXPECT_EQ(0, our_controller.GetEntryAtIndex(0)->page_id()); | 1529 EXPECT_EQ(0, our_controller.GetEntryAtIndex(0)->page_id()); |
| 1524 EXPECT_EQ(NavigationEntry::RESTORE_NONE, | 1530 EXPECT_EQ(NavigationEntry::RESTORE_NONE, |
| 1525 our_controller.GetEntryAtIndex(0)->restore_type()); | 1531 our_controller.GetEntryAtIndex(0)->restore_type()); |
| 1526 EXPECT_TRUE(our_controller.GetEntryAtIndex(0)->site_instance()); | 1532 EXPECT_TRUE(our_controller.GetEntryAtIndex(0)->site_instance()); |
| 1527 | 1533 |
| 1528 // This pending navigation may have caused a different navigation to fail, | 1534 // This pending navigation may have caused a different navigation to fail, |
| 1529 // which causes the pending entry to be cleared. | 1535 // which causes the pending entry to be cleared. |
| 1530 TestRenderViewHost* rvh = | 1536 TestRenderViewHost* rvh = |
| 1531 static_cast<TestRenderViewHost*>(our_contents.render_view_host()); | 1537 static_cast<TestRenderViewHost*>(our_contents.render_view_host()); |
| 1538 ViewHostMsg_DidFailProvisionalLoadWithError_Params fail_load_params; |
| 1539 fail_load_params.frame_id = 1; |
| 1540 fail_load_params.is_main_frame = true; |
| 1541 fail_load_params.error_code = net::ERR_ABORTED; |
| 1542 fail_load_params.error_description = string16(); |
| 1543 fail_load_params.url = url; |
| 1544 fail_load_params.showing_repost_interstitial = false; |
| 1532 rvh->TestOnMessageReceived( | 1545 rvh->TestOnMessageReceived( |
| 1533 ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id | 1546 ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id |
| 1534 1, // frame_id | 1547 fail_load_params)); |
| 1535 true, // is_main_frame | |
| 1536 net::ERR_ABORTED, // error | |
| 1537 url, // url | |
| 1538 false)); // repost | |
| 1539 | 1548 |
| 1540 // Now the pending restored entry commits. | 1549 // Now the pending restored entry commits. |
| 1541 ViewHostMsg_FrameNavigate_Params params; | 1550 ViewHostMsg_FrameNavigate_Params params; |
| 1542 params.page_id = 0; | 1551 params.page_id = 0; |
| 1543 params.url = url; | 1552 params.url = url; |
| 1544 params.transition = PageTransition::LINK; | 1553 params.transition = PageTransition::LINK; |
| 1545 params.should_update_history = false; | 1554 params.should_update_history = false; |
| 1546 params.gesture = NavigationGestureUser; | 1555 params.gesture = NavigationGestureUser; |
| 1547 params.is_post = false; | 1556 params.is_post = false; |
| 1548 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url)); | 1557 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url)); |
| (...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2307 TabNavigation nav(0, url0, GURL(), string16(), | 2316 TabNavigation nav(0, url0, GURL(), string16(), |
| 2308 webkit_glue::CreateHistoryStateForURL(url0), | 2317 webkit_glue::CreateHistoryStateForURL(url0), |
| 2309 PageTransition::LINK); | 2318 PageTransition::LINK); |
| 2310 session_helper_.AssertNavigationEquals(nav, | 2319 session_helper_.AssertNavigationEquals(nav, |
| 2311 windows_[0]->tabs[0]->navigations[0]); | 2320 windows_[0]->tabs[0]->navigations[0]); |
| 2312 nav.set_url(url2); | 2321 nav.set_url(url2); |
| 2313 session_helper_.AssertNavigationEquals(nav, | 2322 session_helper_.AssertNavigationEquals(nav, |
| 2314 windows_[0]->tabs[0]->navigations[1]); | 2323 windows_[0]->tabs[0]->navigations[1]); |
| 2315 } | 2324 } |
| 2316 */ | 2325 */ |
| OLD | NEW |