Commit ba11109c authored by Laís Minchillo's avatar Laís Minchillo Committed by Commit Bot

[aw] Throw exception for null String in findAllAsync

A null String shouldn't be passed to findAllAsync. This CL throws an
IllegalArgumentException so developers have an easier way debugging
(what would otherwise be a native crash).

Also add a new test in AwContentsTest.

Bug: 1014948
Change-Id: I7dd06dd4b09b3024c3f72ecbe3f227fec496fa25
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1865172Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Commit-Queue: Laís Minchillo <laisminchillo@chromium.org>
Auto-Submit: Laís Minchillo <laisminchillo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707826}
parent b86e16f9
......@@ -1623,9 +1623,11 @@ public class AwContents implements SmartClipProvider {
public void findAllAsync(String searchString) {
if (TRACE) Log.i(TAG, "%s findAllAsync", this);
if (!isDestroyed(WARN)) {
AwContentsJni.get().findAllAsync(mNativeAwContents, AwContents.this, searchString);
if (isDestroyed(WARN)) return;
if (searchString == null) {
throw new IllegalArgumentException("Search string shouldn't be null");
}
AwContentsJni.get().findAllAsync(mNativeAwContents, AwContents.this, searchString);
}
public void findNext(boolean forward) {
......
......@@ -1007,4 +1007,19 @@ public class AwContentsTest {
RecordHistogram.getHistogramValueCountForTesting(
AwContents.LOAD_URL_SCHEME_HISTOGRAM_NAME, expectedSchemeEnum));
}
@Test
@Feature({"AndroidWebView"})
@SmallTest
public void testFindAllAsyncEmptySearchString() {
AwTestContainerView testView =
mActivityTestRule.createAwTestContainerViewOnMainSync(mContentsClient);
final AwContents awContents = testView.getAwContents();
try {
awContents.findAllAsync(null);
Assert.fail("A null searchString should cause an exception to be thrown");
} catch (IllegalArgumentException e) {
// expected
}
}
}
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