diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-07 21:40:29 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-07 21:40:29 +0000 |
commit | e16dd167e26e02de97b9f3fdc88f2e50814cee6b (patch) | |
tree | b6bb2e60f47119849886e6e31cc63d55fe0b6f27 /chrome_frame | |
parent | cfa8f06de2c4aae71ce39b67056d6bb85c00de74 (diff) | |
download | chromium_src-e16dd167e26e02de97b9f3fdc88f2e50814cee6b.zip chromium_src-e16dd167e26e02de97b9f3fdc88f2e50814cee6b.tar.gz chromium_src-e16dd167e26e02de97b9f3fdc88f2e50814cee6b.tar.bz2 |
Add Support for window.close in ChromeFrame. Currently the CloseContents notification on the TabContentsDelegate which
the ExternalTabContainer implements is ignored if the window close is not initiated from the host.
Fix is to send over an automation message AutomationMsg_CloseExternalTab to the external host where we close the window.
Currently this functionality is only provided by the active document.
Fixes bug http://code.google.com/p/chromium/issues/detail?id=45930
Bug=45930
Test=Covered by chrome frame unit test FullTabModeIE_WindowCloseInChrome
Review URL: http://codereview.chromium.org/2691004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49093 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-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 |
6 files changed, 74 insertions, 5 deletions
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); +} + |