From 2b5034075bce34d79aa716eb6525f6bc43b26777 Mon Sep 17 00:00:00 2001 From: "grt@chromium.org" Date: Sat, 25 May 2013 13:58:22 +0000 Subject: Fix cross-window focus in Chrome Frame. Text input wasn't working due to requirements of the IME/TSF machinery that weren't being met by ExternalTabContainerWin. * ExternalTabContainerWin now provides an implementation for WebContentsDelegate::WebContentsFocused that calls into its WebView's OnWebContentsFocused method. This mimics BrowserView, and permits proper focus tracking via the FocusManager. * ExternalTabContainerWin now provides a specialization of DesktopRootWindowHostWin that saves and restores focus on blur/focus events. The stock DRWHW does this based on window activation, but this doesn't work for ETCW since the ETCW's DRWHW doesn't receive activation messages due to it being a child of an IE window rather than a top-level window. * IEEventSink::SendKeys now sets focus to the renderer before sending key down/up messages. BUG=241081 Review URL: https://chromiumcodereview.appspot.com/15944007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202270 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome_frame/test/data/window_open.html | 6 ++++-- chrome_frame/test/ie_event_sink.cc | 4 +++- chrome_frame/test/navigation_test.cc | 5 ----- chrome_frame/test/simulate_input.cc | 10 ++++++---- 4 files changed, 13 insertions(+), 12 deletions(-) (limited to 'chrome_frame') diff --git a/chrome_frame/test/data/window_open.html b/chrome_frame/test/data/window_open.html index 7708491..2478c42 100644 --- a/chrome_frame/test/data/window_open.html +++ b/chrome_frame/test/data/window_open.html @@ -7,8 +7,10 @@ function OnClick() { // Open popup to the url from the given query string. var url = window.location.search.substring(1); - new_window = window.open(url, "_blank", - "left=10, top=10, height=250, width=250"); + if (!new_window) { + new_window = window.open(url, "_blank", + "left=10, top=10, height=250, width=250"); + } } function OnKeyPress() { diff --git a/chrome_frame/test/ie_event_sink.cc b/chrome_frame/test/ie_event_sink.cc index 6caa4cd..4ba7126 100644 --- a/chrome_frame/test/ie_event_sink.cc +++ b/chrome_frame/test/ie_event_sink.cc @@ -15,6 +15,7 @@ #include "base/string_util.h" #include "base/stringprintf.h" #include "base/strings/string_piece.h" +#include "base/test/test_timeouts.h" #include "base/time.h" #include "base/utf_string_conversions.h" #include "base/win/scoped_bstr.h" @@ -317,7 +318,8 @@ void IEEventSink::SetFocusToRenderer() { void IEEventSink::SendKeys(const char* input_string) { HWND window = GetRendererWindow(); - const base::TimeDelta kMessageSleep = base::TimeDelta::FromMilliseconds(50); + simulate_input::SetKeyboardFocusToWindow(window); + const base::TimeDelta kMessageSleep = TestTimeouts::tiny_timeout(); const base::StringPiece codes(input_string); for (size_t i = 0; i < codes.length(); ++i) { char character = codes[i]; diff --git a/chrome_frame/test/navigation_test.cc b/chrome_frame/test/navigation_test.cc index 50f9134..1f8485f 100644 --- a/chrome_frame/test/navigation_test.cc +++ b/chrome_frame/test/navigation_test.cc @@ -369,12 +369,7 @@ TEST_P(FullTabNavigationTest, DISABLED_JavascriptWindowOpenDifferentDomain) { // Tests that the parent window can successfully close its popup through // the javascript close method. -#if defined(USE_AURA) -// Key events don't work after window.open; http://crbug.com/241081. -TEST_P(FullTabNavigationTest, DISABLED_JavascriptWindowOpenCanClose) { -#else TEST_P(FullTabNavigationTest, JavascriptWindowOpenCanClose) { -#endif // Please see http://code.google.com/p/chromium/issues/detail?id=60987 // for more information on why this test is disabled for Vista with IE7. if (base::win::GetVersion() == base::win::VERSION_VISTA && diff --git a/chrome_frame/test/simulate_input.cc b/chrome_frame/test/simulate_input.cc index 6317d14..3dca6f1 100644 --- a/chrome_frame/test/simulate_input.cc +++ b/chrome_frame/test/simulate_input.cc @@ -7,6 +7,8 @@ #include #include +#include "base/test/test_timeouts.h" +#include "base/threading/platform_thread.h" #include "chrome_frame/utils.h" namespace simulate_input { @@ -191,6 +193,7 @@ void SetKeyboardFocusToWindow(HWND window) { } void SendMouseClick(int x, int y, MouseButton button) { + const base::TimeDelta kMessageTimeout = TestTimeouts::tiny_timeout(); // TODO(joshia): Fix this. GetSystemMetrics(SM_CXSCREEN) will // retrieve screen size of the primarary monitor only. And monitors // arrangement could be pretty arbitrary. @@ -208,16 +211,15 @@ void SendMouseClick(int x, int y, MouseButton button) { input_info.mi.dx = static_cast(location_x); input_info.mi.dy = static_cast(location_y); ::SendInput(1, &input_info, sizeof(INPUT)); - - Sleep(10); + base::PlatformThread::Sleep(kMessageTimeout); input_info.mi.dwFlags = button_flag | MOUSEEVENTF_ABSOLUTE; ::SendInput(1, &input_info, sizeof(INPUT)); - - Sleep(10); + base::PlatformThread::Sleep(kMessageTimeout); input_info.mi.dwFlags = (button_flag << 1) | MOUSEEVENTF_ABSOLUTE; ::SendInput(1, &input_info, sizeof(INPUT)); + base::PlatformThread::Sleep(kMessageTimeout); } void SendMouseClick(HWND window, int x, int y, MouseButton button) { -- cgit v1.1