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 5271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5282 void kickNoResults() | 5282 void kickNoResults() |
5283 { | 5283 { |
5284 kick(-1, -1, WebTextDecorationTypeSpelling); | 5284 kick(-1, -1, WebTextDecorationTypeSpelling); |
5285 } | 5285 } |
5286 | 5286 |
5287 void kick() | 5287 void kick() |
5288 { | 5288 { |
5289 kick(1, 8, WebTextDecorationTypeSpelling); | 5289 kick(1, 8, WebTextDecorationTypeSpelling); |
5290 } | 5290 } |
5291 | 5291 |
| 5292 void kickGrammar() |
| 5293 { |
| 5294 kick(1, 8, WebTextDecorationTypeGrammar); |
| 5295 } |
| 5296 |
5292 void kickInvisibleSpellcheck() | 5297 void kickInvisibleSpellcheck() |
5293 { | 5298 { |
5294 kick(1, 8, WebTextDecorationTypeInvisibleSpellcheck); | 5299 kick(1, 8, WebTextDecorationTypeInvisibleSpellcheck); |
5295 } | 5300 } |
5296 | 5301 |
5297 private: | 5302 private: |
5298 void kick(int misspellingStartOffset, int misspellingLength, WebTextDecorati
onType type) | 5303 void kick(int misspellingStartOffset, int misspellingLength, WebTextDecorati
onType type) |
5299 { | 5304 { |
5300 if (!m_completion) | 5305 if (!m_completion) |
5301 return; | 5306 return; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5378 | 5383 |
5379 element->focus(); | 5384 element->focus(); |
5380 NonThrowableExceptionState exceptionState; | 5385 NonThrowableExceptionState exceptionState; |
5381 document->execCommand("InsertText", false, "welcome ", exceptionState); | 5386 document->execCommand("InsertText", false, "welcome ", exceptionState); |
5382 | 5387 |
5383 document->updateStyleAndLayout(); | 5388 document->updateStyleAndLayout(); |
5384 | 5389 |
5385 EXPECT_FALSE(exceptionState.hadException()); | 5390 EXPECT_FALSE(exceptionState.hadException()); |
5386 auto range = EphemeralRange::rangeOfContents(*element); | 5391 auto range = EphemeralRange::rangeOfContents(*element); |
5387 document->markers().addMarker(range.startPosition(), range.endPosition(), Do
cumentMarker::Spelling); | 5392 document->markers().addMarker(range.startPosition(), range.endPosition(), Do
cumentMarker::Spelling); |
| 5393 document->markers().addMarker(range.startPosition(), range.endPosition(), Do
cumentMarker::Grammar); |
5388 document->markers().addMarker(range.startPosition(), range.endPosition(), Do
cumentMarker::InvisibleSpellcheck); | 5394 document->markers().addMarker(range.startPosition(), range.endPosition(), Do
cumentMarker::InvisibleSpellcheck); |
5389 EXPECT_EQ(2U, document->markers().markers().size()); | 5395 EXPECT_EQ(3U, document->markers().markers().size()); |
5390 | 5396 |
5391 spellcheck.kickNoResults(); | 5397 spellcheck.kickNoResults(); |
5392 EXPECT_EQ(0U, document->markers().markers().size()); | 5398 EXPECT_EQ(0U, document->markers().markers().size()); |
5393 } | 5399 } |
5394 | 5400 |
5395 TEST_P(ParameterizedWebFrameTest, SpellcheckResultsSavedInDocument) | 5401 TEST_P(ParameterizedWebFrameTest, SpellcheckResultsSavedInDocument) |
5396 { | 5402 { |
5397 registerMockedHttpURLLoad("spell.html"); | 5403 registerMockedHttpURLLoad("spell.html"); |
5398 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5404 FrameTestHelpers::WebViewHelper webViewHelper(this); |
5399 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); | 5405 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); |
(...skipping 14 matching lines...) Expand all Loading... |
5414 EXPECT_FALSE(exceptionState.hadException()); | 5420 EXPECT_FALSE(exceptionState.hadException()); |
5415 | 5421 |
5416 spellcheck.kick(); | 5422 spellcheck.kick(); |
5417 ASSERT_EQ(1U, document->markers().markers().size()); | 5423 ASSERT_EQ(1U, document->markers().markers().size()); |
5418 ASSERT_NE(static_cast<DocumentMarker*>(0), document->markers().markers()[0])
; | 5424 ASSERT_NE(static_cast<DocumentMarker*>(0), document->markers().markers()[0])
; |
5419 EXPECT_EQ(DocumentMarker::Spelling, document->markers().markers()[0]->type()
); | 5425 EXPECT_EQ(DocumentMarker::Spelling, document->markers().markers()[0]->type()
); |
5420 | 5426 |
5421 document->execCommand("InsertText", false, "wellcome ", exceptionState); | 5427 document->execCommand("InsertText", false, "wellcome ", exceptionState); |
5422 EXPECT_FALSE(exceptionState.hadException()); | 5428 EXPECT_FALSE(exceptionState.hadException()); |
5423 | 5429 |
| 5430 spellcheck.kickGrammar(); |
| 5431 ASSERT_EQ(1U, document->markers().markers().size()); |
| 5432 ASSERT_NE(static_cast<DocumentMarker*>(0), document->markers().markers()[0])
; |
| 5433 EXPECT_EQ(DocumentMarker::Grammar, document->markers().markers()[0]->type())
; |
| 5434 |
| 5435 document->execCommand("InsertText", false, "wellcome ", exceptionState); |
| 5436 EXPECT_FALSE(exceptionState.hadException()); |
| 5437 |
5424 spellcheck.kickInvisibleSpellcheck(); | 5438 spellcheck.kickInvisibleSpellcheck(); |
5425 ASSERT_EQ(1U, document->markers().markers().size()); | 5439 ASSERT_EQ(1U, document->markers().markers().size()); |
5426 ASSERT_NE(static_cast<DocumentMarker*>(0), document->markers().markers()[0])
; | 5440 ASSERT_NE(static_cast<DocumentMarker*>(0), document->markers().markers()[0])
; |
5427 EXPECT_EQ(DocumentMarker::InvisibleSpellcheck, document->markers().markers()
[0]->type()); | 5441 EXPECT_EQ(DocumentMarker::InvisibleSpellcheck, document->markers().markers()
[0]->type()); |
5428 } | 5442 } |
5429 | 5443 |
5430 class TestAccessInitialDocumentWebFrameClient : public FrameTestHelpers::TestWeb
FrameClient { | 5444 class TestAccessInitialDocumentWebFrameClient : public FrameTestHelpers::TestWeb
FrameClient { |
5431 public: | 5445 public: |
5432 TestAccessInitialDocumentWebFrameClient() : m_didAccessInitialDocument(false
) | 5446 TestAccessInitialDocumentWebFrameClient() : m_didAccessInitialDocument(false
) |
5433 { | 5447 { |
(...skipping 3390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8824 request.setRequestorOrigin(WebSecurityOrigin::createUnique()); | 8838 request.setRequestorOrigin(WebSecurityOrigin::createUnique()); |
8825 helper.webView()->mainFrameImpl()->loadRequest(request); | 8839 helper.webView()->mainFrameImpl()->loadRequest(request); |
8826 | 8840 |
8827 // Normally, the result of the JS url replaces the existing contents on the | 8841 // Normally, the result of the JS url replaces the existing contents on the |
8828 // Document. However, if the JS triggers a navigation, the contents should | 8842 // Document. However, if the JS triggers a navigation, the contents should |
8829 // not be replaced. | 8843 // not be replaced. |
8830 EXPECT_EQ("", toLocalFrame(helper.webView()->page()->mainFrame())->document(
)->documentElement()->innerText()); | 8844 EXPECT_EQ("", toLocalFrame(helper.webView()->page()->mainFrame())->document(
)->documentElement()->innerText()); |
8831 } | 8845 } |
8832 | 8846 |
8833 } // namespace blink | 8847 } // namespace blink |
OLD | NEW |