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