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

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

Issue 1591053002: Add a password handler to get the list of passwords in md-settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: chrome.passwordsPrivate Created 4 years, 11 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
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 c6467b22fbc5e9f5721db8d886803ffce7f848a1..5e4c88df77d7a7372952d92381892ef9c183a0c2 100644
--- a/chrome/test/data/webui/settings/settings_passwords_section_browsertest.js
+++ b/chrome/test/data/webui/settings/settings_passwords_section_browsertest.js
@@ -26,6 +26,52 @@ SettingsPasswordSectionBrowserTest.prototype = {
/** @override */
extraLibraries: PolymerTest.getLibraries(ROOT_PATH),
+
+ /** @override */
+ setUp: function() {
+ PolymerTest.prototype.setUp.call(this);
+
+ // Test is run on an individual element that won't have a page language.
+ this.accessibilityAuditConfig.auditRulesToIgnore.push('humanLangMissing');
+ },
+
+ /**
+ * Creates a single item for the list of passwords.
+ * @param {string} url
+ * @param {string} username
+ * @param {number} passwordLength
Dan Beam 2016/01/27 00:17:45 needs a @return, might also want to @typedef this
hcarmona 2016/01/27 02:46:18 Done.
+ */
+ createPasswordItem(url, username, passwordLength) {
Dan Beam 2016/01/27 00:17:45 can this be private?
Dan Beam 2016/01/27 00:17:45 createPasswordItem: function(url, username, passwo
hcarmona 2016/01/27 02:46:18 Done.
hcarmona 2016/01/27 02:46:18 Done.
+ return {
+ loginPair: {originUrl: url, username: username},
+ numCharactersInPassword: passwordLength
+ };
+ },
+
+ /**
+ * Helper method that validates a node matches the data for an index.
+ * @param {Array<Element>} nodes The nodes that will be checked.
Dan Beam 2016/01/27 00:17:45 nit: this should probably be !Array<!Element>
hcarmona 2016/01/27 02:46:18 Done.
+ * @param {Array<Object>} passwordList The expected data.
Dan Beam 2016/01/27 00:17:45 and !Array<!Object>
hcarmona 2016/01/27 02:46:18 Done.
+ * @param {number} index The index that should match the node and data.
+ */
+ validate(nodes, passwordList, index) {
+ var node = nodes[index];
+ var passwordInfo = passwordList[index];
+ assertTrue(!!node, 'Failed to get nodes[' + index + ']');
+ assertTrue(!!passwordInfo, 'Failed to get passwordList[' + index + ']');
+ assertEquals(
+ passwordInfo.loginPair.originUrl,
+ node.querySelector('#shownUrl').textContent,
+ 'shownUrl mismatch in nodes[' + index + ']');
+ assertEquals(
+ passwordInfo.loginPair.username,
+ node.querySelector('#username').textContent,
+ 'username mismatch in nodes[' + index + ']');
+ assertEquals(
+ passwordInfo.numCharactersInPassword,
+ node.querySelector('#password').value.length,
+ 'password size mismatch in nodes[' + index + ']');
+ },
};
/**
@@ -39,15 +85,11 @@ TEST_F('SettingsPasswordSectionBrowserTest', 'uiTests', function() {
assertEquals(self.browsePreload, document.location.href,
'Unexpected URL loaded');
- var passwordList = [{origin: 'anotherwebsite.com',
- username: 'luigi',
- password: '*******'},
- {origin: 'longwebsite.com',
- username: 'peach',
- password: '***'},
- {origin: 'website.com',
- username: 'mario',
- password: '*******'}];
+ var passwordList = [
+ self.createPasswordItem('anotherwebsite.com', 'luigi', 7),
+ self.createPasswordItem('longwebsite.com', 'peach', 7),
+ self.createPasswordItem('website.com', 'mario', 7)
+ ];
// Create a passwords-section to use for testing.
var passwordsSection = document.createElement('passwords-section');
@@ -62,26 +104,13 @@ TEST_F('SettingsPasswordSectionBrowserTest', 'uiTests', function() {
'Failed to pass list of passwords to iron-list');
var list = Polymer.dom(passwordsSection.$.passwordList);
- assertTrue(!!list, "Failed to get the password list");
+ assertTrue(!!list, 'Failed to get the password list');
// Skip the first child because it's the template.
var listChildren = list.children.slice(1);
- var validate = function(nodes, passwordList, index) {
- assertTrue(!!nodes[index], 'Failed to get nodes[' + index + ']');
- assertEquals(passwordList[index].origin,
- nodes[index].querySelector('#origin').textContent,
- 'origin mismatch in nodes[' + index + ']');
- assertEquals(passwordList[index].username,
- nodes[index].querySelector('#username').textContent,
- 'username mismatch in nodes[' + index + ']');
- assertEquals(passwordList[index].password,
- nodes[index].querySelector('#password').textContent,
- 'password mismatch in nodes[' + index + ']');
- };
-
- validate(listChildren, passwordList, 0);
- validate(listChildren, passwordList, 1);
- validate(listChildren, passwordList, 2);
+ self.validate(listChildren, passwordList, 0);
+ self.validate(listChildren, passwordList, 1);
+ self.validate(listChildren, passwordList, 2);
done();
}, 0);
});

Powered by Google App Engine
This is Rietveld 408576698