Bug 1616842 [wpt PR 21899] - [text-fragment] Fix prefix matching edge case, a=testonly
commit58c4792f58164764a679838f5fe38d1f5644bf9e
authorDavid Bokan <bokan@chromium.org>
Fri, 21 Feb 2020 21:59:40 +0000 (21 21:59 +0000)
committermoz-wptsync-bot <wptsync@mozilla.com>
Mon, 24 Feb 2020 10:22:54 +0000 (24 10:22 +0000)
tree1bb3713e02c8c284704d08f8566a07db249245f9
parent28b609b202a3271e5fd37e42bd8db7cdf5a2a68d
Bug 1616842 [wpt PR 21899] - [text-fragment] Fix prefix matching edge case, a=testonly

Automatic update from web-platform-tests
[text-fragment] Fix prefix matching edge case

The current algorithm first finds a |prefix|, then checks if the
immediate following text is the |search_text|. If it is it'll advance
|search_start| to the end of the |search_text| so it can confirm it's
followed by the |suffix| text. However, this means that if the |suffix|
text doesn't match, the next iteration of the algorithm will start
searching for the |prefix| at the end of the |search_text|. This is a
problem if the |search_text| == |prefix| because we've now skipped the
|search_text| part of the range for prefix matching.

E.g. With prefix=foo search_text=foo suffix=bar we'll fail to match:

foo foo foo bar

Because the first iteration of the loop will use the first "foo" as
the prefix, and the next iteration will use the third "foo" as the
prefix; we skip the second.

Bug: 1054243
Change-Id: I62b8a32f89c987e5bed8ea439ae1b7d53d12436d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2065979
Reviewed-by: Nick Burris <nburris@chromium.org>
Commit-Queue: David Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743108}

--

wpt-commits: 845ce4ccd97b2ff6b39e698ce2abe7d639111ede
wpt-pr: 21899
testing/web-platform/tests/scroll-to-text-fragment/scroll-to-text-fragment-target.html
testing/web-platform/tests/scroll-to-text-fragment/scroll-to-text-fragment.html