| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 function AccountsOptionsWebUITest() {} | 5 function AccountsOptionsWebUITest() {} |
| 6 | 6 |
| 7 AccountsOptionsWebUITest.prototype = { | 7 AccountsOptionsWebUITest.prototype = { |
| 8 __proto__: testing.Test.prototype, | 8 __proto__: testing.Test.prototype, |
| 9 | 9 |
| 10 /** | 10 /** |
| 11 * Browse to accounts options. | 11 * Browse to accounts options. |
| 12 **/ | 12 */ |
| 13 browsePreload: 'chrome://settings-frame/accounts', | 13 browsePreload: 'chrome://settings-frame/accounts', |
| 14 }; | 14 }; |
| 15 | 15 |
| 16 function createEnterKeyboardEvent(type) { | 16 function createEnterKeyboardEvent(type) { |
| 17 return new KeyboardEvent(type, { | 17 return new KeyboardEvent(type, { |
| 18 'bubbles': true, | 18 'bubbles': true, |
| 19 'cancelable': true, | 19 'cancelable': true, |
| 20 'keyIdentifier': 'Enter' | 20 'keyIdentifier': 'Enter' |
| 21 }); | 21 }); |
| 22 } | 22 } |
| 23 | 23 |
| 24 TEST_F('AccountsOptionsWebUITest', 'testNoCloseOnEnter', function() { | 24 TEST_F('AccountsOptionsWebUITest', 'testNoCloseOnEnter', function() { |
| 25 assertEquals(this.browsePreload, document.location.href); | 25 assertEquals(this.browsePreload, document.location.href); |
| 26 | 26 |
| 27 var inputField = $('userNameEdit'); | 27 var inputField = $('userNameEdit'); |
| 28 var accountsOptionsPage = AccountsOptions.getInstance(); | 28 var accountsOptionsPage = AccountsOptions.getInstance(); |
| 29 | 29 |
| 30 // Overlay is visible. | 30 // Overlay is visible. |
| 31 assertTrue(accountsOptionsPage.visible); | 31 assertTrue(accountsOptionsPage.visible); |
| 32 | 32 |
| 33 // Simulate pressing the enter key in the edit field. | 33 // Simulate pressing the enter key in the edit field. |
| 34 inputField.dispatchEvent(createEnterKeyboardEvent('keydown')); | 34 inputField.dispatchEvent(createEnterKeyboardEvent('keydown')); |
| 35 inputField.dispatchEvent(createEnterKeyboardEvent('keypress')); | 35 inputField.dispatchEvent(createEnterKeyboardEvent('keypress')); |
| 36 inputField.dispatchEvent(createEnterKeyboardEvent('keyup')); | 36 inputField.dispatchEvent(createEnterKeyboardEvent('keyup')); |
| 37 | 37 |
| 38 // Verify the overlay is still visible. | 38 // Verify the overlay is still visible. |
| 39 assertTrue(accountsOptionsPage.visible); | 39 assertTrue(accountsOptionsPage.visible); |
| 40 }); | 40 }); |
| OLD | NEW |