| 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 6272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6283 int numberOfTimesChecked() const { return m_numberOfTimesChecked; } | 6283 int numberOfTimesChecked() const { return m_numberOfTimesChecked; } |
| 6284 | 6284 |
| 6285 private: | 6285 private: |
| 6286 int m_numberOfTimesChecked; | 6286 int m_numberOfTimesChecked; |
| 6287 }; | 6287 }; |
| 6288 | 6288 |
| 6289 TEST_P(ParameterizedWebFrameTest, ReplaceMisspelledRange) { | 6289 TEST_P(ParameterizedWebFrameTest, ReplaceMisspelledRange) { |
| 6290 registerMockedHttpURLLoad("spell.html"); | 6290 registerMockedHttpURLLoad("spell.html"); |
| 6291 FrameTestHelpers::WebViewHelper webViewHelper; | 6291 FrameTestHelpers::WebViewHelper webViewHelper; |
| 6292 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); | 6292 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); |
| 6293 TextCheckClient textcheck; | |
| 6294 webViewHelper.webView()->setTextCheckClient(&textcheck); | |
| 6295 | 6293 |
| 6296 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | 6294 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
| 6295 TextCheckClient textcheck; |
| 6296 frame->setTextCheckClient(&textcheck); |
| 6297 |
| 6297 Document* document = frame->frame()->document(); | 6298 Document* document = frame->frame()->document(); |
| 6298 Element* element = document->getElementById("data"); | 6299 Element* element = document->getElementById("data"); |
| 6299 | 6300 |
| 6300 webViewHelper.webView()->settings()->setEditingBehavior( | 6301 webViewHelper.webView()->settings()->setEditingBehavior( |
| 6301 WebSettings::EditingBehaviorWin); | 6302 WebSettings::EditingBehaviorWin); |
| 6302 | 6303 |
| 6303 element->focus(); | 6304 element->focus(); |
| 6304 NonThrowableExceptionState exceptionState; | 6305 NonThrowableExceptionState exceptionState; |
| 6305 document->execCommand("InsertText", false, "_wellcome_.", exceptionState); | 6306 document->execCommand("InsertText", false, "_wellcome_.", exceptionState); |
| 6306 EXPECT_FALSE(exceptionState.hadException()); | 6307 EXPECT_FALSE(exceptionState.hadException()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 6330 EXPECT_EQ("_welcome_.", | 6331 EXPECT_EQ("_welcome_.", |
| 6331 WebFrameContentDumper::dumpWebViewAsText( | 6332 WebFrameContentDumper::dumpWebViewAsText( |
| 6332 webViewHelper.webView(), std::numeric_limits<size_t>::max()) | 6333 webViewHelper.webView(), std::numeric_limits<size_t>::max()) |
| 6333 .utf8()); | 6334 .utf8()); |
| 6334 } | 6335 } |
| 6335 | 6336 |
| 6336 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkers) { | 6337 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkers) { |
| 6337 registerMockedHttpURLLoad("spell.html"); | 6338 registerMockedHttpURLLoad("spell.html"); |
| 6338 FrameTestHelpers::WebViewHelper webViewHelper; | 6339 FrameTestHelpers::WebViewHelper webViewHelper; |
| 6339 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); | 6340 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); |
| 6340 TextCheckClient textcheck; | |
| 6341 webViewHelper.webView()->setTextCheckClient(&textcheck); | |
| 6342 | 6341 |
| 6343 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | 6342 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
| 6343 TextCheckClient textcheck; |
| 6344 frame->setTextCheckClient(&textcheck); |
| 6345 |
| 6344 Document* document = frame->frame()->document(); | 6346 Document* document = frame->frame()->document(); |
| 6345 Element* element = document->getElementById("data"); | 6347 Element* element = document->getElementById("data"); |
| 6346 | 6348 |
| 6347 webViewHelper.webView()->settings()->setEditingBehavior( | 6349 webViewHelper.webView()->settings()->setEditingBehavior( |
| 6348 WebSettings::EditingBehaviorWin); | 6350 WebSettings::EditingBehaviorWin); |
| 6349 | 6351 |
| 6350 element->focus(); | 6352 element->focus(); |
| 6351 NonThrowableExceptionState exceptionState; | 6353 NonThrowableExceptionState exceptionState; |
| 6352 document->execCommand("InsertText", false, "_wellcome_.", exceptionState); | 6354 document->execCommand("InsertText", false, "_wellcome_.", exceptionState); |
| 6353 EXPECT_FALSE(exceptionState.hadException()); | 6355 EXPECT_FALSE(exceptionState.hadException()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 6372 | 6374 |
| 6373 EXPECT_EQ(0U, document->markers() | 6375 EXPECT_EQ(0U, document->markers() |
| 6374 .markersInRange(selectionRange, DocumentMarker::Spelling) | 6376 .markersInRange(selectionRange, DocumentMarker::Spelling) |
| 6375 .size()); | 6377 .size()); |
| 6376 } | 6378 } |
| 6377 | 6379 |
| 6378 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkersUnderWords) { | 6380 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkersUnderWords) { |
| 6379 registerMockedHttpURLLoad("spell.html"); | 6381 registerMockedHttpURLLoad("spell.html"); |
| 6380 FrameTestHelpers::WebViewHelper webViewHelper; | 6382 FrameTestHelpers::WebViewHelper webViewHelper; |
| 6381 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); | 6383 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); |
| 6384 |
| 6385 WebLocalFrameImpl* webFrame = webViewHelper.webView()->mainFrameImpl(); |
| 6382 TextCheckClient textcheck; | 6386 TextCheckClient textcheck; |
| 6383 webViewHelper.webView()->setTextCheckClient(&textcheck); | 6387 webFrame->setTextCheckClient(&textcheck); |
| 6384 | 6388 |
| 6385 LocalFrame* frame = webViewHelper.webView()->mainFrameImpl()->frame(); | 6389 LocalFrame* frame = webFrame->frame(); |
| 6386 Document* document = frame->document(); | 6390 Document* document = frame->document(); |
| 6387 Element* element = document->getElementById("data"); | 6391 Element* element = document->getElementById("data"); |
| 6388 | 6392 |
| 6389 webViewHelper.webView()->settings()->setEditingBehavior( | 6393 webViewHelper.webView()->settings()->setEditingBehavior( |
| 6390 WebSettings::EditingBehaviorWin); | 6394 WebSettings::EditingBehaviorWin); |
| 6391 | 6395 |
| 6392 element->focus(); | 6396 element->focus(); |
| 6393 NonThrowableExceptionState exceptionState; | 6397 NonThrowableExceptionState exceptionState; |
| 6394 document->execCommand("InsertText", false, " wellcome ", exceptionState); | 6398 document->execCommand("InsertText", false, " wellcome ", exceptionState); |
| 6395 EXPECT_FALSE(exceptionState.hadException()); | 6399 EXPECT_FALSE(exceptionState.hadException()); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6449 } | 6453 } |
| 6450 | 6454 |
| 6451 WebTextCheckingCompletion* m_completion; | 6455 WebTextCheckingCompletion* m_completion; |
| 6452 }; | 6456 }; |
| 6453 | 6457 |
| 6454 TEST_P(ParameterizedWebFrameTest, SlowSpellcheckMarkerPosition) { | 6458 TEST_P(ParameterizedWebFrameTest, SlowSpellcheckMarkerPosition) { |
| 6455 registerMockedHttpURLLoad("spell.html"); | 6459 registerMockedHttpURLLoad("spell.html"); |
| 6456 FrameTestHelpers::WebViewHelper webViewHelper; | 6460 FrameTestHelpers::WebViewHelper webViewHelper; |
| 6457 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); | 6461 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); |
| 6458 | 6462 |
| 6463 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
| 6459 StubbornTextCheckClient textcheck; | 6464 StubbornTextCheckClient textcheck; |
| 6460 webViewHelper.webView()->setTextCheckClient(&textcheck); | 6465 frame->setTextCheckClient(&textcheck); |
| 6461 | 6466 |
| 6462 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | |
| 6463 Document* document = frame->frame()->document(); | 6467 Document* document = frame->frame()->document(); |
| 6464 Element* element = document->getElementById("data"); | 6468 Element* element = document->getElementById("data"); |
| 6465 | 6469 |
| 6466 webViewHelper.webView()->settings()->setEditingBehavior( | 6470 webViewHelper.webView()->settings()->setEditingBehavior( |
| 6467 WebSettings::EditingBehaviorWin); | 6471 WebSettings::EditingBehaviorWin); |
| 6468 | 6472 |
| 6469 element->focus(); | 6473 element->focus(); |
| 6470 NonThrowableExceptionState exceptionState; | 6474 NonThrowableExceptionState exceptionState; |
| 6471 document->execCommand("InsertText", false, "wellcome ", exceptionState); | 6475 document->execCommand("InsertText", false, "wellcome ", exceptionState); |
| 6472 EXPECT_FALSE(exceptionState.hadException()); | 6476 EXPECT_FALSE(exceptionState.hadException()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 6490 // This test verifies that cancelling spelling request does not cause a | 6494 // This test verifies that cancelling spelling request does not cause a |
| 6491 // write-after-free when there's no spellcheck client set. | 6495 // write-after-free when there's no spellcheck client set. |
| 6492 TEST_P(ParameterizedWebFrameTest, CancelSpellingRequestCrash) { | 6496 TEST_P(ParameterizedWebFrameTest, CancelSpellingRequestCrash) { |
| 6493 // The relevant code paths are obsolete with idle time spell checker. | 6497 // The relevant code paths are obsolete with idle time spell checker. |
| 6494 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) | 6498 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) |
| 6495 return; | 6499 return; |
| 6496 | 6500 |
| 6497 registerMockedHttpURLLoad("spell.html"); | 6501 registerMockedHttpURLLoad("spell.html"); |
| 6498 FrameTestHelpers::WebViewHelper webViewHelper; | 6502 FrameTestHelpers::WebViewHelper webViewHelper; |
| 6499 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); | 6503 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); |
| 6500 webViewHelper.webView()->setTextCheckClient(0); | |
| 6501 | 6504 |
| 6502 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | 6505 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
| 6506 frame->setTextCheckClient(0); |
| 6507 |
| 6503 Document* document = frame->frame()->document(); | 6508 Document* document = frame->frame()->document(); |
| 6504 Element* element = document->getElementById("data"); | 6509 Element* element = document->getElementById("data"); |
| 6505 | 6510 |
| 6506 webViewHelper.webView()->settings()->setEditingBehavior( | 6511 webViewHelper.webView()->settings()->setEditingBehavior( |
| 6507 WebSettings::EditingBehaviorWin); | 6512 WebSettings::EditingBehaviorWin); |
| 6508 | 6513 |
| 6509 element->focus(); | 6514 element->focus(); |
| 6510 frame->frame()->editor().replaceSelectionWithText( | 6515 frame->frame()->editor().replaceSelectionWithText( |
| 6511 "A", false, false, InputEvent::InputType::InsertReplacementText); | 6516 "A", false, false, InputEvent::InputType::InsertReplacementText); |
| 6512 frame->frame()->spellChecker().cancelCheck(); | 6517 frame->frame()->spellChecker().cancelCheck(); |
| 6513 } | 6518 } |
| 6514 | 6519 |
| 6515 TEST_P(ParameterizedWebFrameTest, SpellcheckResultErasesMarkers) { | 6520 TEST_P(ParameterizedWebFrameTest, SpellcheckResultErasesMarkers) { |
| 6516 registerMockedHttpURLLoad("spell.html"); | 6521 registerMockedHttpURLLoad("spell.html"); |
| 6517 FrameTestHelpers::WebViewHelper webViewHelper; | 6522 FrameTestHelpers::WebViewHelper webViewHelper; |
| 6518 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); | 6523 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); |
| 6519 | 6524 |
| 6525 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
| 6520 StubbornTextCheckClient textcheck; | 6526 StubbornTextCheckClient textcheck; |
| 6521 webViewHelper.webView()->setTextCheckClient(&textcheck); | 6527 frame->setTextCheckClient(&textcheck); |
| 6522 | 6528 |
| 6523 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | |
| 6524 Document* document = frame->frame()->document(); | 6529 Document* document = frame->frame()->document(); |
| 6525 Element* element = document->getElementById("data"); | 6530 Element* element = document->getElementById("data"); |
| 6526 | 6531 |
| 6527 webViewHelper.webView()->settings()->setEditingBehavior( | 6532 webViewHelper.webView()->settings()->setEditingBehavior( |
| 6528 WebSettings::EditingBehaviorWin); | 6533 WebSettings::EditingBehaviorWin); |
| 6529 | 6534 |
| 6530 element->focus(); | 6535 element->focus(); |
| 6531 NonThrowableExceptionState exceptionState; | 6536 NonThrowableExceptionState exceptionState; |
| 6532 document->execCommand("InsertText", false, "welcome ", exceptionState); | 6537 document->execCommand("InsertText", false, "welcome ", exceptionState); |
| 6533 | 6538 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 6550 | 6555 |
| 6551 textcheck.kickNoResults(); | 6556 textcheck.kickNoResults(); |
| 6552 EXPECT_EQ(0U, document->markers().markers().size()); | 6557 EXPECT_EQ(0U, document->markers().markers().size()); |
| 6553 } | 6558 } |
| 6554 | 6559 |
| 6555 TEST_P(ParameterizedWebFrameTest, SpellcheckResultsSavedInDocument) { | 6560 TEST_P(ParameterizedWebFrameTest, SpellcheckResultsSavedInDocument) { |
| 6556 registerMockedHttpURLLoad("spell.html"); | 6561 registerMockedHttpURLLoad("spell.html"); |
| 6557 FrameTestHelpers::WebViewHelper webViewHelper; | 6562 FrameTestHelpers::WebViewHelper webViewHelper; |
| 6558 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); | 6563 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); |
| 6559 | 6564 |
| 6565 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); |
| 6560 StubbornTextCheckClient textcheck; | 6566 StubbornTextCheckClient textcheck; |
| 6561 webViewHelper.webView()->setTextCheckClient(&textcheck); | 6567 frame->setTextCheckClient(&textcheck); |
| 6562 | 6568 |
| 6563 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); | |
| 6564 Document* document = frame->frame()->document(); | 6569 Document* document = frame->frame()->document(); |
| 6565 Element* element = document->getElementById("data"); | 6570 Element* element = document->getElementById("data"); |
| 6566 | 6571 |
| 6567 webViewHelper.webView()->settings()->setEditingBehavior( | 6572 webViewHelper.webView()->settings()->setEditingBehavior( |
| 6568 WebSettings::EditingBehaviorWin); | 6573 WebSettings::EditingBehaviorWin); |
| 6569 | 6574 |
| 6570 element->focus(); | 6575 element->focus(); |
| 6571 NonThrowableExceptionState exceptionState; | 6576 NonThrowableExceptionState exceptionState; |
| 6572 document->execCommand("InsertText", false, "wellcome ", exceptionState); | 6577 document->execCommand("InsertText", false, "wellcome ", exceptionState); |
| 6573 EXPECT_FALSE(exceptionState.hadException()); | 6578 EXPECT_FALSE(exceptionState.hadException()); |
| (...skipping 5024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11598 FrameTestHelpers::loadFrame(localFrame, "data:text/html,some page"); | 11603 FrameTestHelpers::loadFrame(localFrame, "data:text/html,some page"); |
| 11599 | 11604 |
| 11600 // Local frame with remote parent should have transparent baseBackgroundColor. | 11605 // Local frame with remote parent should have transparent baseBackgroundColor. |
| 11601 Color color = localFrame->frameView()->baseBackgroundColor(); | 11606 Color color = localFrame->frameView()->baseBackgroundColor(); |
| 11602 EXPECT_EQ(Color::transparent, color); | 11607 EXPECT_EQ(Color::transparent, color); |
| 11603 | 11608 |
| 11604 view->close(); | 11609 view->close(); |
| 11605 } | 11610 } |
| 11606 | 11611 |
| 11607 } // namespace blink | 11612 } // namespace blink |
| OLD | NEW |