| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 GEN_INCLUDE(['options_browsertest_base.js']); |
| 6 |
| 5 /** | 7 /** |
| 6 * Returns the HTML element for the |field|. | 8 * Returns the HTML element for the |field|. |
| 7 * @param {string} field The field name for the element. | 9 * @param {string} field The field name for the element. |
| 8 * @return {HTMLElement} The HTML element. | 10 * @return {HTMLElement} The HTML element. |
| 9 */ | 11 */ |
| 10 function getField(field) { | 12 function getField(field) { |
| 11 return document.querySelector( | 13 return document.querySelector( |
| 12 '#autofill-edit-address-overlay [field=' + field + ']'); | 14 '#autofill-edit-address-overlay [field=' + field + ']'); |
| 13 } | 15 } |
| 14 | 16 |
| 15 /** | 17 /** |
| 16 * Returns the size of the |list|. | 18 * Returns the size of the |list|. |
| 17 * @param {HTMLElement} list The list to check. | 19 * @param {HTMLElement} list The list to check. |
| 18 * @return {number} The size of the list. | 20 * @return {number} The size of the list. |
| 19 */ | 21 */ |
| 20 function getListSize(list) { | 22 function getListSize(list) { |
| 21 // Remove 1 for placeholder input field. | 23 // Remove 1 for placeholder input field. |
| 22 return list.items.length - 1; | 24 return list.items.length - 1; |
| 23 } | 25 } |
| 24 | 26 |
| 25 /** | 27 /** |
| 26 * TestFixture for autofill options WebUI testing. | 28 * TestFixture for autofill options WebUI testing. |
| 27 * @extends {testing.Test} | 29 * @extends {testing.Test} |
| 28 * @constructor | 30 * @constructor |
| 29 */ | 31 */ |
| 30 function AutofillOptionsWebUITest() {} | 32 function AutofillOptionsWebUITest() {} |
| 31 | 33 |
| 32 AutofillOptionsWebUITest.prototype = { | 34 AutofillOptionsWebUITest.prototype = { |
| 33 __proto__: testing.Test.prototype, | 35 __proto__: OptionsBrowsertestBase.prototype, |
| 34 | 36 |
| 35 /** | 37 /** |
| 36 * Browse to autofill options. | 38 * Browse to autofill options. |
| 39 * @override |
| 37 */ | 40 */ |
| 38 browsePreload: 'chrome://settings-frame/autofill', | 41 browsePreload: 'chrome://settings-frame/autofill', |
| 39 }; | 42 }; |
| 40 | 43 |
| 41 // Test opening the autofill options has correct location. | 44 // Test opening the autofill options has correct location. |
| 42 TEST_F('AutofillOptionsWebUITest', 'testOpenAutofillOptions', function() { | 45 TEST_F('AutofillOptionsWebUITest', 'testOpenAutofillOptions', function() { |
| 43 assertEquals(this.browsePreload, document.location.href); | 46 assertEquals(this.browsePreload, document.location.href); |
| 44 }); | 47 }); |
| 45 | 48 |
| 46 /** | 49 /** |
| 47 * TestFixture for autofill edit address overlay WebUI testing. | 50 * TestFixture for autofill edit address overlay WebUI testing. |
| 48 * @extends {testing.Test} | 51 * @extends {testing.Test} |
| 49 * @constructor | 52 * @constructor |
| 50 */ | 53 */ |
| 51 function AutofillEditAddressWebUITest() {} | 54 function AutofillEditAddressWebUITest() {} |
| 52 | 55 |
| 53 AutofillEditAddressWebUITest.prototype = { | 56 AutofillEditAddressWebUITest.prototype = { |
| 54 __proto__: testing.Test.prototype, | 57 __proto__: OptionsBrowsertestBase.prototype, |
| 55 | 58 |
| 56 /** @override */ | 59 /** @override */ |
| 57 browsePreload: 'chrome://settings-frame/autofillEditAddress', | 60 browsePreload: 'chrome://settings-frame/autofillEditAddress', |
| 58 }; | 61 }; |
| 59 | 62 |
| 60 TEST_F('AutofillEditAddressWebUITest', 'testInitialFormLayout', function() { | 63 TEST_F('AutofillEditAddressWebUITest', 'testInitialFormLayout', function() { |
| 61 assertEquals(this.browsePreload, document.location.href); | 64 assertEquals(this.browsePreload, document.location.href); |
| 62 | 65 |
| 63 assertEquals(getField('country').value, ''); | 66 assertEquals(getField('country').value, ''); |
| 64 assertEquals(0, getListSize(getField('phone'))); | 67 assertEquals(0, getListSize(getField('phone'))); |
| 65 assertEquals(0, getListSize(getField('email'))); | 68 assertEquals(0, getListSize(getField('email'))); |
| 66 assertEquals(0, getListSize(getField('fullName'))); | 69 assertEquals(0, getListSize(getField('fullName'))); |
| 67 assertEquals('', getField('city').value); | 70 assertEquals('', getField('city').value); |
| 68 | 71 |
| 69 testDone(); | 72 testDone(); |
| 70 }); | 73 }); |
| 71 | 74 |
| 72 TEST_F('AutofillEditAddressWebUITest', 'testLoadAddress', function() { | 75 TEST_F('AutofillEditAddressWebUITest', 'testLoadAddress', function() { |
| 76 // http://crbug.com/434502 |
| 77 // Accessibility failure was originally (and consistently) seen on Mac OS and |
| 78 // Chromium OS. Disabling for all OSs because of a flake in Windows. There is |
| 79 // a possibility for flake in linux too. |
| 80 this.disableAccessibilityChecks(); |
| 81 |
| 73 assertEquals(this.browsePreload, document.location.href); | 82 assertEquals(this.browsePreload, document.location.href); |
| 74 | 83 |
| 75 var testAddress = { | 84 var testAddress = { |
| 76 guid: 'GUID Value', | 85 guid: 'GUID Value', |
| 77 fullName: ['Full Name 1', 'Full Name 2'], | 86 fullName: ['Full Name 1', 'Full Name 2'], |
| 78 companyName: 'Company Name Value', | 87 companyName: 'Company Name Value', |
| 79 addrLines: 'First Line Value\nSecond Line Value', | 88 addrLines: 'First Line Value\nSecond Line Value', |
| 80 dependentLocality: 'Dependent Locality Value', | 89 dependentLocality: 'Dependent Locality Value', |
| 81 city: 'City Value', | 90 city: 'City Value', |
| 82 state: 'State Value', | 91 state: 'State Value', |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 // phoneList.blur(); | 214 // phoneList.blur(); |
| 206 // makes the result more deterministic when the test is run by itself. | 215 // makes the result more deterministic when the test is run by itself. |
| 207 // | 216 // |
| 208 // phoneList.blur() calls cr.ui.List.handleElementBlur_, which triggers | 217 // phoneList.blur() calls cr.ui.List.handleElementBlur_, which triggers |
| 209 // InlineEditableItemList.handleListFocusChange_, which sends the | 218 // InlineEditableItemList.handleListFocusChange_, which sends the |
| 210 // 'commitedit' event. | 219 // 'commitedit' event. |
| 211 phoneList.blur(); | 220 phoneList.blur(); |
| 212 phoneList.doneValidating().then(testDone); | 221 phoneList.doneValidating().then(testDone); |
| 213 }); | 222 }); |
| 214 }); | 223 }); |
| OLD | NEW |