Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(273)

Side by Side Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

Issue 2797073002: Move WebTextCheckClient reference from WebViewImpl to WebLocalFrameImpl (Closed)
Patch Set: Tue Apr 4 20:53:35 PDT 2017 Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 6271 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 TextCheckClient textcheck;
6293 webViewHelper.webView()->setTextCheckClient(&textcheck);
6294 6292
6295 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); 6293 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl();
6294 TextCheckClient textcheck;
6295 frame->setTextCheckClient(&textcheck);
6296
6296 Document* document = frame->frame()->document(); 6297 Document* document = frame->frame()->document();
6297 Element* element = document->getElementById("data"); 6298 Element* element = document->getElementById("data");
6298 6299
6299 webViewHelper.webView()->settings()->setEditingBehavior( 6300 webViewHelper.webView()->settings()->setEditingBehavior(
6300 WebSettings::EditingBehaviorWin); 6301 WebSettings::EditingBehaviorWin);
6301 6302
6302 element->focus(); 6303 element->focus();
6303 NonThrowableExceptionState exceptionState; 6304 NonThrowableExceptionState exceptionState;
6304 document->execCommand("InsertText", false, "_wellcome_.", exceptionState); 6305 document->execCommand("InsertText", false, "_wellcome_.", exceptionState);
6305 EXPECT_FALSE(exceptionState.hadException()); 6306 EXPECT_FALSE(exceptionState.hadException());
(...skipping 23 matching lines...) Expand all
6329 EXPECT_EQ("_welcome_.", 6330 EXPECT_EQ("_welcome_.",
6330 WebFrameContentDumper::dumpWebViewAsText( 6331 WebFrameContentDumper::dumpWebViewAsText(
6331 webViewHelper.webView(), std::numeric_limits<size_t>::max()) 6332 webViewHelper.webView(), std::numeric_limits<size_t>::max())
6332 .utf8()); 6333 .utf8());
6333 } 6334 }
6334 6335
6335 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkers) { 6336 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkers) {
6336 registerMockedHttpURLLoad("spell.html"); 6337 registerMockedHttpURLLoad("spell.html");
6337 FrameTestHelpers::WebViewHelper webViewHelper; 6338 FrameTestHelpers::WebViewHelper webViewHelper;
6338 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); 6339 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper);
6339 TextCheckClient textcheck;
6340 webViewHelper.webView()->setTextCheckClient(&textcheck);
6341 6340
6342 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); 6341 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl();
6342 TextCheckClient textcheck;
6343 frame->setTextCheckClient(&textcheck);
6344
6343 Document* document = frame->frame()->document(); 6345 Document* document = frame->frame()->document();
6344 Element* element = document->getElementById("data"); 6346 Element* element = document->getElementById("data");
6345 6347
6346 webViewHelper.webView()->settings()->setEditingBehavior( 6348 webViewHelper.webView()->settings()->setEditingBehavior(
6347 WebSettings::EditingBehaviorWin); 6349 WebSettings::EditingBehaviorWin);
6348 6350
6349 element->focus(); 6351 element->focus();
6350 NonThrowableExceptionState exceptionState; 6352 NonThrowableExceptionState exceptionState;
6351 document->execCommand("InsertText", false, "_wellcome_.", exceptionState); 6353 document->execCommand("InsertText", false, "_wellcome_.", exceptionState);
6352 EXPECT_FALSE(exceptionState.hadException()); 6354 EXPECT_FALSE(exceptionState.hadException());
(...skipping 18 matching lines...) Expand all
6371 6373
6372 EXPECT_EQ(0U, document->markers() 6374 EXPECT_EQ(0U, document->markers()
6373 .markersInRange(selectionRange, DocumentMarker::Spelling) 6375 .markersInRange(selectionRange, DocumentMarker::Spelling)
6374 .size()); 6376 .size());
6375 } 6377 }
6376 6378
6377 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkersUnderWords) { 6379 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkersUnderWords) {
6378 registerMockedHttpURLLoad("spell.html"); 6380 registerMockedHttpURLLoad("spell.html");
6379 FrameTestHelpers::WebViewHelper webViewHelper; 6381 FrameTestHelpers::WebViewHelper webViewHelper;
6380 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); 6382 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper);
6383
6384 WebLocalFrameImpl* webFrame = webViewHelper.webView()->mainFrameImpl();
6381 TextCheckClient textcheck; 6385 TextCheckClient textcheck;
6382 webViewHelper.webView()->setTextCheckClient(&textcheck); 6386 webFrame->setTextCheckClient(&textcheck);
6383 6387
6384 LocalFrame* frame = webViewHelper.webView()->mainFrameImpl()->frame(); 6388 LocalFrame* frame = webFrame->frame();
6385 Document* document = frame->document(); 6389 Document* document = frame->document();
6386 Element* element = document->getElementById("data"); 6390 Element* element = document->getElementById("data");
6387 6391
6388 webViewHelper.webView()->settings()->setEditingBehavior( 6392 webViewHelper.webView()->settings()->setEditingBehavior(
6389 WebSettings::EditingBehaviorWin); 6393 WebSettings::EditingBehaviorWin);
6390 6394
6391 element->focus(); 6395 element->focus();
6392 NonThrowableExceptionState exceptionState; 6396 NonThrowableExceptionState exceptionState;
6393 document->execCommand("InsertText", false, " wellcome ", exceptionState); 6397 document->execCommand("InsertText", false, " wellcome ", exceptionState);
6394 EXPECT_FALSE(exceptionState.hadException()); 6398 EXPECT_FALSE(exceptionState.hadException());
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
6448 } 6452 }
6449 6453
6450 WebTextCheckingCompletion* m_completion; 6454 WebTextCheckingCompletion* m_completion;
6451 }; 6455 };
6452 6456
6453 TEST_P(ParameterizedWebFrameTest, SlowSpellcheckMarkerPosition) { 6457 TEST_P(ParameterizedWebFrameTest, SlowSpellcheckMarkerPosition) {
6454 registerMockedHttpURLLoad("spell.html"); 6458 registerMockedHttpURLLoad("spell.html");
6455 FrameTestHelpers::WebViewHelper webViewHelper; 6459 FrameTestHelpers::WebViewHelper webViewHelper;
6456 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); 6460 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper);
6457 6461
6462 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl();
6458 StubbornTextCheckClient textcheck; 6463 StubbornTextCheckClient textcheck;
6459 webViewHelper.webView()->setTextCheckClient(&textcheck); 6464 frame->setTextCheckClient(&textcheck);
6460 6465
6461 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl();
6462 Document* document = frame->frame()->document(); 6466 Document* document = frame->frame()->document();
6463 Element* element = document->getElementById("data"); 6467 Element* element = document->getElementById("data");
6464 6468
6465 webViewHelper.webView()->settings()->setEditingBehavior( 6469 webViewHelper.webView()->settings()->setEditingBehavior(
6466 WebSettings::EditingBehaviorWin); 6470 WebSettings::EditingBehaviorWin);
6467 6471
6468 element->focus(); 6472 element->focus();
6469 NonThrowableExceptionState exceptionState; 6473 NonThrowableExceptionState exceptionState;
6470 document->execCommand("InsertText", false, "wellcome ", exceptionState); 6474 document->execCommand("InsertText", false, "wellcome ", exceptionState);
6471 EXPECT_FALSE(exceptionState.hadException()); 6475 EXPECT_FALSE(exceptionState.hadException());
(...skipping 17 matching lines...) Expand all
6489 // This test verifies that cancelling spelling request does not cause a 6493 // This test verifies that cancelling spelling request does not cause a
6490 // write-after-free when there's no spellcheck client set. 6494 // write-after-free when there's no spellcheck client set.
6491 TEST_P(ParameterizedWebFrameTest, CancelSpellingRequestCrash) { 6495 TEST_P(ParameterizedWebFrameTest, CancelSpellingRequestCrash) {
6492 // The relevant code paths are obsolete with idle time spell checker. 6496 // The relevant code paths are obsolete with idle time spell checker.
6493 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) 6497 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled())
6494 return; 6498 return;
6495 6499
6496 registerMockedHttpURLLoad("spell.html"); 6500 registerMockedHttpURLLoad("spell.html");
6497 FrameTestHelpers::WebViewHelper webViewHelper; 6501 FrameTestHelpers::WebViewHelper webViewHelper;
6498 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); 6502 webViewHelper.initializeAndLoad(m_baseURL + "spell.html");
6499 webViewHelper.webView()->setTextCheckClient(0);
6500 6503
6501 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); 6504 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl();
6505 frame->setTextCheckClient(0);
6506
6502 Document* document = frame->frame()->document(); 6507 Document* document = frame->frame()->document();
6503 Element* element = document->getElementById("data"); 6508 Element* element = document->getElementById("data");
6504 6509
6505 webViewHelper.webView()->settings()->setEditingBehavior( 6510 webViewHelper.webView()->settings()->setEditingBehavior(
6506 WebSettings::EditingBehaviorWin); 6511 WebSettings::EditingBehaviorWin);
6507 6512
6508 element->focus(); 6513 element->focus();
6509 frame->frame()->editor().replaceSelectionWithText( 6514 frame->frame()->editor().replaceSelectionWithText(
6510 "A", false, false, InputEvent::InputType::InsertReplacementText); 6515 "A", false, false, InputEvent::InputType::InsertReplacementText);
6511 frame->frame()->spellChecker().cancelCheck(); 6516 frame->frame()->spellChecker().cancelCheck();
6512 } 6517 }
6513 6518
6514 TEST_P(ParameterizedWebFrameTest, SpellcheckResultErasesMarkers) { 6519 TEST_P(ParameterizedWebFrameTest, SpellcheckResultErasesMarkers) {
6515 registerMockedHttpURLLoad("spell.html"); 6520 registerMockedHttpURLLoad("spell.html");
6516 FrameTestHelpers::WebViewHelper webViewHelper; 6521 FrameTestHelpers::WebViewHelper webViewHelper;
6517 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); 6522 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper);
6518 6523
6524 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl();
6519 StubbornTextCheckClient textcheck; 6525 StubbornTextCheckClient textcheck;
6520 webViewHelper.webView()->setTextCheckClient(&textcheck); 6526 frame->setTextCheckClient(&textcheck);
6521 6527
6522 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl();
6523 Document* document = frame->frame()->document(); 6528 Document* document = frame->frame()->document();
6524 Element* element = document->getElementById("data"); 6529 Element* element = document->getElementById("data");
6525 6530
6526 webViewHelper.webView()->settings()->setEditingBehavior( 6531 webViewHelper.webView()->settings()->setEditingBehavior(
6527 WebSettings::EditingBehaviorWin); 6532 WebSettings::EditingBehaviorWin);
6528 6533
6529 element->focus(); 6534 element->focus();
6530 NonThrowableExceptionState exceptionState; 6535 NonThrowableExceptionState exceptionState;
6531 document->execCommand("InsertText", false, "welcome ", exceptionState); 6536 document->execCommand("InsertText", false, "welcome ", exceptionState);
6532 6537
(...skipping 16 matching lines...) Expand all
6549 6554
6550 textcheck.kickNoResults(); 6555 textcheck.kickNoResults();
6551 EXPECT_EQ(0U, document->markers().markers().size()); 6556 EXPECT_EQ(0U, document->markers().markers().size());
6552 } 6557 }
6553 6558
6554 TEST_P(ParameterizedWebFrameTest, SpellcheckResultsSavedInDocument) { 6559 TEST_P(ParameterizedWebFrameTest, SpellcheckResultsSavedInDocument) {
6555 registerMockedHttpURLLoad("spell.html"); 6560 registerMockedHttpURLLoad("spell.html");
6556 FrameTestHelpers::WebViewHelper webViewHelper; 6561 FrameTestHelpers::WebViewHelper webViewHelper;
6557 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper); 6562 initializeTextSelectionWebView(m_baseURL + "spell.html", &webViewHelper);
6558 6563
6564 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl();
6559 StubbornTextCheckClient textcheck; 6565 StubbornTextCheckClient textcheck;
6560 webViewHelper.webView()->setTextCheckClient(&textcheck); 6566 frame->setTextCheckClient(&textcheck);
6561 6567
6562 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl();
6563 Document* document = frame->frame()->document(); 6568 Document* document = frame->frame()->document();
6564 Element* element = document->getElementById("data"); 6569 Element* element = document->getElementById("data");
6565 6570
6566 webViewHelper.webView()->settings()->setEditingBehavior( 6571 webViewHelper.webView()->settings()->setEditingBehavior(
6567 WebSettings::EditingBehaviorWin); 6572 WebSettings::EditingBehaviorWin);
6568 6573
6569 element->focus(); 6574 element->focus();
6570 NonThrowableExceptionState exceptionState; 6575 NonThrowableExceptionState exceptionState;
6571 document->execCommand("InsertText", false, "wellcome ", exceptionState); 6576 document->execCommand("InsertText", false, "wellcome ", exceptionState);
6572 EXPECT_FALSE(exceptionState.hadException()); 6577 EXPECT_FALSE(exceptionState.hadException());
(...skipping 5025 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698