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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 #include "core/dom/Document.h" | 47 #include "core/dom/Document.h" |
48 #include "core/dom/DocumentUserGestureToken.h" | 48 #include "core/dom/DocumentUserGestureToken.h" |
49 #include "core/dom/Fullscreen.h" | 49 #include "core/dom/Fullscreen.h" |
50 #include "core/dom/NodeComputedStyle.h" | 50 #include "core/dom/NodeComputedStyle.h" |
51 #include "core/dom/Range.h" | 51 #include "core/dom/Range.h" |
52 #include "core/editing/Editor.h" | 52 #include "core/editing/Editor.h" |
53 #include "core/editing/EphemeralRange.h" | 53 #include "core/editing/EphemeralRange.h" |
54 #include "core/editing/FrameSelection.h" | 54 #include "core/editing/FrameSelection.h" |
55 #include "core/editing/VisiblePosition.h" | 55 #include "core/editing/VisiblePosition.h" |
56 #include "core/editing/markers/DocumentMarkerController.h" | 56 #include "core/editing/markers/DocumentMarkerController.h" |
| 57 #include "core/editing/spellcheck/IdleSpellCheckCallback.h" |
57 #include "core/editing/spellcheck/SpellChecker.h" | 58 #include "core/editing/spellcheck/SpellChecker.h" |
58 #include "core/events/MouseEvent.h" | 59 #include "core/events/MouseEvent.h" |
59 #include "core/frame/FrameHost.h" | 60 #include "core/frame/FrameHost.h" |
60 #include "core/frame/FrameView.h" | 61 #include "core/frame/FrameView.h" |
61 #include "core/frame/LocalFrame.h" | 62 #include "core/frame/LocalFrame.h" |
62 #include "core/frame/RemoteFrame.h" | 63 #include "core/frame/RemoteFrame.h" |
63 #include "core/frame/Settings.h" | 64 #include "core/frame/Settings.h" |
64 #include "core/frame/VisualViewport.h" | 65 #include "core/frame/VisualViewport.h" |
65 #include "core/html/HTMLBodyElement.h" | 66 #include "core/html/HTMLBodyElement.h" |
66 #include "core/html/HTMLFormElement.h" | 67 #include "core/html/HTMLFormElement.h" |
(...skipping 6202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6269 } | 6270 } |
6270 int numberOfTimesChecked() const { return m_numberOfTimesChecked; } | 6271 int numberOfTimesChecked() const { return m_numberOfTimesChecked; } |
6271 | 6272 |
6272 private: | 6273 private: |
6273 int m_numberOfTimesChecked; | 6274 int m_numberOfTimesChecked; |
6274 }; | 6275 }; |
6275 | 6276 |
6276 TEST_P(ParameterizedWebFrameTest, ReplaceMisspelledRange) { | 6277 TEST_P(ParameterizedWebFrameTest, ReplaceMisspelledRange) { |
6277 registerMockedHttpURLLoad("spell.html"); | 6278 registerMockedHttpURLLoad("spell.html"); |
6278 FrameTestHelpers::WebViewHelper webViewHelper; | 6279 FrameTestHelpers::WebViewHelper webViewHelper; |
6279 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); | 6280 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); |
6280 SpellCheckClient spellcheck; | 6281 SpellCheckClient spellcheck; |
6281 webViewHelper.webView()->setSpellCheckClient(&spellcheck); | 6282 webViewHelper.webView()->setSpellCheckClient(&spellcheck); |
6282 | 6283 |
6283 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | 6284 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
6284 Document* document = frame->frame()->document(); | 6285 Document* document = frame->frame()->document(); |
6285 Element* element = document->getElementById("data"); | 6286 Element* element = document->getElementById("data"); |
6286 | 6287 |
6287 webViewHelper.webView()->settings()->setEditingBehavior( | 6288 webViewHelper.webView()->settings()->setEditingBehavior( |
6288 WebSettings::EditingBehaviorWin); | 6289 WebSettings::EditingBehaviorWin); |
6289 | 6290 |
6290 element->focus(); | 6291 element->focus(); |
6291 NonThrowableExceptionState exceptionState; | 6292 NonThrowableExceptionState exceptionState; |
6292 document->execCommand("InsertText", false, "_wellcome_.", exceptionState); | 6293 document->execCommand("InsertText", false, "_wellcome_.", exceptionState); |
6293 EXPECT_FALSE(exceptionState.hadException()); | 6294 EXPECT_FALSE(exceptionState.hadException()); |
6294 | 6295 |
| 6296 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) { |
| 6297 document->frame() |
| 6298 ->spellChecker() |
| 6299 .idleSpellCheckCallback() |
| 6300 .forceInvocationForTesting(); |
| 6301 } |
| 6302 |
6295 const int allTextBeginOffset = 0; | 6303 const int allTextBeginOffset = 0; |
6296 const int allTextLength = 11; | 6304 const int allTextLength = 11; |
6297 frame->selectRange(WebRange(allTextBeginOffset, allTextLength)); | 6305 frame->selectRange(WebRange(allTextBeginOffset, allTextLength)); |
6298 EphemeralRange selectionRange = | 6306 EphemeralRange selectionRange = |
6299 frame->frame() | 6307 frame->frame() |
6300 ->selection() | 6308 ->selection() |
6301 .computeVisibleSelectionInDOMTreeDeprecated() | 6309 .computeVisibleSelectionInDOMTreeDeprecated() |
6302 .toNormalizedEphemeralRange(); | 6310 .toNormalizedEphemeralRange(); |
6303 | 6311 |
6304 EXPECT_EQ(1, spellcheck.numberOfTimesChecked()); | 6312 EXPECT_EQ(1, spellcheck.numberOfTimesChecked()); |
6305 EXPECT_EQ(1U, document->markers() | 6313 EXPECT_EQ(1U, document->markers() |
6306 .markersInRange(selectionRange, DocumentMarker::Spelling) | 6314 .markersInRange(selectionRange, DocumentMarker::Spelling) |
6307 .size()); | 6315 .size()); |
6308 | 6316 |
6309 frame->replaceMisspelledRange("welcome"); | 6317 frame->replaceMisspelledRange("welcome"); |
6310 EXPECT_EQ("_welcome_.", | 6318 EXPECT_EQ("_welcome_.", |
6311 WebFrameContentDumper::dumpWebViewAsText( | 6319 WebFrameContentDumper::dumpWebViewAsText( |
6312 webViewHelper.webView(), std::numeric_limits<size_t>::max()) | 6320 webViewHelper.webView(), std::numeric_limits<size_t>::max()) |
6313 .utf8()); | 6321 .utf8()); |
6314 } | 6322 } |
6315 | 6323 |
6316 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkers) { | 6324 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkers) { |
6317 registerMockedHttpURLLoad("spell.html"); | 6325 registerMockedHttpURLLoad("spell.html"); |
6318 FrameTestHelpers::WebViewHelper webViewHelper; | 6326 FrameTestHelpers::WebViewHelper webViewHelper; |
6319 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); | 6327 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); |
6320 SpellCheckClient spellcheck; | 6328 SpellCheckClient spellcheck; |
6321 webViewHelper.webView()->setSpellCheckClient(&spellcheck); | 6329 webViewHelper.webView()->setSpellCheckClient(&spellcheck); |
6322 | 6330 |
6323 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | 6331 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
6324 Document* document = frame->frame()->document(); | 6332 Document* document = frame->frame()->document(); |
6325 Element* element = document->getElementById("data"); | 6333 Element* element = document->getElementById("data"); |
6326 | 6334 |
6327 webViewHelper.webView()->settings()->setEditingBehavior( | 6335 webViewHelper.webView()->settings()->setEditingBehavior( |
6328 WebSettings::EditingBehaviorWin); | 6336 WebSettings::EditingBehaviorWin); |
6329 | 6337 |
6330 element->focus(); | 6338 element->focus(); |
6331 NonThrowableExceptionState exceptionState; | 6339 NonThrowableExceptionState exceptionState; |
6332 document->execCommand("InsertText", false, "_wellcome_.", exceptionState); | 6340 document->execCommand("InsertText", false, "_wellcome_.", exceptionState); |
6333 EXPECT_FALSE(exceptionState.hadException()); | 6341 EXPECT_FALSE(exceptionState.hadException()); |
6334 | 6342 |
| 6343 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) { |
| 6344 document->frame() |
| 6345 ->spellChecker() |
| 6346 .idleSpellCheckCallback() |
| 6347 .forceInvocationForTesting(); |
| 6348 } |
| 6349 |
6335 frame->removeSpellingMarkers(); | 6350 frame->removeSpellingMarkers(); |
6336 | 6351 |
6337 const int allTextBeginOffset = 0; | 6352 const int allTextBeginOffset = 0; |
6338 const int allTextLength = 11; | 6353 const int allTextLength = 11; |
6339 frame->selectRange(WebRange(allTextBeginOffset, allTextLength)); | 6354 frame->selectRange(WebRange(allTextBeginOffset, allTextLength)); |
6340 EphemeralRange selectionRange = | 6355 EphemeralRange selectionRange = |
6341 frame->frame() | 6356 frame->frame() |
6342 ->selection() | 6357 ->selection() |
6343 .computeVisibleSelectionInDOMTreeDeprecated() | 6358 .computeVisibleSelectionInDOMTreeDeprecated() |
6344 .toNormalizedEphemeralRange(); | 6359 .toNormalizedEphemeralRange(); |
6345 | 6360 |
6346 EXPECT_EQ(0U, document->markers() | 6361 EXPECT_EQ(0U, document->markers() |
6347 .markersInRange(selectionRange, DocumentMarker::Spelling) | 6362 .markersInRange(selectionRange, DocumentMarker::Spelling) |
6348 .size()); | 6363 .size()); |
6349 } | 6364 } |
6350 | 6365 |
6351 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkersUnderWords) { | 6366 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkersUnderWords) { |
6352 registerMockedHttpURLLoad("spell.html"); | 6367 registerMockedHttpURLLoad("spell.html"); |
6353 FrameTestHelpers::WebViewHelper webViewHelper; | 6368 FrameTestHelpers::WebViewHelper webViewHelper; |
6354 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); | 6369 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); |
6355 SpellCheckClient spellcheck; | 6370 SpellCheckClient spellcheck; |
6356 webViewHelper.webView()->setSpellCheckClient(&spellcheck); | 6371 webViewHelper.webView()->setSpellCheckClient(&spellcheck); |
6357 | 6372 |
6358 LocalFrame* frame = webViewHelper.webView()->mainFrameImpl()->frame(); | 6373 LocalFrame* frame = webViewHelper.webView()->mainFrameImpl()->frame(); |
6359 Document* document = frame->document(); | 6374 Document* document = frame->document(); |
6360 Element* element = document->getElementById("data"); | 6375 Element* element = document->getElementById("data"); |
6361 | 6376 |
6362 webViewHelper.webView()->settings()->setEditingBehavior( | 6377 webViewHelper.webView()->settings()->setEditingBehavior( |
6363 WebSettings::EditingBehaviorWin); | 6378 WebSettings::EditingBehaviorWin); |
6364 | 6379 |
6365 element->focus(); | 6380 element->focus(); |
6366 NonThrowableExceptionState exceptionState; | 6381 NonThrowableExceptionState exceptionState; |
6367 document->execCommand("InsertText", false, " wellcome ", exceptionState); | 6382 document->execCommand("InsertText", false, " wellcome ", exceptionState); |
6368 EXPECT_FALSE(exceptionState.hadException()); | 6383 EXPECT_FALSE(exceptionState.hadException()); |
6369 | 6384 |
| 6385 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) |
| 6386 frame->spellChecker().idleSpellCheckCallback().forceInvocationForTesting(); |
| 6387 |
6370 WebVector<unsigned> offsets1; | 6388 WebVector<unsigned> offsets1; |
6371 webViewHelper.webView()->spellingMarkerOffsetsForTest(&offsets1); | 6389 webViewHelper.webView()->spellingMarkerOffsetsForTest(&offsets1); |
6372 EXPECT_EQ(1U, offsets1.size()); | 6390 EXPECT_EQ(1U, offsets1.size()); |
6373 | 6391 |
6374 Vector<String> words; | 6392 Vector<String> words; |
6375 words.push_back("wellcome"); | 6393 words.push_back("wellcome"); |
6376 frame->removeSpellingMarkersUnderWords(words); | 6394 frame->removeSpellingMarkersUnderWords(words); |
6377 | 6395 |
6378 WebVector<unsigned> offsets2; | 6396 WebVector<unsigned> offsets2; |
6379 webViewHelper.webView()->spellingMarkerOffsetsForTest(&offsets2); | 6397 webViewHelper.webView()->spellingMarkerOffsetsForTest(&offsets2); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6417 m_completion->didFinishCheckingText(results); | 6435 m_completion->didFinishCheckingText(results); |
6418 m_completion = 0; | 6436 m_completion = 0; |
6419 } | 6437 } |
6420 | 6438 |
6421 WebTextCheckingCompletion* m_completion; | 6439 WebTextCheckingCompletion* m_completion; |
6422 }; | 6440 }; |
6423 | 6441 |
6424 TEST_P(ParameterizedWebFrameTest, SlowSpellcheckMarkerPosition) { | 6442 TEST_P(ParameterizedWebFrameTest, SlowSpellcheckMarkerPosition) { |
6425 registerMockedHttpURLLoad("spell.html"); | 6443 registerMockedHttpURLLoad("spell.html"); |
6426 FrameTestHelpers::WebViewHelper webViewHelper; | 6444 FrameTestHelpers::WebViewHelper webViewHelper; |
6427 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); | 6445 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); |
6428 | 6446 |
6429 StubbornSpellCheckClient spellcheck; | 6447 StubbornSpellCheckClient spellcheck; |
6430 webViewHelper.webView()->setSpellCheckClient(&spellcheck); | 6448 webViewHelper.webView()->setSpellCheckClient(&spellcheck); |
6431 | 6449 |
6432 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | 6450 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
6433 Document* document = frame->frame()->document(); | 6451 Document* document = frame->frame()->document(); |
6434 Element* element = document->getElementById("data"); | 6452 Element* element = document->getElementById("data"); |
6435 | 6453 |
6436 webViewHelper.webView()->settings()->setEditingBehavior( | 6454 webViewHelper.webView()->settings()->setEditingBehavior( |
6437 WebSettings::EditingBehaviorWin); | 6455 WebSettings::EditingBehaviorWin); |
6438 | 6456 |
6439 element->focus(); | 6457 element->focus(); |
6440 NonThrowableExceptionState exceptionState; | 6458 NonThrowableExceptionState exceptionState; |
6441 document->execCommand("InsertText", false, "wellcome ", exceptionState); | 6459 document->execCommand("InsertText", false, "wellcome ", exceptionState); |
6442 EXPECT_FALSE(exceptionState.hadException()); | 6460 EXPECT_FALSE(exceptionState.hadException()); |
6443 document->execCommand("InsertText", false, "he", exceptionState); | 6461 document->execCommand("InsertText", false, "he", exceptionState); |
6444 EXPECT_FALSE(exceptionState.hadException()); | 6462 EXPECT_FALSE(exceptionState.hadException()); |
6445 | 6463 |
| 6464 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) { |
| 6465 document->frame() |
| 6466 ->spellChecker() |
| 6467 .idleSpellCheckCallback() |
| 6468 .forceInvocationForTesting(); |
| 6469 } |
| 6470 |
6446 spellcheck.kick(); | 6471 spellcheck.kick(); |
6447 | 6472 |
6448 WebVector<unsigned> offsets; | 6473 WebVector<unsigned> offsets; |
6449 webViewHelper.webView()->spellingMarkerOffsetsForTest(&offsets); | 6474 webViewHelper.webView()->spellingMarkerOffsetsForTest(&offsets); |
6450 EXPECT_EQ(0U, offsets.size()); | 6475 EXPECT_EQ(0U, offsets.size()); |
6451 } | 6476 } |
6452 | 6477 |
6453 // This test verifies that cancelling spelling request does not cause a | 6478 // This test verifies that cancelling spelling request does not cause a |
6454 // write-after-free when there's no spellcheck client set. | 6479 // write-after-free when there's no spellcheck client set. |
6455 TEST_P(ParameterizedWebFrameTest, CancelSpellingRequestCrash) { | 6480 TEST_P(ParameterizedWebFrameTest, CancelSpellingRequestCrash) { |
| 6481 // The relevant code paths are obsolete with idle time spell checker. |
| 6482 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) |
| 6483 return; |
| 6484 |
6456 registerMockedHttpURLLoad("spell.html"); | 6485 registerMockedHttpURLLoad("spell.html"); |
6457 FrameTestHelpers::WebViewHelper webViewHelper; | 6486 FrameTestHelpers::WebViewHelper webViewHelper; |
6458 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); | 6487 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); |
6459 webViewHelper.webView()->setSpellCheckClient(0); | 6488 webViewHelper.webView()->setSpellCheckClient(0); |
6460 | 6489 |
6461 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | 6490 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
6462 Document* document = frame->frame()->document(); | 6491 Document* document = frame->frame()->document(); |
6463 Element* element = document->getElementById("data"); | 6492 Element* element = document->getElementById("data"); |
6464 | 6493 |
6465 webViewHelper.webView()->settings()->setEditingBehavior( | 6494 webViewHelper.webView()->settings()->setEditingBehavior( |
6466 WebSettings::EditingBehaviorWin); | 6495 WebSettings::EditingBehaviorWin); |
6467 | 6496 |
6468 element->focus(); | 6497 element->focus(); |
6469 frame->frame()->editor().replaceSelectionWithText( | 6498 frame->frame()->editor().replaceSelectionWithText( |
6470 "A", false, false, InputEvent::InputType::InsertReplacementText); | 6499 "A", false, false, InputEvent::InputType::InsertReplacementText); |
6471 frame->frame()->spellChecker().cancelCheck(); | 6500 frame->frame()->spellChecker().cancelCheck(); |
6472 } | 6501 } |
6473 | 6502 |
6474 TEST_P(ParameterizedWebFrameTest, SpellcheckResultErasesMarkers) { | 6503 TEST_P(ParameterizedWebFrameTest, SpellcheckResultErasesMarkers) { |
6475 registerMockedHttpURLLoad("spell.html"); | 6504 registerMockedHttpURLLoad("spell.html"); |
6476 FrameTestHelpers::WebViewHelper webViewHelper; | 6505 FrameTestHelpers::WebViewHelper webViewHelper; |
6477 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); | 6506 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); |
6478 | 6507 |
6479 StubbornSpellCheckClient spellcheck; | 6508 StubbornSpellCheckClient spellcheck; |
6480 webViewHelper.webView()->setSpellCheckClient(&spellcheck); | 6509 webViewHelper.webView()->setSpellCheckClient(&spellcheck); |
6481 | 6510 |
6482 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | 6511 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
6483 Document* document = frame->frame()->document(); | 6512 Document* document = frame->frame()->document(); |
6484 Element* element = document->getElementById("data"); | 6513 Element* element = document->getElementById("data"); |
6485 | 6514 |
6486 webViewHelper.webView()->settings()->setEditingBehavior( | 6515 webViewHelper.webView()->settings()->setEditingBehavior( |
6487 WebSettings::EditingBehaviorWin); | 6516 WebSettings::EditingBehaviorWin); |
6488 | 6517 |
6489 element->focus(); | 6518 element->focus(); |
6490 NonThrowableExceptionState exceptionState; | 6519 NonThrowableExceptionState exceptionState; |
6491 document->execCommand("InsertText", false, "welcome ", exceptionState); | 6520 document->execCommand("InsertText", false, "welcome ", exceptionState); |
6492 | 6521 |
| 6522 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) { |
| 6523 document->frame() |
| 6524 ->spellChecker() |
| 6525 .idleSpellCheckCallback() |
| 6526 .forceInvocationForTesting(); |
| 6527 } |
| 6528 |
6493 document->updateStyleAndLayout(); | 6529 document->updateStyleAndLayout(); |
6494 | 6530 |
6495 EXPECT_FALSE(exceptionState.hadException()); | 6531 EXPECT_FALSE(exceptionState.hadException()); |
6496 auto range = EphemeralRange::rangeOfContents(*element); | 6532 auto range = EphemeralRange::rangeOfContents(*element); |
6497 document->markers().addMarker(range.startPosition(), range.endPosition(), | 6533 document->markers().addMarker(range.startPosition(), range.endPosition(), |
6498 DocumentMarker::Spelling); | 6534 DocumentMarker::Spelling); |
6499 document->markers().addMarker(range.startPosition(), range.endPosition(), | 6535 document->markers().addMarker(range.startPosition(), range.endPosition(), |
6500 DocumentMarker::Grammar); | 6536 DocumentMarker::Grammar); |
6501 EXPECT_EQ(2U, document->markers().markers().size()); | 6537 EXPECT_EQ(2U, document->markers().markers().size()); |
6502 | 6538 |
6503 spellcheck.kickNoResults(); | 6539 spellcheck.kickNoResults(); |
6504 EXPECT_EQ(0U, document->markers().markers().size()); | 6540 EXPECT_EQ(0U, document->markers().markers().size()); |
6505 } | 6541 } |
6506 | 6542 |
6507 TEST_P(ParameterizedWebFrameTest, SpellcheckResultsSavedInDocument) { | 6543 TEST_P(ParameterizedWebFrameTest, SpellcheckResultsSavedInDocument) { |
6508 registerMockedHttpURLLoad("spell.html"); | 6544 registerMockedHttpURLLoad("spell.html"); |
6509 FrameTestHelpers::WebViewHelper webViewHelper; | 6545 FrameTestHelpers::WebViewHelper webViewHelper; |
6510 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); | 6546 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); |
6511 | 6547 |
6512 StubbornSpellCheckClient spellcheck; | 6548 StubbornSpellCheckClient spellcheck; |
6513 webViewHelper.webView()->setSpellCheckClient(&spellcheck); | 6549 webViewHelper.webView()->setSpellCheckClient(&spellcheck); |
6514 | 6550 |
6515 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | 6551 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
6516 Document* document = frame->frame()->document(); | 6552 Document* document = frame->frame()->document(); |
6517 Element* element = document->getElementById("data"); | 6553 Element* element = document->getElementById("data"); |
6518 | 6554 |
6519 webViewHelper.webView()->settings()->setEditingBehavior( | 6555 webViewHelper.webView()->settings()->setEditingBehavior( |
6520 WebSettings::EditingBehaviorWin); | 6556 WebSettings::EditingBehaviorWin); |
6521 | 6557 |
6522 element->focus(); | 6558 element->focus(); |
6523 NonThrowableExceptionState exceptionState; | 6559 NonThrowableExceptionState exceptionState; |
6524 document->execCommand("InsertText", false, "wellcome ", exceptionState); | 6560 document->execCommand("InsertText", false, "wellcome ", exceptionState); |
6525 EXPECT_FALSE(exceptionState.hadException()); | 6561 EXPECT_FALSE(exceptionState.hadException()); |
6526 | 6562 |
| 6563 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) { |
| 6564 document->frame() |
| 6565 ->spellChecker() |
| 6566 .idleSpellCheckCallback() |
| 6567 .forceInvocationForTesting(); |
| 6568 } |
| 6569 |
6527 spellcheck.kick(); | 6570 spellcheck.kick(); |
6528 ASSERT_EQ(1U, document->markers().markers().size()); | 6571 ASSERT_EQ(1U, document->markers().markers().size()); |
6529 ASSERT_NE(static_cast<DocumentMarker*>(0), document->markers().markers()[0]); | 6572 ASSERT_NE(static_cast<DocumentMarker*>(0), document->markers().markers()[0]); |
6530 EXPECT_EQ(DocumentMarker::Spelling, document->markers().markers()[0]->type()); | 6573 EXPECT_EQ(DocumentMarker::Spelling, document->markers().markers()[0]->type()); |
6531 | 6574 |
6532 document->execCommand("InsertText", false, "wellcome ", exceptionState); | 6575 document->execCommand("InsertText", false, "wellcome ", exceptionState); |
6533 EXPECT_FALSE(exceptionState.hadException()); | 6576 EXPECT_FALSE(exceptionState.hadException()); |
6534 | 6577 |
| 6578 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) { |
| 6579 document->frame() |
| 6580 ->spellChecker() |
| 6581 .idleSpellCheckCallback() |
| 6582 .forceInvocationForTesting(); |
| 6583 } |
| 6584 |
6535 spellcheck.kickGrammar(); | 6585 spellcheck.kickGrammar(); |
6536 ASSERT_EQ(1U, document->markers().markers().size()); | 6586 ASSERT_EQ(1U, document->markers().markers().size()); |
6537 ASSERT_NE(static_cast<DocumentMarker*>(0), document->markers().markers()[0]); | 6587 ASSERT_NE(static_cast<DocumentMarker*>(0), document->markers().markers()[0]); |
6538 EXPECT_EQ(DocumentMarker::Grammar, document->markers().markers()[0]->type()); | 6588 EXPECT_EQ(DocumentMarker::Grammar, document->markers().markers()[0]->type()); |
6539 | |
6540 document->execCommand("InsertText", false, "wellcome ", exceptionState); | |
6541 EXPECT_FALSE(exceptionState.hadException()); | |
6542 } | 6589 } |
6543 | 6590 |
6544 class TestAccessInitialDocumentWebFrameClient | 6591 class TestAccessInitialDocumentWebFrameClient |
6545 : public FrameTestHelpers::TestWebFrameClient { | 6592 : public FrameTestHelpers::TestWebFrameClient { |
6546 public: | 6593 public: |
6547 TestAccessInitialDocumentWebFrameClient() | 6594 TestAccessInitialDocumentWebFrameClient() |
6548 : m_didAccessInitialDocument(false) {} | 6595 : m_didAccessInitialDocument(false) {} |
6549 | 6596 |
6550 virtual void didAccessInitialDocument() { m_didAccessInitialDocument = true; } | 6597 virtual void didAccessInitialDocument() { m_didAccessInitialDocument = true; } |
6551 | 6598 |
(...skipping 4810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11362 FrameTestHelpers::WebViewHelper openerHelper; | 11409 FrameTestHelpers::WebViewHelper openerHelper; |
11363 openerHelper.initialize(false, nullptr, &openerWebViewClient); | 11410 openerHelper.initialize(false, nullptr, &openerWebViewClient); |
11364 FrameTestHelpers::WebViewHelper helper; | 11411 FrameTestHelpers::WebViewHelper helper; |
11365 helper.initializeWithOpener(openerHelper.webView()->mainFrame()); | 11412 helper.initializeWithOpener(openerHelper.webView()->mainFrame()); |
11366 | 11413 |
11367 openerHelper.reset(); | 11414 openerHelper.reset(); |
11368 EXPECT_EQ(nullptr, helper.webView()->mainFrameImpl()->opener()); | 11415 EXPECT_EQ(nullptr, helper.webView()->mainFrameImpl()->opener()); |
11369 } | 11416 } |
11370 | 11417 |
11371 } // namespace blink | 11418 } // namespace blink |
OLD | NEW |