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

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

Issue 2272793002: Make WebViewImpl::textInputInfo update layout before working on ranges. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments addressed. Created 4 years, 3 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) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 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 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 { 724 {
725 testTextInputType(WebTextInputTypeText, "input_field_default.html"); 725 testTextInputType(WebTextInputTypeText, "input_field_default.html");
726 testTextInputType(WebTextInputTypePassword, "input_field_password.html"); 726 testTextInputType(WebTextInputTypePassword, "input_field_password.html");
727 testTextInputType(WebTextInputTypeEmail, "input_field_email.html"); 727 testTextInputType(WebTextInputTypeEmail, "input_field_email.html");
728 testTextInputType(WebTextInputTypeSearch, "input_field_search.html"); 728 testTextInputType(WebTextInputTypeSearch, "input_field_search.html");
729 testTextInputType(WebTextInputTypeNumber, "input_field_number.html"); 729 testTextInputType(WebTextInputTypeNumber, "input_field_number.html");
730 testTextInputType(WebTextInputTypeTelephone, "input_field_tel.html"); 730 testTextInputType(WebTextInputTypeTelephone, "input_field_tel.html");
731 testTextInputType(WebTextInputTypeURL, "input_field_url.html"); 731 testTextInputType(WebTextInputTypeURL, "input_field_url.html");
732 } 732 }
733 733
734 TEST_F(WebViewTest, TextInputInfoUpdateStyleAndLayout)
735 {
736 FrameTestHelpers::TestWebViewClient client;
737 FrameTestHelpers::WebViewHelper m_webViewHelper;
738 WebViewImpl* webViewImpl = m_webViewHelper.initialize(true, 0, &client);
739
740 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/");
741 // Here, we need to construct a document that has a special property:
742 // Adding id="foo" to the <path> element will trigger creation of an SVG ins tance tree
743 // for the use <use> element.
744 // This is significant, because SVG instance trees are actually created lazi ly
745 // during Document::updateStyleAndLayout code, thus incrementing the DOM tre e version
746 // and freaking out the EphemeralRange (invalidating it).
747 FrameTestHelpers::loadHTMLString(webViewImpl->mainFrame(),
748 "<svg height='100%' version='1.1' viewBox='0 0 14 14' width='100%'>"
749 "<use xmlns:xlink='http://www.w3.org/1999/xlink' xlink:href='#foo'></use >"
750 "<path d='M 100 100 L 300 100 L 200 300 z' fill='#000'></path>"
751 "</svg>"
752 "<input>", baseURL);
753 webViewImpl->setInitialFocus(false);
754
755 // Add id="foo" to <path>, thus triggering the condition described above.
756 Document* document = webViewImpl->mainFrameImpl()->frame()->document();
757 document->body()->querySelector("path", ASSERT_NO_EXCEPTION)->setIdAttribute ("foo");
758
759 // This should not DCHECK.
760 EXPECT_EQ(WebTextInputTypeText, webViewImpl->textInputInfo().type);
761 }
762
734 void WebViewTest::testInputMode(const WebString& expectedInputMode, const std::s tring& htmlFile) 763 void WebViewTest::testInputMode(const WebString& expectedInputMode, const std::s tring& htmlFile)
735 { 764 {
736 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8(htmlFile.c_str())); 765 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8(htmlFile.c_str()));
737 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + htmlFile); 766 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + htmlFile);
738 webView->setInitialFocus(false); 767 webView->setInitialFocus(false);
739 EXPECT_EQ(expectedInputMode, webView->textInputInfo().inputMode); 768 EXPECT_EQ(expectedInputMode, webView->textInputInfo().inputMode);
740 } 769 }
741 770
742 TEST_F(WebViewTest, InputMode) 771 TEST_F(WebViewTest, InputMode)
743 { 772 {
(...skipping 2536 matching lines...) Expand 10 before | Expand all | Expand 10 after
3280 EXPECT_TRUE(webView->page()->defersLoading()); 3309 EXPECT_TRUE(webView->page()->defersLoading());
3281 } 3310 }
3282 3311
3283 EXPECT_TRUE(webView->page()->defersLoading()); 3312 EXPECT_TRUE(webView->page()->defersLoading());
3284 } 3313 }
3285 3314
3286 EXPECT_FALSE(webView->page()->defersLoading()); 3315 EXPECT_FALSE(webView->page()->defersLoading());
3287 } 3316 }
3288 3317
3289 } // namespace blink 3318 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698