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