diff options
-rw-r--r-- | chrome/browser/external_tab_container.cc | 4 | ||||
-rw-r--r-- | chrome/test/automation/automation_messages_internal.h | 10 | ||||
-rw-r--r-- | chrome_frame/chrome_active_document.cc | 7 | ||||
-rw-r--r-- | chrome_frame/chrome_active_document.h | 1 | ||||
-rw-r--r-- | chrome_frame/chrome_frame_delegate.cc | 2 | ||||
-rw-r--r-- | chrome_frame/chrome_frame_delegate.h | 1 | ||||
-rw-r--r-- | chrome_frame/test/data/chrome_frame_window_open.html | 18 | ||||
-rw-r--r-- | chrome_frame/test/test_mock_with_web_server.cc | 50 |
8 files changed, 87 insertions, 6 deletions
diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc index eeefdaa..5fd672b 100644 --- a/chrome/browser/external_tab_container.cc +++ b/chrome/browser/external_tab_container.cc @@ -396,6 +396,10 @@ void ExternalTabContainer::CloseContents(TabContents* source) { return; } MessageLoop::current()->Quit(); + } else { + if (automation_) { + automation_->Send(new AutomationMsg_CloseExternalTab(0, tab_handle_)); + } } } diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h index 4c0dafa..9e37390 100644 --- a/chrome/test/automation/automation_messages_internal.h +++ b/chrome/test/automation/automation_messages_internal.h @@ -1389,10 +1389,18 @@ IPC_BEGIN_MESSAGES(Automation) bool /* result */) - // This message requests the cookie be delete for given url in the + // This message requests the cookie be deleted for given url in the // profile of the tab identified by the first parameter. The second // parameter is the cookie name. IPC_SYNC_MESSAGE_ROUTED3_1(AutomationMsg_DeleteCookie, GURL, std::string, int, bool) + // This message requests the external tab identified by the tab handle + // passed in be closed. + // Request: + // -int: Tab handle + // Response: + // None expected + IPC_MESSAGE_ROUTED1(AutomationMsg_CloseExternalTab, int) + IPC_END_MESSAGES(Automation) diff --git a/chrome_frame/chrome_active_document.cc b/chrome_frame/chrome_active_document.cc index afe62e8..fda2d5b 100644 --- a/chrome_frame/chrome_active_document.cc +++ b/chrome_frame/chrome_active_document.cc @@ -618,6 +618,13 @@ void ChromeActiveDocument::OnDidNavigate(int tab_handle, UpdateNavigationState(nav_info); } +void ChromeActiveDocument::OnCloseTab(int tab_handle) { + ScopedComPtr<IWebBrowser2> web_browser2; + DoQueryService(SID_SWebBrowserApp, m_spClientSite, web_browser2.Receive()); + if (web_browser2) + web_browser2->Quit(); +} + void ChromeActiveDocument::UpdateNavigationState( const IPC::NavigationInfo& new_navigation_info) { HRESULT hr = S_OK; diff --git a/chrome_frame/chrome_active_document.h b/chrome_frame/chrome_active_document.h index bd1474f..5c3d8fb 100644 --- a/chrome_frame/chrome_active_document.h +++ b/chrome_frame/chrome_active_document.h @@ -280,6 +280,7 @@ END_EXEC_COMMAND_MAP() virtual void OnTabbedOut(int tab_handle, bool reverse); virtual void OnDidNavigate(int tab_handle, const IPC::NavigationInfo& nav_info); + virtual void OnCloseTab(int tab_handle); // Override DoVerb STDMETHOD(DoVerb)(LONG verb, LPMSG msg, diff --git a/chrome_frame/chrome_frame_delegate.cc b/chrome_frame/chrome_frame_delegate.cc index 3e69bd9..6d3186a 100644 --- a/chrome_frame/chrome_frame_delegate.cc +++ b/chrome_frame/chrome_frame_delegate.cc @@ -27,6 +27,7 @@ bool ChromeFrameDelegateImpl::IsTabMessage(const IPC::Message& message, IPC_MESSAGE_HANDLER_GENERIC(AutomationMsg_AttachExternalTab, ) IPC_MESSAGE_HANDLER_GENERIC(AutomationMsg_RequestGoToHistoryEntryOffset, ) IPC_MESSAGE_HANDLER_GENERIC(AutomationMsg_GetCookiesFromHost, ) + IPC_MESSAGE_HANDLER_GENERIC(AutomationMsg_CloseExternalTab, ) IPC_MESSAGE_UNHANDLED(is_tab_message = false); IPC_END_MESSAGE_MAP() @@ -71,5 +72,6 @@ void ChromeFrameDelegateImpl::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(AutomationMsg_RequestGoToHistoryEntryOffset, OnGoToHistoryEntryOffset) IPC_MESSAGE_HANDLER(AutomationMsg_GetCookiesFromHost, OnGetCookiesFromHost) + IPC_MESSAGE_HANDLER(AutomationMsg_CloseExternalTab, OnCloseTab) IPC_END_MESSAGE_MAP() } diff --git a/chrome_frame/chrome_frame_delegate.h b/chrome_frame/chrome_frame_delegate.h index cc2aa95..8ca11c7 100644 --- a/chrome_frame/chrome_frame_delegate.h +++ b/chrome_frame/chrome_frame_delegate.h @@ -127,6 +127,7 @@ class ChromeFrameDelegateImpl : public ChromeFrameDelegate { virtual void OnGetCookiesFromHost(int tab_handle, const GURL& url, int cookie_id) {} + virtual void OnCloseTab(int tab_handle) {} }; // This interface enables tasks to be marshaled to desired threads. diff --git a/chrome_frame/test/data/chrome_frame_window_open.html b/chrome_frame/test/data/chrome_frame_window_open.html index e7194cf..cf96a9e 100644 --- a/chrome_frame/test/data/chrome_frame_window_open.html +++ b/chrome_frame/test/data/chrome_frame_window_open.html @@ -15,14 +15,26 @@ function onLoad() { } } +var new_window; + function OpenPopup() { - window.open("chrome_frame_window_open_popup.html", "mywindow", - "left=10, top=10, height=100, width=100"); + new_window = window.open("chrome_frame_window_open_popup.html", "mywindow", + "left=10, top=10, height=100, width=100"); } + +function OnKeyPress() { + var char_code = String.fromCharCode(event.keyCode); + if (char_code == 'O') { + OpenPopup(); + } else if (char_code == 'C') { + new_window.close(); + } +} + </script> </head> -<body onload="onLoad();" onkeypress="OpenPopup();"> +<body onload="onLoad();" onkeypress="OnKeyPress();"> <div id="statusPanel" style="border: 1px solid red; width: 100%"> ChromeFrame full tab mode window open test running.... </div> diff --git a/chrome_frame/test/test_mock_with_web_server.cc b/chrome_frame/test/test_mock_with_web_server.cc index 174311d..ffc2f9e 100644 --- a/chrome_frame/test/test_mock_with_web_server.cc +++ b/chrome_frame/test/test_mock_with_web_server.cc @@ -361,11 +361,10 @@ TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_WindowOpenInChrome) { mock.ExpectNavigationAndSwitch(kWindowOpenUrl); - const wchar_t* input = L"A"; EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kWindowOpenUrl))) .WillOnce(testing::DoAll( DelaySendMouseClick(&mock, &loop, 0, 10, 10, simulate_input::LEFT), - DelaySendChar(&loop, 500, 'A', simulate_input::NONE))); + DelaySendChar(&loop, 500, 'O', simulate_input::NONE))); // Watch for new window mock.ExpectNewWindow(&new_window_mock); @@ -1521,3 +1520,50 @@ TEST_F(ChromeFrameTestWithWebServer, ASSERT_TRUE(mock.web_browser2() != NULL); loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); } + +// This test checks if window.open calls issued by a full tab mode ChromeFrame +// instance make it back to IE and then transitions back to Chrome as the +// window.open target page is supposed to render within Chrome and whether this +// window can be closed correctly. +// Marking this test as FLAKY initially as it relies on getting focus and user +// input which don't work correctly at times. +// http://code.google.com/p/chromium/issues/detail?id=26549 +TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_WindowCloseInChrome) { + CloseIeAtEndOfScope last_resort_close_ie; + ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; + ComStackObjectWithUninitialize<MockWebBrowserEventSink> new_window_mock; + chrome_frame_test::TimedMsgLoop loop; + + mock.ExpectNavigationAndSwitch(kWindowOpenUrl); + + EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kWindowOpenUrl))) + .WillOnce(testing::DoAll( + DelaySendMouseClick(&mock, &loop, 0, 10, 10, simulate_input::LEFT), + DelaySendChar(&loop, 500, 'O', simulate_input::NONE))); + // Watch for new window + mock.ExpectNewWindow(&new_window_mock); + + EXPECT_CALL(new_window_mock, OnLoad(testing::StrCaseEq(kWindowOpenPopupUrl))) + .WillOnce(testing::DoAll( + VerifyAddressBarUrl(&new_window_mock), + DelaySendMouseClick(&mock, &loop, 0, 10, 10, simulate_input::LEFT), + DelaySendChar(&loop, 500, 'C', simulate_input::NONE))); + + EXPECT_CALL(new_window_mock, OnQuit()) + .Times(testing::AtMost(1)) + .WillOnce(CloseBrowserMock(&mock)); + + EXPECT_CALL(mock, OnQuit()) + .Times(testing::AtMost(1)) + .WillOnce(QUIT_LOOP_SOON(loop, 2)); + + HRESULT hr = mock.LaunchIEAndNavigate(kWindowOpenUrl); + ASSERT_HRESULT_SUCCEEDED(hr); + if (hr == S_FALSE) + return; + + ASSERT_TRUE(mock.web_browser2() != NULL); + + loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); +} + |