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

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

Issue 2627123002: Load Passwords and Autofill in the corresponding sub page. (Closed)
Patch Set: feedback Created 3 years, 10 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 17 matching lines...) Expand all
28 browsePreload: 28 browsePreload:
29 'chrome://md-settings/passwords_and_forms_page/passwords_section.html', 29 'chrome://md-settings/passwords_and_forms_page/passwords_section.html',
30 30
31 /** @override */ 31 /** @override */
32 extraLibraries: PolymerTest.getLibraries(ROOT_PATH), 32 extraLibraries: PolymerTest.getLibraries(ROOT_PATH),
33 33
34 /** @override */ 34 /** @override */
35 setUp: function() { 35 setUp: function() {
36 PolymerTest.prototype.setUp.call(this); 36 PolymerTest.prototype.setUp.call(this);
37 37
38 // Override the PasswordManagerImpl for testing.
39 this.passwordManager = new TestPasswordManager();
dpapad 2017/01/28 00:10:30 Some drive by questions: Can we use the Mocha suit
hcarmona 2017/02/14 00:59:38 Awesome!
40 PasswordManagerImpl.instance_ = this.passwordManager;
41
38 // Test is run on an individual element that won't have a page language. 42 // Test is run on an individual element that won't have a page language.
39 this.accessibilityAuditConfig.auditRulesToIgnore.push('humanLangMissing'); 43 this.accessibilityAuditConfig.auditRulesToIgnore.push('humanLangMissing');
40 }, 44 },
41 45
46 tearDown: function() {
47 PasswordManagerImpl.instance_ = null;
hcarmona 2017/01/26 21:34:47 Moved this here to clean up after the test.
Dan Beam 2017/01/27 01:11:32 we're just re-creating on setup, why does this mat
hcarmona 2017/01/27 18:28:16 PasswordManagerImpl.instance_ is global. If 2 test
Dan Beam 2017/01/27 23:55:22 i mean, you can leave this in, but nobody else doe
hcarmona 2017/02/14 00:59:38 Going w/ dpapad@'s suggestion for Mocha suite setu
48 },
49
42 /** 50 /**
43 * Helper method that validates a that elements in the password list match 51 * Helper method that validates a that elements in the password list match
44 * the expected data. 52 * the expected data.
45 * @param {!Element} listElement The iron-list element that will be checked. 53 * @param {!Element} listElement The iron-list element that will be checked.
46 * @param {!Array<!chrome.passwordsPrivate.PasswordUiEntry>} passwordList The 54 * @param {!Array<!chrome.passwordsPrivate.PasswordUiEntry>} passwordList The
47 * expected data. 55 * expected data.
48 * @private 56 * @private
49 */ 57 */
50 validatePasswordList: function(listElement, passwordList) { 58 validatePasswordList: function(listElement, passwordList) {
dpapad 2017/01/28 00:10:30 A lot of the methods on SettingsPasswordSectionBro
51 assertEquals(passwordList.length, listElement.items.length); 59 assertEquals(passwordList.length, listElement.items.length);
52 if (passwordList.length > 0) { 60 if (passwordList.length > 0) {
53 // The first child is a template, skip and get the real 'first child'. 61 // The first child is a template, skip and get the real 'first child'.
54 var node = Polymer.dom(listElement).children[1]; 62 var node = Polymer.dom(listElement).children[1];
55 assert(node); 63 assert(node);
56 var passwordInfo = passwordList[0]; 64 var passwordInfo = passwordList[0];
57 assertEquals(passwordInfo.loginPair.originUrl, 65 assertEquals(passwordInfo.loginPair.originUrl,
58 node.querySelector('#originUrl').textContent.trim()); 66 node.querySelector('#originUrl').textContent.trim());
59 assertEquals(passwordInfo.linkUrl, 67 assertEquals(passwordInfo.linkUrl,
60 node.querySelector('#originUrl').href); 68 node.querySelector('#originUrl').href);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 }, 107 },
100 108
101 /** 109 /**
102 * Helper method used to create a password section for the given lists. 110 * Helper method used to create a password section for the given lists.
103 * @param {!Array<!chrome.passwordsPrivate.PasswordUiEntry>} passwordList 111 * @param {!Array<!chrome.passwordsPrivate.PasswordUiEntry>} passwordList
104 * @param {!Array<!chrome.passwordsPrivate.ExceptionPair>} exceptionList 112 * @param {!Array<!chrome.passwordsPrivate.ExceptionPair>} exceptionList
105 * @return {!Object} 113 * @return {!Object}
106 * @private 114 * @private
107 */ 115 */
108 createPasswordsSection_: function(passwordList, exceptionList) { 116 createPasswordsSection_: function(passwordList, exceptionList) {
117 // Override the PasswordManager data for testing.
118 this.passwordManager.data.passwords = passwordList;
119 this.passwordManager.data.exceptions = exceptionList;
120
109 // Create a passwords-section to use for testing. 121 // Create a passwords-section to use for testing.
110 var passwordsSection = document.createElement('passwords-section'); 122 var passwordsSection = document.createElement('passwords-section');
111 passwordsSection.savedPasswords = passwordList;
112 passwordsSection.passwordExceptions = exceptionList;
113 document.body.appendChild(passwordsSection); 123 document.body.appendChild(passwordsSection);
114 this.flushPasswordSection_(passwordsSection); 124 this.flushPasswordSection_(passwordsSection);
115 return passwordsSection; 125 return passwordsSection;
116 }, 126 },
117 127
118 /** 128 /**
119 * Helper method used to create a password editing dialog. 129 * Helper method used to create a password editing dialog.
120 * @param {!chrome.passwordsPrivate.PasswordUiEntry} passwordItem 130 * @param {!chrome.passwordsPrivate.PasswordUiEntry} passwordItem
121 * @return {!Object} 131 * @return {!Object}
122 * @private 132 * @private
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 FakeDataMaker.passwordEntry('six', 'one', 6), 250 FakeDataMaker.passwordEntry('six', 'one', 6),
241 ]; 251 ];
242 252
243 var passwordsSection = self.createPasswordsSection_(passwordList, []); 253 var passwordsSection = self.createPasswordsSection_(passwordList, []);
244 254
245 // The first child is a template, skip and get the real 'first child'. 255 // The first child is a template, skip and get the real 'first child'.
246 var firstNode = Polymer.dom(passwordsSection.$.passwordList).children[1]; 256 var firstNode = Polymer.dom(passwordsSection.$.passwordList).children[1];
247 assert(firstNode); 257 assert(firstNode);
248 var firstPassword = passwordList[0]; 258 var firstPassword = passwordList[0];
249 259
250 // Listen for the remove event. If this event isn't received, the test 260 self.passwordManager.onRemoveSavedPassword = function(detail) {
dpapad 2017/01/28 00:10:30 The PasswordManager class seems to be just like an
251 // will time out and fail.
252 passwordsSection.addEventListener('remove-saved-password',
253 function(event) {
254 // Verify that the event matches the expected value. 261 // Verify that the event matches the expected value.
255 assertEquals(firstPassword.loginPair.originUrl, 262 assertEquals(firstPassword.loginPair.originUrl, detail.originUrl);
256 event.detail.originUrl); 263 assertEquals(firstPassword.loginPair.username, detail.username);
257 assertEquals(firstPassword.loginPair.username, 264
258 event.detail.username); 265 // Clean up after self.
266 self.passwordManager.onRemoveSavedPassword = null;
267
259 done(); 268 done();
260 }); 269 };
261 270
262 // Click the remove button on the first password. 271 // Click the remove button on the first password.
263 MockInteractions.tap(firstNode.querySelector('#passwordMenu')); 272 MockInteractions.tap(firstNode.querySelector('#passwordMenu'));
264 MockInteractions.tap(passwordsSection.$.menuRemovePassword); 273 MockInteractions.tap(passwordsSection.$.menuRemovePassword);
265 }); 274 });
266 275
267 test('verifyFilterPasswords', function() { 276 test('verifyFilterPasswords', function() {
268 var passwordList = [ 277 var passwordList = [
269 FakeDataMaker.passwordEntry('one.com', 'show', 5), 278 FakeDataMaker.passwordEntry('one.com', 'show', 5),
270 FakeDataMaker.passwordEntry('two.com', 'shower', 3), 279 FakeDataMaker.passwordEntry('two.com', 'shower', 3),
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 self.getDomRepeatChildren_(passwordsSection.$.passwordExceptionsList); 399 self.getDomRepeatChildren_(passwordsSection.$.passwordExceptionsList);
391 400
392 // The index of the button currently being checked. 401 // The index of the button currently being checked.
393 var index = 0; 402 var index = 0;
394 403
395 var clickRemoveButton = function() { 404 var clickRemoveButton = function() {
396 MockInteractions.tap( 405 MockInteractions.tap(
397 exceptions[index].querySelector('#removeExceptionButton')); 406 exceptions[index].querySelector('#removeExceptionButton'));
398 }; 407 };
399 408
400 // Listen for the remove event. If this event isn't received, the test 409 self.passwordManager.onRemoveException = function(detail) {
401 // will time out and fail.
402 passwordsSection.addEventListener('remove-password-exception',
Dan Beam 2017/01/27 01:11:32 why can't we just use events like we were before?
hcarmona 2017/01/27 18:28:16 The event was fired so the parent element could ha
403 function(event) {
404 // Verify that the event matches the expected value. 410 // Verify that the event matches the expected value.
405 assertTrue(index < exceptionList.length); 411 assertTrue(index < exceptionList.length);
406 assertEquals(exceptionList[index].exceptionUrl, event.detail); 412 assertEquals(exceptionList[index].exceptionUrl, detail);
407 413
408 if (++index < exceptionList.length) 414 if (++index < exceptionList.length) {
409 clickRemoveButton(); // Click 'remove' on all passwords, one by one. 415 clickRemoveButton(); // Click 'remove' on all passwords, one by one.
410 else 416 } else {
417 // Clean up after self.
418 self.passwordManager.onRemoveException = null;
419
411 done(); 420 done();
412 }); 421 }
422 };
413 423
414 // Start removing. 424 // Start removing.
415 clickRemoveButton(); 425 clickRemoveButton();
416 }); 426 });
417 427
418 test('showSavedPassword', function() { 428 test('showSavedPassword', function() {
419 var PASSWORD = 'bAn@n@5'; 429 var PASSWORD = 'bAn@n@5';
420 var item = FakeDataMaker.passwordEntry('goo.gl', 'bart', PASSWORD.length); 430 var item = FakeDataMaker.passwordEntry('goo.gl', 'bart', PASSWORD.length);
421 var passwordDialog = self.createPasswordDialog_(item); 431 var passwordDialog = self.createPasswordDialog_(item);
422 432
(...skipping 19 matching lines...) Expand all
442 assertEquals(item.loginPair.username, event.detail.username); 452 assertEquals(item.loginPair.username, event.detail.username);
443 done(); 453 done();
444 }); 454 });
445 455
446 MockInteractions.tap(passwordDialog.$.showPasswordButton); 456 MockInteractions.tap(passwordDialog.$.showPasswordButton);
447 }); 457 });
448 }); 458 });
449 459
450 mocha.run(); 460 mocha.run();
451 }); 461 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698