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

Side by Side 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: Feedback 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 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 21 matching lines...) Expand all
32 * This test will validate that the section is loaded with data. 32 * This test will validate that the section is loaded with data.
33 */ 33 */
34 TEST_F('SettingsPasswordSectionBrowserTest', 'uiTests', function() { 34 TEST_F('SettingsPasswordSectionBrowserTest', 'uiTests', function() {
35 var self = this; 35 var self = this;
36 36
37 suite('PasswordsSection', function() { 37 suite('PasswordsSection', function() {
38 test('doWork', function(done) { 38 test('doWork', function(done) {
39 assertEquals(self.browsePreload, document.location.href, 39 assertEquals(self.browsePreload, document.location.href,
40 'Unexpected URL loaded'); 40 'Unexpected URL loaded');
41 41
42 var passwordList = [{origin: 'anotherwebsite.com', 42 var passwordList = [{shownUrl: 'anotherwebsite.com',
43 username: 'luigi', 43 username: 'luigi',
44 password: '*******'}, 44 password: '*******'},
45 {origin: 'longwebsite.com', 45 {shownUrl: 'longwebsite.com',
46 username: 'peach', 46 username: 'peach',
47 password: '***'}, 47 password: '***'},
48 {origin: 'website.com', 48 {shownUrl: 'website.com',
49 username: 'mario', 49 username: 'mario',
50 password: '*******'}]; 50 password: '*******'}];
51 51
52 // Create a passwords-section to use for testing. 52 // Create a passwords-section to use for testing.
53 var passwordsSection = document.createElement('passwords-section'); 53 var passwordsSection = document.createElement('passwords-section');
54 passwordsSection.savedPasswords = passwordList; 54 passwordsSection.savedPasswords = passwordList;
55 document.body.appendChild(passwordsSection); 55 document.body.appendChild(passwordsSection);
56 56
57 // TODO(hcarmona): use an event listener rather than a setTimeout(0). 57 // TODO(hcarmona): use an event listener rather than a setTimeout(0).
58 window.setTimeout(function() { 58 window.setTimeout(function() {
59 // Assert that the data is passed into the iron list. If this fails, 59 // Assert that the data is passed into the iron list. If this fails,
60 // then other expectations will also fail. 60 // then other expectations will also fail.
61 assertEquals(passwordList, passwordsSection.$.passwordList.items, 61 assertEquals(passwordList, passwordsSection.$.passwordList.items,
62 'Failed to pass list of passwords to iron-list'); 62 'Failed to pass list of passwords to iron-list');
63 63
64 var list = Polymer.dom(passwordsSection.$.passwordList); 64 var list = Polymer.dom(passwordsSection.$.passwordList);
65 assertTrue(!!list, "Failed to get the password list"); 65 assertTrue(!!list, 'Failed to get the password list');
66 // Skip the first child because it's the template. 66 // Skip the first child because it's the template.
67 var listChildren = list.children.slice(1); 67 var listChildren = list.children.slice(1);
68 68
69 var validate = function(nodes, passwordList, index) { 69 var validate = function(nodes, passwordList, index) {
dpapad 2016/01/20 17:56:07 Nit: Can you add some type annotation to this func
hcarmona 2016/01/20 23:13:53 Done.
70 assertTrue(!!nodes[index], 'Failed to get nodes[' + index + ']'); 70 assertTrue(!!nodes[index], 'Failed to get nodes[' + index + ']');
dpapad 2016/01/20 17:56:07 Nit (optional): How about var node = nodes[index]
hcarmona 2016/01/20 23:13:53 Done.
71 assertEquals(passwordList[index].origin, 71 assertEquals(passwordList[index].shownUrl,
72 nodes[index].querySelector('#origin').textContent, 72 nodes[index].querySelector('#shownUrl').textContent,
73 'origin mismatch in nodes[' + index + ']'); 73 'shownUrl mismatch in nodes[' + index + ']');
74 assertEquals(passwordList[index].username, 74 assertEquals(passwordList[index].username,
75 nodes[index].querySelector('#username').textContent, 75 nodes[index].querySelector('#username').textContent,
76 'username mismatch in nodes[' + index + ']'); 76 'username mismatch in nodes[' + index + ']');
77 assertEquals(passwordList[index].password, 77 assertEquals(passwordList[index].password,
78 nodes[index].querySelector('#password').textContent, 78 nodes[index].querySelector('#password').value,
79 'password mismatch in nodes[' + index + ']'); 79 'password mismatch in nodes[' + index + ']');
80 }; 80 };
81 81
82 validate(listChildren, passwordList, 0); 82 validate(listChildren, passwordList, 0);
83 validate(listChildren, passwordList, 1); 83 validate(listChildren, passwordList, 1);
84 validate(listChildren, passwordList, 2); 84 validate(listChildren, passwordList, 2);
85 done(); 85 done();
86 }, 0); 86 }, 0);
87 }); 87 });
88 }); 88 });
89 89
90 mocha.run(); 90 mocha.run();
91 }); 91 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698