Commit 6475c17c authored by Tao Bai's avatar Tao Bai Committed by Commit Bot

[WebView autofill] Not call cancel when WebView starts

Calling cancel() seems not neccessary when WebView first starts.
this could break the exsiting autofill session when WebView is
only for ads.

Bug: 791182
Change-Id: I7feb37f930ba1eedcab6cbeb50645d4128656fe8
Reviewed-on: https://chromium-review.googlesource.com/806319Reviewed-by: default avatarChangwan Ryu <changwan@chromium.org>
Commit-Queue: Tao Bai <michaelbai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522302}
parent 29756f9c
......@@ -352,7 +352,6 @@ public class AwAutofillProvider extends AutofillProvider {
@Override
protected void setNativeAutofillProvider(long nativeAutofillProvider) {
if (nativeAutofillProvider == mNativeAutofillProvider) return;
mNativeAutofillProvider = nativeAutofillProvider;
// Setting the mNativeAutofillProvider to 0 may occur as a
// result of WebView.destroy, or because a WebView has been
// gc'ed. In the former case we can go ahead and clean up the
......@@ -362,10 +361,9 @@ public class AwAutofillProvider extends AutofillProvider {
// possible to know which case we're in, so just catch and
// ignore the exception.
try {
reset();
if (nativeAutofillProvider == 0) {
mAutofillManager.destroy();
}
if (mNativeAutofillProvider != 0) reset();
mNativeAutofillProvider = nativeAutofillProvider;
if (nativeAutofillProvider == 0) mAutofillManager.destroy();
} catch (IllegalStateException e) {
}
}
......@@ -373,8 +371,8 @@ public class AwAutofillProvider extends AutofillProvider {
@Override
public void setWebContents(WebContents webContents) {
if (webContents == mWebContents) return;
if (mWebContents != null) reset();
mWebContents = webContents;
reset();
}
@Override
......
......@@ -538,9 +538,6 @@ public class AwAutofillTest {
int cnt = 0;
final String url = webServer.setResponse(FILE, data, null);
loadUrlSync(url);
// Note that we cancel autofill in loading as a precautious measure.
cnt += waitForCallbackAndVerifyTypes(
cnt, new Integer[] {AUTOFILL_CANCEL, AUTOFILL_CANCEL});
DOMUtils.waitForNonZeroNodeBounds(mAwContents.getWebContents(), "text1");
// Note that we currently depend on keyboard app's behavior.
// TODO(changwan): mock out IME interaction.
......@@ -586,9 +583,6 @@ public class AwAutofillTest {
final String url = webServer.setResponse(FILE, data, null);
loadUrlSync(url);
executeJavaScriptAndWaitForResult("document.getElementById('text1').select();");
// Note that we cancel autofill in loading as a precautious measure.
cnt += waitForCallbackAndVerifyTypes(
cnt, new Integer[] {AUTOFILL_CANCEL, AUTOFILL_CANCEL});
dispatchDownAndUpKeyEvents(KeyEvent.KEYCODE_A);
// Note that we currently call ENTER/EXIT one more time.
cnt += waitForCallbackAndVerifyTypes(cnt,
......@@ -703,10 +697,6 @@ public class AwAutofillTest {
loadUrlSync(url);
int cnt = 0;
executeJavaScriptAndWaitForResult("document.getElementById('text1').select();");
// Note that we cancel autofill in loading as a precautious measure.
cnt += waitForCallbackAndVerifyTypes(
cnt, new Integer[] {AUTOFILL_CANCEL, AUTOFILL_CANCEL});
dispatchDownAndUpKeyEvents(KeyEvent.KEYCODE_A);
// Note that we currently call ENTER/EXIT one more time.
......@@ -749,9 +739,6 @@ public class AwAutofillTest {
loadUrlSync(url);
int cnt = 0;
executeJavaScriptAndWaitForResult("document.getElementById('text1').select();");
// Note that we cancel autofill in loading as a precautious measure.
cnt += waitForCallbackAndVerifyTypes(
cnt, new Integer[] {AUTOFILL_CANCEL, AUTOFILL_CANCEL});
dispatchDownAndUpKeyEvents(KeyEvent.KEYCODE_A);
// Note that we currently call ENTER/EXIT one more time.
cnt += waitForCallbackAndVerifyTypes(cnt,
......@@ -762,7 +749,7 @@ public class AwAutofillTest {
assertEquals(1, values.size());
assertEquals("a", values.get(0).second.getTextValue());
executeJavaScriptAndWaitForResult("document.getElementById('text1').value='c';");
assertEquals(7, getCallbackCount());
assertEquals(5, getCallbackCount());
dispatchDownAndUpKeyEvents(KeyEvent.KEYCODE_B);
// Check if NotifyVirtualValueChanged() called one more time and value is 'cb', this
// means javascript change didn't trigger the NotifyVirtualValueChanged().
......@@ -796,9 +783,6 @@ public class AwAutofillTest {
loadUrlSync(url);
int cnt = 0;
executeJavaScriptAndWaitForResult("document.getElementById('text1').select();");
// Note that we cancel autofill in loading as a precautious measure.
cnt += waitForCallbackAndVerifyTypes(
cnt, new Integer[] {AUTOFILL_CANCEL, AUTOFILL_CANCEL});
dispatchDownAndUpKeyEvents(KeyEvent.KEYCODE_A);
// Note that we currently call ENTER/EXIT one more time.
cnt += waitForCallbackAndVerifyTypes(cnt,
......@@ -836,8 +820,6 @@ public class AwAutofillTest {
int cnt = 0;
loadUrlSync(FILE_URL);
executeJavaScriptAndWaitForResult("document.getElementById('text1').select();");
// Note that we cancel autofill in loading as a precautious measure.
cnt += waitForCallbackAndVerifyTypes(cnt, new Integer[] {AUTOFILL_CANCEL, AUTOFILL_CANCEL});
dispatchDownAndUpKeyEvents(KeyEvent.KEYCODE_A);
// Cancel called for the first query.
// Note that we currently call ENTER/EXIT one more time.
......@@ -866,9 +848,6 @@ public class AwAutofillTest {
final String url = webServer.setResponse(FILE, data, null);
loadUrlSync(url);
executeJavaScriptAndWaitForResult("document.getElementById('text1').select();");
// Note that we cancel autofill in loading as a precautious measure.
cnt += waitForCallbackAndVerifyTypes(
cnt, new Integer[] {AUTOFILL_CANCEL, AUTOFILL_CANCEL});
dispatchDownAndUpKeyEvents(KeyEvent.KEYCODE_A);
// Note that we currently call ENTER/EXIT one more time.
cnt += waitForCallbackAndVerifyTypes(cnt,
......
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