Commit 76cae137 authored by Yi Su's avatar Yi Su Committed by Commit Bot

Add support for searching over multiple HTML Nodes in FindInPage.

This CL lets FindInPage support searching over multiple HTML Nodes, and
adds a unittest case for that.

Bug: 228585
Change-Id: Iec2715034bebb36afcf9160e2bad6c4276ca8008
Reviewed-on: https://chromium-review.googlesource.com/c/1352153
Commit-Queue: Yi Su <mrsuyi@chromium.org>
Reviewed-by: default avatarPeter Lee <pkl@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611789}
parent 62bc7e64
......@@ -244,4 +244,22 @@ TEST_F(FindInPageJsTest, SearchForWhitespace) {
AssertJavaScriptValue(kJavaScriptSpansLength, 8);
}
// Tests that FindInPage works when match results cover mutiple HTML Nodes.
TEST_F(FindInPageJsTest, SearchOverMultipleNodes) {
LoadHtml(@"<html><body>"
@"<p>xx1<span>2</span>3<a>4512345xxx12</a>34<a>5xxx12345xx</p>"
@"</body></html>");
// Assert the index and span count contain their initialized values.
AssertJavaScriptValue(kJavaScriptIndex, -1);
AssertJavaScriptValue(kJavaScriptSpansLength, 0);
// Search for "12345". Performing the search sets the index to
// point to the first visible occurrence of "12345".
NSString* result = ExecuteJavaScript(
[NSString stringWithFormat:kJavaScriptSearchCallFormat, @"12345"]);
ASSERT_TRUE(result);
AssertJavaScriptValue(kJavaScriptIndex, 0);
AssertJavaScriptValue(kJavaScriptSpansLength, 4);
}
} // namespace
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment