Chromium Code Reviews| Index: chrome/test/data/webui/settings/settings_passwords_section_browsertest.js |
| diff --git a/chrome/test/data/webui/settings/settings_passwords_section_browsertest.js b/chrome/test/data/webui/settings/settings_passwords_section_browsertest.js |
| index 6ba6a8999ee7b2e80f8de6601b04c3d436e2c7e8..2dd01571bbc891d9cad3c3d83144a5181f48e693 100644 |
| --- a/chrome/test/data/webui/settings/settings_passwords_section_browsertest.js |
| +++ b/chrome/test/data/webui/settings/settings_passwords_section_browsertest.js |
| @@ -112,14 +112,28 @@ SettingsPasswordSectionBrowserTest.prototype = { |
| passwordsSection.savedPasswords = passwordList; |
| passwordsSection.passwordExceptions = exceptionList; |
| document.body.appendChild(passwordsSection); |
| - this.flush_(passwordsSection); |
| + this.flushPasswordSection_(passwordsSection); |
| return passwordsSection; |
| }, |
| /** |
| + * Helper method used to create a password editing dialog. |
| + * @param {!chrome.passwordsPrivate.PasswordUiEntry} passwordItem |
| + * @return {!Object} |
| + * @private |
| + */ |
| + createPasswordDialog_: function(passwordItem) { |
| + var passwordDialog = document.createElement('password-edit-dialog'); |
| + passwordDialog.item = passwordItem; |
| + document.body.appendChild(passwordDialog); |
| + this.flushPolymer_(); |
| + return passwordDialog; |
| + }, |
| + |
| + /** |
| * Helper method used to test for a url in a list of passwords. |
| * @param {!Array<!chrome.passwordsPrivate.PasswordUiEntry>} passwordList |
| - * @param {!String} url The URL that is being searched for. |
| + * @param {!string} url The URL that is being searched for. |
| */ |
| listContainsUrl(passwordList, url) { |
| for (var i = 0; i < passwordList.length; ++i) { |
| @@ -134,11 +148,19 @@ SettingsPasswordSectionBrowserTest.prototype = { |
| * @param {!Object} passwordsSection |
| * @private |
| */ |
| - flush_: function(passwordsSection) { |
| + flushPasswordSection_: function(passwordsSection) { |
| passwordsSection.$.passwordList.notifyResize(); |
| passwordsSection.$.passwordExceptionsList.notifyResize(); |
| Polymer.dom.flush(); |
| }, |
| + |
| + /** |
| + * Flush any pending polymer updates. |
| + * @private |
| + */ |
| + flushPolymer_: function() { |
| + Polymer.dom.flush(); |
| + }, |
|
Dan Beam
2016/03/25 03:12:55
i don't think this is better than just calling Pol
hcarmona
2016/03/25 19:08:20
Sounds good. Removed.
|
| }; |
| /** |
| @@ -186,7 +208,7 @@ TEST_F('SettingsPasswordSectionBrowserTest', 'uiTests', function() { |
| passwordList); |
| // Simulate 'longwebsite.com' being removed from the list. |
| passwordsSection.splice('savedPasswords', 1, 1); |
| - self.flush_(passwordsSection); |
| + self.flushPasswordSection_(passwordsSection); |
| assertFalse(self.listContainsUrl(passwordsSection.savedPasswords, |
| 'longwebsite.com')); |
| @@ -288,7 +310,7 @@ TEST_F('SettingsPasswordSectionBrowserTest', 'uiTests', function() { |
| passwordsSection.splice('passwordExceptions', 1, 1); |
| assertEquals(-1, passwordsSection.passwordExceptions.indexOf('mail.com')); |
| assertEquals(-1, exceptionList.indexOf('mail.com')); |
| - self.flush_(passwordsSection); |
| + self.flushPasswordSection_(passwordsSection); |
| self.validateExceptionList_( |
| self.getIronListChildren_(passwordsSection.$.passwordExceptionsList), |
| @@ -336,6 +358,85 @@ TEST_F('SettingsPasswordSectionBrowserTest', 'uiTests', function() { |
| // Start removing. |
| clickRemoveButton(); |
| }); |
| + |
| + test('usePasswordDialogTwice', function() { |
| + var blankPassword = ' '.repeat(7); |
|
Dan Beam
2016/03/25 03:12:55
nit: BLANK_PASSWORD
Dan Beam
2016/03/25 03:12:55
nit: why 7?
Dan Beam
2016/03/25 03:12:55
nit: put closer to use
hcarmona
2016/03/25 19:08:20
Done.
hcarmona
2016/03/25 19:08:20
Arbitrary. I replaced it with ' ' for simpli
hcarmona
2016/03/25 19:08:20
Used on next line.
|
| + var item = self.createPasswordItem_('google.com', 'homer', |
| + blankPassword.length); |
| + var passwordDialog = self.createPasswordDialog_(item); |
| + |
| + passwordDialog.open(); |
| + self.flushPolymer_(); |
| + |
| + assertEquals(item.loginPair.originUrl, |
| + passwordDialog.$.websiteInput.value); |
| + assertEquals(item.loginPair.username, |
| + passwordDialog.$.usernameInput.value); |
| + assertEquals(blankPassword, |
| + passwordDialog.$.passwordInput.value); |
| + // Password should NOT be visible. |
| + assertEquals('password', |
| + passwordDialog.$.passwordInput.type); |
| + |
| + passwordDialog.close(); |
| + self.flushPolymer_(); |
| + |
| + var blankPassword2 = ' '.repeat(17); |
| + var item2 = self.createPasswordItem_('drive.google.com', 'marge', |
| + blankPassword2.length); |
| + |
| + passwordDialog.item = item2; |
| + passwordDialog.open(); |
| + self.flushPolymer_(); |
| + |
| + assertEquals(item2.loginPair.originUrl, |
| + passwordDialog.$.websiteInput.value); |
| + assertEquals(item2.loginPair.username, |
| + passwordDialog.$.usernameInput.value); |
| + assertEquals(blankPassword2, |
| + passwordDialog.$.passwordInput.value); |
| + // Password should NOT be visible. |
| + assertEquals('password', |
| + passwordDialog.$.passwordInput.type); |
| + }); |
| + |
| + test('showSavedPassword', function() { |
| + var password = 'bAn@n@5'; |
|
Dan Beam
2016/03/25 03:12:55
nit: put closer to use
hcarmona
2016/03/25 19:08:20
Used on next line.
|
| + var item = self.createPasswordItem_('goo.gl', 'bart', password.length); |
| + var passwordDialog = self.createPasswordDialog_(item); |
| + |
| + passwordDialog.open(); |
| + self.flushPolymer_(); |
| + |
| + passwordDialog.password = password; |
| + passwordDialog.showPassword = true; |
| + |
| + self.flushPolymer_(); |
| + |
| + assertEquals(password, |
| + passwordDialog.$.passwordInput.value); |
| + // Password should be visible. |
| + assertEquals('text', |
| + passwordDialog.$.passwordInput.type); |
| + }); |
| + |
| + // Test will timeout if event is not received. |
| + test('onShowSavedPassword', function(done) { |
| + var item = self.createPasswordItem_('goo.gl', 'bart', 1); |
| + var passwordDialog = self.createPasswordDialog_(item); |
| + |
| + passwordDialog.open(); |
| + self.flushPolymer_(); |
| + |
| + passwordDialog.addEventListener('show-password', |
| + function(event) { |
|
Dan Beam
2016/03/25 03:12:55
nit: doesn't this fit on one line?
hcarmona
2016/03/25 19:08:20
Done.
|
| + assertEquals(item.loginPair.originUrl, event.detail.originUrl); |
| + assertEquals(item.loginPair.username, event.detail.username); |
| + done(); |
| + }); |
| + |
| + passwordDialog.$.showPasswordButton.click(); |
|
Dan Beam
2016/03/25 03:12:55
can you use MockInteractions.tap() instead?
hcarmona
2016/03/25 19:08:20
Yes! Replaced all |click| calls.
|
| + }); |
| }); |
| mocha.run(); |