Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5150)

Unified Diff: chrome/test/data/webui/settings/settings_passwords_section_browsertest.js

Issue 1822913003: Handle the button presses in the password edit dialog. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@password-edit-dialog.gitbr
Patch Set: simplify Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/settings/passwords_and_forms_page/passwords_section.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..2d9ee7710660e152954236651e47c93120453c9e 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);
+ Polymer.dom.flush();
+ 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,7 +148,7 @@ SettingsPasswordSectionBrowserTest.prototype = {
* @param {!Object} passwordsSection
* @private
*/
- flush_: function(passwordsSection) {
+ flushPasswordSection_: function(passwordsSection) {
passwordsSection.$.passwordList.notifyResize();
passwordsSection.$.passwordExceptionsList.notifyResize();
Polymer.dom.flush();
@@ -186,7 +200,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'));
@@ -218,8 +232,8 @@ TEST_F('SettingsPasswordSectionBrowserTest', 'uiTests', function() {
var index = 0;
var clickRemoveButton = function() {
- passwords[index].querySelector('#passwordMenu').click();
- passwordsSection.$.menuRemovePassword.click();
+ MockInteractions.tap(passwords[index].querySelector('#passwordMenu'));
+ MockInteractions.tap(passwordsSection.$.menuRemovePassword);
};
// Listen for the remove event. If this event isn't received, the test
@@ -288,7 +302,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),
@@ -316,7 +330,8 @@ TEST_F('SettingsPasswordSectionBrowserTest', 'uiTests', function() {
var index = 0;
var clickRemoveButton = function() {
- exceptions[index].querySelector('#removeExceptionButton').click();
+ MockInteractions.tap(
+ exceptions[index].querySelector('#removeExceptionButton'));
};
// Listen for the remove event. If this event isn't received, the test
@@ -336,6 +351,84 @@ TEST_F('SettingsPasswordSectionBrowserTest', 'uiTests', function() {
// Start removing.
clickRemoveButton();
});
+
+ test('usePasswordDialogTwice', function() {
+ var BLANK_PASSWORD = ' ';
+ var item = self.createPasswordItem_('google.com', 'homer',
+ BLANK_PASSWORD.length);
+ var passwordDialog = self.createPasswordDialog_(item);
+
+ passwordDialog.open();
+ Polymer.dom.flush();
+
+ assertEquals(item.loginPair.originUrl,
+ passwordDialog.$.websiteInput.value);
+ assertEquals(item.loginPair.username,
+ passwordDialog.$.usernameInput.value);
+ assertEquals(BLANK_PASSWORD,
+ passwordDialog.$.passwordInput.value);
+ // Password should NOT be visible.
+ assertEquals('password',
+ passwordDialog.$.passwordInput.type);
+
+ passwordDialog.close();
+ Polymer.dom.flush();
+
+ var blankPassword2 = ' '.repeat(17);
+ var item2 = self.createPasswordItem_('drive.google.com', 'marge',
+ blankPassword2.length);
+
+ passwordDialog.item = item2;
+ passwordDialog.open();
+ Polymer.dom.flush();
+
+ 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';
+ var item = self.createPasswordItem_('goo.gl', 'bart', PASSWORD.length);
+ var passwordDialog = self.createPasswordDialog_(item);
+
+ passwordDialog.open();
+ Polymer.dom.flush();
+
+ passwordDialog.password = PASSWORD;
+ passwordDialog.showPassword = true;
+
+ Polymer.dom.flush();
+
+ 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();
+ Polymer.dom.flush();
+
+ passwordDialog.addEventListener('show-password', function(event) {
+ assertEquals(item.loginPair.originUrl, event.detail.originUrl);
+ assertEquals(item.loginPair.username, event.detail.username);
+ done();
+ });
+
+ MockInteractions.tap(passwordDialog.$.showPasswordButton);
+ });
});
mocha.run();
« no previous file with comments | « chrome/browser/resources/settings/passwords_and_forms_page/passwords_section.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698