diff options
author | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-27 05:18:56 +0000 |
---|---|---|
committer | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-27 05:18:56 +0000 |
commit | 2edebab0140ef46246cb53e338b0f1055ba871d7 (patch) | |
tree | 0db7386806d1bace926383f4aeda7a66c147b808 /chrome/browser/autofill | |
parent | ff72dd1d95125512b475bcaee0a4252aa057d3f2 (diff) | |
download | chromium_src-2edebab0140ef46246cb53e338b0f1055ba871d7.zip chromium_src-2edebab0140ef46246cb53e338b0f1055ba871d7.tar.gz chromium_src-2edebab0140ef46246cb53e338b0f1055ba871d7.tar.bz2 |
[Autofill] Don't crash if autocomplete is disabled while the user is interacting with the form.
BUG=160476
TEST=browser_tests --gtest_filter=AutofillTest.DisableAutocompleteWhileFilling
Review URL: https://chromiumcodereview.appspot.com/11280138
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169588 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill')
-rw-r--r-- | chrome/browser/autofill/autofill_browsertest.cc | 52 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_manager.cc | 7 |
2 files changed, 54 insertions, 5 deletions
diff --git a/chrome/browser/autofill/autofill_browsertest.cc b/chrome/browser/autofill/autofill_browsertest.cc index d1d3f32..7d6a5b3 100644 --- a/chrome/browser/autofill/autofill_browsertest.cc +++ b/chrome/browser/autofill/autofill_browsertest.cc @@ -375,8 +375,8 @@ class AutofillTest : public InProcessBrowserTest { void SendKeyAndWait(ui::KeyboardCode key, int notification_type) { content::WindowedNotificationObserver observer( notification_type, content::Source<RenderViewHost>(render_view_host())); - content::SimulateKeyPress(chrome::GetActiveWebContents( - browser()), key, false, false, false, false); + content::SimulateKeyPress(chrome::GetActiveWebContents(browser()), + key, false, false, false, false); observer.Wait(); } @@ -1525,6 +1525,54 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_FormFillLatencyAfterSubmit) { load_stop_observer.Wait(); } +// http://crbug.com/150084 +#if defined(OS_MACOSX) +#define MAYBE_DisableAutocompleteWhileFilling DisableAutocompleteWhileFilling +#else +#define MAYBE_DisableAutocompleteWhileFilling \ + DISABLED_DisableAutocompleteWhileFilling +#endif +// Test that Chrome doesn't crash when autocomplete is disabled while the user +// is interacting with the form. This is a regression test for +// http://crbug.com/160476 +IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_DisableAutocompleteWhileFilling) { + CreateTestProfile(); + + // Load the test page. + ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), + GURL(std::string(kDataURIPrefix) + kTestFormString))); + + // Invoke Autofill: Start filling the first name field with "M" and wait for + // the popup to be shown. + FocusFirstNameField(); + SendKeyAndWait( + ui::VKEY_M, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS); + + // Now that the popup with suggestions is showing, disable autocomplete for + // the active field. + ASSERT_TRUE(content::ExecuteJavaScript( + render_view_host(), L"", + L"document.querySelector('input').autocomplete = 'off';")); + + // Press the down arrow to select the suggestion and attempt to preview the + // autofilled form. + content::SimulateKeyPress(chrome::GetActiveWebContents(browser()), + ui::VKEY_DOWN, false, false, false, false); + + // Wait for any IPCs to complete by performing an action that generates an + // IPC that's easy to wait for. Chrome shouldn't crash. + bool result = false; + ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( + render_view_host(), L"", + L"var city = document.getElementById('city');" + L"city.onfocus = function() { domAutomationController.send(true); };" + L"city.focus()", + &result)); + ASSERT_TRUE(result); + SendKeyAndWait( + ui::VKEY_A, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS); +} + // Test that profiles merge for aggregated data with same address. // The criterion for when two profiles are expected to be merged is when their // 'Address Line 1' and 'City' data match. When two profiles are merged, any diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc index 4d08afe..5d291f8 100644 --- a/chrome/browser/autofill/autofill_manager.cc +++ b/chrome/browser/autofill/autofill_manager.cc @@ -1052,9 +1052,10 @@ bool AutofillManager::GetCachedFormAndField(const FormData& form, } } - // We always update the cache, so we should be guaranteed to find the field. - DCHECK(*autofill_field); - return true; + // Even though we always update the cache, the field might not exist if the + // website disables autocomplete while the user is interacting with the form. + // See http://crbug.com/160476 + return *autofill_field != NULL; } bool AutofillManager::UpdateCachedForm(const FormData& live_form, |