| Index: third_party/WebKit/Source/web/tests/WebFrameTest.cpp
|
| diff --git a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
|
| index d276af66905c075db75afc84d80e65087912c83b..a2fd5bc6e1f81b9c860c8f5171e9396187ed86b3 100644
|
| --- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
|
| +++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
|
| @@ -54,6 +54,7 @@
|
| #include "core/editing/FrameSelection.h"
|
| #include "core/editing/VisiblePosition.h"
|
| #include "core/editing/markers/DocumentMarkerController.h"
|
| +#include "core/editing/spellcheck/IdleSpellCheckCallback.h"
|
| #include "core/editing/spellcheck/SpellChecker.h"
|
| #include "core/events/MouseEvent.h"
|
| #include "core/frame/FrameHost.h"
|
| @@ -6276,7 +6277,7 @@ class SpellCheckClient : public WebSpellCheckClient {
|
| TEST_P(ParameterizedWebFrameTest, ReplaceMisspelledRange) {
|
| registerMockedHttpURLLoad("spell.html");
|
| FrameTestHelpers::WebViewHelper webViewHelper;
|
| - webViewHelper.initializeAndLoad(m_baseURL + "spell.html");
|
| + initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper);
|
| SpellCheckClient spellcheck;
|
| webViewHelper.webView()->setSpellCheckClient(&spellcheck);
|
|
|
| @@ -6292,6 +6293,13 @@ TEST_P(ParameterizedWebFrameTest, ReplaceMisspelledRange) {
|
| document->execCommand("InsertText", false, "_wellcome_.", exceptionState);
|
| EXPECT_FALSE(exceptionState.hadException());
|
|
|
| + if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) {
|
| + document->frame()
|
| + ->spellChecker()
|
| + .idleSpellCheckCallback()
|
| + .forceInvocationForTesting();
|
| + }
|
| +
|
| const int allTextBeginOffset = 0;
|
| const int allTextLength = 11;
|
| frame->selectRange(WebRange(allTextBeginOffset, allTextLength));
|
| @@ -6316,7 +6324,7 @@ TEST_P(ParameterizedWebFrameTest, ReplaceMisspelledRange) {
|
| TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkers) {
|
| registerMockedHttpURLLoad("spell.html");
|
| FrameTestHelpers::WebViewHelper webViewHelper;
|
| - webViewHelper.initializeAndLoad(m_baseURL + "spell.html");
|
| + initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper);
|
| SpellCheckClient spellcheck;
|
| webViewHelper.webView()->setSpellCheckClient(&spellcheck);
|
|
|
| @@ -6332,6 +6340,13 @@ TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkers) {
|
| document->execCommand("InsertText", false, "_wellcome_.", exceptionState);
|
| EXPECT_FALSE(exceptionState.hadException());
|
|
|
| + if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) {
|
| + document->frame()
|
| + ->spellChecker()
|
| + .idleSpellCheckCallback()
|
| + .forceInvocationForTesting();
|
| + }
|
| +
|
| frame->removeSpellingMarkers();
|
|
|
| const int allTextBeginOffset = 0;
|
| @@ -6351,7 +6366,7 @@ TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkers) {
|
| TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkersUnderWords) {
|
| registerMockedHttpURLLoad("spell.html");
|
| FrameTestHelpers::WebViewHelper webViewHelper;
|
| - webViewHelper.initializeAndLoad(m_baseURL + "spell.html");
|
| + initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper);
|
| SpellCheckClient spellcheck;
|
| webViewHelper.webView()->setSpellCheckClient(&spellcheck);
|
|
|
| @@ -6367,6 +6382,9 @@ TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkersUnderWords) {
|
| document->execCommand("InsertText", false, " wellcome ", exceptionState);
|
| EXPECT_FALSE(exceptionState.hadException());
|
|
|
| + if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled())
|
| + frame->spellChecker().idleSpellCheckCallback().forceInvocationForTesting();
|
| +
|
| WebVector<unsigned> offsets1;
|
| webViewHelper.webView()->spellingMarkerOffsetsForTest(&offsets1);
|
| EXPECT_EQ(1U, offsets1.size());
|
| @@ -6424,7 +6442,7 @@ class StubbornSpellCheckClient : public WebSpellCheckClient {
|
| TEST_P(ParameterizedWebFrameTest, SlowSpellcheckMarkerPosition) {
|
| registerMockedHttpURLLoad("spell.html");
|
| FrameTestHelpers::WebViewHelper webViewHelper;
|
| - webViewHelper.initializeAndLoad(m_baseURL + "spell.html");
|
| + initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper);
|
|
|
| StubbornSpellCheckClient spellcheck;
|
| webViewHelper.webView()->setSpellCheckClient(&spellcheck);
|
| @@ -6443,6 +6461,13 @@ TEST_P(ParameterizedWebFrameTest, SlowSpellcheckMarkerPosition) {
|
| document->execCommand("InsertText", false, "he", exceptionState);
|
| EXPECT_FALSE(exceptionState.hadException());
|
|
|
| + if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) {
|
| + document->frame()
|
| + ->spellChecker()
|
| + .idleSpellCheckCallback()
|
| + .forceInvocationForTesting();
|
| + }
|
| +
|
| spellcheck.kick();
|
|
|
| WebVector<unsigned> offsets;
|
| @@ -6453,6 +6478,10 @@ TEST_P(ParameterizedWebFrameTest, SlowSpellcheckMarkerPosition) {
|
| // This test verifies that cancelling spelling request does not cause a
|
| // write-after-free when there's no spellcheck client set.
|
| TEST_P(ParameterizedWebFrameTest, CancelSpellingRequestCrash) {
|
| + // The relevant code paths are obsolete with idle time spell checker.
|
| + if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled())
|
| + return;
|
| +
|
| registerMockedHttpURLLoad("spell.html");
|
| FrameTestHelpers::WebViewHelper webViewHelper;
|
| webViewHelper.initializeAndLoad(m_baseURL + "spell.html");
|
| @@ -6474,7 +6503,7 @@ TEST_P(ParameterizedWebFrameTest, CancelSpellingRequestCrash) {
|
| TEST_P(ParameterizedWebFrameTest, SpellcheckResultErasesMarkers) {
|
| registerMockedHttpURLLoad("spell.html");
|
| FrameTestHelpers::WebViewHelper webViewHelper;
|
| - webViewHelper.initializeAndLoad(m_baseURL + "spell.html");
|
| + initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper);
|
|
|
| StubbornSpellCheckClient spellcheck;
|
| webViewHelper.webView()->setSpellCheckClient(&spellcheck);
|
| @@ -6490,6 +6519,13 @@ TEST_P(ParameterizedWebFrameTest, SpellcheckResultErasesMarkers) {
|
| NonThrowableExceptionState exceptionState;
|
| document->execCommand("InsertText", false, "welcome ", exceptionState);
|
|
|
| + if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) {
|
| + document->frame()
|
| + ->spellChecker()
|
| + .idleSpellCheckCallback()
|
| + .forceInvocationForTesting();
|
| + }
|
| +
|
| document->updateStyleAndLayout();
|
|
|
| EXPECT_FALSE(exceptionState.hadException());
|
| @@ -6507,7 +6543,7 @@ TEST_P(ParameterizedWebFrameTest, SpellcheckResultErasesMarkers) {
|
| TEST_P(ParameterizedWebFrameTest, SpellcheckResultsSavedInDocument) {
|
| registerMockedHttpURLLoad("spell.html");
|
| FrameTestHelpers::WebViewHelper webViewHelper;
|
| - webViewHelper.initializeAndLoad(m_baseURL + "spell.html");
|
| + initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper);
|
|
|
| StubbornSpellCheckClient spellcheck;
|
| webViewHelper.webView()->setSpellCheckClient(&spellcheck);
|
| @@ -6524,6 +6560,13 @@ TEST_P(ParameterizedWebFrameTest, SpellcheckResultsSavedInDocument) {
|
| document->execCommand("InsertText", false, "wellcome ", exceptionState);
|
| EXPECT_FALSE(exceptionState.hadException());
|
|
|
| + if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) {
|
| + document->frame()
|
| + ->spellChecker()
|
| + .idleSpellCheckCallback()
|
| + .forceInvocationForTesting();
|
| + }
|
| +
|
| spellcheck.kick();
|
| ASSERT_EQ(1U, document->markers().markers().size());
|
| ASSERT_NE(static_cast<DocumentMarker*>(0), document->markers().markers()[0]);
|
| @@ -6532,13 +6575,17 @@ TEST_P(ParameterizedWebFrameTest, SpellcheckResultsSavedInDocument) {
|
| document->execCommand("InsertText", false, "wellcome ", exceptionState);
|
| EXPECT_FALSE(exceptionState.hadException());
|
|
|
| + if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) {
|
| + document->frame()
|
| + ->spellChecker()
|
| + .idleSpellCheckCallback()
|
| + .forceInvocationForTesting();
|
| + }
|
| +
|
| spellcheck.kickGrammar();
|
| ASSERT_EQ(1U, document->markers().markers().size());
|
| ASSERT_NE(static_cast<DocumentMarker*>(0), document->markers().markers()[0]);
|
| EXPECT_EQ(DocumentMarker::Grammar, document->markers().markers()[0]->type());
|
| -
|
| - document->execCommand("InsertText", false, "wellcome ", exceptionState);
|
| - EXPECT_FALSE(exceptionState.hadException());
|
| }
|
|
|
| class TestAccessInitialDocumentWebFrameClient
|
|
|