OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 #include "public/web/WebHistoryItem.h" | 129 #include "public/web/WebHistoryItem.h" |
130 #include "public/web/WebPrintParams.h" | 130 #include "public/web/WebPrintParams.h" |
131 #include "public/web/WebRange.h" | 131 #include "public/web/WebRange.h" |
132 #include "public/web/WebRemoteFrame.h" | 132 #include "public/web/WebRemoteFrame.h" |
133 #include "public/web/WebScriptExecutionCallback.h" | 133 #include "public/web/WebScriptExecutionCallback.h" |
134 #include "public/web/WebScriptSource.h" | 134 #include "public/web/WebScriptSource.h" |
135 #include "public/web/WebSearchableFormData.h" | 135 #include "public/web/WebSearchableFormData.h" |
136 #include "public/web/WebSecurityPolicy.h" | 136 #include "public/web/WebSecurityPolicy.h" |
137 #include "public/web/WebSelection.h" | 137 #include "public/web/WebSelection.h" |
138 #include "public/web/WebSettings.h" | 138 #include "public/web/WebSettings.h" |
139 #include "public/web/WebSpellCheckClient.h" | 139 #include "public/web/WebTextCheckClient.h" |
140 #include "public/web/WebTextCheckingCompletion.h" | 140 #include "public/web/WebTextCheckingCompletion.h" |
141 #include "public/web/WebTextCheckingResult.h" | 141 #include "public/web/WebTextCheckingResult.h" |
142 #include "public/web/WebViewClient.h" | 142 #include "public/web/WebViewClient.h" |
143 #include "testing/gmock/include/gmock/gmock.h" | 143 #include "testing/gmock/include/gmock/gmock.h" |
144 #include "testing/gtest/include/gtest/gtest.h" | 144 #include "testing/gtest/include/gtest/gtest.h" |
145 #include "v8/include/v8.h" | 145 #include "v8/include/v8.h" |
146 #include "web/TextFinder.h" | 146 #include "web/TextFinder.h" |
147 #include "web/WebLocalFrameImpl.h" | 147 #include "web/WebLocalFrameImpl.h" |
148 #include "web/WebRemoteFrameImpl.h" | 148 #include "web/WebRemoteFrameImpl.h" |
149 #include "web/WebViewImpl.h" | 149 #include "web/WebViewImpl.h" |
(...skipping 6107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6257 TEST_P(ParameterizedWebFrameTest, | 6257 TEST_P(ParameterizedWebFrameTest, |
6258 MoveCaretSelectionTowardsWindowPointWithNoSelection) { | 6258 MoveCaretSelectionTowardsWindowPointWithNoSelection) { |
6259 FrameTestHelpers::WebViewHelper webViewHelper; | 6259 FrameTestHelpers::WebViewHelper webViewHelper; |
6260 webViewHelper.initializeAndLoad("about:blank", true); | 6260 webViewHelper.initializeAndLoad("about:blank", true); |
6261 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 6261 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
6262 | 6262 |
6263 // This test passes if this doesn't crash. | 6263 // This test passes if this doesn't crash. |
6264 frame->toWebLocalFrame()->moveCaretSelection(WebPoint(0, 0)); | 6264 frame->toWebLocalFrame()->moveCaretSelection(WebPoint(0, 0)); |
6265 } | 6265 } |
6266 | 6266 |
6267 class SpellCheckClient : public WebSpellCheckClient { | 6267 class TextCheckClient : public WebTextCheckClient { |
6268 public: | 6268 public: |
6269 SpellCheckClient() : m_numberOfTimesChecked(0) {} | 6269 TextCheckClient() : m_numberOfTimesChecked(0) {} |
6270 virtual ~SpellCheckClient() {} | 6270 virtual ~TextCheckClient() {} |
6271 void requestCheckingOfText(const WebString&, | 6271 void requestCheckingOfText(const WebString&, |
6272 WebTextCheckingCompletion* completion) override { | 6272 WebTextCheckingCompletion* completion) override { |
6273 ++m_numberOfTimesChecked; | 6273 ++m_numberOfTimesChecked; |
6274 Vector<WebTextCheckingResult> results; | 6274 Vector<WebTextCheckingResult> results; |
6275 const int misspellingStartOffset = 1; | 6275 const int misspellingStartOffset = 1; |
6276 const int misspellingLength = 8; | 6276 const int misspellingLength = 8; |
6277 results.push_back(WebTextCheckingResult(WebTextDecorationTypeSpelling, | 6277 results.push_back(WebTextCheckingResult(WebTextDecorationTypeSpelling, |
6278 misspellingStartOffset, | 6278 misspellingStartOffset, |
6279 misspellingLength, WebString())); | 6279 misspellingLength, WebString())); |
6280 completion->didFinishCheckingText(results); | 6280 completion->didFinishCheckingText(results); |
6281 } | 6281 } |
6282 int numberOfTimesChecked() const { return m_numberOfTimesChecked; } | 6282 int numberOfTimesChecked() const { return m_numberOfTimesChecked; } |
6283 | 6283 |
6284 private: | 6284 private: |
6285 int m_numberOfTimesChecked; | 6285 int m_numberOfTimesChecked; |
6286 }; | 6286 }; |
6287 | 6287 |
6288 TEST_P(ParameterizedWebFrameTest, ReplaceMisspelledRange) { | 6288 TEST_P(ParameterizedWebFrameTest, ReplaceMisspelledRange) { |
6289 registerMockedHttpURLLoad("spell.html"); | 6289 registerMockedHttpURLLoad("spell.html"); |
6290 FrameTestHelpers::WebViewHelper webViewHelper; | 6290 FrameTestHelpers::WebViewHelper webViewHelper; |
6291 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); | 6291 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); |
6292 SpellCheckClient spellcheck; | 6292 TextCheckClient textcheck; |
6293 webViewHelper.webView()->setSpellCheckClient(&spellcheck); | 6293 webViewHelper.webView()->setTextCheckClient(&textcheck); |
6294 | 6294 |
6295 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | 6295 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
6296 Document* document = frame->frame()->document(); | 6296 Document* document = frame->frame()->document(); |
6297 Element* element = document->getElementById("data"); | 6297 Element* element = document->getElementById("data"); |
6298 | 6298 |
6299 webViewHelper.webView()->settings()->setEditingBehavior( | 6299 webViewHelper.webView()->settings()->setEditingBehavior( |
6300 WebSettings::EditingBehaviorWin); | 6300 WebSettings::EditingBehaviorWin); |
6301 | 6301 |
6302 element->focus(); | 6302 element->focus(); |
6303 NonThrowableExceptionState exceptionState; | 6303 NonThrowableExceptionState exceptionState; |
6304 document->execCommand("InsertText", false, "_wellcome_.", exceptionState); | 6304 document->execCommand("InsertText", false, "_wellcome_.", exceptionState); |
6305 EXPECT_FALSE(exceptionState.hadException()); | 6305 EXPECT_FALSE(exceptionState.hadException()); |
6306 | 6306 |
6307 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) { | 6307 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) { |
6308 document->frame() | 6308 document->frame() |
6309 ->spellChecker() | 6309 ->spellChecker() |
6310 .idleSpellCheckCallback() | 6310 .idleSpellCheckCallback() |
6311 .forceInvocationForTesting(); | 6311 .forceInvocationForTesting(); |
6312 } | 6312 } |
6313 | 6313 |
6314 const int allTextBeginOffset = 0; | 6314 const int allTextBeginOffset = 0; |
6315 const int allTextLength = 11; | 6315 const int allTextLength = 11; |
6316 frame->selectRange(WebRange(allTextBeginOffset, allTextLength)); | 6316 frame->selectRange(WebRange(allTextBeginOffset, allTextLength)); |
6317 EphemeralRange selectionRange = | 6317 EphemeralRange selectionRange = |
6318 frame->frame() | 6318 frame->frame() |
6319 ->selection() | 6319 ->selection() |
6320 .computeVisibleSelectionInDOMTreeDeprecated() | 6320 .computeVisibleSelectionInDOMTreeDeprecated() |
6321 .toNormalizedEphemeralRange(); | 6321 .toNormalizedEphemeralRange(); |
6322 | 6322 |
6323 EXPECT_EQ(1, spellcheck.numberOfTimesChecked()); | 6323 EXPECT_EQ(1, textcheck.numberOfTimesChecked()); |
6324 EXPECT_EQ(1U, document->markers() | 6324 EXPECT_EQ(1U, document->markers() |
6325 .markersInRange(selectionRange, DocumentMarker::Spelling) | 6325 .markersInRange(selectionRange, DocumentMarker::Spelling) |
6326 .size()); | 6326 .size()); |
6327 | 6327 |
6328 frame->replaceMisspelledRange("welcome"); | 6328 frame->replaceMisspelledRange("welcome"); |
6329 EXPECT_EQ("_welcome_.", | 6329 EXPECT_EQ("_welcome_.", |
6330 WebFrameContentDumper::dumpWebViewAsText( | 6330 WebFrameContentDumper::dumpWebViewAsText( |
6331 webViewHelper.webView(), std::numeric_limits<size_t>::max()) | 6331 webViewHelper.webView(), std::numeric_limits<size_t>::max()) |
6332 .utf8()); | 6332 .utf8()); |
6333 } | 6333 } |
6334 | 6334 |
6335 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkers) { | 6335 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkers) { |
6336 registerMockedHttpURLLoad("spell.html"); | 6336 registerMockedHttpURLLoad("spell.html"); |
6337 FrameTestHelpers::WebViewHelper webViewHelper; | 6337 FrameTestHelpers::WebViewHelper webViewHelper; |
6338 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); | 6338 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); |
6339 SpellCheckClient spellcheck; | 6339 TextCheckClient textcheck; |
6340 webViewHelper.webView()->setSpellCheckClient(&spellcheck); | 6340 webViewHelper.webView()->setTextCheckClient(&textcheck); |
6341 | 6341 |
6342 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | 6342 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
6343 Document* document = frame->frame()->document(); | 6343 Document* document = frame->frame()->document(); |
6344 Element* element = document->getElementById("data"); | 6344 Element* element = document->getElementById("data"); |
6345 | 6345 |
6346 webViewHelper.webView()->settings()->setEditingBehavior( | 6346 webViewHelper.webView()->settings()->setEditingBehavior( |
6347 WebSettings::EditingBehaviorWin); | 6347 WebSettings::EditingBehaviorWin); |
6348 | 6348 |
6349 element->focus(); | 6349 element->focus(); |
6350 NonThrowableExceptionState exceptionState; | 6350 NonThrowableExceptionState exceptionState; |
(...skipping 20 matching lines...) Expand all Loading... |
6371 | 6371 |
6372 EXPECT_EQ(0U, document->markers() | 6372 EXPECT_EQ(0U, document->markers() |
6373 .markersInRange(selectionRange, DocumentMarker::Spelling) | 6373 .markersInRange(selectionRange, DocumentMarker::Spelling) |
6374 .size()); | 6374 .size()); |
6375 } | 6375 } |
6376 | 6376 |
6377 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkersUnderWords) { | 6377 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkersUnderWords) { |
6378 registerMockedHttpURLLoad("spell.html"); | 6378 registerMockedHttpURLLoad("spell.html"); |
6379 FrameTestHelpers::WebViewHelper webViewHelper; | 6379 FrameTestHelpers::WebViewHelper webViewHelper; |
6380 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); | 6380 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); |
6381 SpellCheckClient spellcheck; | 6381 TextCheckClient textcheck; |
6382 webViewHelper.webView()->setSpellCheckClient(&spellcheck); | 6382 webViewHelper.webView()->setTextCheckClient(&textcheck); |
6383 | 6383 |
6384 LocalFrame* frame = webViewHelper.webView()->mainFrameImpl()->frame(); | 6384 LocalFrame* frame = webViewHelper.webView()->mainFrameImpl()->frame(); |
6385 Document* document = frame->document(); | 6385 Document* document = frame->document(); |
6386 Element* element = document->getElementById("data"); | 6386 Element* element = document->getElementById("data"); |
6387 | 6387 |
6388 webViewHelper.webView()->settings()->setEditingBehavior( | 6388 webViewHelper.webView()->settings()->setEditingBehavior( |
6389 WebSettings::EditingBehaviorWin); | 6389 WebSettings::EditingBehaviorWin); |
6390 | 6390 |
6391 element->focus(); | 6391 element->focus(); |
6392 NonThrowableExceptionState exceptionState; | 6392 NonThrowableExceptionState exceptionState; |
6393 document->execCommand("InsertText", false, " wellcome ", exceptionState); | 6393 document->execCommand("InsertText", false, " wellcome ", exceptionState); |
6394 EXPECT_FALSE(exceptionState.hadException()); | 6394 EXPECT_FALSE(exceptionState.hadException()); |
6395 | 6395 |
6396 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) | 6396 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) |
6397 frame->spellChecker().idleSpellCheckCallback().forceInvocationForTesting(); | 6397 frame->spellChecker().idleSpellCheckCallback().forceInvocationForTesting(); |
6398 | 6398 |
6399 WebVector<unsigned> offsets1; | 6399 WebVector<unsigned> offsets1; |
6400 webViewHelper.webView()->spellingMarkerOffsetsForTest(&offsets1); | 6400 webViewHelper.webView()->spellingMarkerOffsetsForTest(&offsets1); |
6401 EXPECT_EQ(1U, offsets1.size()); | 6401 EXPECT_EQ(1U, offsets1.size()); |
6402 | 6402 |
6403 Vector<String> words; | 6403 Vector<String> words; |
6404 words.push_back("wellcome"); | 6404 words.push_back("wellcome"); |
6405 frame->removeSpellingMarkersUnderWords(words); | 6405 frame->removeSpellingMarkersUnderWords(words); |
6406 | 6406 |
6407 WebVector<unsigned> offsets2; | 6407 WebVector<unsigned> offsets2; |
6408 webViewHelper.webView()->spellingMarkerOffsetsForTest(&offsets2); | 6408 webViewHelper.webView()->spellingMarkerOffsetsForTest(&offsets2); |
6409 EXPECT_EQ(0U, offsets2.size()); | 6409 EXPECT_EQ(0U, offsets2.size()); |
6410 } | 6410 } |
6411 | 6411 |
6412 class StubbornSpellCheckClient : public WebSpellCheckClient { | 6412 class StubbornTextCheckClient : public WebTextCheckClient { |
6413 public: | 6413 public: |
6414 StubbornSpellCheckClient() : m_completion(0) {} | 6414 StubbornTextCheckClient() : m_completion(0) {} |
6415 virtual ~StubbornSpellCheckClient() {} | 6415 virtual ~StubbornTextCheckClient() {} |
6416 | 6416 |
6417 virtual void requestCheckingOfText( | 6417 virtual void requestCheckingOfText( |
6418 const WebString&, | 6418 const WebString&, |
6419 WebTextCheckingCompletion* completion) override { | 6419 WebTextCheckingCompletion* completion) override { |
6420 m_completion = completion; | 6420 m_completion = completion; |
6421 } | 6421 } |
6422 | 6422 |
6423 void cancelAllPendingRequests() override { | 6423 void cancelAllPendingRequests() override { |
6424 if (!m_completion) | 6424 if (!m_completion) |
6425 return; | 6425 return; |
(...skipping 22 matching lines...) Expand all Loading... |
6448 } | 6448 } |
6449 | 6449 |
6450 WebTextCheckingCompletion* m_completion; | 6450 WebTextCheckingCompletion* m_completion; |
6451 }; | 6451 }; |
6452 | 6452 |
6453 TEST_P(ParameterizedWebFrameTest, SlowSpellcheckMarkerPosition) { | 6453 TEST_P(ParameterizedWebFrameTest, SlowSpellcheckMarkerPosition) { |
6454 registerMockedHttpURLLoad("spell.html"); | 6454 registerMockedHttpURLLoad("spell.html"); |
6455 FrameTestHelpers::WebViewHelper webViewHelper; | 6455 FrameTestHelpers::WebViewHelper webViewHelper; |
6456 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); | 6456 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); |
6457 | 6457 |
6458 StubbornSpellCheckClient spellcheck; | 6458 StubbornTextCheckClient textcheck; |
6459 webViewHelper.webView()->setSpellCheckClient(&spellcheck); | 6459 webViewHelper.webView()->setTextCheckClient(&textcheck); |
6460 | 6460 |
6461 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | 6461 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
6462 Document* document = frame->frame()->document(); | 6462 Document* document = frame->frame()->document(); |
6463 Element* element = document->getElementById("data"); | 6463 Element* element = document->getElementById("data"); |
6464 | 6464 |
6465 webViewHelper.webView()->settings()->setEditingBehavior( | 6465 webViewHelper.webView()->settings()->setEditingBehavior( |
6466 WebSettings::EditingBehaviorWin); | 6466 WebSettings::EditingBehaviorWin); |
6467 | 6467 |
6468 element->focus(); | 6468 element->focus(); |
6469 NonThrowableExceptionState exceptionState; | 6469 NonThrowableExceptionState exceptionState; |
6470 document->execCommand("InsertText", false, "wellcome ", exceptionState); | 6470 document->execCommand("InsertText", false, "wellcome ", exceptionState); |
6471 EXPECT_FALSE(exceptionState.hadException()); | 6471 EXPECT_FALSE(exceptionState.hadException()); |
6472 document->execCommand("InsertText", false, "he", exceptionState); | 6472 document->execCommand("InsertText", false, "he", exceptionState); |
6473 EXPECT_FALSE(exceptionState.hadException()); | 6473 EXPECT_FALSE(exceptionState.hadException()); |
6474 | 6474 |
6475 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) { | 6475 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) { |
6476 document->frame() | 6476 document->frame() |
6477 ->spellChecker() | 6477 ->spellChecker() |
6478 .idleSpellCheckCallback() | 6478 .idleSpellCheckCallback() |
6479 .forceInvocationForTesting(); | 6479 .forceInvocationForTesting(); |
6480 } | 6480 } |
6481 | 6481 |
6482 spellcheck.kick(); | 6482 textcheck.kick(); |
6483 | 6483 |
6484 WebVector<unsigned> offsets; | 6484 WebVector<unsigned> offsets; |
6485 webViewHelper.webView()->spellingMarkerOffsetsForTest(&offsets); | 6485 webViewHelper.webView()->spellingMarkerOffsetsForTest(&offsets); |
6486 EXPECT_EQ(0U, offsets.size()); | 6486 EXPECT_EQ(0U, offsets.size()); |
6487 } | 6487 } |
6488 | 6488 |
6489 // This test verifies that cancelling spelling request does not cause a | 6489 // This test verifies that cancelling spelling request does not cause a |
6490 // write-after-free when there's no spellcheck client set. | 6490 // write-after-free when there's no spellcheck client set. |
6491 TEST_P(ParameterizedWebFrameTest, CancelSpellingRequestCrash) { | 6491 TEST_P(ParameterizedWebFrameTest, CancelSpellingRequestCrash) { |
6492 // The relevant code paths are obsolete with idle time spell checker. | 6492 // The relevant code paths are obsolete with idle time spell checker. |
6493 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) | 6493 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) |
6494 return; | 6494 return; |
6495 | 6495 |
6496 registerMockedHttpURLLoad("spell.html"); | 6496 registerMockedHttpURLLoad("spell.html"); |
6497 FrameTestHelpers::WebViewHelper webViewHelper; | 6497 FrameTestHelpers::WebViewHelper webViewHelper; |
6498 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); | 6498 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); |
6499 webViewHelper.webView()->setSpellCheckClient(0); | 6499 webViewHelper.webView()->setTextCheckClient(0); |
6500 | 6500 |
6501 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | 6501 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
6502 Document* document = frame->frame()->document(); | 6502 Document* document = frame->frame()->document(); |
6503 Element* element = document->getElementById("data"); | 6503 Element* element = document->getElementById("data"); |
6504 | 6504 |
6505 webViewHelper.webView()->settings()->setEditingBehavior( | 6505 webViewHelper.webView()->settings()->setEditingBehavior( |
6506 WebSettings::EditingBehaviorWin); | 6506 WebSettings::EditingBehaviorWin); |
6507 | 6507 |
6508 element->focus(); | 6508 element->focus(); |
6509 frame->frame()->editor().replaceSelectionWithText( | 6509 frame->frame()->editor().replaceSelectionWithText( |
6510 "A", false, false, InputEvent::InputType::InsertReplacementText); | 6510 "A", false, false, InputEvent::InputType::InsertReplacementText); |
6511 frame->frame()->spellChecker().cancelCheck(); | 6511 frame->frame()->spellChecker().cancelCheck(); |
6512 } | 6512 } |
6513 | 6513 |
6514 TEST_P(ParameterizedWebFrameTest, SpellcheckResultErasesMarkers) { | 6514 TEST_P(ParameterizedWebFrameTest, SpellcheckResultErasesMarkers) { |
6515 registerMockedHttpURLLoad("spell.html"); | 6515 registerMockedHttpURLLoad("spell.html"); |
6516 FrameTestHelpers::WebViewHelper webViewHelper; | 6516 FrameTestHelpers::WebViewHelper webViewHelper; |
6517 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); | 6517 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); |
6518 | 6518 |
6519 StubbornSpellCheckClient spellcheck; | 6519 StubbornTextCheckClient textcheck; |
6520 webViewHelper.webView()->setSpellCheckClient(&spellcheck); | 6520 webViewHelper.webView()->setTextCheckClient(&textcheck); |
6521 | 6521 |
6522 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | 6522 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
6523 Document* document = frame->frame()->document(); | 6523 Document* document = frame->frame()->document(); |
6524 Element* element = document->getElementById("data"); | 6524 Element* element = document->getElementById("data"); |
6525 | 6525 |
6526 webViewHelper.webView()->settings()->setEditingBehavior( | 6526 webViewHelper.webView()->settings()->setEditingBehavior( |
6527 WebSettings::EditingBehaviorWin); | 6527 WebSettings::EditingBehaviorWin); |
6528 | 6528 |
6529 element->focus(); | 6529 element->focus(); |
6530 NonThrowableExceptionState exceptionState; | 6530 NonThrowableExceptionState exceptionState; |
6531 document->execCommand("InsertText", false, "welcome ", exceptionState); | 6531 document->execCommand("InsertText", false, "welcome ", exceptionState); |
6532 | 6532 |
6533 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) { | 6533 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) { |
6534 document->frame() | 6534 document->frame() |
6535 ->spellChecker() | 6535 ->spellChecker() |
6536 .idleSpellCheckCallback() | 6536 .idleSpellCheckCallback() |
6537 .forceInvocationForTesting(); | 6537 .forceInvocationForTesting(); |
6538 } | 6538 } |
6539 | 6539 |
6540 document->updateStyleAndLayout(); | 6540 document->updateStyleAndLayout(); |
6541 | 6541 |
6542 EXPECT_FALSE(exceptionState.hadException()); | 6542 EXPECT_FALSE(exceptionState.hadException()); |
6543 auto range = EphemeralRange::rangeOfContents(*element); | 6543 auto range = EphemeralRange::rangeOfContents(*element); |
6544 document->markers().addMarker(range.startPosition(), range.endPosition(), | 6544 document->markers().addMarker(range.startPosition(), range.endPosition(), |
6545 DocumentMarker::Spelling); | 6545 DocumentMarker::Spelling); |
6546 document->markers().addMarker(range.startPosition(), range.endPosition(), | 6546 document->markers().addMarker(range.startPosition(), range.endPosition(), |
6547 DocumentMarker::Grammar); | 6547 DocumentMarker::Grammar); |
6548 EXPECT_EQ(2U, document->markers().markers().size()); | 6548 EXPECT_EQ(2U, document->markers().markers().size()); |
6549 | 6549 |
6550 spellcheck.kickNoResults(); | 6550 textcheck.kickNoResults(); |
6551 EXPECT_EQ(0U, document->markers().markers().size()); | 6551 EXPECT_EQ(0U, document->markers().markers().size()); |
6552 } | 6552 } |
6553 | 6553 |
6554 TEST_P(ParameterizedWebFrameTest, SpellcheckResultsSavedInDocument) { | 6554 TEST_P(ParameterizedWebFrameTest, SpellcheckResultsSavedInDocument) { |
6555 registerMockedHttpURLLoad("spell.html"); | 6555 registerMockedHttpURLLoad("spell.html"); |
6556 FrameTestHelpers::WebViewHelper webViewHelper; | 6556 FrameTestHelpers::WebViewHelper webViewHelper; |
6557 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); | 6557 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); |
6558 | 6558 |
6559 StubbornSpellCheckClient spellcheck; | 6559 StubbornTextCheckClient textcheck; |
6560 webViewHelper.webView()->setSpellCheckClient(&spellcheck); | 6560 webViewHelper.webView()->setTextCheckClient(&textcheck); |
6561 | 6561 |
6562 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | 6562 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
6563 Document* document = frame->frame()->document(); | 6563 Document* document = frame->frame()->document(); |
6564 Element* element = document->getElementById("data"); | 6564 Element* element = document->getElementById("data"); |
6565 | 6565 |
6566 webViewHelper.webView()->settings()->setEditingBehavior( | 6566 webViewHelper.webView()->settings()->setEditingBehavior( |
6567 WebSettings::EditingBehaviorWin); | 6567 WebSettings::EditingBehaviorWin); |
6568 | 6568 |
6569 element->focus(); | 6569 element->focus(); |
6570 NonThrowableExceptionState exceptionState; | 6570 NonThrowableExceptionState exceptionState; |
6571 document->execCommand("InsertText", false, "wellcome ", exceptionState); | 6571 document->execCommand("InsertText", false, "wellcome ", exceptionState); |
6572 EXPECT_FALSE(exceptionState.hadException()); | 6572 EXPECT_FALSE(exceptionState.hadException()); |
6573 | 6573 |
6574 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) { | 6574 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) { |
6575 document->frame() | 6575 document->frame() |
6576 ->spellChecker() | 6576 ->spellChecker() |
6577 .idleSpellCheckCallback() | 6577 .idleSpellCheckCallback() |
6578 .forceInvocationForTesting(); | 6578 .forceInvocationForTesting(); |
6579 } | 6579 } |
6580 | 6580 |
6581 spellcheck.kick(); | 6581 textcheck.kick(); |
6582 ASSERT_EQ(1U, document->markers().markers().size()); | 6582 ASSERT_EQ(1U, document->markers().markers().size()); |
6583 ASSERT_NE(static_cast<DocumentMarker*>(0), document->markers().markers()[0]); | 6583 ASSERT_NE(static_cast<DocumentMarker*>(0), document->markers().markers()[0]); |
6584 EXPECT_EQ(DocumentMarker::Spelling, document->markers().markers()[0]->type()); | 6584 EXPECT_EQ(DocumentMarker::Spelling, document->markers().markers()[0]->type()); |
6585 | 6585 |
6586 document->execCommand("InsertText", false, "wellcome ", exceptionState); | 6586 document->execCommand("InsertText", false, "wellcome ", exceptionState); |
6587 EXPECT_FALSE(exceptionState.hadException()); | 6587 EXPECT_FALSE(exceptionState.hadException()); |
6588 | 6588 |
6589 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) { | 6589 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) { |
6590 document->frame() | 6590 document->frame() |
6591 ->spellChecker() | 6591 ->spellChecker() |
6592 .idleSpellCheckCallback() | 6592 .idleSpellCheckCallback() |
6593 .forceInvocationForTesting(); | 6593 .forceInvocationForTesting(); |
6594 } | 6594 } |
6595 | 6595 |
6596 spellcheck.kickGrammar(); | 6596 textcheck.kickGrammar(); |
6597 ASSERT_EQ(1U, document->markers().markers().size()); | 6597 ASSERT_EQ(1U, document->markers().markers().size()); |
6598 ASSERT_NE(static_cast<DocumentMarker*>(0), document->markers().markers()[0]); | 6598 ASSERT_NE(static_cast<DocumentMarker*>(0), document->markers().markers()[0]); |
6599 EXPECT_EQ(DocumentMarker::Grammar, document->markers().markers()[0]->type()); | 6599 EXPECT_EQ(DocumentMarker::Grammar, document->markers().markers()[0]->type()); |
6600 } | 6600 } |
6601 | 6601 |
6602 class TestAccessInitialDocumentWebFrameClient | 6602 class TestAccessInitialDocumentWebFrameClient |
6603 : public FrameTestHelpers::TestWebFrameClient { | 6603 : public FrameTestHelpers::TestWebFrameClient { |
6604 public: | 6604 public: |
6605 TestAccessInitialDocumentWebFrameClient() | 6605 TestAccessInitialDocumentWebFrameClient() |
6606 : m_didAccessInitialDocument(false) {} | 6606 : m_didAccessInitialDocument(false) {} |
(...skipping 4917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11524 FrameTestHelpers::loadFrame(localFrame, "data:text/html,some page"); | 11524 FrameTestHelpers::loadFrame(localFrame, "data:text/html,some page"); |
11525 | 11525 |
11526 // Local frame with remote parent should have transparent baseBackgroundColor. | 11526 // Local frame with remote parent should have transparent baseBackgroundColor. |
11527 Color color = localFrame->frameView()->baseBackgroundColor(); | 11527 Color color = localFrame->frameView()->baseBackgroundColor(); |
11528 EXPECT_EQ(Color::transparent, color); | 11528 EXPECT_EQ(Color::transparent, color); |
11529 | 11529 |
11530 view->close(); | 11530 view->close(); |
11531 } | 11531 } |
11532 | 11532 |
11533 } // namespace blink | 11533 } // namespace blink |
OLD | NEW |