Index: components/test_runner/web_widget_test_client.cc |
diff --git a/components/test_runner/web_widget_test_client.cc b/components/test_runner/web_widget_test_client.cc |
index baaaece8274e55321744f9a0c54c827ef09fee2f..8705a5cb5a02bd3af08e4869181ade415bb6861c 100644 |
--- a/components/test_runner/web_widget_test_client.cc |
+++ b/components/test_runner/web_widget_test_client.cc |
@@ -16,7 +16,11 @@ |
#include "components/test_runner/web_view_test_proxy.h" |
#include "components/test_runner/web_widget_test_proxy.h" |
#include "third_party/WebKit/public/platform/WebScreenInfo.h" |
+#include "third_party/WebKit/public/web/WebFrameWidget.h" |
+#include "third_party/WebKit/public/web/WebInputMethodController.h" |
+#include "third_party/WebKit/public/web/WebLocalFrame.h" |
#include "third_party/WebKit/public/web/WebPagePopup.h" |
+#include "third_party/WebKit/public/web/WebView.h" |
#include "third_party/WebKit/public/web/WebWidget.h" |
namespace test_runner { |
@@ -100,11 +104,23 @@ void WebWidgetTestClient::setToolTipText(const blink::WebString& text, |
} |
void WebWidgetTestClient::resetInputMethod() { |
- // If a composition text exists, then we need to let the browser process |
- // to cancel the input method's ongoing composition session. |
- if (web_widget_test_proxy_base_) |
- web_widget_test_proxy_base_->web_widget()->finishComposingText( |
- blink::WebWidget::KeepSelection); |
+ // We should finish any ongoing composition. |
+ blink::WebFrameWidget* frame_widget = nullptr; |
+ if (web_widget_test_proxy_base_ && |
+ web_widget_test_proxy_base_->web_widget()->isWebFrameWidget()) { |
+ frame_widget = static_cast<blink::WebFrameWidget*>( |
+ web_widget_test_proxy_base_->web_widget()); |
+ } else if (web_view_test_proxy_base_) { |
+ blink::WebLocalFrame* main_frame = |
+ web_view_test_proxy_base_->web_view()->mainFrame()->toWebLocalFrame(); |
+ DCHECK(main_frame); |
+ frame_widget = main_frame->frameWidget(); |
+ } |
+ |
+ if (frame_widget && frame_widget->getActiveWebInputMethodController()) { |
+ frame_widget->getActiveWebInputMethodController()->finishComposingText( |
+ blink::WebInputMethodController::DoNotKeepSelection); |
+ } |
} |
} // namespace test_runner |