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

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: Undo indent for better diff Created 3 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 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 }, 99 },
100 100
101 /** 101 /**
102 * Helper method used to create a password section for the given lists. 102 * Helper method used to create a password section for the given lists.
103 * @param {!Array<!chrome.passwordsPrivate.PasswordUiEntry>} passwordList 103 * @param {!Array<!chrome.passwordsPrivate.PasswordUiEntry>} passwordList
104 * @param {!Array<!chrome.passwordsPrivate.ExceptionPair>} exceptionList 104 * @param {!Array<!chrome.passwordsPrivate.ExceptionPair>} exceptionList
105 * @return {!Object} 105 * @return {!Object}
106 * @private 106 * @private
107 */ 107 */
108 createPasswordsSection_: function(passwordList, exceptionList) { 108 createPasswordsSection_: function(passwordList, exceptionList) {
109 // Override the PasswordManagerImpl for testing.
110 this.passwordManager = new TestPasswordManager();
111 this.passwordManager.data.passwords = passwordList;
112 this.passwordManager.data.exceptions = exceptionList;
113 PasswordManagerImpl.instance_ = this.passwordManager;
114
109 // Create a passwords-section to use for testing. 115 // Create a passwords-section to use for testing.
110 var passwordsSection = document.createElement('passwords-section'); 116 var passwordsSection = document.createElement('passwords-section');
111 passwordsSection.savedPasswords = passwordList;
112 passwordsSection.passwordExceptions = exceptionList;
113 document.body.appendChild(passwordsSection); 117 document.body.appendChild(passwordsSection);
114 this.flushPasswordSection_(passwordsSection); 118 this.flushPasswordSection_(passwordsSection);
115 return passwordsSection; 119 return passwordsSection;
116 }, 120 },
117 121
118 /** 122 /**
119 * Helper method used to create a password editing dialog. 123 * Helper method used to create a password editing dialog.
120 * @param {!chrome.passwordsPrivate.PasswordUiEntry} passwordItem 124 * @param {!chrome.passwordsPrivate.PasswordUiEntry} passwordItem
121 * @return {!Object} 125 * @return {!Object}
122 * @private 126 * @private
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 FakeDataMaker.passwordEntry('six', 'one', 6), 244 FakeDataMaker.passwordEntry('six', 'one', 6),
241 ]; 245 ];
242 246
243 var passwordsSection = self.createPasswordsSection_(passwordList, []); 247 var passwordsSection = self.createPasswordsSection_(passwordList, []);
244 248
245 // The first child is a template, skip and get the real 'first child'. 249 // The first child is a template, skip and get the real 'first child'.
246 var firstNode = Polymer.dom(passwordsSection.$.passwordList).children[1]; 250 var firstNode = Polymer.dom(passwordsSection.$.passwordList).children[1];
247 assert(firstNode); 251 assert(firstNode);
248 var firstPassword = passwordList[0]; 252 var firstPassword = passwordList[0];
249 253
250 // Listen for the remove event. If this event isn't received, the test 254 self.passwordManager.removeSavedPassword = function(detail) {
Dan Beam 2017/01/26 19:10:45 wait, what is this doing? redefining a part of a
hcarmona 2017/01/26 21:34:47 Yes. That's weird. Updated.
251 // will time out and fail.
252 passwordsSection.addEventListener('remove-saved-password',
253 function(event) {
254 // Verify that the event matches the expected value. 255 // Verify that the event matches the expected value.
255 assertEquals(firstPassword.loginPair.originUrl, 256 assertEquals(firstPassword.loginPair.originUrl, detail.originUrl);
256 event.detail.originUrl); 257 assertEquals(firstPassword.loginPair.username, detail.username);
257 assertEquals(firstPassword.loginPair.username,
258 event.detail.username);
259 done(); 258 done();
260 }); 259 };
261 260
262 // Click the remove button on the first password. 261 // Click the remove button on the first password.
263 MockInteractions.tap(firstNode.querySelector('#passwordMenu')); 262 MockInteractions.tap(firstNode.querySelector('#passwordMenu'));
264 MockInteractions.tap(passwordsSection.$.menuRemovePassword); 263 MockInteractions.tap(passwordsSection.$.menuRemovePassword);
265 }); 264 });
266 265
267 test('verifyFilterPasswords', function() { 266 test('verifyFilterPasswords', function() {
268 var passwordList = [ 267 var passwordList = [
269 FakeDataMaker.passwordEntry('one.com', 'show', 5), 268 FakeDataMaker.passwordEntry('one.com', 'show', 5),
270 FakeDataMaker.passwordEntry('two.com', 'shower', 3), 269 FakeDataMaker.passwordEntry('two.com', 'shower', 3),
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 self.getDomRepeatChildren_(passwordsSection.$.passwordExceptionsList); 389 self.getDomRepeatChildren_(passwordsSection.$.passwordExceptionsList);
391 390
392 // The index of the button currently being checked. 391 // The index of the button currently being checked.
393 var index = 0; 392 var index = 0;
394 393
395 var clickRemoveButton = function() { 394 var clickRemoveButton = function() {
396 MockInteractions.tap( 395 MockInteractions.tap(
397 exceptions[index].querySelector('#removeExceptionButton')); 396 exceptions[index].querySelector('#removeExceptionButton'));
398 }; 397 };
399 398
400 // Listen for the remove event. If this event isn't received, the test 399 self.passwordManager.removeException = function(detail) {
401 // will time out and fail.
402 passwordsSection.addEventListener('remove-password-exception',
403 function(event) {
404 // Verify that the event matches the expected value. 400 // Verify that the event matches the expected value.
405 assertTrue(index < exceptionList.length); 401 assertTrue(index < exceptionList.length);
406 assertEquals(exceptionList[index].exceptionUrl, event.detail); 402 assertEquals(exceptionList[index].exceptionUrl, detail);
407 403
408 if (++index < exceptionList.length) 404 if (++index < exceptionList.length)
409 clickRemoveButton(); // Click 'remove' on all passwords, one by one. 405 clickRemoveButton(); // Click 'remove' on all passwords, one by one.
410 else 406 else
411 done(); 407 done();
412 }); 408 };
413 409
414 // Start removing. 410 // Start removing.
415 clickRemoveButton(); 411 clickRemoveButton();
416 }); 412 });
417 413
418 test('showSavedPassword', function() { 414 test('showSavedPassword', function() {
419 var PASSWORD = 'bAn@n@5'; 415 var PASSWORD = 'bAn@n@5';
420 var item = FakeDataMaker.passwordEntry('goo.gl', 'bart', PASSWORD.length); 416 var item = FakeDataMaker.passwordEntry('goo.gl', 'bart', PASSWORD.length);
421 var passwordDialog = self.createPasswordDialog_(item); 417 var passwordDialog = self.createPasswordDialog_(item);
422 418
(...skipping 19 matching lines...) Expand all
442 assertEquals(item.loginPair.username, event.detail.username); 438 assertEquals(item.loginPair.username, event.detail.username);
443 done(); 439 done();
444 }); 440 });
445 441
446 MockInteractions.tap(passwordDialog.$.showPasswordButton); 442 MockInteractions.tap(passwordDialog.$.showPasswordButton);
447 }); 443 });
448 }); 444 });
449 445
450 mocha.run(); 446 mocha.run();
451 }); 447 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698