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

Side by Side Diff: chrome/test/data/webui/settings/settings_passwords_section_browsertest.js

Issue 2651663003: Show human readable origin for Android apps (Closed)
Patch Set: New Round Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** @fileoverview Runs the Polymer Password Settings tests. */ 5 /** @fileoverview Runs the Polymer Password Settings tests. */
6 6
7 /** @const {string} Path to root from chrome/test/data/webui/settings/. */ 7 /** @const {string} Path to root from chrome/test/data/webui/settings/. */
8 var ROOT_PATH = '../../../../../'; 8 var ROOT_PATH = '../../../../../';
9 9
10 // Polymer BrowserTest fixture. 10 // Polymer BrowserTest fixture.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 * expected data. 53 * expected data.
54 * @private 54 * @private
55 */ 55 */
56 function validatePasswordList(listElement, passwordList) { 56 function validatePasswordList(listElement, passwordList) {
57 assertEquals(passwordList.length, listElement.items.length); 57 assertEquals(passwordList.length, listElement.items.length);
58 if (passwordList.length > 0) { 58 if (passwordList.length > 0) {
59 // The first child is a template, skip and get the real 'first child'. 59 // The first child is a template, skip and get the real 'first child'.
60 var node = Polymer.dom(listElement).children[1]; 60 var node = Polymer.dom(listElement).children[1];
61 assert(node); 61 assert(node);
62 var passwordInfo = passwordList[0]; 62 var passwordInfo = passwordList[0];
63 assertEquals(passwordInfo.loginPair.originUrl, 63 assertEquals(passwordInfo.loginPair.urls.shownUrl,
64 node.querySelector('#originUrl').textContent.trim()); 64 node.querySelector('#originUrl').textContent.trim());
65 assertEquals(passwordInfo.linkUrl, 65 assertEquals(passwordInfo.loginPair.urls.linkUrl,
66 node.querySelector('#originUrl').href); 66 node.querySelector('#originUrl').href);
67 assertEquals(passwordInfo.loginPair.username, 67 assertEquals(passwordInfo.loginPair.username,
68 node.querySelector('#username').textContent); 68 node.querySelector('#username').textContent);
69 assertEquals(passwordInfo.numCharactersInPassword, 69 assertEquals(passwordInfo.numCharactersInPassword,
70 node.querySelector('#password').value.length); 70 node.querySelector('#password').value.length);
71 } 71 }
72 } 72 }
73 73
74 /** 74 /**
75 * Helper method that validates a that elements in the exception list match 75 * Helper method that validates a that elements in the exception list match
76 * the expected data. 76 * the expected data.
77 * @param {!Array<!Element>} nodes The nodes that will be checked. 77 * @param {!Array<!Element>} nodes The nodes that will be checked.
78 * @param {!Array<!chrome.passwordsPrivate.ExceptionPair>} exceptionList The 78 * @param {!Array<!chrome.passwordsPrivate.ExceptionEntry>} exceptionList The
79 * expected data. 79 * expected data.
80 * @private 80 * @private
81 */ 81 */
82 function validateExceptionList(nodes, exceptionList) { 82 function validateExceptionList(nodes, exceptionList) {
83 assertEquals(exceptionList.length, nodes.length); 83 assertEquals(exceptionList.length, nodes.length);
84 for (var index = 0; index < exceptionList.length; ++index) { 84 for (var index = 0; index < exceptionList.length; ++index) {
85 var node = nodes[index]; 85 var node = nodes[index];
86 var exception = exceptionList[index]; 86 var exception = exceptionList[index];
87 assertEquals(exception.exceptionUrl, 87 assertEquals(exception.exceptionUrl,
88 node.querySelector('#exception').textContent); 88 node.querySelector('#exception').textContent);
(...skipping 20 matching lines...) Expand all
109 */ 109 */
110 function flushPasswordSection(passwordsSection) { 110 function flushPasswordSection(passwordsSection) {
111 passwordsSection.$.passwordList.notifyResize(); 111 passwordsSection.$.passwordList.notifyResize();
112 Polymer.dom.flush(); 112 Polymer.dom.flush();
113 } 113 }
114 114
115 /** 115 /**
116 * Helper method used to create a password section for the given lists. 116 * Helper method used to create a password section for the given lists.
117 * @param {!PasswordManager} passwordManager 117 * @param {!PasswordManager} passwordManager
118 * @param {!Array<!chrome.passwordsPrivate.PasswordUiEntry>} passwordList 118 * @param {!Array<!chrome.passwordsPrivate.PasswordUiEntry>} passwordList
119 * @param {!Array<!chrome.passwordsPrivate.ExceptionPair>} exceptionList 119 * @param {!Array<!chrome.passwordsPrivate.ExceptionEntry>} exceptionList
120 * @return {!Object} 120 * @return {!Object}
121 * @private 121 * @private
122 */ 122 */
123 function createPasswordsSection(passwordManager, passwordList, 123 function createPasswordsSection(passwordManager, passwordList,
124 exceptionList) { 124 exceptionList) {
125 // Override the PasswordManager data for testing. 125 // Override the PasswordManager data for testing.
126 passwordManager.data.passwords = passwordList; 126 passwordManager.data.passwords = passwordList;
127 passwordManager.data.exceptions = exceptionList; 127 passwordManager.data.exceptions = exceptionList;
128 128
129 // Create a passwords-section to use for testing. 129 // Create a passwords-section to use for testing.
(...skipping 17 matching lines...) Expand all
147 return passwordDialog; 147 return passwordDialog;
148 } 148 }
149 149
150 /** 150 /**
151 * Helper method used to test for a url in a list of passwords. 151 * Helper method used to test for a url in a list of passwords.
152 * @param {!Array<!chrome.passwordsPrivate.PasswordUiEntry>} passwordList 152 * @param {!Array<!chrome.passwordsPrivate.PasswordUiEntry>} passwordList
153 * @param {string} url The URL that is being searched for. 153 * @param {string} url The URL that is being searched for.
154 */ 154 */
155 function listContainsUrl(passwordList, url) { 155 function listContainsUrl(passwordList, url) {
156 for (var i = 0; i < passwordList.length; ++i) { 156 for (var i = 0; i < passwordList.length; ++i) {
157 if (passwordList[i].loginPair.originUrl == url) 157 if (passwordList[i].loginPair.urls.originUrl == url)
158 return true; 158 return true;
159 } 159 }
160 return false; 160 return false;
161 } 161 }
162 162
163 /** 163 /**
164 * Helper method used to test for a url in a list of passwords. 164 * Helper method used to test for a url in a list of passwords.
165 * @param {!Array<!chrome.passwordsPrivate.ExceptionPair>} exceptionList 165 * @param {!Array<!chrome.passwordsPrivate.ExceptionEntry>} exceptionList
166 * @param {string} url The URL that is being searched for. 166 * @param {string} url The URL that is being searched for.
167 */ 167 */
168 function exceptionsListContainsUrl(exceptionList, url) { 168 function exceptionsListContainsUrl(exceptionList, url) {
169 for (var i = 0; i < exceptionList.length; ++i) { 169 for (var i = 0; i < exceptionList.length; ++i) {
170 if (exceptionList[i].exceptionUrl == url) 170 if (exceptionList[i].urls.orginUrl == url)
171 return true; 171 return true;
172 } 172 }
173 return false; 173 return false;
174 } 174 }
175 175
176 suite('PasswordsSection', function() { 176 suite('PasswordsSection', function() {
177 /** @type {TestPasswordManager} */ 177 /** @type {TestPasswordManager} */
178 var passwordManager = null; 178 var passwordManager = null;
179 179
180 setup(function() { 180 setup(function() {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 var passwordsSection = createPasswordsSection( 267 var passwordsSection = createPasswordsSection(
268 passwordManager, passwordList, []); 268 passwordManager, passwordList, []);
269 269
270 // The first child is a template, skip and get the real 'first child'. 270 // The first child is a template, skip and get the real 'first child'.
271 var firstNode = Polymer.dom(passwordsSection.$.passwordList).children[1]; 271 var firstNode = Polymer.dom(passwordsSection.$.passwordList).children[1];
272 assert(firstNode); 272 assert(firstNode);
273 var firstPassword = passwordList[0]; 273 var firstPassword = passwordList[0];
274 274
275 passwordManager.onRemoveSavedPassword = function(detail) { 275 passwordManager.onRemoveSavedPassword = function(detail) {
276 // Verify that the event matches the expected value. 276 // Verify that the event matches the expected value.
277 assertEquals(firstPassword.loginPair.originUrl, detail.originUrl); 277 assertEquals(firstPassword.loginPair.urls.originUrl, detail.originUrl);
278 assertEquals(firstPassword.loginPair.username, detail.username); 278 assertEquals(firstPassword.loginPair.username, detail.username);
279 279
280 // Clean up after self. 280 // Clean up after self.
281 passwordManager.onRemoveSavedPassword = null; 281 passwordManager.onRemoveSavedPassword = null;
282 282
283 done(); 283 done();
284 }; 284 };
285 285
286 // Click the remove button on the first password. 286 // Click the remove button on the first password.
287 MockInteractions.tap(firstNode.querySelector('#passwordMenu')); 287 MockInteractions.tap(firstNode.querySelector('#passwordMenu'));
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 assertEquals('text', 461 assertEquals('text',
462 passwordDialog.$.passwordInput.type); 462 passwordDialog.$.passwordInput.type);
463 }); 463 });
464 464
465 // Test will timeout if event is not received. 465 // Test will timeout if event is not received.
466 test('onShowSavedPassword', function(done) { 466 test('onShowSavedPassword', function(done) {
467 var item = FakeDataMaker.passwordEntry('goo.gl', 'bart', 1); 467 var item = FakeDataMaker.passwordEntry('goo.gl', 'bart', 1);
468 var passwordDialog = createPasswordDialog(item); 468 var passwordDialog = createPasswordDialog(item);
469 469
470 passwordDialog.addEventListener('show-password', function(event) { 470 passwordDialog.addEventListener('show-password', function(event) {
471 assertEquals(item.loginPair.originUrl, event.detail.originUrl); 471 assertEquals(item.loginPair.url.originUrl, event.detail.originUrl);
472 assertEquals(item.loginPair.username, event.detail.username); 472 assertEquals(item.loginPair.username, event.detail.username);
473 done(); 473 done();
474 }); 474 });
475 475
476 MockInteractions.tap(passwordDialog.$.showPasswordButton); 476 MockInteractions.tap(passwordDialog.$.showPasswordButton);
477 }); 477 });
478 }); 478 });
479 479
480 mocha.run(); 480 mocha.run();
481 }); 481 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698