| Index: content/browser/frame_host/navigation_controller_impl_unittest.cc
|
| diff --git a/content/browser/frame_host/navigation_controller_impl_unittest.cc b/content/browser/frame_host/navigation_controller_impl_unittest.cc
|
| index 43d7fa6766bfc7d0ae7af5729a2050d1b3b7f962..c8b319221bf70bc47aef696c2b87a714c0edd069 100644
|
| --- a/content/browser/frame_host/navigation_controller_impl_unittest.cc
|
| +++ b/content/browser/frame_host/navigation_controller_impl_unittest.cc
|
| @@ -23,6 +23,7 @@
|
| #include "content/browser/frame_host/frame_navigation_entry.h"
|
| #include "content/browser/frame_host/navigation_entry_impl.h"
|
| #include "content/browser/frame_host/navigation_entry_screenshot_manager.h"
|
| +#include "content/browser/frame_host/navigation_handle_impl.h"
|
| #include "content/browser/frame_host/navigation_request.h"
|
| #include "content/browser/frame_host/navigator.h"
|
| #include "content/browser/frame_host/navigator_impl.h"
|
| @@ -32,7 +33,6 @@
|
| #include "content/common/frame_owner_properties.h"
|
| #include "content/common/site_isolation_policy.h"
|
| #include "content/common/view_messages.h"
|
| -#include "content/public/browser/navigation_details.h"
|
| #include "content/public/browser/notification_registrar.h"
|
| #include "content/public/browser/notification_types.h"
|
| #include "content/public/browser/render_view_host.h"
|
| @@ -311,18 +311,36 @@ class LoadCommittedDetailsObserver : public WebContentsObserver {
|
| public:
|
| // Observes navigation for the specified |web_contents|.
|
| explicit LoadCommittedDetailsObserver(WebContents* web_contents)
|
| - : WebContentsObserver(web_contents) {}
|
| -
|
| - const LoadCommittedDetails& details() { return details_; }
|
| + : WebContentsObserver(web_contents),
|
| + navigation_type_(NAVIGATION_TYPE_UNKNOWN),
|
| + is_in_page_(false),
|
| + is_main_frame_(false),
|
| + did_replace_entry_(false) {}
|
| +
|
| + NavigationType navigation_type() { return navigation_type_; }
|
| + const GURL& previous_url() { return previous_url_; }
|
| + bool is_in_page() { return is_in_page_; }
|
| + bool is_main_frame() { return is_main_frame_; }
|
| + bool did_replace_entry() { return did_replace_entry_; }
|
|
|
| private:
|
| - void DidNavigateAnyFrame(RenderFrameHost* render_frame_host,
|
| - const LoadCommittedDetails& details,
|
| - const FrameNavigateParams& params) override {
|
| - details_ = details;
|
| + void DidFinishNavigation(NavigationHandle* navigation_handle) override {
|
| + if (!navigation_handle->HasCommitted())
|
| + return;
|
| +
|
| + navigation_type_ = static_cast<NavigationHandleImpl*>(navigation_handle)
|
| + ->navigation_type();
|
| + previous_url_ = navigation_handle->GetPreviousURL();
|
| + is_in_page_ = navigation_handle->IsSamePage();
|
| + is_main_frame_ = navigation_handle->IsInMainFrame();
|
| + did_replace_entry_ = navigation_handle->DidReplaceEntry();
|
| }
|
|
|
| - LoadCommittedDetails details_;
|
| + NavigationType navigation_type_;
|
| + GURL previous_url_;
|
| + bool is_in_page_;
|
| + bool is_main_frame_;
|
| + bool did_replace_entry_;
|
| };
|
|
|
| // PlzNavigate
|
| @@ -2018,7 +2036,7 @@ TEST_F(NavigationControllerTest, Redirect) {
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
|
|
| - EXPECT_EQ(NAVIGATION_TYPE_SAME_PAGE, observer.details().type);
|
| + EXPECT_EQ(NAVIGATION_TYPE_SAME_PAGE, observer.navigation_type());
|
| EXPECT_EQ(controller.GetEntryCount(), 1);
|
| EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0);
|
| EXPECT_TRUE(controller.GetLastCommittedEntry());
|
| @@ -2086,7 +2104,7 @@ TEST_F(NavigationControllerTest, PostThenRedirect) {
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
|
|
| - EXPECT_EQ(NAVIGATION_TYPE_SAME_PAGE, observer.details().type);
|
| + EXPECT_EQ(NAVIGATION_TYPE_SAME_PAGE, observer.navigation_type());
|
| EXPECT_EQ(controller.GetEntryCount(), 1);
|
| EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0);
|
| EXPECT_TRUE(controller.GetLastCommittedEntry());
|
| @@ -2137,7 +2155,7 @@ TEST_F(NavigationControllerTest, ImmediateRedirect) {
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
|
|
| - EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, observer.details().type);
|
| + EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, observer.navigation_type());
|
| EXPECT_EQ(controller.GetEntryCount(), 1);
|
| EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0);
|
| EXPECT_TRUE(controller.GetLastCommittedEntry());
|
| @@ -2197,7 +2215,7 @@ TEST_F(NavigationControllerTest,
|
|
|
| main_test_rfh()->PrepareForCommit();
|
| main_test_rfh()->SendNavigateWithParams(¶ms);
|
| - EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, observer.details().type);
|
| + EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, observer.navigation_type());
|
| }
|
|
|
| // Tests navigation via link click within a subframe. A new navigation entry
|
| @@ -2262,14 +2280,13 @@ TEST_F(NavigationControllerTest, NewSubframe) {
|
| subframe->SendNavigateWithParams(¶ms);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| - EXPECT_EQ(url1, observer.details().previous_url);
|
| - EXPECT_FALSE(observer.details().is_in_page);
|
| - EXPECT_FALSE(observer.details().is_main_frame);
|
| + EXPECT_EQ(url1, observer.previous_url());
|
| + EXPECT_FALSE(observer.is_in_page());
|
| + EXPECT_FALSE(observer.is_main_frame());
|
|
|
| // The new entry should be appended.
|
| NavigationEntryImpl* entry = controller.GetLastCommittedEntry();
|
| EXPECT_EQ(2, controller.GetEntryCount());
|
| - EXPECT_EQ(entry, observer.details().entry);
|
|
|
| // New entry should refer to the new page, but the old URL (entries only
|
| // reflect the toplevel URL).
|
| @@ -2645,8 +2662,8 @@ TEST_F(NavigationControllerTest, InPage) {
|
| NavigationEntry* entry1 = controller.GetLastCommittedEntry();
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| - EXPECT_TRUE(observer.details().is_in_page);
|
| - EXPECT_TRUE(observer.details().did_replace_entry);
|
| + EXPECT_TRUE(observer.is_in_page());
|
| + EXPECT_TRUE(observer.did_replace_entry());
|
| EXPECT_EQ(1, controller.GetEntryCount());
|
|
|
| // Fragment navigation to a new page.
|
| @@ -2670,8 +2687,8 @@ TEST_F(NavigationControllerTest, InPage) {
|
| NavigationEntry* entry2 = controller.GetLastCommittedEntry();
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| - EXPECT_TRUE(observer.details().is_in_page);
|
| - EXPECT_FALSE(observer.details().did_replace_entry);
|
| + EXPECT_TRUE(observer.is_in_page());
|
| + EXPECT_FALSE(observer.did_replace_entry());
|
| EXPECT_EQ(2, controller.GetEntryCount());
|
|
|
| // Go back one.
|
| @@ -2682,7 +2699,7 @@ TEST_F(NavigationControllerTest, InPage) {
|
| main_test_rfh()->SendNavigateWithParams(&back_params);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| - EXPECT_TRUE(observer.details().is_in_page);
|
| + EXPECT_TRUE(observer.is_in_page());
|
| EXPECT_EQ(2, controller.GetEntryCount());
|
| EXPECT_EQ(0, controller.GetCurrentEntryIndex());
|
| EXPECT_EQ(back_params.url, controller.GetVisibleEntry()->GetURL());
|
| @@ -2695,7 +2712,7 @@ TEST_F(NavigationControllerTest, InPage) {
|
| main_test_rfh()->SendNavigateWithParams(&forward_params);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| - EXPECT_TRUE(observer.details().is_in_page);
|
| + EXPECT_TRUE(observer.is_in_page());
|
| EXPECT_EQ(2, controller.GetEntryCount());
|
| EXPECT_EQ(1, controller.GetCurrentEntryIndex());
|
| EXPECT_EQ(forward_params.url,
|
| @@ -2727,7 +2744,7 @@ TEST_F(NavigationControllerTest, InPage) {
|
| main_test_rfh()->SendNavigateWithParams(¶ms);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| - EXPECT_FALSE(observer.details().is_in_page);
|
| + EXPECT_FALSE(observer.is_in_page());
|
| EXPECT_EQ(3, controller.GetEntryCount());
|
| EXPECT_EQ(2, controller.GetCurrentEntryIndex());
|
| }
|
| @@ -2761,8 +2778,8 @@ TEST_F(NavigationControllerTest, InPage_Replace) {
|
| main_test_rfh()->SendNavigateWithParams(¶ms);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| - EXPECT_TRUE(observer.details().is_in_page);
|
| - EXPECT_TRUE(observer.details().did_replace_entry);
|
| + EXPECT_TRUE(observer.is_in_page());
|
| + EXPECT_TRUE(observer.did_replace_entry());
|
| EXPECT_EQ(1, controller.GetEntryCount());
|
| }
|
|
|
| @@ -2813,8 +2830,8 @@ TEST_F(NavigationControllerTest, ClientRedirectAfterInPageNavigation) {
|
| main_test_rfh()->SendNavigateWithParams(¶ms);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| - EXPECT_TRUE(observer.details().is_in_page);
|
| - EXPECT_TRUE(observer.details().did_replace_entry);
|
| + EXPECT_TRUE(observer.is_in_page());
|
| + EXPECT_TRUE(observer.did_replace_entry());
|
| EXPECT_EQ(2, controller.GetEntryCount());
|
| }
|
|
|
| @@ -2840,7 +2857,7 @@ TEST_F(NavigationControllerTest, ClientRedirectAfterInPageNavigation) {
|
| main_test_rfh()->SendNavigateWithParams(¶ms);
|
| EXPECT_EQ(1U, navigation_entry_committed_counter_);
|
| navigation_entry_committed_counter_ = 0;
|
| - EXPECT_FALSE(observer.details().is_in_page);
|
| + EXPECT_FALSE(observer.is_in_page());
|
| EXPECT_EQ(3, controller.GetEntryCount());
|
| }
|
|
|
| @@ -5089,7 +5106,7 @@ TEST_F(NavigationControllerTest, UnreachableURLGivesErrorPage) {
|
| main_test_rfh()->SendNavigateWithParams(¶ms);
|
| EXPECT_EQ(PAGE_TYPE_ERROR,
|
| controller_impl().GetLastCommittedEntry()->GetPageType());
|
| - EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, observer.details().type);
|
| + EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, observer.navigation_type());
|
| }
|
|
|
| // Navigate to existing page.
|
| @@ -5101,7 +5118,7 @@ TEST_F(NavigationControllerTest, UnreachableURLGivesErrorPage) {
|
| main_test_rfh()->SendNavigateWithParams(¶ms);
|
| EXPECT_EQ(PAGE_TYPE_ERROR,
|
| controller_impl().GetLastCommittedEntry()->GetPageType());
|
| - EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, observer.details().type);
|
| + EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, observer.navigation_type());
|
| }
|
|
|
| // Navigate to same page.
|
| @@ -5117,7 +5134,7 @@ TEST_F(NavigationControllerTest, UnreachableURLGivesErrorPage) {
|
| main_test_rfh()->SendNavigateWithParams(¶ms);
|
| EXPECT_EQ(PAGE_TYPE_ERROR,
|
| controller_impl().GetLastCommittedEntry()->GetPageType());
|
| - EXPECT_EQ(NAVIGATION_TYPE_SAME_PAGE, observer.details().type);
|
| + EXPECT_EQ(NAVIGATION_TYPE_SAME_PAGE, observer.navigation_type());
|
| }
|
|
|
| // Navigate in page.
|
| @@ -5129,7 +5146,7 @@ TEST_F(NavigationControllerTest, UnreachableURLGivesErrorPage) {
|
| main_test_rfh()->SendNavigateWithParams(¶ms);
|
| EXPECT_EQ(PAGE_TYPE_ERROR,
|
| controller_impl().GetLastCommittedEntry()->GetPageType());
|
| - EXPECT_TRUE(observer.details().is_in_page);
|
| + EXPECT_TRUE(observer.is_in_page());
|
| }
|
| }
|
|
|
|
|