summaryrefslogtreecommitdiffstats
path: root/chrome_frame
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-27 23:16:47 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-27 23:16:47 +0000
commitfe9eb4f9d93a56a26d99fba1d3d3761fd6590fb2 (patch)
treebb145bf68ee0fef814d5abfbc0ef39151465025a /chrome_frame
parent07d05acb91a5ab60b7d5f2b71a201f4f896f43ef (diff)
downloadchromium_src-fe9eb4f9d93a56a26d99fba1d3d3761fd6590fb2.zip
chromium_src-fe9eb4f9d93a56a26d99fba1d3d3761fd6590fb2.tar.gz
chromium_src-fe9eb4f9d93a56a26d99fba1d3d3761fd6590fb2.tar.bz2
Ensure that ChromeFrame link navigations which occur when the opener frame is NULL are
always reported back to the host browser as top level navigations. The other change is to always send over navigation requests from the automation client even if the url remains the same if the client is already initialized, i.e this is treated as a new navigation. Fixes bug http://code.google.com/p/chromium/issues/detail?id=38456 Bug=38456 Test=The ChromeFrame side of the change is covered by a new chrome frame mock test. Will add a test for the render view change in a subsequent CL. Review URL: http://codereview.chromium.org/3235001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57748 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r--chrome_frame/chrome_frame_automation.cc6
-rw-r--r--chrome_frame/test/automation_client_mock.cc63
-rw-r--r--chrome_frame/test/automation_client_mock.h6
3 files changed, 68 insertions, 7 deletions
diff --git a/chrome_frame/chrome_frame_automation.cc b/chrome_frame/chrome_frame_automation.cc
index 6ede7e3..aa89256 100644
--- a/chrome_frame/chrome_frame_automation.cc
+++ b/chrome_frame/chrome_frame_automation.cc
@@ -686,7 +686,11 @@ bool ChromeFrameAutomationClient::InitiateNavigation(const std::string& url,
return false;
}
- if (!chrome_launch_params_ || parsed_url != chrome_launch_params_->url()) {
+ // If we are not yet initialized ignore attempts to navigate to the same url.
+ // Navigation attempts to the same URL could occur if the automation client
+ // was reused for a new active document instance.
+ if (!chrome_launch_params_ || is_initialized() ||
+ parsed_url != chrome_launch_params_->url()) {
// Important: Since we will be using the referrer_ variable from a
// different thread, we need to force a new std::string buffer instance for
// the referrer_ GURL variable. Otherwise we can run into strangeness when
diff --git a/chrome_frame/test/automation_client_mock.cc b/chrome_frame/test/automation_client_mock.cc
index 6ef792e..8ea09b6 100644
--- a/chrome_frame/test/automation_client_mock.cc
+++ b/chrome_frame/test/automation_client_mock.cc
@@ -83,6 +83,10 @@ ACTION_P3(HandleCreateTab, tab_handle, external_tab_container, tab_wnd) {
delete context;
}
+ACTION_P4(InitiateNavigation, client, url, referrer, privileged) {
+ client->InitiateNavigation(url, referrer, privileged);
+}
+
// We mock ChromeFrameDelegate only. The rest is with real AutomationProxy
TEST(CFACWithChrome, CreateTooFast) {
MockCFDelegate cfd;
@@ -155,9 +159,8 @@ TEST(CFACWithChrome, NavigateOk) {
client = new ChromeFrameAutomationClient;
EXPECT_CALL(cfd, OnAutomationServerReady())
- .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs(CreateFunctor(
- client.get(), &ChromeFrameAutomationClient::InitiateNavigation,
- url, std::string(), false))));
+ .WillOnce(InitiateNavigation(client.get(),
+ url, std::string(), false));
EXPECT_CALL(cfd, GetBounds(_)).Times(testing::AnyNumber());
@@ -410,3 +413,57 @@ TEST_F(CFACMockTest, OnChannelError) {
client2 = NULL;
client3 = NULL;
}
+
+TEST_F(CFACMockTest, NavigateTwiceAfterInitToSameUrl) {
+ int timeout = 500;
+ CreateTab();
+ SetAutomationServerOk(1);
+
+ EXPECT_CALL(mock_proxy_, server_version()).Times(testing::AnyNumber())
+ .WillRepeatedly(Return(""));
+
+ // We need some valid HWNDs, when responding to CreateExternalTab
+ HWND h1 = ::GetDesktopWindow();
+ HWND h2 = ::GetDesktopWindow();
+ EXPECT_CALL(mock_proxy_, SendAsAsync(testing::Property(
+ &IPC::SyncMessage::type, AutomationMsg_CreateExternalTab__ID),
+ testing::NotNull(), _))
+ .Times(1).WillOnce(HandleCreateTab(tab_handle_, h1, h2));
+
+ EXPECT_CALL(mock_proxy_, CreateTabProxy(testing::Eq(tab_handle_)))
+ .WillOnce(Return(tab_));
+
+ EXPECT_CALL(cfd_, OnAutomationServerReady())
+ .WillOnce(InitiateNavigation(client_.get(),
+ std::string("http://www.nonexistent.com"),
+ std::string(), false));
+
+ EXPECT_CALL(mock_proxy_, SendAsAsync(testing::Property(
+ &IPC::SyncMessage::type, AutomationMsg_NavigateInExternalTab__ID),
+ testing::NotNull(), _))
+ .Times(1).WillOnce(QUIT_LOOP(loop_));
+
+ EXPECT_CALL(mock_proxy_, CancelAsync(_)).Times(testing::AnyNumber());
+
+ EXPECT_CALL(mock_proxy_, Send(
+ testing::Property(&IPC::Message::type, AutomationMsg_TabReposition__ID)))
+ .Times(1)
+ .WillOnce(Return(true));
+
+ EXPECT_CALL(cfd_, GetBounds(_)).Times(1);
+
+ // Here we go!
+ GURL empty;
+ scoped_refptr<ChromeFrameLaunchParams> launch_params(
+ new ChromeFrameLaunchParams(
+ GURL("http://www.nonexistent.com"), empty, profile_path_,
+ profile_path_.BaseName().value(), L"", false, false));
+ launch_params->set_launch_timeout(timeout);
+ launch_params->set_version_check(false);
+ EXPECT_TRUE(client_->Initialize(&cfd_, launch_params));
+ loop_.RunFor(10);
+
+ EXPECT_CALL(mock_proxy_, ReleaseTabProxy(testing::Eq(tab_handle_))).Times(1);
+ client_->Uninitialize();
+}
+
diff --git a/chrome_frame/test/automation_client_mock.h b/chrome_frame/test/automation_client_mock.h
index 09b1484..2ac30e8 100644
--- a/chrome_frame/test/automation_client_mock.h
+++ b/chrome_frame/test/automation_client_mock.h
@@ -105,12 +105,12 @@ class MockAutomationProxy : public ChromeFrameAutomationProxy {
};
struct MockAutomationMessageSender : public AutomationMessageSender {
- MOCK_METHOD1(Send, bool(IPC::Message*));
+ virtual bool Send(IPC::Message* msg) {
+ return proxy_->Send(msg);
+ }
void ForwardTo(StrictMock<MockAutomationProxy> *p) {
proxy_ = p;
- ON_CALL(*this, Send(testing::_))
- .WillByDefault(testing::Invoke(proxy_, &MockAutomationProxy::Send));
}
StrictMock<MockAutomationProxy>* proxy_;