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

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: Fix tests and nits Created 3 years, 7 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.shown,
64 node.querySelector('#originUrl').textContent.trim()); 64 node.querySelector('#originUrl').textContent.trim());
65 assertEquals(passwordInfo.linkUrl, 65 assertEquals(passwordInfo.loginPair.urls.link,
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.urls.shown,
88 node.querySelector('#exception').textContent); 88 node.querySelector('#exception').textContent);
89 assertEquals(exception.linkUrl, 89 assertEquals(exception.urls.link, node.querySelector('#exception').href);
90 node.querySelector('#exception').href);
91 } 90 }
92 } 91 }
93 92
94 /** 93 /**
95 * Returns all children of an element that has children added by a dom-repeat. 94 * Returns all children of an element that has children added by a dom-repeat.
96 * @param {!Element} element 95 * @param {!Element} element
97 * @return {!Array<!Element>} 96 * @return {!Array<!Element>}
98 * @private 97 * @private
99 */ 98 */
100 function getDomRepeatChildren(element) { 99 function getDomRepeatChildren(element) {
101 var nodes = element.querySelectorAll('.list-item:not([id])'); 100 var nodes = element.querySelectorAll('.list-item:not([id])');
102 return nodes; 101 return nodes;
103 } 102 }
104 103
105 /** 104 /**
106 * Allow the iron-list to be sized properly. 105 * Allow the iron-list to be sized properly.
107 * @param {!Object} passwordsSection 106 * @param {!Object} passwordsSection
108 * @private 107 * @private
109 */ 108 */
110 function flushPasswordSection(passwordsSection) { 109 function flushPasswordSection(passwordsSection) {
111 passwordsSection.$.passwordList.notifyResize(); 110 passwordsSection.$.passwordList.notifyResize();
112 Polymer.dom.flush(); 111 Polymer.dom.flush();
113 } 112 }
114 113
115 /** 114 /**
116 * Helper method used to create a password section for the given lists. 115 * Helper method used to create a password section for the given lists.
117 * @param {!PasswordManager} passwordManager 116 * @param {!PasswordManager} passwordManager
118 * @param {!Array<!chrome.passwordsPrivate.PasswordUiEntry>} passwordList 117 * @param {!Array<!chrome.passwordsPrivate.PasswordUiEntry>} passwordList
119 * @param {!Array<!chrome.passwordsPrivate.ExceptionPair>} exceptionList 118 * @param {!Array<!chrome.passwordsPrivate.ExceptionEntry>} exceptionList
120 * @return {!Object} 119 * @return {!Object}
121 * @private 120 * @private
122 */ 121 */
123 function createPasswordsSection(passwordManager, passwordList, 122 function createPasswordsSection(passwordManager, passwordList,
124 exceptionList) { 123 exceptionList) {
125 // Override the PasswordManager data for testing. 124 // Override the PasswordManager data for testing.
126 passwordManager.data.passwords = passwordList; 125 passwordManager.data.passwords = passwordList;
127 passwordManager.data.exceptions = exceptionList; 126 passwordManager.data.exceptions = exceptionList;
128 127
129 // Create a passwords-section to use for testing. 128 // Create a passwords-section to use for testing.
(...skipping 17 matching lines...) Expand all
147 return passwordDialog; 146 return passwordDialog;
148 } 147 }
149 148
150 /** 149 /**
151 * Helper method used to test for a url in a list of passwords. 150 * Helper method used to test for a url in a list of passwords.
152 * @param {!Array<!chrome.passwordsPrivate.PasswordUiEntry>} passwordList 151 * @param {!Array<!chrome.passwordsPrivate.PasswordUiEntry>} passwordList
153 * @param {string} url The URL that is being searched for. 152 * @param {string} url The URL that is being searched for.
154 */ 153 */
155 function listContainsUrl(passwordList, url) { 154 function listContainsUrl(passwordList, url) {
156 for (var i = 0; i < passwordList.length; ++i) { 155 for (var i = 0; i < passwordList.length; ++i) {
157 if (passwordList[i].loginPair.originUrl == url) 156 if (passwordList[i].loginPair.urls.origin == url)
158 return true; 157 return true;
159 } 158 }
160 return false; 159 return false;
161 } 160 }
162 161
163 /** 162 /**
164 * Helper method used to test for a url in a list of passwords. 163 * Helper method used to test for a url in a list of passwords.
165 * @param {!Array<!chrome.passwordsPrivate.ExceptionPair>} exceptionList 164 * @param {!Array<!chrome.passwordsPrivate.ExceptionEntry>} exceptionList
166 * @param {string} url The URL that is being searched for. 165 * @param {string} url The URL that is being searched for.
167 */ 166 */
168 function exceptionsListContainsUrl(exceptionList, url) { 167 function exceptionsListContainsUrl(exceptionList, url) {
169 for (var i = 0; i < exceptionList.length; ++i) { 168 for (var i = 0; i < exceptionList.length; ++i) {
170 if (exceptionList[i].exceptionUrl == url) 169 if (exceptionList[i].urls.orginUrl == url)
171 return true; 170 return true;
172 } 171 }
173 return false; 172 return false;
174 } 173 }
175 174
176 suite('PasswordsSection', function() { 175 suite('PasswordsSection', function() {
177 /** @type {TestPasswordManager} */ 176 /** @type {TestPasswordManager} */
178 var passwordManager = null; 177 var passwordManager = null;
179 178
180 setup(function() { 179 setup(function() {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 var passwordsSection = createPasswordsSection( 266 var passwordsSection = createPasswordsSection(
268 passwordManager, passwordList, []); 267 passwordManager, passwordList, []);
269 268
270 // The first child is a template, skip and get the real 'first child'. 269 // The first child is a template, skip and get the real 'first child'.
271 var firstNode = Polymer.dom(passwordsSection.$.passwordList).children[1]; 270 var firstNode = Polymer.dom(passwordsSection.$.passwordList).children[1];
272 assert(firstNode); 271 assert(firstNode);
273 var firstPassword = passwordList[0]; 272 var firstPassword = passwordList[0];
274 273
275 passwordManager.onRemoveSavedPassword = function(detail) { 274 passwordManager.onRemoveSavedPassword = function(detail) {
276 // Verify that the event matches the expected value. 275 // Verify that the event matches the expected value.
277 assertEquals(firstPassword.loginPair.originUrl, detail.originUrl); 276 assertEquals(firstPassword.loginPair.urls.origin, detail.urls.origin);
278 assertEquals(firstPassword.loginPair.username, detail.username); 277 assertEquals(firstPassword.loginPair.username, detail.username);
279 278
280 // Clean up after self. 279 // Clean up after self.
281 passwordManager.onRemoveSavedPassword = null; 280 passwordManager.onRemoveSavedPassword = null;
282 281
283 done(); 282 done();
284 }; 283 };
285 284
286 // Click the remove button on the first password. 285 // Click the remove button on the first password.
287 MockInteractions.tap(firstNode.querySelector('#passwordMenu')); 286 MockInteractions.tap(firstNode.querySelector('#passwordMenu'));
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 var index = 0; 421 var index = 0;
423 422
424 var clickRemoveButton = function() { 423 var clickRemoveButton = function() {
425 MockInteractions.tap( 424 MockInteractions.tap(
426 exceptions[index].querySelector('#removeExceptionButton')); 425 exceptions[index].querySelector('#removeExceptionButton'));
427 }; 426 };
428 427
429 passwordManager.onRemoveException = function(detail) { 428 passwordManager.onRemoveException = function(detail) {
430 // Verify that the event matches the expected value. 429 // Verify that the event matches the expected value.
431 assertTrue(index < exceptionList.length); 430 assertTrue(index < exceptionList.length);
432 assertEquals(exceptionList[index].exceptionUrl, detail); 431 assertEquals(exceptionList[index].urls.origin, detail);
433 432
434 if (++index < exceptionList.length) { 433 if (++index < exceptionList.length) {
435 clickRemoveButton(); // Click 'remove' on all passwords, one by one. 434 clickRemoveButton(); // Click 'remove' on all passwords, one by one.
436 } else { 435 } else {
437 // Clean up after self. 436 // Clean up after self.
438 passwordManager.onRemoveException = null; 437 passwordManager.onRemoveException = null;
439 438
440 done(); 439 done();
441 } 440 }
442 }; 441 };
(...skipping 18 matching lines...) Expand all
461 assertEquals('text', 460 assertEquals('text',
462 passwordDialog.$.passwordInput.type); 461 passwordDialog.$.passwordInput.type);
463 }); 462 });
464 463
465 // Test will timeout if event is not received. 464 // Test will timeout if event is not received.
466 test('onShowSavedPassword', function(done) { 465 test('onShowSavedPassword', function(done) {
467 var item = FakeDataMaker.passwordEntry('goo.gl', 'bart', 1); 466 var item = FakeDataMaker.passwordEntry('goo.gl', 'bart', 1);
468 var passwordDialog = createPasswordDialog(item); 467 var passwordDialog = createPasswordDialog(item);
469 468
470 passwordDialog.addEventListener('show-password', function(event) { 469 passwordDialog.addEventListener('show-password', function(event) {
471 assertEquals(item.loginPair.originUrl, event.detail.originUrl); 470 assertEquals(item.loginPair.urls.origin, event.detail.urls.origin);
472 assertEquals(item.loginPair.username, event.detail.username); 471 assertEquals(item.loginPair.username, event.detail.username);
473 done(); 472 done();
474 }); 473 });
475 474
476 MockInteractions.tap(passwordDialog.$.showPasswordButton); 475 MockInteractions.tap(passwordDialog.$.showPasswordButton);
477 }); 476 });
478 }); 477 });
479 478
480 mocha.run(); 479 mocha.run();
481 }); 480 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698