OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/frame_host/navigation_controller_impl.h" | 5 #include "content/browser/frame_host/navigation_controller_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 2545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2556 // Go back one. | 2556 // Go back one. |
2557 controller.GoBack(); | 2557 controller.GoBack(); |
2558 params.page_id = 2; | 2558 params.page_id = 2; |
2559 params.nav_entry_id = entry2->GetUniqueID(); | 2559 params.nav_entry_id = entry2->GetUniqueID(); |
2560 params.frame_unique_name = unique_name; | 2560 params.frame_unique_name = unique_name; |
2561 params.did_create_new_entry = false; | 2561 params.did_create_new_entry = false; |
2562 params.url = url2; | 2562 params.url = url2; |
2563 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; | 2563 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
2564 params.page_state = PageState::CreateFromURL(url2); | 2564 params.page_state = PageState::CreateFromURL(url2); |
2565 params.item_sequence_number = item_sequence_number2; | 2565 params.item_sequence_number = item_sequence_number2; |
2566 subframe->PrepareForCommit(); | 2566 // If PlzNavigate is enabled, the TestRenderFrameHost::PrepareForCommit() |
2567 // function expects the navigation request to be available in the | |
2568 // FrameTreeNode. This may not always be true. Please refer to the | |
2569 // NavigationControllerImpl::NavigateToPendingEntryInternal() function for | |
2570 // more information. The gist is we may run out of frames to navigate due to | |
2571 // lack of available history or we are unable to match a frame by name. | |
2572 subframe->PrepareForCommitIfNecessary(); | |
clamy
2016/09/06 12:32:08
This test used to work with PlzNavigate enabled. W
ananta
2016/09/07 02:43:37
Thanks for the tip. It does fail because of the ch
| |
2567 subframe->SendNavigateWithParams(¶ms); | 2573 subframe->SendNavigateWithParams(¶ms); |
2568 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2574 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2569 navigation_entry_committed_counter_ = 0; | 2575 navigation_entry_committed_counter_ = 0; |
2570 EXPECT_EQ(entry2, controller.GetLastCommittedEntry()); | 2576 EXPECT_EQ(entry2, controller.GetLastCommittedEntry()); |
2571 EXPECT_EQ(3, controller.GetEntryCount()); | 2577 EXPECT_EQ(3, controller.GetEntryCount()); |
2572 EXPECT_EQ(1, controller.GetCurrentEntryIndex()); | 2578 EXPECT_EQ(1, controller.GetCurrentEntryIndex()); |
2573 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 2579 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
2574 EXPECT_FALSE(controller.GetPendingEntry()); | 2580 EXPECT_FALSE(controller.GetPendingEntry()); |
2575 | 2581 |
2576 // Go back one more. | 2582 // Go back one more. |
2577 controller.GoBack(); | 2583 controller.GoBack(); |
2578 params.page_id = 1; | 2584 params.page_id = 1; |
2579 params.nav_entry_id = entry1->GetUniqueID(); | 2585 params.nav_entry_id = entry1->GetUniqueID(); |
2580 params.frame_unique_name = unique_name; | 2586 params.frame_unique_name = unique_name; |
2581 params.did_create_new_entry = false; | 2587 params.did_create_new_entry = false; |
2582 params.url = subframe_url; | 2588 params.url = subframe_url; |
2583 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; | 2589 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
2584 params.page_state = PageState::CreateFromURL(subframe_url); | 2590 params.page_state = PageState::CreateFromURL(subframe_url); |
2585 params.item_sequence_number = item_sequence_number1; | 2591 params.item_sequence_number = item_sequence_number1; |
2586 subframe->PrepareForCommit(); | 2592 // Please refer to the comments for the test case above as to why we are |
2593 // using PrepareForCommitIfNecessary() instead of PrepareForCommit(). | |
2594 subframe->PrepareForCommitIfNecessary(); | |
2587 subframe->SendNavigateWithParams(¶ms); | 2595 subframe->SendNavigateWithParams(¶ms); |
2588 EXPECT_EQ(1U, navigation_entry_committed_counter_); | 2596 EXPECT_EQ(1U, navigation_entry_committed_counter_); |
2589 navigation_entry_committed_counter_ = 0; | 2597 navigation_entry_committed_counter_ = 0; |
2590 EXPECT_EQ(entry1, controller.GetLastCommittedEntry()); | 2598 EXPECT_EQ(entry1, controller.GetLastCommittedEntry()); |
2591 EXPECT_EQ(3, controller.GetEntryCount()); | 2599 EXPECT_EQ(3, controller.GetEntryCount()); |
2592 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); | 2600 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); |
2593 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); | 2601 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
2594 EXPECT_FALSE(controller.GetPendingEntry()); | 2602 EXPECT_FALSE(controller.GetPendingEntry()); |
2595 } | 2603 } |
2596 | 2604 |
(...skipping 2721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5318 // means that occasionally a navigation conflict will end up with one entry | 5326 // means that occasionally a navigation conflict will end up with one entry |
5319 // bubbling to the end of the entry list, but that's the least-bad option. | 5327 // bubbling to the end of the entry list, but that's the least-bad option. |
5320 EXPECT_EQ(3, controller.GetEntryCount()); | 5328 EXPECT_EQ(3, controller.GetEntryCount()); |
5321 EXPECT_EQ(2, controller.GetCurrentEntryIndex()); | 5329 EXPECT_EQ(2, controller.GetCurrentEntryIndex()); |
5322 EXPECT_EQ(url_a, controller.GetEntryAtIndex(0)->GetURL()); | 5330 EXPECT_EQ(url_a, controller.GetEntryAtIndex(0)->GetURL()); |
5323 EXPECT_EQ(url_c, controller.GetEntryAtIndex(1)->GetURL()); | 5331 EXPECT_EQ(url_c, controller.GetEntryAtIndex(1)->GetURL()); |
5324 EXPECT_EQ(url_b, controller.GetEntryAtIndex(2)->GetURL()); | 5332 EXPECT_EQ(url_b, controller.GetEntryAtIndex(2)->GetURL()); |
5325 } | 5333 } |
5326 | 5334 |
5327 } // namespace content | 5335 } // namespace content |
OLD | NEW |