| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import logging | 6 import logging |
| 7 import os | 7 import os |
| 8 import pickle | 8 import pickle |
| 9 import re | 9 import re |
| 10 | 10 |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 """Test Autofill does not aggregate profiles with no address info. | 258 """Test Autofill does not aggregate profiles with no address info. |
| 259 | 259 |
| 260 The minimum required address fields must be specified: First Name, | 260 The minimum required address fields must be specified: First Name, |
| 261 Last Name, Address Line 1, City, Zip Code, and State. | 261 Last Name, Address Line 1, City, Zip Code, and State. |
| 262 """ | 262 """ |
| 263 profile = {'NAME_FIRST': 'Bob', | 263 profile = {'NAME_FIRST': 'Bob', |
| 264 'NAME_LAST': 'Smith', | 264 'NAME_LAST': 'Smith', |
| 265 'EMAIL_ADDRESS': 'bsmith@example.com', | 265 'EMAIL_ADDRESS': 'bsmith@example.com', |
| 266 'COMPANY_NAME': 'Company X', | 266 'COMPANY_NAME': 'Company X', |
| 267 'ADDRESS_HOME_CITY': 'Mountain View', | 267 'ADDRESS_HOME_CITY': 'Mountain View', |
| 268 'PHONE_HOME_WHOLE_NUMBER': '650-123-4567',} | 268 'PHONE_HOME_WHOLE_NUMBER': '650-555-4567',} |
| 269 self._FillFormAndSubmit( | 269 self._FillFormAndSubmit( |
| 270 profile, 'duplicate_profiles_test.html', tab_index=0, windex=0) | 270 profile, 'duplicate_profiles_test.html', tab_index=0, windex=0) |
| 271 self.assertFalse(self.GetAutofillProfile()['profiles'], | 271 self.assertFalse(self.GetAutofillProfile()['profiles'], |
| 272 msg='Profile with no address info was aggregated.') | 272 msg='Profile with no address info was aggregated.') |
| 273 | 273 |
| 274 def testProfilesNotAggregatedWithInvalidEmail(self): | 274 def testProfilesNotAggregatedWithInvalidEmail(self): |
| 275 """Test Autofill does not aggregate profiles with an invalid email.""" | 275 """Test Autofill does not aggregate profiles with an invalid email.""" |
| 276 profile = {'NAME_FIRST': 'Bob', | 276 profile = {'NAME_FIRST': 'Bob', |
| 277 'NAME_LAST': 'Smith', | 277 'NAME_LAST': 'Smith', |
| 278 'EMAIL_ADDRESS': 'garbage', | 278 'EMAIL_ADDRESS': 'garbage', |
| 279 'ADDRESS_HOME_LINE1': '1234 H St.', | 279 'ADDRESS_HOME_LINE1': '1234 H St.', |
| 280 'ADDRESS_HOME_CITY': 'San Jose', | 280 'ADDRESS_HOME_CITY': 'San Jose', |
| 281 'ADDRESS_HOME_STATE': 'CA', | 281 'ADDRESS_HOME_STATE': 'CA', |
| 282 'ADDRESS_HOME_ZIP': '95110', | 282 'ADDRESS_HOME_ZIP': '95110', |
| 283 'COMPANY_NAME': 'Company X', | 283 'COMPANY_NAME': 'Company X', |
| 284 'PHONE_HOME_WHOLE_NUMBER': '408-123-4567',} | 284 'PHONE_HOME_WHOLE_NUMBER': '408-871-4567',} |
| 285 self._FillFormAndSubmit( | 285 self._FillFormAndSubmit( |
| 286 profile, 'duplicate_profiles_test.html', tab_index=0, windex=0) | 286 profile, 'duplicate_profiles_test.html', tab_index=0, windex=0) |
| 287 self.assertFalse(self.GetAutofillProfile()['profiles'], | 287 self.assertFalse(self.GetAutofillProfile()['profiles'], |
| 288 msg='Profile with invalid email was aggregated.') | 288 msg='Profile with invalid email was aggregated.') |
| 289 | 289 |
| 290 def testComparePhoneNumbers(self): | 290 def testComparePhoneNumbers(self): |
| 291 """Test phone fields parse correctly from a given profile. | 291 """Test phone fields parse correctly from a given profile. |
| 292 | 292 |
| 293 The high level key presses execute the following: Select the first text | 293 The high level key presses execute the following: Select the first text |
| 294 field, invoke the autofill popup list, select the first profile within the | 294 field, invoke the autofill popup list, select the first profile within the |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 def testNoAutofillForReadOnlyFields(self): | 344 def testNoAutofillForReadOnlyFields(self): |
| 345 """Test that Autofill does not fill in read-only fields.""" | 345 """Test that Autofill does not fill in read-only fields.""" |
| 346 profile = {'NAME_FIRST': 'Bob', | 346 profile = {'NAME_FIRST': 'Bob', |
| 347 'NAME_LAST': 'Smith', | 347 'NAME_LAST': 'Smith', |
| 348 'EMAIL_ADDRESS': 'bsmith@gmail.com', | 348 'EMAIL_ADDRESS': 'bsmith@gmail.com', |
| 349 'ADDRESS_HOME_LINE1': '1234 H St.', | 349 'ADDRESS_HOME_LINE1': '1234 H St.', |
| 350 'ADDRESS_HOME_CITY': 'San Jose', | 350 'ADDRESS_HOME_CITY': 'San Jose', |
| 351 'ADDRESS_HOME_STATE': 'CA', | 351 'ADDRESS_HOME_STATE': 'CA', |
| 352 'ADDRESS_HOME_ZIP': '95110', | 352 'ADDRESS_HOME_ZIP': '95110', |
| 353 'COMPANY_NAME': 'Company X', | 353 'COMPANY_NAME': 'Company X', |
| 354 'PHONE_HOME_WHOLE_NUMBER': '408-123-4567',} | 354 'PHONE_HOME_WHOLE_NUMBER': '408-871-4567',} |
| 355 | 355 |
| 356 self.FillAutofillProfile(profiles=[profile]) | 356 self.FillAutofillProfile(profiles=[profile]) |
| 357 url = self.GetHttpURLForDataPath( | 357 url = self.GetHttpURLForDataPath( |
| 358 'autofill', 'functional', 'read_only_field_test.html') | 358 'autofill', 'functional', 'read_only_field_test.html') |
| 359 self.NavigateToURL(url) | 359 self.NavigateToURL(url) |
| 360 self.assertTrue(self.AutofillPopulateForm('firstname'), | 360 self.assertTrue(self.AutofillPopulateForm('firstname'), |
| 361 msg='Autofill form could not be populated.') | 361 msg='Autofill form could not be populated.') |
| 362 js_return_readonly_field = ( | 362 js_return_readonly_field = ( |
| 363 'var field_value = document.getElementById("email").value;' | 363 'var field_value = document.getElementById("email").value;' |
| 364 'window.domAutomationController.send(field_value);') | 364 'window.domAutomationController.send(field_value);') |
| (...skipping 18 matching lines...) Expand all Loading... |
| 383 Steps: | 383 Steps: |
| 384 1. Fill form using a saved profile. | 384 1. Fill form using a saved profile. |
| 385 2. Reset the form. | 385 2. Reset the form. |
| 386 3. Fill form using a saved profile. | 386 3. Fill form using a saved profile. |
| 387 """ | 387 """ |
| 388 profile = {'NAME_FIRST': 'Bob', | 388 profile = {'NAME_FIRST': 'Bob', |
| 389 'NAME_LAST': 'Smith', | 389 'NAME_LAST': 'Smith', |
| 390 'EMAIL_ADDRESS': 'bsmith@gmail.com', | 390 'EMAIL_ADDRESS': 'bsmith@gmail.com', |
| 391 'ADDRESS_HOME_LINE1': '1234 H St.', | 391 'ADDRESS_HOME_LINE1': '1234 H St.', |
| 392 'ADDRESS_HOME_CITY': 'San Jose', | 392 'ADDRESS_HOME_CITY': 'San Jose', |
| 393 'PHONE_HOME_WHOLE_NUMBER': '4081234567',} | 393 'PHONE_HOME_WHOLE_NUMBER': '4088714567',} |
| 394 | 394 |
| 395 self.FillAutofillProfile(profiles=[profile]) | 395 self.FillAutofillProfile(profiles=[profile]) |
| 396 url = self.GetHttpURLForDataPath( | 396 url = self.GetHttpURLForDataPath( |
| 397 'autofill', 'functional', 'autofill_test_form.html') | 397 'autofill', 'functional', 'autofill_test_form.html') |
| 398 self.NavigateToURL(url) | 398 self.NavigateToURL(url) |
| 399 # Fill form using an address profile. | 399 # Fill form using an address profile. |
| 400 self.assertTrue(self.AutofillPopulateForm('NAME_FIRST'), | 400 self.assertTrue(self.AutofillPopulateForm('NAME_FIRST'), |
| 401 msg='Autofill form could not be populated.') | 401 msg='Autofill form could not be populated.') |
| 402 # Reset the form. | 402 # Reset the form. |
| 403 self.ExecuteJavascript('document.getElementById("testform").reset();' | 403 self.ExecuteJavascript('document.getElementById("testform").reset();' |
| (...skipping 18 matching lines...) Expand all Loading... |
| 422 key, value, form_values[key]))) | 422 key, value, form_values[key]))) |
| 423 | 423 |
| 424 def testDistinguishMiddleInitialWithinName(self): | 424 def testDistinguishMiddleInitialWithinName(self): |
| 425 """Test Autofill distinguishes a middle initial in a name.""" | 425 """Test Autofill distinguishes a middle initial in a name.""" |
| 426 profile = {'NAME_FIRST': 'Bob', | 426 profile = {'NAME_FIRST': 'Bob', |
| 427 'NAME_MIDDLE': 'Leo', | 427 'NAME_MIDDLE': 'Leo', |
| 428 'NAME_LAST': 'Smith', | 428 'NAME_LAST': 'Smith', |
| 429 'EMAIL_ADDRESS': 'bsmith@gmail.com', | 429 'EMAIL_ADDRESS': 'bsmith@gmail.com', |
| 430 'ADDRESS_HOME_LINE1': '1234 H St.', | 430 'ADDRESS_HOME_LINE1': '1234 H St.', |
| 431 'ADDRESS_HOME_CITY': 'San Jose', | 431 'ADDRESS_HOME_CITY': 'San Jose', |
| 432 'PHONE_HOME_WHOLE_NUMBER': '4081234567',} | 432 'PHONE_HOME_WHOLE_NUMBER': '4088714567',} |
| 433 | 433 |
| 434 middle_initial = profile['NAME_MIDDLE'][0] | 434 middle_initial = profile['NAME_MIDDLE'][0] |
| 435 self.FillAutofillProfile(profiles=[profile]) | 435 self.FillAutofillProfile(profiles=[profile]) |
| 436 url = self.GetHttpURLForDataPath( | 436 url = self.GetHttpURLForDataPath( |
| 437 'autofill', 'functional', 'autofill_middleinit_form.html') | 437 'autofill', 'functional', 'autofill_middleinit_form.html') |
| 438 self.NavigateToURL(url) | 438 self.NavigateToURL(url) |
| 439 # Fill form using an address profile. | 439 # Fill form using an address profile. |
| 440 self.assertTrue(self.AutofillPopulateForm('NAME_FIRST'), | 440 self.assertTrue(self.AutofillPopulateForm('NAME_FIRST'), |
| 441 msg='Autofill form could not be populated.') | 441 msg='Autofill form could not be populated.') |
| 442 js_return_middleinit_field = ( | 442 js_return_middleinit_field = ( |
| 443 'var field_value = document.getElementById("NAME_MIDDLE").value;' | 443 'var field_value = document.getElementById("NAME_MIDDLE").value;' |
| 444 'window.domAutomationController.send(field_value);') | 444 'window.domAutomationController.send(field_value);') |
| 445 middleinit_field_value = self.ExecuteJavascript( | 445 middleinit_field_value = self.ExecuteJavascript( |
| 446 js_return_middleinit_field, 0, 0) | 446 js_return_middleinit_field, 0, 0) |
| 447 self.assertEqual(middleinit_field_value, middle_initial, | 447 self.assertEqual(middleinit_field_value, middle_initial, |
| 448 msg=('Middle initial "%s" not distinguished from "%s".' % | 448 msg=('Middle initial "%s" not distinguished from "%s".' % |
| 449 (middleinit_field_value, profile['NAME_MIDDLE']))) | 449 (middleinit_field_value, profile['NAME_MIDDLE']))) |
| 450 | 450 |
| 451 def testMultipleEmailFilledByOneUserGesture(self): | 451 def testMultipleEmailFilledByOneUserGesture(self): |
| 452 """Test forms with multiple email addresses are filled properly. | 452 """Test forms with multiple email addresses are filled properly. |
| 453 | 453 |
| 454 Entire form should be filled with one user gesture. | 454 Entire form should be filled with one user gesture. |
| 455 """ | 455 """ |
| 456 profile = {'NAME_FIRST': 'Bob', | 456 profile = {'NAME_FIRST': 'Bob', |
| 457 'NAME_LAST': 'Smith', | 457 'NAME_LAST': 'Smith', |
| 458 'EMAIL_ADDRESS': 'bsmith@gmail.com', | 458 'EMAIL_ADDRESS': 'bsmith@gmail.com', |
| 459 'PHONE_HOME_WHOLE_NUMBER': '4081234567',} | 459 'PHONE_HOME_WHOLE_NUMBER': '4088714567',} |
| 460 | 460 |
| 461 self.FillAutofillProfile(profiles=[profile]) | 461 self.FillAutofillProfile(profiles=[profile]) |
| 462 url = self.GetHttpURLForDataPath( | 462 url = self.GetHttpURLForDataPath( |
| 463 'autofill', 'functional', 'autofill_confirmemail_form.html') | 463 'autofill', 'functional', 'autofill_confirmemail_form.html') |
| 464 self.NavigateToURL(url) | 464 self.NavigateToURL(url) |
| 465 # Fill form using an address profile. | 465 # Fill form using an address profile. |
| 466 self.assertTrue(self.AutofillPopulateForm('NAME_FIRST'), | 466 self.assertTrue(self.AutofillPopulateForm('NAME_FIRST'), |
| 467 msg='Autofill form could not be populated.') | 467 msg='Autofill form could not be populated.') |
| 468 js_return_confirmemail_field = ( | 468 js_return_confirmemail_field = ( |
| 469 'var field_value = document.getElementById("EMAIL_CONFIRM").value;' | 469 'var field_value = document.getElementById("EMAIL_CONFIRM").value;' |
| 470 'window.domAutomationController.send(field_value);') | 470 'window.domAutomationController.send(field_value);') |
| 471 confirmemail_field_value = self.ExecuteJavascript( | 471 confirmemail_field_value = self.ExecuteJavascript( |
| 472 js_return_confirmemail_field, 0, 0) | 472 js_return_confirmemail_field, 0, 0) |
| 473 self.assertEqual(confirmemail_field_value, profile['EMAIL_ADDRESS'], | 473 self.assertEqual(confirmemail_field_value, profile['EMAIL_ADDRESS'], |
| 474 msg=('Confirmation Email address "%s" not equal to Email\n' | 474 msg=('Confirmation Email address "%s" not equal to Email\n' |
| 475 'address "%s".' % (confirmemail_field_value, | 475 'address "%s".' % (confirmemail_field_value, |
| 476 profile['EMAIL_ADDRESS']))) | 476 profile['EMAIL_ADDRESS']))) |
| 477 | 477 |
| 478 def testProfileWithEmailInOtherFieldNotSaved(self): | 478 def testProfileWithEmailInOtherFieldNotSaved(self): |
| 479 """Test profile not aggregated if email found in non-email field.""" | 479 """Test profile not aggregated if email found in non-email field.""" |
| 480 profile = {'NAME_FIRST': 'Bob', | 480 profile = {'NAME_FIRST': 'Bob', |
| 481 'NAME_LAST': 'Smith', | 481 'NAME_LAST': 'Smith', |
| 482 'ADDRESS_HOME_LINE1': 'bsmith@gmail.com', | 482 'ADDRESS_HOME_LINE1': 'bsmith@gmail.com', |
| 483 'ADDRESS_HOME_CITY': 'San Jose', | 483 'ADDRESS_HOME_CITY': 'San Jose', |
| 484 'ADDRESS_HOME_STATE': 'CA', | 484 'ADDRESS_HOME_STATE': 'CA', |
| 485 'ADDRESS_HOME_ZIP': '95110', | 485 'ADDRESS_HOME_ZIP': '95110', |
| 486 'COMPANY_NAME': 'Company X', | 486 'COMPANY_NAME': 'Company X', |
| 487 'PHONE_HOME_WHOLE_NUMBER': '408-123-4567',} | 487 'PHONE_HOME_WHOLE_NUMBER': '408-871-4567',} |
| 488 self._FillFormAndSubmit( | 488 self._FillFormAndSubmit( |
| 489 profile, 'duplicate_profiles_test.html', tab_index=0, windex=0) | 489 profile, 'duplicate_profiles_test.html', tab_index=0, windex=0) |
| 490 self.assertFalse(self.GetAutofillProfile()['profiles'], | 490 self.assertFalse(self.GetAutofillProfile()['profiles'], |
| 491 msg='Profile with email in a non-email field was ' | 491 msg='Profile with email in a non-email field was ' |
| 492 'aggregated.') | 492 'aggregated.') |
| 493 | 493 |
| 494 def FormFillLatencyAfterSubmit(self): | 494 def FormFillLatencyAfterSubmit(self): |
| 495 """Test latency time on form submit with lots of stored Autofill profiles. | 495 """Test latency time on form submit with lots of stored Autofill profiles. |
| 496 | 496 |
| 497 This test verifies when a profile is selected from the Autofill dictionary | 497 This test verifies when a profile is selected from the Autofill dictionary |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 'window.domAutomationController.send("done");') % (key, value) | 620 'window.domAutomationController.send("done");') % (key, value) |
| 621 self.ExecuteJavascript(script, 0, 0) | 621 self.ExecuteJavascript(script, 0, 0) |
| 622 self.ExecuteJavascript('document.getElementById("testform").submit();' | 622 self.ExecuteJavascript('document.getElementById("testform").submit();' |
| 623 'window.domAutomationController.send("done");', | 623 'window.domAutomationController.send("done");', |
| 624 0, 0) | 624 0, 0) |
| 625 return len(list_of_dict) | 625 return len(list_of_dict) |
| 626 | 626 |
| 627 | 627 |
| 628 if __name__ == '__main__': | 628 if __name__ == '__main__': |
| 629 pyauto_functional.Main() | 629 pyauto_functional.Main() |
| OLD | NEW |