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.
5 // None of these tests is relevant for Chrome OS.
6 GEN('#if !defined(OS_CHROMEOS)');
9 * TestFixture for ManageProfileOverlay and CreateProfileOverlay WebUI testing.
10 * @extends {testing.Test}
13 function ManageProfileUITest() {}
15 ManageProfileUITest
.prototype = {
16 __proto__
: testing
.Test
.prototype,
19 browsePreload
: 'chrome://settings-frame/manageProfile',
22 * No need to run these for every OptionsPage test, since they'll cover the
23 * whole consolidated page each time.
26 runAccessibilityChecks
: false,
29 * Some default profile infos.
35 * Returns a test profile-info object with configurable "managed" status.
36 * @param {boolean} managed If true, the test profile will be marked as
38 * @return {Object} A test profile-info object.
40 testProfileInfo_: function(managed
) {
43 iconURL
: 'chrome://path/to/icon/image',
44 filePath
: '/path/to/profile/data/on/disk',
45 isCurrentProfile
: true,
51 * Overrides WebUI methods that provide profile info, making them return a
52 * test profile-info object.
53 * @param {boolean} managed Whether the test profile should be marked managed.
54 * @param {string} mode The mode of the overlay (either 'manage' or 'create').
56 setProfileManaged_: function(managed
, mode
) {
57 // Override the BrowserOptions method to return the fake info.
58 BrowserOptions
.getCurrentProfile = function() {
59 return this.testProfileInfo_(managed
);
61 // Set the profile info in the overlay.
62 ManageProfileOverlay
.setProfileInfo(this.testProfileInfo_(managed
), mode
);
66 * Set some default profile infos (icon URLs and names).
67 * @param {boolean} managed Whether the test profile should be marked managed.
68 * @param {string} mode The mode of the overlay (either 'manage' or 'create').
70 initDefaultProfiles_: function(mode
) {
71 OptionsPage
.showPageByName(mode
+ 'Profile');
73 var defaultProfile
= {
75 iconURL
: '/default/path',
77 this.defaultIconURLs
= ['/some/path',
78 defaultProfile
.iconURL
,
81 this.defaultNames
= ['Some Name', defaultProfile
.name
, '', 'Another Name'];
82 ManageProfileOverlay
.receiveDefaultProfileIconsAndNames(
83 mode
, this.defaultIconURLs
, this.defaultNames
);
84 ManageProfileOverlay
.receiveNewProfileDefaults(defaultProfile
);
86 // Make sure the correct item in the icon grid was selected.
87 var gridEl
= $(mode
+ '-profile-icon-grid');
88 expectEquals(defaultProfile
.iconURL
, gridEl
.selectedItem
);
92 // Receiving the new profile defaults in the manage-user overlay shouldn't mess
93 // up the focus in a visible higher-level overlay.
94 TEST_F('ManageProfileUITest', 'NewProfileDefaultsFocus', function() {
97 function checkFocus(pageName
, expectedFocus
, initialFocus
) {
98 OptionsPage
.showPageByName(pageName
);
100 expectEquals(initialFocus
, document
.activeElement
, pageName
);
102 ManageProfileOverlay
.receiveNewProfileDefaults(
103 self
.testProfileInfo_(false));
104 expectEquals(expectedFocus
, document
.activeElement
, pageName
);
105 OptionsPage
.closeOverlay();
108 // Receiving new profile defaults sets focus to the name field if the create
109 // overlay is open, and should not change focus at all otherwise.
110 checkFocus('manageProfile',
111 $('manage-profile-cancel'),
112 $('manage-profile-cancel'));
113 checkFocus('createProfile',
114 $('create-profile-name'),
115 $('create-profile-cancel'));
116 checkFocus('managedUserLearnMore',
117 $('managed-user-learn-more-done'),
118 $('managed-user-learn-more-done'));
119 checkFocus('managedUserLearnMore',
120 document
.querySelector('#managed-user-learn-more-text a'),
121 document
.querySelector('#managed-user-learn-more-text a'));
124 // The default options should be reset each time the creation overlay is shown.
125 TEST_F('ManageProfileUITest', 'DefaultCreateOptions', function() {
126 OptionsPage
.showPageByName('createProfile');
127 var shortcutsAllowed
= loadTimeData
.getBoolean('profileShortcutsEnabled');
128 var createShortcut
= $('create-shortcut');
129 var createManaged
= $('create-profile-managed');
130 assertEquals(shortcutsAllowed
, createShortcut
.checked
);
131 assertFalse(createManaged
.checked
);
133 createShortcut
.checked
= !shortcutsAllowed
;
134 createManaged
.checked
= true;
135 OptionsPage
.closeOverlay();
136 OptionsPage
.showPageByName('createProfile');
137 assertEquals(shortcutsAllowed
, createShortcut
.checked
);
138 assertFalse(createManaged
.checked
);
141 // The checkbox label should change depending on whether the user is signed in.
142 TEST_F('ManageProfileUITest', 'CreateManagedUserText', function() {
143 var signedInText
= $('create-profile-managed-signed-in');
144 var notSignedInText
= $('create-profile-managed-not-signed-in');
146 ManageProfileOverlay
.getInstance().initializePage();
148 var custodianEmail
= 'chrome.playpen.test@gmail.com';
149 CreateProfileOverlay
.updateSignedInStatus(custodianEmail
);
150 assertEquals(custodianEmail
,
151 CreateProfileOverlay
.getInstance().signedInEmail_
);
152 assertFalse(signedInText
.hidden
);
153 assertTrue(notSignedInText
.hidden
);
154 // Make sure the email is in the string somewhere, without depending on the
155 // exact details of the message.
156 assertNotEquals(-1, signedInText
.textContent
.indexOf(custodianEmail
));
158 CreateProfileOverlay
.updateSignedInStatus('');
159 assertEquals('', CreateProfileOverlay
.getInstance().signedInEmail_
);
160 assertTrue(signedInText
.hidden
);
161 assertFalse(notSignedInText
.hidden
);
162 assertFalse($('create-profile-managed').checked
);
163 assertTrue($('create-profile-managed').disabled
);
166 function ManageProfileUITestAsync() {}
168 ManageProfileUITestAsync
.prototype = {
169 __proto__
: ManageProfileUITest
.prototype,
174 // The import link should show up if the user tries to create a profile with the
175 // same name as an existing managed user profile.
176 TEST_F('ManageProfileUITestAsync', 'CreateExistingManagedUser', function() {
177 // Initialize the list of existing managed users.
182 iconURL
: 'chrome://path/to/icon/image',
183 onCurrentDevice
: false,
189 iconURL
: 'chrome://path/to/icon/image',
190 onCurrentDevice
: false,
196 iconURL
: 'chrome://path/to/icon/image',
197 onCurrentDevice
: true,
203 iconURL
: 'chrome://path/to/icon/image',
204 onCurrentDevice
: false,
207 var promise
= Promise
.resolve(managedUsers
);
208 options
.ManagedUserListData
.getInstance().promise_
= promise
;
210 // Initialize the ManageProfileOverlay.
211 ManageProfileOverlay
.getInstance().initializePage();
212 var custodianEmail
= 'chrome.playpen.test@gmail.com';
213 CreateProfileOverlay
.updateSignedInStatus(custodianEmail
);
214 assertEquals(custodianEmail
,
215 CreateProfileOverlay
.getInstance().signedInEmail_
);
216 this.setProfileManaged_(false, 'create');
218 // Also add the names 'Test' and 'SameName' to |existingProfileNames_| to
219 // simulate that profiles with those names exist on the device.
220 ManageProfileOverlay
.getInstance().existingProfileNames_
.Test
= true;
221 ManageProfileOverlay
.getInstance().existingProfileNames_
.SameName
= true;
223 // Initially, the ok button should be enabled and the import link should not
225 assertFalse($('create-profile-ok').disabled
);
226 assertTrue($('supervised-user-import') == null);
228 // Now try to create profiles with the names of existing supervised users.
229 $('create-profile-managed').checked
= true;
230 var nameField
= $('create-profile-name');
231 // A profile which already has an avatar.
232 nameField
.value
= 'Rosalie';
233 ManageProfileOverlay
.getInstance().onNameChanged_('create');
234 // Need to wait until the promise resolves.
235 promise
.then(function() {
236 assertTrue($('create-profile-ok').disabled
);
237 assertFalse($('supervised-user-import') == null);
239 // A profile which doesn't have an avatar yet.
240 nameField
.value
= 'Fritz';
241 ManageProfileOverlay
.getInstance().onNameChanged_('create');
242 return options
.ManagedUserListData
.getInstance().promise_
;
244 assertTrue($('create-profile-ok').disabled
);
245 assertFalse($('supervised-user-import') == null);
247 // A profile which already exists on the device.
248 nameField
.value
= 'Test';
249 ManageProfileOverlay
.getInstance().onNameChanged_('create');
250 return options
.ManagedUserListData
.getInstance().promise_
;
252 assertTrue($('create-profile-ok').disabled
);
253 assertTrue($('supervised-user-import') == null);
255 // A profile which does not exist on the device, but there is a profile with
256 // the same name already on the device.
257 nameField
.value
= 'SameName';
258 ManageProfileOverlay
.getInstance().onNameChanged_('create');
259 return options
.ManagedUserListData
.getInstance().promise_
;
261 assertTrue($('create-profile-ok').disabled
);
262 assertFalse($('supervised-user-import') == null);
264 // A profile which does not exist yet.
265 nameField
.value
= 'NewProfileName';
266 ManageProfileOverlay
.getInstance().onNameChanged_('create');
267 return options
.ManagedUserListData
.getInstance().promise_
;
269 assertFalse($('create-profile-ok').disabled
);
270 assertTrue($('supervised-user-import') == null);
275 // Managed users should not be able to edit their profile names, and the initial
276 // focus should be adjusted accordingly.
277 TEST_F('ManageProfileUITest', 'EditManagedUserNameAllowed', function() {
278 var nameField
= $('manage-profile-name');
280 this.setProfileManaged_(false, 'manage');
281 ManageProfileOverlay
.showManageDialog();
282 expectFalse(nameField
.disabled
);
283 expectEquals(nameField
, document
.activeElement
);
285 OptionsPage
.closeOverlay();
287 this.setProfileManaged_(true, 'manage');
288 ManageProfileOverlay
.showManageDialog();
289 expectTrue(nameField
.disabled
);
290 expectEquals($('manage-profile-ok'), document
.activeElement
);
293 // Setting profile information should allow the confirmation to be shown.
294 TEST_F('ManageProfileUITest', 'ShowCreateConfirmation', function() {
295 var testProfile
= this.testProfileInfo_(true);
296 testProfile
.custodianEmail
= 'foo@bar.example.com';
297 ManagedUserCreateConfirmOverlay
.setProfileInfo(testProfile
);
298 assertTrue(ManagedUserCreateConfirmOverlay
.getInstance().canShowPage());
299 OptionsPage
.showPageByName('managedUserCreateConfirm', false);
300 assertEquals('managedUserCreateConfirm',
301 OptionsPage
.getTopmostVisiblePage().name
);
304 // Trying to show a confirmation dialog with no profile information should fall
305 // back to the default (main) settings page.
306 TEST_F('ManageProfileUITest', 'NoEmptyConfirmation', function() {
307 assertEquals('manageProfile', OptionsPage
.getTopmostVisiblePage().name
);
308 assertFalse(ManagedUserCreateConfirmOverlay
.getInstance().canShowPage());
309 OptionsPage
.showPageByName('managedUserCreateConfirm', true);
310 assertEquals('settings', OptionsPage
.getTopmostVisiblePage().name
);
313 // A confirmation dialog should be shown after creating a new managed user.
314 TEST_F('ManageProfileUITest', 'ShowCreateConfirmationOnSuccess', function() {
315 OptionsPage
.showPageByName('createProfile');
316 assertEquals('createProfile', OptionsPage
.getTopmostVisiblePage().name
);
317 CreateProfileOverlay
.onSuccess(this.testProfileInfo_(false));
318 assertEquals('settings', OptionsPage
.getTopmostVisiblePage().name
);
320 OptionsPage
.showPageByName('createProfile');
321 assertEquals('createProfile', OptionsPage
.getTopmostVisiblePage().name
);
322 CreateProfileOverlay
.onSuccess(this.testProfileInfo_(true));
323 assertEquals('managedUserCreateConfirm',
324 OptionsPage
.getTopmostVisiblePage().name
);
325 expectEquals($('managed-user-created-switch'), document
.activeElement
);
328 // An error should be shown if creating a new managed user fails.
329 TEST_F('ManageProfileUITest', 'NoCreateConfirmationOnError', function() {
330 OptionsPage
.showPageByName('createProfile');
331 assertEquals('createProfile', OptionsPage
.getTopmostVisiblePage().name
);
332 var errorBubble
= $('create-profile-error-bubble');
333 assertTrue(errorBubble
.hidden
);
335 CreateProfileOverlay
.onError('An Error Message!');
336 assertEquals('createProfile', OptionsPage
.getTopmostVisiblePage().name
);
337 assertFalse(errorBubble
.hidden
);
340 // The name and email should be inserted into the confirmation dialog.
341 TEST_F('ManageProfileUITest', 'CreateConfirmationText', function() {
343 var custodianEmail
= 'foo@example.com';
345 // Checks the strings in the confirmation dialog. If |expectedNameText| is
346 // given, it should be present in the dialog's textContent; otherwise the name
347 // is expected. If |expectedNameHtml| is given, it should be present in the
348 // dialog's innerHTML; otherwise the expected text is expected in the HTML
350 function checkDialog(name
, expectedNameText
, expectedNameHtml
) {
351 var expectedText
= expectedNameText
|| name
;
352 var expectedHtml
= expectedNameHtml
|| expectedText
;
354 // Configure the test profile and show the confirmation dialog.
355 var testProfile
= self
.testProfileInfo_(true);
356 testProfile
.name
= name
;
357 CreateProfileOverlay
.onSuccess(testProfile
);
358 assertEquals('managedUserCreateConfirm',
359 OptionsPage
.getTopmostVisiblePage().name
);
361 // Check for the presence of the name and email in the UI, without depending
362 // on the details of the messsages.
364 $('managed-user-created-title').textContent
.indexOf(expectedText
));
366 $('managed-user-created-switch').textContent
.indexOf(expectedText
));
367 var message
= $('managed-user-created-text');
368 assertNotEquals(-1, message
.textContent
.indexOf(expectedText
));
369 assertNotEquals(-1, message
.textContent
.indexOf(custodianEmail
));
371 // The name should be properly HTML-escaped.
372 assertNotEquals(-1, message
.innerHTML
.indexOf(expectedHtml
));
374 OptionsPage
.closeOverlay();
375 assertEquals('settings', OptionsPage
.getTopmostVisiblePage().name
, name
);
378 // Show and configure the create-profile dialog.
379 OptionsPage
.showPageByName('createProfile');
380 CreateProfileOverlay
.updateSignedInStatus(custodianEmail
);
381 assertEquals('createProfile', OptionsPage
.getTopmostVisiblePage().name
);
383 checkDialog('OneWord');
384 checkDialog('Multiple Words');
385 checkDialog('It\'s "<HTML> injection" & more!',
386 'It\'s "<HTML> injection" & more!',
387 // The innerHTML getter doesn't escape quotation marks,
388 // independent of whether they were escaped in the setter.
389 'It\'s "<HTML> injection" & more!');
391 // Test elision. MAX_LENGTH = 50, minus 1 for the ellipsis.
392 var name49Characters
= '0123456789012345678901234567890123456789012345678';
393 var name50Characters
= name49Characters
+ '9';
394 var name51Characters
= name50Characters
+ '0';
395 var name60Characters
= name51Characters
+ '123456789';
396 checkDialog(name49Characters
, name49Characters
);
397 checkDialog(name50Characters
, name50Characters
);
398 checkDialog(name51Characters
, name49Characters
+ '\u2026');
399 checkDialog(name60Characters
, name49Characters
+ '\u2026');
401 // Test both elision and HTML escaping. The allowed string length is the
402 // visible length, not the length including the entity names.
403 name49Characters
= name49Characters
.replace('0', '&').replace('1', '>');
404 name60Characters
= name60Characters
.replace('0', '&').replace('1', '>');
405 var escaped
= name49Characters
.replace('&', '&').replace('>', '>');
407 name60Characters
, name49Characters
+ '\u2026', escaped
+ '\u2026');
410 // An additional warning should be shown when deleting a managed user.
411 TEST_F('ManageProfileUITest', 'DeleteManagedUserWarning', function() {
412 var addendum
= $('delete-managed-profile-addendum');
414 ManageProfileOverlay
.showDeleteDialog(this.testProfileInfo_(true));
415 assertFalse(addendum
.hidden
);
417 ManageProfileOverlay
.showDeleteDialog(this.testProfileInfo_(false));
418 assertTrue(addendum
.hidden
);
421 // The policy prohibiting managed users should update the UI dynamically.
422 TEST_F('ManageProfileUITest', 'PolicyDynamicRefresh', function() {
423 ManageProfileOverlay
.getInstance().initializePage();
425 var custodianEmail
= 'chrome.playpen.test@gmail.com';
426 CreateProfileOverlay
.updateSignedInStatus(custodianEmail
);
427 CreateProfileOverlay
.updateManagedUsersAllowed(true);
428 var checkbox
= $('create-profile-managed');
429 var link
= $('create-profile-managed-not-signed-in-link');
430 var indicator
= $('create-profile-managed-indicator');
432 assertFalse(checkbox
.disabled
, 'allowed and signed in');
433 assertFalse(link
.hidden
, 'allowed and signed in');
434 assertEquals('none', window
.getComputedStyle(indicator
, null).display
,
435 'allowed and signed in');
437 CreateProfileOverlay
.updateSignedInStatus('');
438 CreateProfileOverlay
.updateManagedUsersAllowed(true);
439 assertTrue(checkbox
.disabled
, 'allowed, not signed in');
440 assertFalse(link
.hidden
, 'allowed, not signed in');
441 assertEquals('none', window
.getComputedStyle(indicator
, null).display
,
442 'allowed, not signed in');
444 CreateProfileOverlay
.updateSignedInStatus('');
445 CreateProfileOverlay
.updateManagedUsersAllowed(false);
446 assertTrue(checkbox
.disabled
, 'disallowed, not signed in');
447 assertTrue(link
.hidden
, 'disallowed, not signed in');
448 assertEquals('inline-block', window
.getComputedStyle(indicator
, null).display
,
449 'disallowed, not signed in');
450 assertEquals('policy', indicator
.getAttribute('controlled-by'));
452 CreateProfileOverlay
.updateSignedInStatus(custodianEmail
);
453 CreateProfileOverlay
.updateManagedUsersAllowed(false);
454 assertTrue(checkbox
.disabled
, 'disallowed, signed in');
455 assertTrue(link
.hidden
, 'disallowed, signed in');
456 assertEquals('inline-block', window
.getComputedStyle(indicator
, null).display
,
457 'disallowed, signed in');
458 assertEquals('policy', indicator
.getAttribute('controlled-by'));
460 CreateProfileOverlay
.updateSignedInStatus(custodianEmail
);
461 CreateProfileOverlay
.updateManagedUsersAllowed(true);
462 assertFalse(checkbox
.disabled
, 're-allowed and signed in');
463 assertFalse(link
.hidden
, 're-allowed and signed in');
464 assertEquals('none', window
.getComputedStyle(indicator
, null).display
,
465 're-allowed and signed in');
468 // The managed user checkbox should correctly update its state during profile
469 // creation and afterwards.
470 TEST_F('ManageProfileUITest', 'CreateInProgress', function() {
471 ManageProfileOverlay
.getInstance().initializePage();
473 var custodianEmail
= 'chrome.playpen.test@gmail.com';
474 CreateProfileOverlay
.updateSignedInStatus(custodianEmail
);
475 CreateProfileOverlay
.updateManagedUsersAllowed(true);
476 var checkbox
= $('create-profile-managed');
477 var link
= $('create-profile-managed-not-signed-in-link');
478 var indicator
= $('create-profile-managed-indicator');
480 assertFalse(checkbox
.disabled
, 'allowed and signed in');
481 assertFalse(link
.hidden
, 'allowed and signed in');
482 assertEquals('none', window
.getComputedStyle(indicator
, null).display
,
483 'allowed and signed in');
484 assertFalse(indicator
.hasAttribute('controlled-by'));
486 CreateProfileOverlay
.updateCreateInProgress(true);
487 assertTrue(checkbox
.disabled
, 'creation in progress');
489 // A no-op update to the sign-in status should not change the UI.
490 CreateProfileOverlay
.updateSignedInStatus(custodianEmail
);
491 CreateProfileOverlay
.updateManagedUsersAllowed(true);
492 assertTrue(checkbox
.disabled
, 'creation in progress');
494 CreateProfileOverlay
.updateCreateInProgress(false);
495 assertFalse(checkbox
.disabled
, 'creation finished');
498 // Managed users shouldn't be able to open the delete or create dialogs.
499 TEST_F('ManageProfileUITest', 'ManagedShowDeleteAndCreate', function() {
500 this.setProfileManaged_(false, 'create');
502 ManageProfileOverlay
.showCreateDialog();
503 assertEquals('createProfile', OptionsPage
.getTopmostVisiblePage().name
);
504 OptionsPage
.closeOverlay();
505 assertEquals('settings', OptionsPage
.getTopmostVisiblePage().name
);
506 ManageProfileOverlay
.showDeleteDialog(this.testProfileInfo_(false));
507 assertEquals('manageProfile', OptionsPage
.getTopmostVisiblePage().name
);
508 assertFalse($('manage-profile-overlay-delete').hidden
);
509 OptionsPage
.closeOverlay();
510 assertEquals('settings', OptionsPage
.getTopmostVisiblePage().name
);
512 this.setProfileManaged_(true, 'create');
513 ManageProfileOverlay
.showCreateDialog();
514 assertEquals('settings', OptionsPage
.getTopmostVisiblePage().name
);
515 ManageProfileOverlay
.showDeleteDialog(this.testProfileInfo_(false));
516 assertEquals('settings', OptionsPage
.getTopmostVisiblePage().name
);
519 // Only non-managed users should be able to delete profiles.
520 TEST_F('ManageProfileUITest', 'ManagedDelete', function() {
521 ManageProfileOverlay
.showDeleteDialog(this.testProfileInfo_(false));
522 assertEquals('manageProfile', OptionsPage
.getTopmostVisiblePage().name
);
523 assertFalse($('manage-profile-overlay-delete').hidden
);
525 // Clicks the "Delete" button, after overriding chrome.send to record what
526 // messages were sent.
527 function clickAndListen() {
528 var originalChromeSend
= chrome
.send
;
529 var chromeSendMessages
= [];
530 chrome
.send = function(message
) {
531 chromeSendMessages
.push(message
);
533 $('delete-profile-ok').onclick();
534 // Restore the original function so the test framework can use it.
535 chrome
.send
= originalChromeSend
;
536 return chromeSendMessages
;
539 this.setProfileManaged_(false, 'manage');
540 var messages
= clickAndListen();
541 assertEquals(1, messages
.length
);
542 assertEquals('deleteProfile', messages
[0]);
543 assertEquals('settings', OptionsPage
.getTopmostVisiblePage().name
);
545 ManageProfileOverlay
.showDeleteDialog(this.testProfileInfo_(false));
546 this.setProfileManaged_(true, 'manage');
547 messages
= clickAndListen();
548 assertEquals(0, messages
.length
);
549 assertEquals('settings', OptionsPage
.getTopmostVisiblePage().name
);
552 // Selecting a different avatar image should update the suggested profile name.
553 TEST_F('ManageProfileUITest', 'Create_NameUpdateOnAvatarSelected', function() {
555 this.initDefaultProfiles_(mode
);
557 var gridEl
= $(mode
+ '-profile-icon-grid');
558 var nameEl
= $(mode
+ '-profile-name');
560 // Select another icon and check that the profile name was updated.
561 assertNotEquals(gridEl
.selectedItem
, this.defaultIconURLs
[0]);
562 gridEl
.selectedItem
= this.defaultIconURLs
[0];
563 expectEquals(this.defaultNames
[0], nameEl
.value
);
565 // Select icon without an associated name; the profile name shouldn't change.
566 var oldName
= nameEl
.value
;
567 assertEquals('', this.defaultNames
[2]);
568 gridEl
.selectedItem
= this.defaultIconURLs
[2];
569 expectEquals(oldName
, nameEl
.value
);
571 // Select another icon with a name and check that the name is updated again.
572 assertNotEquals('', this.defaultNames
[1]);
573 gridEl
.selectedItem
= this.defaultIconURLs
[1];
574 expectEquals(this.defaultNames
[1], nameEl
.value
);
576 OptionsPage
.closeOverlay();
579 // After the user edited the profile name, selecting a different avatar image
580 // should not update the suggested name anymore.
581 TEST_F('ManageProfileUITest', 'Create_NoNameUpdateOnAvatarSelectedAfterEdit',
584 this.initDefaultProfiles_(mode
);
586 var gridEl
= $(mode
+ '-profile-icon-grid');
587 var nameEl
= $(mode
+ '-profile-name');
589 // After the user manually entered a name, it should not be changed anymore
590 // (even if the entered name is another default name).
591 nameEl
.value
= this.defaultNames
[3];
593 gridEl
.selectedItem
= this.defaultIconURLs
[0];
594 expectEquals(this.defaultNames
[3], nameEl
.value
);
596 OptionsPage
.closeOverlay();
599 // After the user edited the profile name, selecting a different avatar image
600 // should not update the suggested name anymore even if the original suggestion
602 TEST_F('ManageProfileUITest', 'Create_NoNameUpdateOnAvatarSelectedAfterRevert',
605 this.initDefaultProfiles_(mode
);
607 var gridEl
= $(mode
+ '-profile-icon-grid');
608 var nameEl
= $(mode
+ '-profile-name');
610 // After the user manually entered a name, it should not be changed anymore,
611 // even if the user then reverts to the original suggestion.
612 var oldName
= nameEl
.value
;
613 nameEl
.value
= 'Custom Name';
615 nameEl
.value
= oldName
;
617 // Now select another avatar and check that the name remained the same.
618 assertNotEquals(gridEl
.selectedItem
, this.defaultIconURLs
[0]);
619 gridEl
.selectedItem
= this.defaultIconURLs
[0];
620 expectEquals(oldName
, nameEl
.value
);
622 OptionsPage
.closeOverlay();
625 // In the manage dialog, the name should never be updated on avatar selection.
626 TEST_F('ManageProfileUITest', 'Manage_NoNameUpdateOnAvatarSelected',
629 this.setProfileManaged_(false, mode
);
630 OptionsPage
.showPageByName(mode
+ 'Profile');
632 var testProfile
= this.testProfileInfo_(false);
633 var iconURLs
= [testProfile
.iconURL
, '/some/path', '/another/path'];
634 var names
= [testProfile
.name
, 'Some Name', ''];
635 ManageProfileOverlay
.receiveDefaultProfileIconsAndNames(
636 mode
, iconURLs
, names
);
638 var gridEl
= $(mode
+ '-profile-icon-grid');
639 var nameEl
= $(mode
+ '-profile-name');
641 // Select another icon and check if the profile name was updated.
642 var oldName
= nameEl
.value
;
643 gridEl
.selectedItem
= iconURLs
[1];
644 expectEquals(oldName
, nameEl
.value
);
646 OptionsPage
.closeOverlay();
649 GEN('#endif // OS_CHROMEOS');