| 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 6540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6551 frame->GetFrame() | 6551 frame->GetFrame() |
| 6552 ->Selection() | 6552 ->Selection() |
| 6553 .ComputeVisibleSelectionInDOMTreeDeprecated() | 6553 .ComputeVisibleSelectionInDOMTreeDeprecated() |
| 6554 .ToNormalizedEphemeralRange(); | 6554 .ToNormalizedEphemeralRange(); |
| 6555 | 6555 |
| 6556 EXPECT_EQ(0U, document->Markers() | 6556 EXPECT_EQ(0U, document->Markers() |
| 6557 .MarkersInRange(selection_range, DocumentMarker::kSpelling) | 6557 .MarkersInRange(selection_range, DocumentMarker::kSpelling) |
| 6558 .size()); | 6558 .size()); |
| 6559 } | 6559 } |
| 6560 | 6560 |
| 6561 static void GetSpellingMarkerOffsets(WebVector<unsigned>* offsets, |
| 6562 const Document& document) { |
| 6563 Vector<unsigned> result; |
| 6564 const DocumentMarkerVector& document_markers = document.Markers().Markers(); |
| 6565 for (size_t i = 0; i < document_markers.size(); ++i) |
| 6566 result.push_back(document_markers[i]->StartOffset()); |
| 6567 offsets->Assign(result); |
| 6568 } |
| 6569 |
| 6561 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkersUnderWords) { | 6570 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkersUnderWords) { |
| 6562 RegisterMockedHttpURLLoad("spell.html"); | 6571 RegisterMockedHttpURLLoad("spell.html"); |
| 6563 FrameTestHelpers::WebViewHelper web_view_helper; | 6572 FrameTestHelpers::WebViewHelper web_view_helper; |
| 6564 InitializeTextSelectionWebView(base_url_ + "spell.html", &web_view_helper); | 6573 InitializeTextSelectionWebView(base_url_ + "spell.html", &web_view_helper); |
| 6565 | 6574 |
| 6566 WebLocalFrameImpl* web_frame = web_view_helper.WebView()->MainFrameImpl(); | 6575 WebLocalFrameImpl* web_frame = web_view_helper.WebView()->MainFrameImpl(); |
| 6567 TextCheckClient textcheck; | 6576 TextCheckClient textcheck; |
| 6568 web_frame->SetTextCheckClient(&textcheck); | 6577 web_frame->SetTextCheckClient(&textcheck); |
| 6569 | 6578 |
| 6570 LocalFrame* frame = web_frame->GetFrame(); | 6579 LocalFrame* frame = web_frame->GetFrame(); |
| 6571 Document* document = frame->GetDocument(); | 6580 Document* document = frame->GetDocument(); |
| 6572 Element* element = document->GetElementById("data"); | 6581 Element* element = document->GetElementById("data"); |
| 6573 | 6582 |
| 6574 web_view_helper.WebView()->GetSettings()->SetEditingBehavior( | 6583 web_view_helper.WebView()->GetSettings()->SetEditingBehavior( |
| 6575 WebSettings::kEditingBehaviorWin); | 6584 WebSettings::kEditingBehaviorWin); |
| 6576 | 6585 |
| 6577 element->focus(); | 6586 element->focus(); |
| 6578 NonThrowableExceptionState exception_state; | 6587 NonThrowableExceptionState exception_state; |
| 6579 document->execCommand("InsertText", false, " wellcome ", exception_state); | 6588 document->execCommand("InsertText", false, " wellcome ", exception_state); |
| 6580 EXPECT_FALSE(exception_state.HadException()); | 6589 EXPECT_FALSE(exception_state.HadException()); |
| 6581 | 6590 |
| 6582 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) | 6591 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) |
| 6583 frame->GetSpellChecker() | 6592 frame->GetSpellChecker() |
| 6584 .GetIdleSpellCheckCallback() | 6593 .GetIdleSpellCheckCallback() |
| 6585 .ForceInvocationForTesting(); | 6594 .ForceInvocationForTesting(); |
| 6586 | 6595 |
| 6587 WebVector<unsigned> offsets1; | 6596 WebVector<unsigned> offsets1; |
| 6588 web_frame->SpellingMarkerOffsetsForTest(&offsets1); | 6597 GetSpellingMarkerOffsets(&offsets1, *frame->GetDocument()); |
| 6589 EXPECT_EQ(1U, offsets1.size()); | 6598 EXPECT_EQ(1U, offsets1.size()); |
| 6590 | 6599 |
| 6591 Vector<String> words; | 6600 Vector<String> words; |
| 6592 words.push_back("wellcome"); | 6601 words.push_back("wellcome"); |
| 6593 frame->RemoveSpellingMarkersUnderWords(words); | 6602 frame->RemoveSpellingMarkersUnderWords(words); |
| 6594 | 6603 |
| 6595 WebVector<unsigned> offsets2; | 6604 WebVector<unsigned> offsets2; |
| 6596 web_frame->SpellingMarkerOffsetsForTest(&offsets2); | 6605 GetSpellingMarkerOffsets(&offsets2, *frame->GetDocument()); |
| 6597 EXPECT_EQ(0U, offsets2.size()); | 6606 EXPECT_EQ(0U, offsets2.size()); |
| 6598 } | 6607 } |
| 6599 | 6608 |
| 6600 class StubbornTextCheckClient : public WebTextCheckClient { | 6609 class StubbornTextCheckClient : public WebTextCheckClient { |
| 6601 public: | 6610 public: |
| 6602 StubbornTextCheckClient() : completion_(0) {} | 6611 StubbornTextCheckClient() : completion_(0) {} |
| 6603 virtual ~StubbornTextCheckClient() {} | 6612 virtual ~StubbornTextCheckClient() {} |
| 6604 | 6613 |
| 6605 virtual void RequestCheckingOfText( | 6614 virtual void RequestCheckingOfText( |
| 6606 const WebString&, | 6615 const WebString&, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6663 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) { | 6672 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) { |
| 6664 document->GetFrame() | 6673 document->GetFrame() |
| 6665 ->GetSpellChecker() | 6674 ->GetSpellChecker() |
| 6666 .GetIdleSpellCheckCallback() | 6675 .GetIdleSpellCheckCallback() |
| 6667 .ForceInvocationForTesting(); | 6676 .ForceInvocationForTesting(); |
| 6668 } | 6677 } |
| 6669 | 6678 |
| 6670 textcheck.Kick(); | 6679 textcheck.Kick(); |
| 6671 | 6680 |
| 6672 WebVector<unsigned> offsets; | 6681 WebVector<unsigned> offsets; |
| 6673 frame->SpellingMarkerOffsetsForTest(&offsets); | 6682 GetSpellingMarkerOffsets(&offsets, *frame->GetFrame()->GetDocument()); |
| 6674 EXPECT_EQ(0U, offsets.size()); | 6683 EXPECT_EQ(0U, offsets.size()); |
| 6675 } | 6684 } |
| 6676 | 6685 |
| 6677 // This test verifies that cancelling spelling request does not cause a | 6686 // This test verifies that cancelling spelling request does not cause a |
| 6678 // write-after-free when there's no spellcheck client set. | 6687 // write-after-free when there's no spellcheck client set. |
| 6679 TEST_P(ParameterizedWebFrameTest, CancelSpellingRequestCrash) { | 6688 TEST_P(ParameterizedWebFrameTest, CancelSpellingRequestCrash) { |
| 6680 // The relevant code paths are obsolete with idle time spell checker. | 6689 // The relevant code paths are obsolete with idle time spell checker. |
| 6681 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) | 6690 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) |
| 6682 return; | 6691 return; |
| 6683 | 6692 |
| (...skipping 5312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11996 | 12005 |
| 11997 // Failing the original child frame navigation and trying to render fallback | 12006 // Failing the original child frame navigation and trying to render fallback |
| 11998 // content shouldn't crash. It should return NoLoadInProgress. This is so the | 12007 // content shouldn't crash. It should return NoLoadInProgress. This is so the |
| 11999 // caller won't attempt to replace the correctly empty frame with an error | 12008 // caller won't attempt to replace the correctly empty frame with an error |
| 12000 // page. | 12009 // page. |
| 12001 EXPECT_EQ(WebLocalFrame::NoLoadInProgress, | 12010 EXPECT_EQ(WebLocalFrame::NoLoadInProgress, |
| 12002 child->MaybeRenderFallbackContent(WebURLError())); | 12011 child->MaybeRenderFallbackContent(WebURLError())); |
| 12003 } | 12012 } |
| 12004 | 12013 |
| 12005 } // namespace blink | 12014 } // namespace blink |
| OLD | NEW |