summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill/autofill_browsertest.cc
diff options
context:
space:
mode:
authorcsharp@chromium.org <csharp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-08 19:53:29 +0000
committercsharp@chromium.org <csharp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-08 19:53:29 +0000
commitca3d027fb89bad134872a328f6f0324035fe7cf5 (patch)
treed1d10d6d3c5e4786ee5c53789b77de8d301a626c /chrome/browser/autofill/autofill_browsertest.cc
parent8e2a392b2c1f5450a25e2df51d29ab75557f4d68 (diff)
downloadchromium_src-ca3d027fb89bad134872a328f6f0324035fe7cf5.zip
chromium_src-ca3d027fb89bad134872a328f6f0324035fe7cf5.tar.gz
chromium_src-ca3d027fb89bad134872a328f6f0324035fe7cf5.tar.bz2
[Autofill] Enable Autofill Tests and Make UI Tests.
The source of the flaky Autofill tests seems to be fixed, so renable the tests and make them interactive UI tests (since they require they window to have focus when showing the popup). BUG=150084 Review URL: https://chromiumcodereview.appspot.com/22267009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@216429 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill/autofill_browsertest.cc')
-rw-r--r--chrome/browser/autofill/autofill_browsertest.cc1004
1 files changed, 0 insertions, 1004 deletions
diff --git a/chrome/browser/autofill/autofill_browsertest.cc b/chrome/browser/autofill/autofill_browsertest.cc
index b1cda4b..4498d2d 100644
--- a/chrome/browser/autofill/autofill_browsertest.cc
+++ b/chrome/browser/autofill/autofill_browsertest.cc
@@ -20,8 +20,6 @@
#include "chrome/browser/infobars/confirm_infobar_delegate.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/translate/translate_infobar_delegate.h"
-#include "chrome/browser/translate/translate_manager.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
@@ -31,9 +29,6 @@
#include "chrome/test/base/ui_test_utils.h"
#include "components/autofill/content/browser/autofill_driver_impl.h"
#include "components/autofill/core/browser/autofill_common_test.h"
-#include "components/autofill/core/browser/autofill_external_delegate.h"
-#include "components/autofill/core/browser/autofill_manager.h"
-#include "components/autofill/core/browser/autofill_manager_test_delegate.h"
#include "components/autofill/core/browser/autofill_profile.h"
#include "components/autofill/core/browser/credit_card.h"
#include "components/autofill/core/browser/personal_data_manager.h"
@@ -55,69 +50,6 @@
namespace autofill {
-static const char* kDataURIPrefix = "data:text/html;charset=utf-8,";
-static const char* kTestFormString =
- "<form action=\"http://www.example.com/\" method=\"POST\">"
- "<label for=\"firstname\">First name:</label>"
- " <input type=\"text\" id=\"firstname\""
- " onFocus=\"domAutomationController.send(true)\"><br>"
- "<label for=\"lastname\">Last name:</label>"
- " <input type=\"text\" id=\"lastname\"><br>"
- "<label for=\"address1\">Address line 1:</label>"
- " <input type=\"text\" id=\"address1\"><br>"
- "<label for=\"address2\">Address line 2:</label>"
- " <input type=\"text\" id=\"address2\"><br>"
- "<label for=\"city\">City:</label>"
- " <input type=\"text\" id=\"city\"><br>"
- "<label for=\"state\">State:</label>"
- " <select id=\"state\">"
- " <option value=\"\" selected=\"yes\">--</option>"
- " <option value=\"CA\">California</option>"
- " <option value=\"TX\">Texas</option>"
- " </select><br>"
- "<label for=\"zip\">ZIP code:</label>"
- " <input type=\"text\" id=\"zip\"><br>"
- "<label for=\"country\">Country:</label>"
- " <select id=\"country\">"
- " <option value=\"\" selected=\"yes\">--</option>"
- " <option value=\"CA\">Canada</option>"
- " <option value=\"US\">United States</option>"
- " </select><br>"
- "<label for=\"phone\">Phone number:</label>"
- " <input type=\"text\" id=\"phone\"><br>"
- "</form>";
-
-class AutofillManagerTestDelegateImpl
- : public autofill::AutofillManagerTestDelegate {
- public:
- AutofillManagerTestDelegateImpl() {}
-
- virtual void DidPreviewFormData() OVERRIDE {
- loop_runner_->Quit();
- }
-
- virtual void DidFillFormData() OVERRIDE {
- loop_runner_->Quit();
- }
-
- virtual void DidShowSuggestions() OVERRIDE {
- loop_runner_->Quit();
- }
-
- void Reset() {
- loop_runner_ = new content::MessageLoopRunner();
- }
-
- void Wait() {
- loop_runner_->Run();
- }
-
- private:
- scoped_refptr<content::MessageLoopRunner> loop_runner_;
-
- DISALLOW_COPY_AND_ASSIGN(AutofillManagerTestDelegateImpl);
-};
-
class WindowedPersonalDataManagerObserver
: public PersonalDataManagerObserver,
public content::NotificationObserver {
@@ -181,39 +113,6 @@ class WindowedPersonalDataManagerObserver
InfoBarService* infobar_service_;
};
-class TestAutofillExternalDelegate : public AutofillExternalDelegate {
- public:
- TestAutofillExternalDelegate(content::WebContents* web_contents,
- AutofillManager* autofill_manager,
- AutofillDriver* autofill_driver)
- : AutofillExternalDelegate(web_contents, autofill_manager,
- autofill_driver),
- keyboard_listener_(NULL) {
- }
- virtual ~TestAutofillExternalDelegate() {}
-
- virtual void OnPopupShown(content::KeyboardListener* listener) OVERRIDE {
- AutofillExternalDelegate::OnPopupShown(listener);
- keyboard_listener_ = listener;
- }
-
- virtual void OnPopupHidden(content::KeyboardListener* listener) OVERRIDE {
- keyboard_listener_ = NULL;
- AutofillExternalDelegate::OnPopupHidden(listener);
- }
-
- content::KeyboardListener* keyboard_listener() {
- return keyboard_listener_;
- }
-
- private:
- // The popup that is currently registered as a keyboard listener, or NULL if
- // there is none.
- content::KeyboardListener* keyboard_listener_;
-
- DISALLOW_COPY_AND_ASSIGN(TestAutofillExternalDelegate);
-};
-
class AutofillTest : public InProcessBrowserTest {
protected:
AutofillTest() {}
@@ -221,19 +120,6 @@ class AutofillTest : public InProcessBrowserTest {
virtual void SetUpOnMainThread() OVERRIDE {
// Don't want Keychain coming up on Mac.
test::DisableSystemServices(browser()->profile());
-
- // When testing the native UI, hook up a test external delegate, which
- // allows us to forward keyboard events to the popup directly.
- content::WebContents* web_contents =
- browser()->tab_strip_model()->GetActiveWebContents();
- AutofillDriverImpl* autofill_driver =
- AutofillDriverImpl::FromWebContents(web_contents);
- AutofillManager* autofill_manager = autofill_driver->autofill_manager();
- scoped_ptr<AutofillExternalDelegate> external_delegate(
- new TestAutofillExternalDelegate(web_contents, autofill_manager,
- autofill_driver));
- autofill_driver->SetAutofillExternalDelegate(external_delegate.Pass());
- autofill_manager->SetTestDelegate(&test_delegate_);
}
virtual void CleanUpOnMainThread() OVERRIDE {
@@ -249,21 +135,6 @@ class AutofillTest : public InProcessBrowserTest {
return PersonalDataManagerFactory::GetForProfile(browser()->profile());
}
- void CreateTestProfile() {
- AutofillProfile profile;
- test::SetProfileInfo(
- &profile, "Milton", "C.", "Waddams",
- "red.swingline@initech.com", "Initech", "4120 Freidrich Lane",
- "Basement", "Austin", "Texas", "78744", "US", "5125551234");
-
- WindowedPersonalDataManagerObserver observer(browser());
- personal_data_manager()->AddProfile(profile);
-
- // AddProfile is asynchronous. Wait for it to finish before continuing the
- // tests.
- observer.Wait();
- }
-
void SetProfiles(std::vector<AutofillProfile>* profiles) {
WindowedPersonalDataManagerObserver observer(browser());
personal_data_manager()->SetProfiles(profiles);
@@ -319,18 +190,6 @@ class AutofillTest : public InProcessBrowserTest {
FillFormAndSubmit("autofill_creditcard_form.html", data);
}
- // Populates a webpage form using autofill data and keypress events.
- // This function focuses the specified input field in the form, and then
- // sends keypress events to the tab to cause the form to be populated.
- void PopulateForm(const std::string& field_id) {
- std::string js("document.getElementById('" + field_id + "').focus();");
- ASSERT_TRUE(content::ExecuteScript(render_view_host(), js));
-
- SendKeyToPageAndWait(ui::VKEY_DOWN);
- SendKeyToPopupAndWait(ui::VKEY_DOWN);
- SendKeyToPopupAndWait(ui::VKEY_RETURN);
- }
-
// Aggregate profiles from forms into Autofill preferences. Returns the number
// of parsed profiles.
int AggregateProfilesIntoAutofillPrefs(const std::string& filename) {
@@ -387,65 +246,6 @@ class AutofillTest : public InProcessBrowserTest {
GetRenderViewHost();
}
- void SimulateURLFetch(bool success) {
- net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0);
- ASSERT_TRUE(fetcher);
- net::URLRequestStatus status;
- status.set_status(success ? net::URLRequestStatus::SUCCESS :
- net::URLRequestStatus::FAILED);
-
- std::string script = " var google = {};"
- "google.translate = (function() {"
- " return {"
- " TranslateService: function() {"
- " return {"
- " isAvailable : function() {"
- " return true;"
- " },"
- " restore : function() {"
- " return;"
- " },"
- " getDetectedLanguage : function() {"
- " return \"ja\";"
- " },"
- " translatePage : function(originalLang, targetLang,"
- " onTranslateProgress) {"
- " document.getElementsByTagName(\"body\")[0].innerHTML = '" +
- std::string(kTestFormString) +
- " ';"
- " onTranslateProgress(100, true, false);"
- " }"
- " };"
- " }"
- " };"
- "})();";
-
- fetcher->set_url(fetcher->GetOriginalURL());
- fetcher->set_status(status);
- fetcher->set_response_code(success ? 200 : 500);
- fetcher->SetResponseString(script);
- fetcher->delegate()->OnURLFetchComplete(fetcher);
- }
-
- void FocusFirstNameField() {
- LOG(WARNING) << "Clicking on the tab.";
- content::SimulateMouseClick(
- browser()->tab_strip_model()->GetActiveWebContents(),
- 0,
- WebKit::WebMouseEvent::ButtonLeft);
-
- LOG(WARNING) << "Focusing the first name field.";
- bool result = false;
- ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
- render_view_host(),
- "if (document.readyState === 'complete')"
- " document.getElementById('firstname').focus();"
- "else"
- " domAutomationController.send(false);",
- &result));
- ASSERT_TRUE(result);
- }
-
void ExpectFilledTestForm() {
ExpectFieldValue("firstname", "Milton");
ExpectFieldValue("lastname", "Waddams");
@@ -458,528 +258,10 @@ class AutofillTest : public InProcessBrowserTest {
ExpectFieldValue("phone", "5125551234");
}
- void SendKeyToPageAndWait(ui::KeyboardCode key) {
- test_delegate_.Reset();
- content::SimulateKeyPress(
- browser()->tab_strip_model()->GetActiveWebContents(),
- key, false, false, false, false);
- test_delegate_.Wait();
- }
-
- void SendKeyToPopupAndWait(ui::KeyboardCode key) {
- // When testing the native UI, route popup-targeted key presses via the
- // external delegate.
- content::NativeWebKeyboardEvent event;
- event.windowsKeyCode = key;
- test_delegate_.Reset();
- external_delegate()->keyboard_listener()->HandleKeyPressEvent(event);
- test_delegate_.Wait();
- }
-
- void TryBasicFormFill() {
- FocusFirstNameField();
-
- // Start filling the first name field with "M" and wait for the popup to be
- // shown.
- LOG(WARNING) << "Typing 'M' to bring up the Autofill popup.";
- SendKeyToPageAndWait(ui::VKEY_M);
-
- // Press the down arrow to select the suggestion and preview the autofilled
- // form.
- LOG(WARNING) << "Simulating down arrow press to initiate Autofill preview.";
- SendKeyToPopupAndWait(ui::VKEY_DOWN);
-
- // The previewed values should not be accessible to JavaScript.
- ExpectFieldValue("firstname", "M");
- ExpectFieldValue("lastname", std::string());
- ExpectFieldValue("address1", std::string());
- ExpectFieldValue("address2", std::string());
- ExpectFieldValue("city", std::string());
- ExpectFieldValue("state", std::string());
- ExpectFieldValue("zip", std::string());
- ExpectFieldValue("country", std::string());
- ExpectFieldValue("phone", std::string());
- // TODO(isherman): It would be nice to test that the previewed values are
- // displayed: http://crbug.com/57220
-
- // Press Enter to accept the autofill suggestions.
- LOG(WARNING) << "Simulating Return press to fill the form.";
- SendKeyToPopupAndWait(ui::VKEY_RETURN);
-
- // The form should be filled.
- ExpectFilledTestForm();
- }
-
- TestAutofillExternalDelegate* external_delegate() {
- content::WebContents* web_contents =
- browser()->tab_strip_model()->GetActiveWebContents();
- AutofillDriverImpl* autofill_driver =
- AutofillDriverImpl::FromWebContents(web_contents);
- return static_cast<TestAutofillExternalDelegate*>(
- autofill_driver->autofill_external_delegate());
- }
-
- AutofillManagerTestDelegateImpl test_delegate_;
-
private:
net::TestURLFetcherFactory url_fetcher_factory_;
};
-// http://crbug.com/150084
-#if defined(OS_MACOSX)
-#define MAYBE_BasicFormFill BasicFormFill
-#else
-#define MAYBE_BasicFormFill DISABLED_BasicFormFill
-#endif
-// Test that basic form fill is working.
-IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_BasicFormFill) {
- CreateTestProfile();
-
- // Load the test page.
- ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
- GURL(std::string(kDataURIPrefix) + kTestFormString)));
-
- // Invoke Autofill.
- TryBasicFormFill();
-}
-
-// http://crbug.com/150084
-#if defined(OS_MACOSX)
-#define MAYBE_AutofillViaDownArrow AutofillViaDownArrow
-#else
-#define MAYBE_AutofillViaDownArrow DISABLED_AutofillViaDownArrow
-#endif
-// Test that form filling can be initiated by pressing the down arrow.
-IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_AutofillViaDownArrow) {
- CreateTestProfile();
-
- // Load the test page.
- ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
- GURL(std::string(kDataURIPrefix) + kTestFormString)));
-
- // Focus a fillable field.
- FocusFirstNameField();
-
- // Press the down arrow to initiate Autofill and wait for the popup to be
- // shown.
- SendKeyToPageAndWait(ui::VKEY_DOWN);
-
- // Press the down arrow to select the suggestion and preview the autofilled
- // form.
- SendKeyToPopupAndWait(ui::VKEY_DOWN);
-
- // Press Enter to accept the autofill suggestions.
- SendKeyToPopupAndWait(ui::VKEY_RETURN);
-
- // The form should be filled.
- ExpectFilledTestForm();
-}
-
-// http://crbug.com/150084
-#if defined(OS_MACOSX)
-#define MAYBE_OnChangeAfterAutofill OnChangeAfterAutofill
-#else
-#define MAYBE_OnChangeAfterAutofill DISABLED_OnChangeAfterAutofill
-#endif
-// Test that a JavaScript onchange event is fired after auto-filling a form.
-IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_OnChangeAfterAutofill) {
- CreateTestProfile();
-
- const char* kOnChangeScript =
- "<script>"
- "focused_fired = false;"
- "unfocused_fired = false;"
- "changed_select_fired = false;"
- "unchanged_select_fired = false;"
- "document.getElementById('firstname').onchange = function() {"
- " focused_fired = true;"
- "};"
- "document.getElementById('lastname').onchange = function() {"
- " unfocused_fired = true;"
- "};"
- "document.getElementById('state').onchange = function() {"
- " changed_select_fired = true;"
- "};"
- "document.getElementById('country').onchange = function() {"
- " unchanged_select_fired = true;"
- "};"
- "document.getElementById('country').value = 'US';"
- "</script>";
-
- // Load the test page.
- ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
- GURL(std::string(kDataURIPrefix) + kTestFormString + kOnChangeScript)));
-
- // Invoke Autofill.
- FocusFirstNameField();
-
- // Start filling the first name field with "M" and wait for the popup to be
- // shown.
- SendKeyToPageAndWait(ui::VKEY_M);
-
- // Press the down arrow to select the suggestion and preview the autofilled
- // form.
- SendKeyToPopupAndWait(ui::VKEY_DOWN);
-
- // Press Enter to accept the autofill suggestions.
- SendKeyToPopupAndWait(ui::VKEY_RETURN);
-
- // The form should be filled.
- ExpectFilledTestForm();
-
- // The change event should have already fired for unfocused fields, both of
- // <input> and of <select> type. However, it should not yet have fired for the
- // focused field.
- bool focused_fired = false;
- bool unfocused_fired = false;
- bool changed_select_fired = false;
- bool unchanged_select_fired = false;
- ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
- render_view_host(),
- "domAutomationController.send(focused_fired);",
- &focused_fired));
- ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
- render_view_host(),
- "domAutomationController.send(unfocused_fired);",
- &unfocused_fired));
- ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
- render_view_host(),
- "domAutomationController.send(changed_select_fired);",
- &changed_select_fired));
- ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
- render_view_host(),
- "domAutomationController.send(unchanged_select_fired);",
- &unchanged_select_fired));
- EXPECT_FALSE(focused_fired);
- EXPECT_TRUE(unfocused_fired);
- EXPECT_TRUE(changed_select_fired);
- EXPECT_FALSE(unchanged_select_fired);
-
- // Unfocus the first name field. Its change event should fire.
- ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
- render_view_host(),
- "document.getElementById('firstname').blur();"
- "domAutomationController.send(focused_fired);", &focused_fired));
- EXPECT_TRUE(focused_fired);
-}
-
-// Test that we can autofill forms distinguished only by their |id| attribute.
-// DISABLED: http://crbug.com/150084
-IN_PROC_BROWSER_TEST_F(AutofillTest, DISABLED_AutofillFormsDistinguishedById) {
- CreateTestProfile();
-
- // Load the test page.
- const std::string kURL =
- std::string(kDataURIPrefix) + kTestFormString +
- "<script>"
- "var mainForm = document.forms[0];"
- "mainForm.id = 'mainForm';"
- "var newForm = document.createElement('form');"
- "newForm.action = mainForm.action;"
- "newForm.method = mainForm.method;"
- "newForm.id = 'newForm';"
- "mainForm.parentNode.insertBefore(newForm, mainForm);"
- "</script>";
- ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), GURL(kURL)));
-
- // Invoke Autofill.
- TryBasicFormFill();
-}
-
-// Test that we properly autofill forms with repeated fields.
-// In the wild, the repeated fields are typically either email fields
-// (duplicated for "confirmation"); or variants that are hot-swapped via
-// JavaScript, with only one actually visible at any given time.
-// DISABLED: http://crbug.com/150084
-IN_PROC_BROWSER_TEST_F(AutofillTest, DISABLED_AutofillFormWithRepeatedField) {
- CreateTestProfile();
-
- // Load the test page.
- ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
- GURL(std::string(kDataURIPrefix) +
- "<form action=\"http://www.example.com/\" method=\"POST\">"
- "<label for=\"firstname\">First name:</label>"
- " <input type=\"text\" id=\"firstname\""
- " onFocus=\"domAutomationController.send(true)\"><br>"
- "<label for=\"lastname\">Last name:</label>"
- " <input type=\"text\" id=\"lastname\"><br>"
- "<label for=\"address1\">Address line 1:</label>"
- " <input type=\"text\" id=\"address1\"><br>"
- "<label for=\"address2\">Address line 2:</label>"
- " <input type=\"text\" id=\"address2\"><br>"
- "<label for=\"city\">City:</label>"
- " <input type=\"text\" id=\"city\"><br>"
- "<label for=\"state\">State:</label>"
- " <select id=\"state\">"
- " <option value=\"\" selected=\"yes\">--</option>"
- " <option value=\"CA\">California</option>"
- " <option value=\"TX\">Texas</option>"
- " </select><br>"
- "<label for=\"state_freeform\" style=\"display:none\">State:</label>"
- " <input type=\"text\" id=\"state_freeform\""
- " style=\"display:none\"><br>"
- "<label for=\"zip\">ZIP code:</label>"
- " <input type=\"text\" id=\"zip\"><br>"
- "<label for=\"country\">Country:</label>"
- " <select id=\"country\">"
- " <option value=\"\" selected=\"yes\">--</option>"
- " <option value=\"CA\">Canada</option>"
- " <option value=\"US\">United States</option>"
- " </select><br>"
- "<label for=\"phone\">Phone number:</label>"
- " <input type=\"text\" id=\"phone\"><br>"
- "</form>")));
-
- // Invoke Autofill.
- TryBasicFormFill();
- ExpectFieldValue("state_freeform", std::string());
-}
-
-// http://crbug.com/150084
-#if defined(OS_MACOSX)
-#define MAYBE_AutofillFormWithNonAutofillableField \
- AutofillFormWithNonAutofillableField
-#else
-#define MAYBE_AutofillFormWithNonAutofillableField \
- DISABLED_AutofillFormWithNonAutofillableField
-#endif
-
-// Test that we properly autofill forms with non-autofillable fields.
-IN_PROC_BROWSER_TEST_F(AutofillTest,
- MAYBE_AutofillFormWithNonAutofillableField) {
- CreateTestProfile();
-
- // Load the test page.
- ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
- GURL(std::string(kDataURIPrefix) +
- "<form action=\"http://www.example.com/\" method=\"POST\">"
- "<label for=\"firstname\">First name:</label>"
- " <input type=\"text\" id=\"firstname\""
- " onFocus=\"domAutomationController.send(true)\"><br>"
- "<label for=\"middlename\">Middle name:</label>"
- " <input type=\"text\" id=\"middlename\" autocomplete=\"off\" /><br>"
- "<label for=\"lastname\">Last name:</label>"
- " <input type=\"text\" id=\"lastname\"><br>"
- "<label for=\"address1\">Address line 1:</label>"
- " <input type=\"text\" id=\"address1\"><br>"
- "<label for=\"address2\">Address line 2:</label>"
- " <input type=\"text\" id=\"address2\"><br>"
- "<label for=\"city\">City:</label>"
- " <input type=\"text\" id=\"city\"><br>"
- "<label for=\"state\">State:</label>"
- " <select id=\"state\">"
- " <option value=\"\" selected=\"yes\">--</option>"
- " <option value=\"CA\">California</option>"
- " <option value=\"TX\">Texas</option>"
- " </select><br>"
- "<label for=\"zip\">ZIP code:</label>"
- " <input type=\"text\" id=\"zip\"><br>"
- "<label for=\"country\">Country:</label>"
- " <select id=\"country\">"
- " <option value=\"\" selected=\"yes\">--</option>"
- " <option value=\"CA\">Canada</option>"
- " <option value=\"US\">United States</option>"
- " </select><br>"
- "<label for=\"phone\">Phone number:</label>"
- " <input type=\"text\" id=\"phone\"><br>"
- "</form>")));
-
- // Invoke Autofill.
- TryBasicFormFill();
-}
-
-// Test that we can Autofill dynamically generated forms.
-// DISABLED: http://crbug.com/150084
-IN_PROC_BROWSER_TEST_F(AutofillTest, DISABLED_DynamicFormFill) {
- CreateTestProfile();
-
- // Load the test page.
- ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
- GURL(std::string(kDataURIPrefix) +
- "<form id=\"form\" action=\"http://www.example.com/\""
- " method=\"POST\"></form>"
- "<script>"
- "function AddElement(name, label) {"
- " var form = document.getElementById('form');"
- ""
- " var label_text = document.createTextNode(label);"
- " var label_element = document.createElement('label');"
- " label_element.setAttribute('for', name);"
- " label_element.appendChild(label_text);"
- " form.appendChild(label_element);"
- ""
- " if (name === 'state' || name === 'country') {"
- " var select_element = document.createElement('select');"
- " select_element.setAttribute('id', name);"
- " select_element.setAttribute('name', name);"
- ""
- " /* Add an empty selected option. */"
- " var default_option = new Option('--', '', true);"
- " select_element.appendChild(default_option);"
- ""
- " /* Add the other options. */"
- " if (name == 'state') {"
- " var option1 = new Option('California', 'CA');"
- " select_element.appendChild(option1);"
- " var option2 = new Option('Texas', 'TX');"
- " select_element.appendChild(option2);"
- " } else {"
- " var option1 = new Option('Canada', 'CA');"
- " select_element.appendChild(option1);"
- " var option2 = new Option('United States', 'US');"
- " select_element.appendChild(option2);"
- " }"
- ""
- " form.appendChild(select_element);"
- " } else {"
- " var input_element = document.createElement('input');"
- " input_element.setAttribute('id', name);"
- " input_element.setAttribute('name', name);"
- ""
- " /* Add the onFocus listener to the 'firstname' field. */"
- " if (name === 'firstname') {"
- " input_element.setAttribute("
- " 'onFocus', 'domAutomationController.send(true)');"
- " }"
- ""
- " form.appendChild(input_element);"
- " }"
- ""
- " form.appendChild(document.createElement('br'));"
- "};"
- ""
- "function BuildForm() {"
- " var elements = ["
- " ['firstname', 'First name:'],"
- " ['lastname', 'Last name:'],"
- " ['address1', 'Address line 1:'],"
- " ['address2', 'Address line 2:'],"
- " ['city', 'City:'],"
- " ['state', 'State:'],"
- " ['zip', 'ZIP code:'],"
- " ['country', 'Country:'],"
- " ['phone', 'Phone number:'],"
- " ];"
- ""
- " for (var i = 0; i < elements.length; i++) {"
- " var name = elements[i][0];"
- " var label = elements[i][1];"
- " AddElement(name, label);"
- " }"
- "};"
- "</script>")));
-
- // Dynamically construct the form.
- ASSERT_TRUE(content::ExecuteScript(render_view_host(), "BuildForm();"));
-
- // Invoke Autofill.
- TryBasicFormFill();
-}
-
-// Test that form filling works after reloading the current page.
-// This test brought to you by http://crbug.com/69204
-#if defined(OS_MACOSX)
-// Now flaky on everything but mac.
-// http://crbug.com/150084
-#define MAYBE_AutofillAfterReload AutofillAfterReload
-#else
-#define MAYBE_AutofillAfterReload DISABLED_AutofillAfterReload
-#endif
-IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_AutofillAfterReload) {
- LOG(WARNING) << "Creating test profile.";
- CreateTestProfile();
-
- // Load the test page.
- LOG(WARNING) << "Bringing browser window to front.";
- LOG(WARNING) << "Navigating to URL.";
- ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
- GURL(std::string(kDataURIPrefix) + kTestFormString)));
-
- // Reload the page.
- LOG(WARNING) << "Reloading the page.";
- content::WebContents* web_contents =
- browser()->tab_strip_model()->GetActiveWebContents();
- web_contents->GetController().Reload(false);
- content::WaitForLoadStop(web_contents);
-
- // Invoke Autofill.
- LOG(WARNING) << "Trying to fill the form.";
- TryBasicFormFill();
-}
-
-// DISABLED: http://crbug.com/150084
-IN_PROC_BROWSER_TEST_F(AutofillTest, DISABLED_AutofillAfterTranslate) {
- CreateTestProfile();
-
- GURL url(std::string(kDataURIPrefix) +
- "<form action=\"http://www.example.com/\" method=\"POST\">"
- "<label for=\"fn\">なまえ</label>"
- " <input type=\"text\" id=\"fn\""
- " onFocus=\"domAutomationController.send(true)\""
- "><br>"
- "<label for=\"ln\">みょうじ</label>"
- " <input type=\"text\" id=\"ln\"><br>"
- "<label for=\"a1\">Address line 1:</label>"
- " <input type=\"text\" id=\"a1\"><br>"
- "<label for=\"a2\">Address line 2:</label>"
- " <input type=\"text\" id=\"a2\"><br>"
- "<label for=\"ci\">City:</label>"
- " <input type=\"text\" id=\"ci\"><br>"
- "<label for=\"st\">State:</label>"
- " <select id=\"st\">"
- " <option value=\"\" selected=\"yes\">--</option>"
- " <option value=\"CA\">California</option>"
- " <option value=\"TX\">Texas</option>"
- " </select><br>"
- "<label for=\"z\">ZIP code:</label>"
- " <input type=\"text\" id=\"z\"><br>"
- "<label for=\"co\">Country:</label>"
- " <select id=\"co\">"
- " <option value=\"\" selected=\"yes\">--</option>"
- " <option value=\"CA\">Canada</option>"
- " <option value=\"US\">United States</option>"
- " </select><br>"
- "<label for=\"ph\">Phone number:</label>"
- " <input type=\"text\" id=\"ph\"><br>"
- "</form>");
- ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), url));
-
- // Get translation bar.
- LanguageDetectionDetails details;
- details.adopted_language = "ja";
- content::RenderViewHostTester::TestOnMessageReceived(
- render_view_host(),
- ChromeViewHostMsg_TranslateLanguageDetermined(0, details, true));
- TranslateInfoBarDelegate* delegate = InfoBarService::FromWebContents(
- browser()->tab_strip_model()->GetActiveWebContents())->infobar_at(0)->
- AsTranslateInfoBarDelegate();
- ASSERT_TRUE(delegate);
- EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE,
- delegate->infobar_type());
-
- // Simulate translation button press.
- delegate->Translate();
-
- // Simulate the translate script being retrieved.
- // Pass fake google.translate lib as the translate script.
- SimulateURLFetch(true);
-
- content::WindowedNotificationObserver translation_observer(
- chrome::NOTIFICATION_PAGE_TRANSLATED,
- content::NotificationService::AllSources());
-
- // Simulate translation to kick onTranslateElementLoad.
- // But right now, the call stucks here.
- // Once click the text field, it starts again.
- ASSERT_TRUE(content::ExecuteScript(
- render_view_host(), "cr.googleTranslate.onTranslateElementLoad();"));
-
- // Simulate the render notifying the translation has been done.
- translation_observer.Wait();
-
- TryBasicFormFill();
-}
-
// Test filling profiles with unicode strings and crazy characters.
// TODO(isherman): rewrite as unit test under PersonalDataManagerTest.
IN_PROC_BROWSER_TEST_F(AutofillTest, FillProfileCrazyCharacters) {
@@ -1273,52 +555,6 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, ProfilesNotAggregatedWithInvalidEmail) {
ASSERT_TRUE(personal_data_manager()->GetProfiles().empty());
}
-// http://crbug.com/150084
-#if defined(OS_MACOSX)
-#define MAYBE_ComparePhoneNumbers ComparePhoneNumbers
-#else
-#define MAYBE_ComparePhoneNumbers DISABLED_ComparePhoneNumbers
-#endif
-// Test phone fields parse correctly from a given profile.
-// The high level key presses execute the following: Select the first text
-// field, invoke the autofill popup list, select the first profile within the
-// list, and commit to the profile to populate the form.
-IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_ComparePhoneNumbers) {
- ASSERT_TRUE(test_server()->Start());
-
- AutofillProfile profile;
- profile.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Bob"));
- profile.SetRawInfo(NAME_LAST, ASCIIToUTF16("Smith"));
- profile.SetRawInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("1234 H St."));
- profile.SetRawInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("San Jose"));
- profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("CA"));
- profile.SetRawInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("95110"));
- profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("1-408-555-4567"));
- SetProfile(profile);
-
- GURL url = test_server()->GetURL("files/autofill/form_phones.html");
- ui_test_utils::NavigateToURL(browser(), url);
- PopulateForm("NAME_FIRST");
-
- ExpectFieldValue("NAME_FIRST", "Bob");
- ExpectFieldValue("NAME_LAST", "Smith");
- ExpectFieldValue("ADDRESS_HOME_LINE1", "1234 H St.");
- ExpectFieldValue("ADDRESS_HOME_CITY", "San Jose");
- ExpectFieldValue("ADDRESS_HOME_STATE", "CA");
- ExpectFieldValue("ADDRESS_HOME_ZIP", "95110");
- ExpectFieldValue("PHONE_HOME_WHOLE_NUMBER", "14085554567");
- ExpectFieldValue("PHONE_HOME_CITY_CODE-1", "408");
- ExpectFieldValue("PHONE_HOME_CITY_CODE-2", "408");
- ExpectFieldValue("PHONE_HOME_NUMBER", "5554567");
- ExpectFieldValue("PHONE_HOME_NUMBER_3-1", "555");
- ExpectFieldValue("PHONE_HOME_NUMBER_3-2", "555");
- ExpectFieldValue("PHONE_HOME_NUMBER_4-1", "4567");
- ExpectFieldValue("PHONE_HOME_NUMBER_4-2", "4567");
- ExpectFieldValue("PHONE_HOME_EXT-1", std::string());
- ExpectFieldValue("PHONE_HOME_EXT-2", std::string());
- ExpectFieldValue("PHONE_HOME_COUNTRY_CODE-1", "1");
-}
-
// Test profile is saved if phone number is valid in selected country.
// The data file contains two profiles with valid phone numbers and two
// profiles with invalid phone numbers from their respective country.
@@ -1432,129 +668,6 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, CCInfoNotStoredWhenAutocompleteOff) {
infobar_count());
}
-// http://crbug.com/150084
-#if defined(OS_MACOSX)
-#define MAYBE_NoAutofillForReadOnlyFields NoAutofillForReadOnlyFields
-#else
-#define MAYBE_NoAutofillForReadOnlyFields DISABLED_NoAutofillForReadOnlyFields
-#endif
-// Test that Autofill does not fill in read-only fields.
-IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_NoAutofillForReadOnlyFields) {
- ASSERT_TRUE(test_server()->Start());
-
- std::string addr_line1("1234 H St.");
-
- AutofillProfile profile;
- profile.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Bob"));
- profile.SetRawInfo(NAME_LAST, ASCIIToUTF16("Smith"));
- profile.SetRawInfo(EMAIL_ADDRESS, ASCIIToUTF16("bsmith@gmail.com"));
- profile.SetRawInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16(addr_line1));
- profile.SetRawInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("San Jose"));
- profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("CA"));
- profile.SetRawInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("95110"));
- profile.SetRawInfo(COMPANY_NAME, ASCIIToUTF16("Company X"));
- profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("408-871-4567"));
- SetProfile(profile);
-
- GURL url = test_server()->GetURL("files/autofill/read_only_field_test.html");
- ui_test_utils::NavigateToURL(browser(), url);
- PopulateForm("firstname");
-
- ExpectFieldValue("email", std::string());
- ExpectFieldValue("address", addr_line1);
-}
-
-// http://crbug.com/150084
-#if defined(OS_MACOSX)
-#define MAYBE_FormFillableOnReset FormFillableOnReset
-#else
-#define MAYBE_FormFillableOnReset DISABLED_FormFillableOnReset
-#endif
-// Test form is fillable from a profile after form was reset.
-// Steps:
-// 1. Fill form using a saved profile.
-// 2. Reset the form.
-// 3. Fill form using a saved profile.
-IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_FormFillableOnReset) {
- ASSERT_TRUE(test_server()->Start());
-
- CreateTestProfile();
-
- GURL url = test_server()->GetURL("files/autofill/autofill_test_form.html");
- ui_test_utils::NavigateToURL(browser(), url);
- PopulateForm("NAME_FIRST");
-
- ASSERT_TRUE(content::ExecuteScript(
- browser()->tab_strip_model()->GetActiveWebContents(),
- "document.getElementById('testform').reset()"));
-
- PopulateForm("NAME_FIRST");
-
- ExpectFieldValue("NAME_FIRST", "Milton");
- ExpectFieldValue("NAME_LAST", "Waddams");
- ExpectFieldValue("EMAIL_ADDRESS", "red.swingline@initech.com");
- ExpectFieldValue("ADDRESS_HOME_LINE1", "4120 Freidrich Lane");
- ExpectFieldValue("ADDRESS_HOME_CITY", "Austin");
- ExpectFieldValue("ADDRESS_HOME_STATE", "Texas");
- ExpectFieldValue("ADDRESS_HOME_ZIP", "78744");
- ExpectFieldValue("ADDRESS_HOME_COUNTRY", "United States");
- ExpectFieldValue("PHONE_HOME_WHOLE_NUMBER", "5125551234");
-}
-
-// http://crbug.com/150084
-#if defined(OS_MACOSX)
-#define MAYBE_DistinguishMiddleInitialWithinName \
- DistinguishMiddleInitialWithinName
-#else
-#define MAYBE_DistinguishMiddleInitialWithinName \
- DISABLED_DistinguishMiddleInitialWithinName
-#endif
-// Test Autofill distinguishes a middle initial in a name.
-IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_DistinguishMiddleInitialWithinName) {
- ASSERT_TRUE(test_server()->Start());
-
- CreateTestProfile();
-
- GURL url = test_server()->GetURL(
- "files/autofill/autofill_middleinit_form.html");
- ui_test_utils::NavigateToURL(browser(), url);
- PopulateForm("NAME_FIRST");
-
- ExpectFieldValue("NAME_MIDDLE", "C");
-}
-
-// http://crbug.com/150084
-#if defined(OS_MACOSX)
-#define MAYBE_MultipleEmailFilledByOneUserGesture \
- MultipleEmailFilledByOneUserGesture
-#else
-#define MAYBE_MultipleEmailFilledByOneUserGesture \
- DISABLED_MultipleEmailFilledByOneUserGesture
-#endif
-// Test forms with multiple email addresses are filled properly.
-// Entire form should be filled with one user gesture.
-IN_PROC_BROWSER_TEST_F(AutofillTest,
- MAYBE_MultipleEmailFilledByOneUserGesture) {
- ASSERT_TRUE(test_server()->Start());
-
- std::string email("bsmith@gmail.com");
-
- AutofillProfile profile;
- profile.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Bob"));
- profile.SetRawInfo(NAME_LAST, ASCIIToUTF16("Smith"));
- profile.SetRawInfo(EMAIL_ADDRESS, ASCIIToUTF16(email));
- profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("4088714567"));
- SetProfile(profile);
-
- GURL url = test_server()->GetURL(
- "files/autofill/autofill_confirmemail_form.html");
- ui_test_utils::NavigateToURL(browser(), url);
- PopulateForm("NAME_FIRST");
-
- ExpectFieldValue("EMAIL_CONFIRM", email);
- // TODO(isherman): verify entire form.
-}
-
// Test profile not aggregated if email found in non-email field.
IN_PROC_BROWSER_TEST_F(AutofillTest, ProfileWithEmailInOtherFieldNotSaved) {
ASSERT_TRUE(test_server()->Start());
@@ -1573,123 +686,6 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, ProfileWithEmailInOtherFieldNotSaved) {
ASSERT_EQ(0u, personal_data_manager()->GetProfiles().size());
}
-// http://crbug.com/150084
-#if defined(OS_MACOSX)
-#define MAYBE_FormFillLatencyAfterSubmit FormFillLatencyAfterSubmit
-#else
-#define MAYBE_FormFillLatencyAfterSubmit DISABLED_FormFillLatencyAfterSubmit
-#endif
-// Test latency time on form submit with lots of stored Autofill profiles.
-// This test verifies when a profile is selected from the Autofill dictionary
-// that consists of thousands of profiles, the form does not hang after being
-// submitted.
-IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_FormFillLatencyAfterSubmit) {
- ASSERT_TRUE(test_server()->Start());
-
- std::vector<std::string> cities;
- cities.push_back("San Jose");
- cities.push_back("San Francisco");
- cities.push_back("Sacramento");
- cities.push_back("Los Angeles");
-
- std::vector<std::string> streets;
- streets.push_back("St");
- streets.push_back("Ave");
- streets.push_back("Ln");
- streets.push_back("Ct");
-
- const int kNumProfiles = 1500;
- base::Time start_time = base::Time::Now();
- std::vector<AutofillProfile> profiles;
- for (int i = 0; i < kNumProfiles; i++) {
- AutofillProfile profile;
- string16 name(base::IntToString16(i));
- string16 email(name + ASCIIToUTF16("@example.com"));
- string16 street = ASCIIToUTF16(
- base::IntToString(base::RandInt(0, 10000)) + " " +
- streets[base::RandInt(0, streets.size() - 1)]);
- string16 city = ASCIIToUTF16(cities[base::RandInt(0, cities.size() - 1)]);
- string16 zip(base::IntToString16(base::RandInt(0, 10000)));
- profile.SetRawInfo(NAME_FIRST, name);
- profile.SetRawInfo(EMAIL_ADDRESS, email);
- profile.SetRawInfo(ADDRESS_HOME_LINE1, street);
- profile.SetRawInfo(ADDRESS_HOME_CITY, city);
- profile.SetRawInfo(ADDRESS_HOME_STATE, WideToUTF16(L"CA"));
- profile.SetRawInfo(ADDRESS_HOME_ZIP, zip);
- profile.SetRawInfo(ADDRESS_HOME_COUNTRY, WideToUTF16(L"US"));
- profiles.push_back(profile);
- }
- SetProfiles(&profiles);
- // TODO(isherman): once we're sure this test doesn't timeout on any bots, this
- // can be removd.
- LOG(INFO) << "Created " << kNumProfiles << " profiles in " <<
- (base::Time::Now() - start_time).InSeconds() << " seconds.";
-
- GURL url = test_server()->GetURL(
- "files/autofill/latency_after_submit_test.html");
- ui_test_utils::NavigateToURL(browser(), url);
- PopulateForm("NAME_FIRST");
-
- content::WindowedNotificationObserver load_stop_observer(
- content::NOTIFICATION_LOAD_STOP,
- content::Source<content::NavigationController>(
- &browser()->tab_strip_model()->GetActiveWebContents()->
- GetController()));
-
- ASSERT_TRUE(content::ExecuteScript(
- render_view_host(),
- "document.getElementById('testform').submit();"));
- // This will ensure the test didn't hang.
- 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();
- SendKeyToPageAndWait(ui::VKEY_M);
-
- // Now that the popup with suggestions is showing, disable autocomplete for
- // the active field.
- ASSERT_TRUE(content::ExecuteScript(
- render_view_host(),
- "document.querySelector('input').autocomplete = 'off';"));
-
- // Press the down arrow to select the suggestion and attempt to preview the
- // autofilled form.
- content::NativeWebKeyboardEvent event;
- event.windowsKeyCode = ui::VKEY_DOWN;
- external_delegate()->keyboard_listener()->HandleKeyPressEvent(event);
-
- // 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::ExecuteScriptAndExtractBool(
- render_view_host(),
- "var city = document.getElementById('city');"
- "city.onfocus = function() { domAutomationController.send(true); };"
- "city.focus()",
- &result));
- ASSERT_TRUE(result);
- SendKeyToPageAndWait(ui::VKEY_A);
-}
-
// 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