diff options
| author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-02-03 09:55:33 +0100 |
|---|---|---|
| committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-02-03 09:55:33 +0100 |
| commit | cd44dc59cdfc39534aef4d417e9f3c412e3be139 (patch) | |
| tree | 8d89889ba95ed6ec9322e733846cc9cce9d7dff1 /Source/WebKit/chromium/tests/WebFrameTest.cpp | |
| parent | d11f84f5b5cdc0d92a08af01b13472fdd5f9acb9 (diff) | |
| download | qtwebkit-cd44dc59cdfc39534aef4d417e9f3c412e3be139.tar.gz | |
Imported WebKit commit fce473cb4d55aa9fe9d0b0322a2fffecb731b961 (http://svn.webkit.org/repository/webkit/trunk@106560)
Diffstat (limited to 'Source/WebKit/chromium/tests/WebFrameTest.cpp')
| -rw-r--r-- | Source/WebKit/chromium/tests/WebFrameTest.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/Source/WebKit/chromium/tests/WebFrameTest.cpp b/Source/WebKit/chromium/tests/WebFrameTest.cpp index 2b2ea7601..06b26469a 100644 --- a/Source/WebKit/chromium/tests/WebFrameTest.cpp +++ b/Source/WebKit/chromium/tests/WebFrameTest.cpp @@ -33,9 +33,11 @@ #include "FrameTestHelpers.h" #include "ResourceError.h" #include "WebDocument.h" +#include "WebFindOptions.h" #include "WebFormElement.h" #include "WebFrame.h" #include "WebFrameClient.h" +#include "WebRange.h" #include "WebScriptSource.h" #include "WebSearchableFormData.h" #include "WebSecurityPolicy.h" @@ -379,4 +381,54 @@ TEST_F(WebFrameTest, ContextNotificationsIsolatedWorlds) EXPECT_EQ(1, matchCount); } +TEST_F(WebFrameTest, DISABLED_FindInPage) +{ + registerMockedHttpURLLoad("find.html"); + WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "find.html"); + WebFrame* frame = webView->mainFrame(); + const int findIdentifier = 12345; + WebFindOptions options; + + // Find in a <div> element. + EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar1"), options, false, 0)); + frame->stopFinding(false); + WebRange range = frame->selectionRange(); + EXPECT_EQ(5, range.startOffset()); + EXPECT_EQ(9, range.endOffset()); + EXPECT_TRUE(frame->document().focusedNode().isNull()); + + // Find in an <input> value. + EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar2"), options, false, 0)); + // Confirm stopFinding(false) sets the selection on the found text. + frame->stopFinding(false); + range = frame->selectionRange(); + ASSERT_FALSE(range.isNull()); + EXPECT_EQ(5, range.startOffset()); + EXPECT_EQ(9, range.endOffset()); + EXPECT_EQ(WebString::fromUTF8("INPUT"), frame->document().focusedNode().nodeName()); + + // Find in a <textarea> content. + EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar3"), options, false, 0)); + // Confirm stopFinding(false) sets the selection on the found text. + frame->stopFinding(false); + range = frame->selectionRange(); + ASSERT_FALSE(range.isNull()); + EXPECT_EQ(5, range.startOffset()); + EXPECT_EQ(9, range.endOffset()); + EXPECT_EQ(WebString::fromUTF8("TEXTAREA"), frame->document().focusedNode().nodeName()); + + // Find in a contentEditable element. + EXPECT_TRUE(frame->find(findIdentifier, WebString::fromUTF8("bar4"), options, false, 0)); + // Confirm stopFinding(false) sets the selection on the found text. + frame->stopFinding(false); + range = frame->selectionRange(); + ASSERT_FALSE(range.isNull()); + EXPECT_EQ(0, range.startOffset()); + EXPECT_EQ(4, range.endOffset()); + // "bar4" is surrounded by <span>, but the focusable node should be the parent <div>. + EXPECT_EQ(WebString::fromUTF8("DIV"), frame->document().focusedNode().nodeName()); + + webView->close(); +} + } // namespace |
