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 "supervised" status.
36 * @param {boolean} supervised If true, the test profile will be marked as
38 * @return {Object} A test profile-info object.
40 testProfileInfo_: function(supervised
) {
43 iconURL
: 'chrome://path/to/icon/image',
44 filePath
: '/path/to/profile/data/on/disk',
45 isCurrentProfile
: true,
46 isSupervised
: supervised
51 * Overrides WebUI methods that provide profile info, making them return a
52 * test profile-info object.
53 * @param {boolean} supervised Whether the test profile should be marked
55 * @param {string} mode The mode of the overlay (either 'manage' or 'create').
57 setProfileSupervised_: function(supervised
, mode
) {
58 // Override the BrowserOptions method to return the fake info.
59 BrowserOptions
.getCurrentProfile = function() {
60 return this.testProfileInfo_(supervised
);
62 // Set the profile info in the overlay.
63 ManageProfileOverlay
.setProfileInfo(this.testProfileInfo_(supervised
),
68 * Set some default profile infos (icon URLs and names).
69 * @param {boolean} supervised Whether the test profile should be marked as
71 * @param {string} mode The mode of the overlay (either 'manage' or 'create').
73 initDefaultProfiles_: function(mode
) {
74 PageManager
.showPageByName(mode
+ 'Profile');
76 var defaultProfile
= {
78 iconURL
: '/default/path',
80 this.defaultIconURLs
= ['/some/path',
81 defaultProfile
.iconURL
,
84 this.defaultNames
= ['Some Name', defaultProfile
.name
, '', 'Another Name'];
85 ManageProfileOverlay
.receiveDefaultProfileIconsAndNames(
86 mode
, this.defaultIconURLs
, this.defaultNames
);
87 ManageProfileOverlay
.receiveNewProfileDefaults(defaultProfile
);
89 // Make sure the correct item in the icon grid was selected.
90 var gridEl
= $(mode
+ '-profile-icon-grid');
91 expectEquals(defaultProfile
.iconURL
, gridEl
.selectedItem
);
95 // Receiving the new profile defaults in the manage-user overlay shouldn't mess
96 // up the focus in a visible higher-level overlay.
97 TEST_F('ManageProfileUITest', 'NewProfileDefaultsFocus', function() {
100 function checkFocus(pageName
, expectedFocus
, initialFocus
) {
101 PageManager
.showPageByName(pageName
);
102 initialFocus
.focus();
103 expectEquals(initialFocus
, document
.activeElement
, pageName
);
105 ManageProfileOverlay
.receiveNewProfileDefaults(
106 self
.testProfileInfo_(false));
107 expectEquals(expectedFocus
, document
.activeElement
, pageName
);
108 PageManager
.closeOverlay();
111 // Receiving new profile defaults sets focus to the name field if the create
112 // overlay is open, and should not change focus at all otherwise.
113 checkFocus('manageProfile',
114 $('manage-profile-cancel'),
115 $('manage-profile-cancel'));
116 checkFocus('createProfile',
117 $('create-profile-name'),
118 $('create-profile-cancel'));
119 checkFocus('supervisedUserLearnMore',
120 $('supervised-user-learn-more-done'),
121 $('supervised-user-learn-more-done'));
122 checkFocus('supervisedUserLearnMore',
123 document
.querySelector('#supervised-user-learn-more-text a'),
124 document
.querySelector('#supervised-user-learn-more-text a'));
127 // The default options should be reset each time the creation overlay is shown.
128 TEST_F('ManageProfileUITest', 'DefaultCreateOptions', function() {
129 PageManager
.showPageByName('createProfile');
130 var shortcutsAllowed
= loadTimeData
.getBoolean('profileShortcutsEnabled');
131 var createShortcut
= $('create-shortcut');
132 var createSupervised
= $('create-profile-supervised');
133 assertEquals(shortcutsAllowed
, createShortcut
.checked
);
134 assertFalse(createSupervised
.checked
);
136 createShortcut
.checked
= !shortcutsAllowed
;
137 createSupervised
.checked
= true;
138 PageManager
.closeOverlay();
139 PageManager
.showPageByName('createProfile');
140 assertEquals(shortcutsAllowed
, createShortcut
.checked
);
141 assertFalse(createSupervised
.checked
);
144 // The checkbox label should change depending on whether the user is signed in.
145 TEST_F('ManageProfileUITest', 'CreateSupervisedUserText', function() {
146 var signedInText
= $('create-profile-supervised-signed-in');
147 var notSignedInText
= $('create-profile-supervised-not-signed-in');
149 ManageProfileOverlay
.getInstance().initializePage();
151 var custodianEmail
= 'chrome.playpen.test@gmail.com';
152 CreateProfileOverlay
.updateSignedInStatus(custodianEmail
);
153 assertEquals(custodianEmail
,
154 CreateProfileOverlay
.getInstance().signedInEmail_
);
155 assertFalse(signedInText
.hidden
);
156 assertTrue(notSignedInText
.hidden
);
157 // Make sure the email is in the string somewhere, without depending on the
158 // exact details of the message.
159 assertNotEquals(-1, signedInText
.textContent
.indexOf(custodianEmail
));
161 CreateProfileOverlay
.updateSignedInStatus('');
162 assertEquals('', CreateProfileOverlay
.getInstance().signedInEmail_
);
163 assertTrue(signedInText
.hidden
);
164 assertFalse(notSignedInText
.hidden
);
165 assertFalse($('create-profile-supervised').checked
);
166 assertTrue($('create-profile-supervised').disabled
);
169 function ManageProfileUITestAsync() {}
171 ManageProfileUITestAsync
.prototype = {
172 __proto__
: ManageProfileUITest
.prototype,
177 // The import link should show up if the user tries to create a profile with the
178 // same name as an existing supervised user profile.
179 TEST_F('ManageProfileUITestAsync', 'CreateExistingSupervisedUser', function() {
180 // Initialize the list of existing supervised users.
181 var supervisedUsers
= [
183 id
: 'supervisedUser1',
185 iconURL
: 'chrome://path/to/icon/image',
186 onCurrentDevice
: false,
190 id
: 'supervisedUser2',
192 iconURL
: 'chrome://path/to/icon/image',
193 onCurrentDevice
: false,
197 id
: 'supervisedUser3',
199 iconURL
: 'chrome://path/to/icon/image',
200 onCurrentDevice
: true,
204 id
: 'supervisedUser4',
206 iconURL
: 'chrome://path/to/icon/image',
207 onCurrentDevice
: false,
210 var promise
= Promise
.resolve(supervisedUsers
);
211 options
.SupervisedUserListData
.getInstance().promise_
= promise
;
213 // Initialize the ManageProfileOverlay.
214 ManageProfileOverlay
.getInstance().initializePage();
215 var custodianEmail
= 'chrome.playpen.test@gmail.com';
216 CreateProfileOverlay
.updateSignedInStatus(custodianEmail
);
217 assertEquals(custodianEmail
,
218 CreateProfileOverlay
.getInstance().signedInEmail_
);
219 this.setProfileSupervised_(false, 'create');
221 // Also add the names 'Test' and 'SameName' to |existingProfileNames_| to
222 // simulate that profiles with those names exist on the device.
223 ManageProfileOverlay
.getInstance().existingProfileNames_
.Test
= true;
224 ManageProfileOverlay
.getInstance().existingProfileNames_
.SameName
= true;
226 // Initially, the ok button should be enabled and the import link should not
228 assertFalse($('create-profile-ok').disabled
);
229 assertTrue($('supervised-user-import-existing') == null);
231 // Now try to create profiles with the names of existing supervised users.
232 $('create-profile-supervised').checked
= true;
233 var nameField
= $('create-profile-name');
234 // A profile which already has an avatar.
235 nameField
.value
= 'Rosalie';
236 ManageProfileOverlay
.getInstance().onNameChanged_('create');
237 // Need to wait until the promise resolves.
238 promise
.then(function() {
239 assertTrue($('create-profile-ok').disabled
);
240 assertFalse($('supervised-user-import-existing') == null);
242 // A profile which doesn't have an avatar yet.
243 nameField
.value
= 'Fritz';
244 ManageProfileOverlay
.getInstance().onNameChanged_('create');
245 return options
.SupervisedUserListData
.getInstance().promise_
;
247 assertTrue($('create-profile-ok').disabled
);
248 assertFalse($('supervised-user-import-existing') == null);
250 // A profile which already exists on the device.
251 nameField
.value
= 'Test';
252 ManageProfileOverlay
.getInstance().onNameChanged_('create');
253 return options
.SupervisedUserListData
.getInstance().promise_
;
255 assertTrue($('create-profile-ok').disabled
);
256 assertTrue($('supervised-user-import-existing') == null);
258 // A profile which does not exist on the device, but there is a profile with
259 // the same name already on the device.
260 nameField
.value
= 'SameName';
261 ManageProfileOverlay
.getInstance().onNameChanged_('create');
262 return options
.SupervisedUserListData
.getInstance().promise_
;
264 assertTrue($('create-profile-ok').disabled
);
265 assertFalse($('supervised-user-import-existing') == null);
267 // A profile which does not exist yet.
268 nameField
.value
= 'NewProfileName';
269 ManageProfileOverlay
.getInstance().onNameChanged_('create');
270 return options
.SupervisedUserListData
.getInstance().promise_
;
272 assertFalse($('create-profile-ok').disabled
);
273 assertTrue($('supervised-user-import-existing') == null);
278 // Supervised users should not be able to edit their profile names, and the
279 // initial focus should be adjusted accordingly.
280 TEST_F('ManageProfileUITest', 'EditSupervisedUserNameAllowed', function() {
281 var nameField
= $('manage-profile-name');
283 this.setProfileSupervised_(false, 'manage');
284 ManageProfileOverlay
.showManageDialog();
285 expectFalse(nameField
.disabled
);
286 expectEquals(nameField
, document
.activeElement
);
288 PageManager
.closeOverlay();
290 this.setProfileSupervised_(true, 'manage');
291 ManageProfileOverlay
.showManageDialog();
292 expectTrue(nameField
.disabled
);
293 expectEquals($('manage-profile-ok'), document
.activeElement
);
296 // Setting profile information should allow the confirmation to be shown.
297 TEST_F('ManageProfileUITest', 'ShowCreateConfirmation', function() {
298 var testProfile
= this.testProfileInfo_(true);
299 testProfile
.custodianEmail
= 'foo@bar.example.com';
300 SupervisedUserCreateConfirmOverlay
.setProfileInfo(testProfile
);
301 assertTrue(SupervisedUserCreateConfirmOverlay
.getInstance().canShowPage());
302 PageManager
.showPageByName('supervisedUserCreateConfirm', false);
303 assertEquals('supervisedUserCreateConfirm',
304 PageManager
.getTopmostVisiblePage().name
);
307 // Trying to show a confirmation dialog with no profile information should fall
308 // back to the default (main) settings page.
309 TEST_F('ManageProfileUITest', 'NoEmptyConfirmation', function() {
310 assertEquals('manageProfile', PageManager
.getTopmostVisiblePage().name
);
311 assertFalse(SupervisedUserCreateConfirmOverlay
.getInstance().canShowPage());
312 PageManager
.showPageByName('supervisedUserCreateConfirm', true);
313 assertEquals('settings', PageManager
.getTopmostVisiblePage().name
);
316 // A confirmation dialog should be shown after creating a new supervised user.
317 TEST_F('ManageProfileUITest', 'ShowCreateConfirmationOnSuccess', function() {
318 PageManager
.showPageByName('createProfile');
319 assertEquals('createProfile', PageManager
.getTopmostVisiblePage().name
);
320 CreateProfileOverlay
.onSuccess(this.testProfileInfo_(false));
321 assertEquals('settings', PageManager
.getTopmostVisiblePage().name
);
323 PageManager
.showPageByName('createProfile');
324 assertEquals('createProfile', PageManager
.getTopmostVisiblePage().name
);
325 CreateProfileOverlay
.onSuccess(this.testProfileInfo_(true));
326 assertEquals('supervisedUserCreateConfirm',
327 PageManager
.getTopmostVisiblePage().name
);
328 expectEquals($('supervised-user-created-switch'), document
.activeElement
);
331 // An error should be shown if creating a new supervised user fails.
332 TEST_F('ManageProfileUITest', 'NoCreateConfirmationOnError', function() {
333 PageManager
.showPageByName('createProfile');
334 assertEquals('createProfile', PageManager
.getTopmostVisiblePage().name
);
335 var errorBubble
= $('create-profile-error-bubble');
336 assertTrue(errorBubble
.hidden
);
338 CreateProfileOverlay
.onError('An Error Message!');
339 assertEquals('createProfile', PageManager
.getTopmostVisiblePage().name
);
340 assertFalse(errorBubble
.hidden
);
343 // The name and email should be inserted into the confirmation dialog.
344 TEST_F('ManageProfileUITest', 'CreateConfirmationText', function() {
346 var custodianEmail
= 'foo@example.com';
348 // Checks the strings in the confirmation dialog. If |expectedNameText| is
349 // given, it should be present in the dialog's textContent; otherwise the name
350 // is expected. If |expectedNameHtml| is given, it should be present in the
351 // dialog's innerHTML; otherwise the expected text is expected in the HTML
353 function checkDialog(name
, expectedNameText
, expectedNameHtml
) {
354 var expectedText
= expectedNameText
|| name
;
355 var expectedHtml
= expectedNameHtml
|| expectedText
;
357 // Configure the test profile and show the confirmation dialog.
358 var testProfile
= self
.testProfileInfo_(true);
359 testProfile
.name
= name
;
360 CreateProfileOverlay
.onSuccess(testProfile
);
361 assertEquals('supervisedUserCreateConfirm',
362 PageManager
.getTopmostVisiblePage().name
);
364 // Check for the presence of the name and email in the UI, without depending
365 // on the details of the messages.
367 $('supervised-user-created-title').textContent
.indexOf(expectedText
));
369 $('supervised-user-created-switch').textContent
.indexOf(expectedText
));
370 var message
= $('supervised-user-created-text');
371 assertNotEquals(-1, message
.textContent
.indexOf(expectedText
));
372 assertNotEquals(-1, message
.textContent
.indexOf(custodianEmail
));
374 // The name should be properly HTML-escaped.
375 assertNotEquals(-1, message
.innerHTML
.indexOf(expectedHtml
));
377 PageManager
.closeOverlay();
378 assertEquals('settings', PageManager
.getTopmostVisiblePage().name
, name
);
381 // Show and configure the create-profile dialog.
382 PageManager
.showPageByName('createProfile');
383 CreateProfileOverlay
.updateSignedInStatus(custodianEmail
);
384 assertEquals('createProfile', PageManager
.getTopmostVisiblePage().name
);
386 checkDialog('OneWord');
387 checkDialog('Multiple Words');
388 checkDialog('It\'s "<HTML> injection" & more!',
389 'It\'s "<HTML> injection" & more!',
390 // The innerHTML getter doesn't escape quotation marks,
391 // independent of whether they were escaped in the setter.
392 'It\'s "<HTML> injection" & more!');
394 // Test elision. MAX_LENGTH = 50, minus 1 for the ellipsis.
395 var name49Characters
= '0123456789012345678901234567890123456789012345678';
396 var name50Characters
= name49Characters
+ '9';
397 var name51Characters
= name50Characters
+ '0';
398 var name60Characters
= name51Characters
+ '123456789';
399 checkDialog(name49Characters
, name49Characters
);
400 checkDialog(name50Characters
, name50Characters
);
401 checkDialog(name51Characters
, name49Characters
+ '\u2026');
402 checkDialog(name60Characters
, name49Characters
+ '\u2026');
404 // Test both elision and HTML escaping. The allowed string length is the
405 // visible length, not the length including the entity names.
406 name49Characters
= name49Characters
.replace('0', '&').replace('1', '>');
407 name60Characters
= name60Characters
.replace('0', '&').replace('1', '>');
408 var escaped
= name49Characters
.replace('&', '&').replace('>', '>');
410 name60Characters
, name49Characters
+ '\u2026', escaped
+ '\u2026');
413 // An additional warning should be shown when deleting a supervised user.
414 TEST_F('ManageProfileUITest', 'DeleteSupervisedUserWarning', function() {
415 var addendum
= $('delete-supervised-profile-addendum');
417 ManageProfileOverlay
.showDeleteDialog(this.testProfileInfo_(true));
418 assertFalse(addendum
.hidden
);
420 ManageProfileOverlay
.showDeleteDialog(this.testProfileInfo_(false));
421 assertTrue(addendum
.hidden
);
424 // The policy prohibiting supervised users should update the UI dynamically.
425 TEST_F('ManageProfileUITest', 'PolicyDynamicRefresh', function() {
426 ManageProfileOverlay
.getInstance().initializePage();
428 var custodianEmail
= 'chrome.playpen.test@gmail.com';
429 CreateProfileOverlay
.updateSignedInStatus(custodianEmail
);
430 CreateProfileOverlay
.updateSupervisedUsersAllowed(true);
431 var checkbox
= $('create-profile-supervised');
432 var signInPromo
= $('create-profile-supervised-not-signed-in');
433 var signInLink
= $('create-profile-supervised-sign-in-link');
434 var indicator
= $('create-profile-supervised-indicator');
436 assertFalse(checkbox
.disabled
, 'allowed and signed in');
437 assertTrue(signInPromo
.hidden
, 'allowed and signed in');
438 assertEquals('none', window
.getComputedStyle(indicator
, null).display
,
439 'allowed and signed in');
441 CreateProfileOverlay
.updateSignedInStatus('');
442 CreateProfileOverlay
.updateSupervisedUsersAllowed(true);
443 assertTrue(checkbox
.disabled
, 'allowed, not signed in');
444 assertFalse(signInPromo
.hidden
, 'allowed, not signed in');
445 assertTrue(signInLink
.enabled
, 'allowed, not signed in');
446 assertEquals('none', window
.getComputedStyle(indicator
, null).display
,
447 'allowed, not signed in');
449 CreateProfileOverlay
.updateSignedInStatus('');
450 CreateProfileOverlay
.updateSupervisedUsersAllowed(false);
451 assertTrue(checkbox
.disabled
, 'disallowed, not signed in');
452 assertFalse(signInPromo
.hidden
, 'disallowed, not signed in');
453 assertFalse(signInLink
.enabled
, 'disallowed, not signed in');
454 assertEquals('inline-block', window
.getComputedStyle(indicator
, null).display
,
455 'disallowed, not signed in');
456 assertEquals('policy', indicator
.getAttribute('controlled-by'));
458 CreateProfileOverlay
.updateSignedInStatus(custodianEmail
);
459 CreateProfileOverlay
.updateSupervisedUsersAllowed(false);
460 assertTrue(checkbox
.disabled
, 'disallowed, signed in');
461 assertTrue(signInPromo
.hidden
, 'disallowed, signed in');
462 assertEquals('inline-block', window
.getComputedStyle(indicator
, null).display
,
463 'disallowed, signed in');
464 assertEquals('policy', indicator
.getAttribute('controlled-by'));
466 CreateProfileOverlay
.updateSignedInStatus(custodianEmail
);
467 CreateProfileOverlay
.updateSupervisedUsersAllowed(true);
468 assertFalse(checkbox
.disabled
, 're-allowed and signed in');
469 assertTrue(signInPromo
.hidden
, 're-allowed and signed in');
470 assertEquals('none', window
.getComputedStyle(indicator
, null).display
,
471 're-allowed and signed in');
474 // The supervised user checkbox should correctly update its state during profile
475 // creation and afterwards.
476 TEST_F('ManageProfileUITest', 'CreateInProgress', function() {
477 ManageProfileOverlay
.getInstance().initializePage();
479 var custodianEmail
= 'chrome.playpen.test@gmail.com';
480 CreateProfileOverlay
.updateSignedInStatus(custodianEmail
);
481 CreateProfileOverlay
.updateSupervisedUsersAllowed(true);
482 var checkbox
= $('create-profile-supervised');
483 var signInPromo
= $('create-profile-supervised-not-signed-in');
484 var indicator
= $('create-profile-supervised-indicator');
486 assertFalse(checkbox
.disabled
, 'allowed and signed in');
487 assertTrue(signInPromo
.hidden
, 'allowed and signed in');
488 assertEquals('none', window
.getComputedStyle(indicator
, null).display
,
489 'allowed and signed in');
490 assertFalse(indicator
.hasAttribute('controlled-by'));
492 CreateProfileOverlay
.updateCreateInProgress(true);
493 assertTrue(checkbox
.disabled
, 'creation in progress');
495 // A no-op update to the sign-in status should not change the UI.
496 CreateProfileOverlay
.updateSignedInStatus(custodianEmail
);
497 CreateProfileOverlay
.updateSupervisedUsersAllowed(true);
498 assertTrue(checkbox
.disabled
, 'creation in progress');
500 CreateProfileOverlay
.updateCreateInProgress(false);
501 assertFalse(checkbox
.disabled
, 'creation finished');
504 // Supervised users shouldn't be able to open the delete or create dialogs.
505 TEST_F('ManageProfileUITest', 'SupervisedShowDeleteAndCreate', function() {
506 this.setProfileSupervised_(false, 'create');
508 ManageProfileOverlay
.showCreateDialog();
509 assertEquals('createProfile', PageManager
.getTopmostVisiblePage().name
);
510 PageManager
.closeOverlay();
511 assertEquals('settings', PageManager
.getTopmostVisiblePage().name
);
512 ManageProfileOverlay
.showDeleteDialog(this.testProfileInfo_(false));
513 assertEquals('manageProfile', PageManager
.getTopmostVisiblePage().name
);
514 assertFalse($('manage-profile-overlay-delete').hidden
);
515 PageManager
.closeOverlay();
516 assertEquals('settings', PageManager
.getTopmostVisiblePage().name
);
518 this.setProfileSupervised_(true, 'create');
519 ManageProfileOverlay
.showCreateDialog();
520 assertEquals('settings', PageManager
.getTopmostVisiblePage().name
);
521 ManageProfileOverlay
.showDeleteDialog(this.testProfileInfo_(false));
522 assertEquals('settings', PageManager
.getTopmostVisiblePage().name
);
525 // Only non-supervised users should be able to delete profiles.
526 TEST_F('ManageProfileUITest', 'SupervisedDelete', function() {
527 ManageProfileOverlay
.showDeleteDialog(this.testProfileInfo_(false));
528 assertEquals('manageProfile', PageManager
.getTopmostVisiblePage().name
);
529 assertFalse($('manage-profile-overlay-delete').hidden
);
531 // Clicks the "Delete" button, after overriding chrome.send to record what
532 // messages were sent.
533 function clickAndListen() {
534 var originalChromeSend
= chrome
.send
;
535 var chromeSendMessages
= [];
536 chrome
.send = function(message
) {
537 chromeSendMessages
.push(message
);
539 $('delete-profile-ok').onclick();
540 // Restore the original function so the test framework can use it.
541 chrome
.send
= originalChromeSend
;
542 return chromeSendMessages
;
545 this.setProfileSupervised_(false, 'manage');
546 var messages
= clickAndListen();
547 assertEquals(1, messages
.length
);
548 assertEquals('deleteProfile', messages
[0]);
549 assertEquals('settings', PageManager
.getTopmostVisiblePage().name
);
551 ManageProfileOverlay
.showDeleteDialog(this.testProfileInfo_(false));
552 this.setProfileSupervised_(true, 'manage');
553 messages
= clickAndListen();
554 assertEquals(0, messages
.length
);
555 assertEquals('settings', PageManager
.getTopmostVisiblePage().name
);
558 // Selecting a different avatar image should update the suggested profile name.
559 TEST_F('ManageProfileUITest', 'Create_NameUpdateOnAvatarSelected', function() {
561 this.initDefaultProfiles_(mode
);
563 var gridEl
= $(mode
+ '-profile-icon-grid');
564 var nameEl
= $(mode
+ '-profile-name');
566 // Select another icon and check that the profile name was updated.
567 assertNotEquals(gridEl
.selectedItem
, this.defaultIconURLs
[0]);
568 gridEl
.selectedItem
= this.defaultIconURLs
[0];
569 expectEquals(this.defaultNames
[0], nameEl
.value
);
571 // Select icon without an associated name; the profile name shouldn't change.
572 var oldName
= nameEl
.value
;
573 assertEquals('', this.defaultNames
[2]);
574 gridEl
.selectedItem
= this.defaultIconURLs
[2];
575 expectEquals(oldName
, nameEl
.value
);
577 // Select another icon with a name and check that the name is updated again.
578 assertNotEquals('', this.defaultNames
[1]);
579 gridEl
.selectedItem
= this.defaultIconURLs
[1];
580 expectEquals(this.defaultNames
[1], nameEl
.value
);
582 PageManager
.closeOverlay();
585 // After the user edited the profile name, selecting a different avatar image
586 // should not update the suggested name anymore.
587 TEST_F('ManageProfileUITest', 'Create_NoNameUpdateOnAvatarSelectedAfterEdit',
590 this.initDefaultProfiles_(mode
);
592 var gridEl
= $(mode
+ '-profile-icon-grid');
593 var nameEl
= $(mode
+ '-profile-name');
595 // After the user manually entered a name, it should not be changed anymore
596 // (even if the entered name is another default name).
597 nameEl
.value
= this.defaultNames
[3];
599 gridEl
.selectedItem
= this.defaultIconURLs
[0];
600 expectEquals(this.defaultNames
[3], nameEl
.value
);
602 PageManager
.closeOverlay();
605 // After the user edited the profile name, selecting a different avatar image
606 // should not update the suggested name anymore even if the original suggestion
608 TEST_F('ManageProfileUITest', 'Create_NoNameUpdateOnAvatarSelectedAfterRevert',
611 this.initDefaultProfiles_(mode
);
613 var gridEl
= $(mode
+ '-profile-icon-grid');
614 var nameEl
= $(mode
+ '-profile-name');
616 // After the user manually entered a name, it should not be changed anymore,
617 // even if the user then reverts to the original suggestion.
618 var oldName
= nameEl
.value
;
619 nameEl
.value
= 'Custom Name';
621 nameEl
.value
= oldName
;
623 // Now select another avatar and check that the name remained the same.
624 assertNotEquals(gridEl
.selectedItem
, this.defaultIconURLs
[0]);
625 gridEl
.selectedItem
= this.defaultIconURLs
[0];
626 expectEquals(oldName
, nameEl
.value
);
628 PageManager
.closeOverlay();
631 // In the manage dialog, the name should never be updated on avatar selection.
632 TEST_F('ManageProfileUITest', 'Manage_NoNameUpdateOnAvatarSelected',
635 this.setProfileSupervised_(false, mode
);
636 PageManager
.showPageByName(mode
+ 'Profile');
638 var testProfile
= this.testProfileInfo_(false);
639 var iconURLs
= [testProfile
.iconURL
, '/some/path', '/another/path'];
640 var names
= [testProfile
.name
, 'Some Name', ''];
641 ManageProfileOverlay
.receiveDefaultProfileIconsAndNames(
642 mode
, iconURLs
, names
);
644 var gridEl
= $(mode
+ '-profile-icon-grid');
645 var nameEl
= $(mode
+ '-profile-name');
647 // Select another icon and check if the profile name was updated.
648 var oldName
= nameEl
.value
;
649 gridEl
.selectedItem
= iconURLs
[1];
650 expectEquals(oldName
, nameEl
.value
);
652 PageManager
.closeOverlay();
655 GEN('#endif // OS_CHROMEOS');