From 0cf1388a2cf6b4776d437d36156d46169bff6817 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Fri, 30 Mar 2012 17:20:26 +0000 Subject: [PATCH] Merge revision 561 changes: - Fix problem with CefBrowser::GetMainFrame() clearing the frame URL value (issue #556). git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/963@563 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- libcef/browser_impl.cc | 3 ++- tests/unittests/navigation_unittest.cc | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/libcef/browser_impl.cc b/libcef/browser_impl.cc index cd748d2d0..f6b9b71bc 100644 --- a/libcef/browser_impl.cc +++ b/libcef/browser_impl.cc @@ -649,7 +649,8 @@ CefRefPtr CefBrowserImpl::GetMainCefFrame(int64 id, if (id != 0) main_frame_->set_id(id); - main_frame_->set_url(url.spec()); + if (!url.is_empty()) + main_frame_->set_url(url.spec()); return main_frame_; } diff --git a/tests/unittests/navigation_unittest.cc b/tests/unittests/navigation_unittest.cc index 7f7f0e043..792d1003a 100644 --- a/tests/unittests/navigation_unittest.cc +++ b/tests/unittests/navigation_unittest.cc @@ -133,6 +133,21 @@ public: got_correct_can_go_forward_[nav_].yes(); } + virtual void OnLoadStart(CefRefPtr browser, + CefRefPtr frame) OVERRIDE { + if(browser->IsPopup() || !frame->IsMain()) + return; + + const NavListItem& item = kNavList[nav_]; + + got_load_start_[nav_].yes(); + + std::string url1 = browser->GetMainFrame()->GetURL(); + std::string url2 = frame->GetURL(); + if (url1 == item.target && url2 == item.target) + got_correct_load_start_url_[nav_].yes(); + } + virtual void OnLoadEnd(CefRefPtr browser, CefRefPtr frame, int httpStatusCode) OVERRIDE @@ -144,6 +159,11 @@ public: got_load_end_[nav_].yes(); + std::string url1 = browser->GetMainFrame()->GetURL(); + std::string url2 = frame->GetURL(); + if (url1 == item.target && url2 == item.target) + got_correct_load_end_url_[nav_].yes(); + if (item.can_go_back == browser->CanGoBack()) got_correct_can_go_back2_[nav_].yes(); if (item.can_go_forward == browser->CanGoForward()) @@ -161,7 +181,10 @@ public: TrackCallback got_nav_state_change_[NAV_LIST_SIZE()]; TrackCallback got_correct_can_go_back_[NAV_LIST_SIZE()]; TrackCallback got_correct_can_go_forward_[NAV_LIST_SIZE()]; + TrackCallback got_load_start_[NAV_LIST_SIZE()]; + TrackCallback got_correct_load_start_url_[NAV_LIST_SIZE()]; TrackCallback got_load_end_[NAV_LIST_SIZE()]; + TrackCallback got_correct_load_end_url_[NAV_LIST_SIZE()]; TrackCallback got_correct_can_go_back2_[NAV_LIST_SIZE()]; TrackCallback got_correct_can_go_forward2_[NAV_LIST_SIZE()]; }; @@ -180,6 +203,8 @@ TEST(NavigationTest, History) ASSERT_TRUE(handler->got_before_browse_[i]) << "i = " << i; ASSERT_TRUE(handler->got_correct_target_[i]) << "i = " << i; ASSERT_TRUE(handler->got_correct_nav_type_[i]) << "i = " << i; + ASSERT_TRUE(handler->got_load_start_[i]) << "i = " << i; + ASSERT_TRUE(handler->got_correct_load_start_url_[i]) << "i = " << i; } if (i == 0 || kNavList[i].can_go_back != kNavList[i-1].can_go_back || @@ -196,6 +221,7 @@ TEST(NavigationTest, History) if (kNavList[i].action != NA_CLEAR) { ASSERT_TRUE(handler->got_load_end_[i]) << "i = " << i; + ASSERT_TRUE(handler->got_correct_load_end_url_[i]) << "i = " << i; ASSERT_TRUE(handler->got_correct_can_go_back2_[i]) << "i = " << i; ASSERT_TRUE(handler->got_correct_can_go_forward2_[i]) << "i = " << i; }