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

Unified Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

Issue 1605863002: Restart search in page when new text is found. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added default value for local var Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/web/tests/WebFrameTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
index 745754593b26a80208319da5f50690af508331e4..51d49aaa13eaad1904ad515e566172a48500c028 100644
--- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
@@ -4112,6 +4112,53 @@ TEST_P(ParameterizedWebFrameTest, SetTickmarks)
EXPECT_EQ(originalTickmarks, originalTickmarksAfterReset);
}
+TEST_P(ParameterizedWebFrameTest, FindInPageJavaScriptUpdatesDOM)
+{
+ registerMockedHttpURLLoad("find.html");
+
+ FindUpdateWebFrameClient client;
+ FrameTestHelpers::WebViewHelper webViewHelper(this);
+ webViewHelper.initializeAndLoad(m_baseURL + "find.html", true, &client);
+ webViewHelper.resize(WebSize(640, 480));
+ runPendingTasks();
+
+ WebLocalFrame* frame = webViewHelper.webView()->mainFrame()->toWebLocalFrame();
+ const int findIdentifier = 12345;
+ static const char* kFindString = "foo";
+ WebString searchText = WebString::fromUTF8(kFindString);
+ WebFindOptions options;
+ bool activeNow;
+
+ frame->resetMatchCount();
+ frame->scopeStringMatches(findIdentifier, searchText, options, true);
+ runPendingTasks();
+ EXPECT_TRUE(client.findResultsAreReady());
+
+ // Find in a <div> element.
+ options.findNext = true;
+ EXPECT_TRUE(frame->find(findIdentifier, searchText, options, false, 0, &activeNow));
+ EXPECT_TRUE(activeNow);
+
+ // Insert new text, which contains occurence of |searchText|.
+ frame->executeScript(WebScriptSource(
+ "var newTextNode = document.createTextNode('bar5 foo5');"
+ "var textArea = document.getElementsByTagName('textarea')[0];"
+ "document.body.insertBefore(newTextNode, textArea);"));
+
+ // Find in a <input> element.
+ EXPECT_TRUE(frame->find(findIdentifier, searchText, options, false, 0, &activeNow));
+ EXPECT_TRUE(activeNow);
+
+ // Find in the inserted text node.
+ EXPECT_TRUE(frame->find(findIdentifier, searchText, options, false, 0, &activeNow));
+ frame->stopFinding(false);
+ WebRange range = frame->selectionRange();
+ EXPECT_EQ(5, range.startOffset());
+ EXPECT_EQ(8, range.endOffset());
+ EXPECT_TRUE(frame->document().focusedElement().isNull());
+ EXPECT_FALSE(activeNow);
+}
+
static WebPoint topLeft(const WebRect& rect)
{
return WebPoint(rect.x, rect.y);
« no previous file with comments | « third_party/WebKit/Source/web/tests/TextFinderTest.cpp ('k') | third_party/WebKit/public/web/WebLocalFrame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698