Chromium Code Reviews| Index: third_party/WebKit/Source/web/tests/WebViewTest.cpp |
| diff --git a/third_party/WebKit/Source/web/tests/WebViewTest.cpp b/third_party/WebKit/Source/web/tests/WebViewTest.cpp |
| index 9cd65eefc4ad7cf2429fa27f1fde2ba59a29f5cc..80255fcd3b173c082b5b1dd2edbad6bfbaf87ca6 100644 |
| --- a/third_party/WebKit/Source/web/tests/WebViewTest.cpp |
| +++ b/third_party/WebKit/Source/web/tests/WebViewTest.cpp |
| @@ -897,6 +897,37 @@ TEST_P(WebViewTest, SetEditableSelectionOffsetsAndTextInputInfo) { |
| EXPECT_EQ(-1, info.compositionEnd); |
| } |
| +// Regression test for crbug.com/663645 |
| +TEST_P(WebViewTest, FinishComposingTextDoesNotCrash) { |
|
aelias_OOO_until_Jul13
2016/11/11 20:27:31
There's never been a crash here, please rename the
|
| + URLTestHelpers::registerMockedURLFromBaseURL( |
| + WebString::fromUTF8(m_baseURL.c_str()), |
| + WebString::fromUTF8("input_field_default.html")); |
| + WebViewImpl* webView = |
| + m_webViewHelper.initializeAndLoad(m_baseURL + "input_field_default.html"); |
| + webView->setInitialFocus(false); |
| + |
| + WebInputMethodController* activeInputMethodController = |
| + webView->mainFrameImpl() |
| + ->frameWidget() |
| + ->getActiveWebInputMethodController(); |
| + |
| + // The test requires non-empty composition. |
| + std::string compositionText("hello"); |
| + WebVector<WebCompositionUnderline> emptyUnderlines; |
| + activeInputMethodController->setComposition( |
| + WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 5, 5); |
| + |
| + // Do arbitrary change to make layout dirty. |
| + Document& document = *webView->mainFrameImpl()->frame()->document(); |
| + Element* br = document.createElement("br", ASSERT_NO_EXCEPTION); |
| + document.body()->appendChild(br); |
| + |
| + // Should not crash when calling WebInputMethodController::finishComposingText |
| + // with non-empty composition and dirty layout. |
| + activeInputMethodController->finishComposingText( |
| + WebInputMethodController::KeepSelection); |
| +} |
| + |
| TEST_P(WebViewTest, FinishComposingTextCursorPositionChange) { |
| URLTestHelpers::registerMockedURLFromBaseURL( |
| WebString::fromUTF8(m_baseURL.c_str()), |