Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 Passwords and Forms tests. */ | 5 /** @fileoverview Runs the Polymer Passwords and Forms 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. |
| 11 GEN_INCLUDE( | 11 GEN_INCLUDE( |
| 12 [ROOT_PATH + 'chrome/test/data/webui/polymer_browser_test_base.js']); | 12 [ROOT_PATH + 'chrome/test/data/webui/polymer_browser_test_base.js']); |
| 13 | 13 |
| 14 // Fake data generator. | 14 // Fake data generator. |
| 15 GEN_INCLUDE([ROOT_PATH + | 15 GEN_INCLUDE([ROOT_PATH + |
| 16 'chrome/test/data/webui/settings/passwords_and_autofill_fake_data.js']); | 16 'chrome/test/data/webui/settings/passwords_and_autofill_fake_data.js']); |
| 17 | 17 |
| 18 function PasswordManagerExpectations() {}; | |
| 19 PasswordManagerExpectations.prototype = { | |
| 20 requested: { | |
| 21 passwords: 0, | |
| 22 exceptions: 0, | |
| 23 plaintextPassword: 0, | |
| 24 }, | |
| 25 | |
| 26 removed: { | |
| 27 passwords: 0, | |
| 28 exceptions: 0, | |
| 29 }, | |
| 30 | |
| 31 listening: { | |
| 32 passwords: 0, | |
| 33 exceptions: 0, | |
| 34 }, | |
| 35 }; | |
| 36 | |
| 37 /** | |
| 38 * Test implementation | |
| 39 * @implements {PasswordManager} | |
| 40 * @constructor | |
| 41 */ | |
| 42 function TestPasswordManager() { | |
| 43 this.actual_ = new PasswordManagerExpectations(); | |
| 44 }; | |
| 45 TestPasswordManager.prototype = { | |
| 46 /** @override */ | |
| 47 addSavedPasswordListChangedListener: function(listener) { | |
| 48 this.actual_.listening.passwords++; | |
| 49 this.lastCallback.addSavedPasswordListChangedListener = listener; | |
| 50 }, | |
| 51 | |
| 52 /** @override */ | |
| 53 removeSavedPasswordListChangedListener: function(listener) { | |
| 54 this.actual_.listening.passwords--; | |
| 55 }, | |
| 56 | |
| 57 /** @override */ | |
| 58 getSavedPasswordList: function(callback) { | |
| 59 this.actual_.requested.passwords++; | |
| 60 callback(this.data.passwords); | |
| 61 }, | |
| 62 | |
| 63 /** @override */ | |
| 64 removeSavedPassword: function(loginPair) { | |
| 65 this.actual_.removed.passwords++; | |
| 66 }, | |
| 67 | |
| 68 /** @override */ | |
| 69 addExceptionListChangedListener: function(listener) { | |
| 70 this.actual_.listening.exceptions++; | |
| 71 this.lastCallback.addExceptionListChangedListener = listener; | |
| 72 }, | |
| 73 | |
| 74 /** @override */ | |
| 75 removeExceptionListChangedListener: function(listener) { | |
| 76 this.actual_.listening.exceptions--; | |
| 77 }, | |
| 78 | |
| 79 /** @override */ | |
| 80 getExceptionList: function(callback) { | |
| 81 this.actual_.requested.exceptions++; | |
| 82 callback(this.data.exceptions); | |
| 83 }, | |
| 84 | |
| 85 /** @override */ | |
| 86 removeException: function(exception) { | |
| 87 this.actual_.removed.exceptions++; | |
| 88 }, | |
| 89 | |
| 90 /** @override */ | |
| 91 getPlaintextPassword: function(loginPair, callback) { | |
| 92 this.actual_.requested.plaintextPassword++; | |
| 93 this.lastCallback.getPlaintextPassword = callback; | |
| 94 }, | |
| 95 | |
| 96 /** | |
| 97 * Verifies expectations. | |
| 98 * @param {!PasswordManagerExpectations} expected | |
| 99 */ | |
| 100 assertExpectations: function(expected) { | |
| 101 var actual = this.actual_; | |
| 102 | |
| 103 assertEquals(expected.requested.passwords, actual.requested.passwords); | |
| 104 assertEquals(expected.requested.exceptions, actual.requested.exceptions); | |
| 105 assertEquals(expected.requested.plaintextPassword, | |
| 106 actual.requested.plaintextPassword); | |
| 107 | |
| 108 assertEquals(expected.removed.passwords, actual.removed.passwords); | |
| 109 assertEquals(expected.removed.exceptions, actual.removed.exceptions); | |
| 110 | |
| 111 assertEquals(expected.listening.passwords, actual.listening.passwords); | |
| 112 assertEquals(expected.listening.exceptions, actual.listening.exceptions); | |
| 113 }, | |
| 114 | |
| 115 // Set these to have non-empty data. | |
| 116 data: { | |
| 117 passwords: [], | |
| 118 exceptions: [], | |
| 119 }, | |
| 120 | |
| 121 // Holds the last callbacks so they can be called when needed/ | |
| 122 lastCallback: { | |
| 123 addSavedPasswordListChangedListener: null, | |
| 124 addExceptionListChangedListener: null, | |
| 125 getPlaintextPassword: null, | |
| 126 }, | |
| 127 }; | |
| 128 | |
| 129 function AutofillManagerExpectations() {}; | |
| 130 AutofillManagerExpectations.prototype = { | |
| 131 requested: { | |
| 132 addresses: 0, | |
| 133 creditCards: 0, | |
| 134 }, | |
| 135 | |
| 136 listening: { | |
| 137 addresses: 0, | |
| 138 creditCards: 0, | |
| 139 }, | |
| 140 }; | |
| 141 | |
| 142 /** | |
| 143 * Test implementation | |
| 144 * @implements {AutofillManager} | |
| 145 * @constructor | |
| 146 */ | |
| 147 function TestAutofillManager() { | |
| 148 this.actual_ = new AutofillManagerExpectations(); | |
| 149 }; | |
| 150 TestAutofillManager.prototype = { | |
| 151 /** @override */ | |
| 152 addAddressListChangedListener: function(listener) { | |
| 153 this.actual_.listening.addresses++; | |
| 154 this.lastCallback.addAddressListChangedListener = listener; | |
| 155 }, | |
| 156 | |
| 157 /** @override */ | |
| 158 removeAddressListChangedListener: function(listener) { | |
| 159 this.actual_.listening.addresses--; | |
| 160 }, | |
| 161 | |
| 162 /** @override */ | |
| 163 getAddressList: function(callback) { | |
| 164 this.actual_.requested.addresses++; | |
| 165 callback(this.data.addresses); | |
| 166 }, | |
| 167 | |
| 168 /** @override */ | |
| 169 addCreditCardListChangedListener: function(listener) { | |
| 170 this.actual_.listening.creditCards++; | |
| 171 this.lastCallback.addCreditCardListChangedListener = listener; | |
| 172 }, | |
| 173 | |
| 174 /** @override */ | |
| 175 removeCreditCardListChangedListener: function(listener) { | |
| 176 this.actual_.listening.creditCards--; | |
| 177 }, | |
| 178 | |
| 179 /** @override */ | |
| 180 getCreditCardList: function(callback) { | |
| 181 this.actual_.requested.creditCards++; | |
| 182 callback(this.data.creditCards); | |
| 183 }, | |
| 184 | |
| 185 /** | |
| 186 * Verifies expectations. | |
| 187 * @param {!AutofillManagerExpectations} expected | |
| 188 */ | |
| 189 assertExpectations: function(expected) { | |
| 190 var actual = this.actual_; | |
| 191 | |
| 192 assertEquals(expected.requested.addresses, actual.requested.addresses); | |
| 193 assertEquals(expected.requested.creditCards, actual.requested.creditCards); | |
| 194 | |
| 195 assertEquals(expected.listening.addresses, actual.listening.addresses); | |
| 196 assertEquals(expected.listening.creditCards, actual.listening.creditCards); | |
| 197 }, | |
| 198 | |
| 199 // Set these to have non-empty data. | |
| 200 data: { | |
| 201 addresses: [], | |
| 202 creditCards: [], | |
| 203 }, | |
| 204 | |
| 205 // Holds the last callbacks so they can be called when needed/ | |
| 206 lastCallback: { | |
| 207 addAddressListChangedListener: null, | |
| 208 addCreditCardListChangedListener: null, | |
| 209 }, | |
| 210 }; | |
| 211 | |
| 212 /** | 18 /** |
| 213 * @constructor | 19 * @constructor |
| 214 * @extends {PolymerTest} | 20 * @extends {PolymerTest} |
| 215 */ | 21 */ |
| 216 function PasswordsAndFormsBrowserTest() {} | 22 function PasswordsAndFormsBrowserTest() {} |
| 217 | 23 |
| 218 PasswordsAndFormsBrowserTest.prototype = { | 24 PasswordsAndFormsBrowserTest.prototype = { |
| 219 __proto__: PolymerTest.prototype, | 25 __proto__: PolymerTest.prototype, |
| 220 | 26 |
| 221 /** @override */ | 27 /** @override */ |
| 222 browsePreload: 'chrome://md-settings/passwords_and_forms_page/' + | 28 browsePreload: 'chrome://md-settings/passwords_and_forms_page/' + |
| 223 'passwords_and_forms_page.html', | 29 'passwords_and_forms_page.html', |
| 224 | 30 |
| 225 /** @override */ | 31 /** @override */ |
| 226 extraLibraries: PolymerTest.getLibraries(ROOT_PATH).concat([ | 32 extraLibraries: PolymerTest.getLibraries(ROOT_PATH).concat([ |
| 227 '../fake_chrome_event.js', | 33 '../fake_chrome_event.js', |
| 228 'fake_settings_private.js', | 34 'fake_settings_private.js', |
| 229 ]), | 35 ]), |
| 230 | 36 |
| 231 /** @override */ | 37 /** @override */ |
| 232 setUp: function() { | 38 setUp: function() { |
| 233 PolymerTest.prototype.setUp.call(this); | 39 PolymerTest.prototype.setUp.call(this); |
| 234 | 40 |
| 235 // Test is run on an individual element that won't have a page language. | 41 // Test is run on an individual element that won't have a page language. |
| 236 this.accessibilityAuditConfig.auditRulesToIgnore.push('humanLangMissing'); | 42 this.accessibilityAuditConfig.auditRulesToIgnore.push('humanLangMissing'); |
| 237 | 43 |
| 238 // Override the PasswordManagerImpl for testing. | 44 // Override the PasswordManagerImpl for testing. |
| 239 this.passwordManager = new TestPasswordManager(); | 45 this.passwordManager = new TestPasswordManager(); |
| 240 PasswordManagerImpl.instance_ = this.passwordManager; | 46 PasswordManagerImpl.instance_ = this.passwordManager; |
| 241 | 47 |
| 242 // Override the AutofillManagerImpl for testing. | 48 // Override the AutofillManagerImpl for testing. |
| 243 this.autofillManager = new TestAutofillManager(); | 49 this.autofillManager = new TestAutofillManager(); |
| 244 AutofillManagerImpl.instance_ = this.autofillManager; | 50 AutofillManagerImpl.instance_ = this.autofillManager; |
| 245 }, | 51 }, |
| 246 | 52 |
| 247 /** @override */ | 53 /** @override */ |
| 248 tearDown: function() { | 54 tearDown: function() { |
| 249 PolymerTest.clearBody(); | 55 PolymerTest.clearBody(); |
| 250 }, | 56 }, |
| 251 | 57 |
| 252 /** | 58 /** |
| 253 * Creates a new passwords and forms element. | 59 * Creates a new passwords and forms element. |
| 254 * @return {!Object} | 60 * @return {!Object} |
| 255 */ | 61 */ |
| 256 createPasswordsAndFormsElement: function() { | 62 createPasswordsAndFormsElement: function(prefsElement) { |
| 257 var element = document.createElement('settings-passwords-and-forms-page'); | 63 var element = document.createElement('settings-passwords-and-forms-page'); |
| 64 element.prefs = prefsElement.prefs; | |
| 258 document.body.appendChild(element); | 65 document.body.appendChild(element); |
| 66 | |
| 67 var passwordsElement = element.$$('template[route-path="/passwords"'); | |
|
Dan Beam
2017/01/27 01:11:32
this still isn't correct
element.$$('template[rou
hcarmona
2017/01/27 18:28:16
Sorry about that. Done.
| |
| 68 var autofillElement = element.$$('template[route-path="/autofill"'); | |
| 69 | |
| 70 assertTrue(!!passwordsElement); | |
| 71 assertTrue(!!autofillElement); | |
| 72 | |
| 73 passwordsElement.if = true; | |
| 74 autofillElement.if = true; | |
| 75 | |
| 259 Polymer.dom.flush(); | 76 Polymer.dom.flush(); |
| 260 return element; | 77 return element; |
| 261 }, | 78 }, |
| 262 | 79 |
| 263 /** | 80 /** |
| 264 * @pram {boolean} autofill Whether autofill is enabled or not. | 81 * @pram {boolean} autofill Whether autofill is enabled or not. |
| 265 * @param {boolean} passwords Whether passwords are enabled or not. | 82 * @param {boolean} passwords Whether passwords are enabled or not. |
| 266 * @return {!Promise<!Element>} The |prefs| object. | 83 * @return {!Promise<!Element>} The |prefs| element. |
| 267 */ | 84 */ |
| 268 createPrefs: function(autofill, passwords) { | 85 createPrefs: function(autofill, passwords) { |
| 269 return new Promise(function(resolve) { | 86 return new Promise(function(resolve) { |
| 270 CrSettingsPrefs.deferInitialization = true; | 87 CrSettingsPrefs.deferInitialization = true; |
| 271 var prefs = document.createElement('settings-prefs'); | 88 var prefs = document.createElement('settings-prefs'); |
| 272 prefs.initialize(new settings.FakeSettingsPrivate([ | 89 prefs.initialize(new settings.FakeSettingsPrivate([ |
| 273 { | 90 { |
| 274 key: 'autofill.enabled', | 91 key: 'autofill.enabled', |
| 275 type: chrome.settingsPrivate.PrefType.BOOLEAN, | 92 type: chrome.settingsPrivate.PrefType.BOOLEAN, |
| 276 value: autofill, | 93 value: autofill, |
| 277 }, | 94 }, |
| 278 { | 95 { |
| 279 key: 'profile.password_manager_enabled', | 96 key: 'credentials_enable_autosignin', |
| 280 type: chrome.settingsPrivate.PrefType.BOOLEAN, | 97 type: chrome.settingsPrivate.PrefType.BOOLEAN, |
| 281 value: passwords, | 98 value: true, |
| 282 }, | 99 }, |
| 100 { | |
| 101 key: 'profile.password_manager_enabled', | |
| 102 type: chrome.settingsPrivate.PrefType.BOOLEAN, | |
| 103 value: passwords, | |
| 104 }, | |
| 283 ])); | 105 ])); |
| 284 | 106 |
| 285 CrSettingsPrefs.initialized.then(function() { | 107 CrSettingsPrefs.initialized.then(function() { |
| 286 resolve(prefs); | 108 resolve(prefs); |
| 287 }); | 109 }); |
| 288 }); | 110 }); |
| 289 }, | 111 }, |
| 290 | 112 |
| 291 /** | 113 /** |
| 292 * Cleans up prefs so tests can continue to run. | 114 * Cleans up prefs so tests can continue to run. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 326 return expected; | 148 return expected; |
| 327 }, | 149 }, |
| 328 }; | 150 }; |
| 329 | 151 |
| 330 /** This test will validate that the section is loaded with data. */ | 152 /** This test will validate that the section is loaded with data. */ |
| 331 TEST_F('PasswordsAndFormsBrowserTest', 'uiTests', function() { | 153 TEST_F('PasswordsAndFormsBrowserTest', 'uiTests', function() { |
| 332 var self = this; | 154 var self = this; |
| 333 | 155 |
| 334 suite('PasswordsAndForms', function() { | 156 suite('PasswordsAndForms', function() { |
| 335 test('baseLoadAndRemove', function() { | 157 test('baseLoadAndRemove', function() { |
| 336 var element = self.createPasswordsAndFormsElement(); | 158 return self.createPrefs(true, true).then(function(prefs) { |
| 159 var element = self.createPasswordsAndFormsElement(prefs); | |
| 337 | 160 |
| 338 var passwordsExpectations = self.basePasswordExpectations(); | 161 var passwordsExpectations = self.basePasswordExpectations(); |
| 339 self.passwordManager.assertExpectations(passwordsExpectations); | 162 self.passwordManager.assertExpectations(passwordsExpectations); |
| 340 | 163 |
| 341 var autofillExpectations = self.baseAutofillExpectations(); | 164 var autofillExpectations = self.baseAutofillExpectations(); |
| 342 self.autofillManager.assertExpectations(autofillExpectations); | 165 self.autofillManager.assertExpectations(autofillExpectations); |
| 343 | 166 |
| 344 element.remove(); | 167 element.remove(); |
| 345 Polymer.dom.flush(); | 168 Polymer.dom.flush(); |
| 346 | 169 |
| 347 passwordsExpectations.listening.passwords = 0; | 170 passwordsExpectations.listening.passwords = 0; |
| 348 passwordsExpectations.listening.exceptions = 0; | 171 passwordsExpectations.listening.exceptions = 0; |
| 349 self.passwordManager.assertExpectations(passwordsExpectations); | 172 self.passwordManager.assertExpectations(passwordsExpectations); |
| 350 | 173 |
| 351 autofillExpectations.listening.addresses = 0; | 174 autofillExpectations.listening.addresses = 0; |
| 352 autofillExpectations.listening.creditCards = 0; | 175 autofillExpectations.listening.creditCards = 0; |
| 353 self.autofillManager.assertExpectations(autofillExpectations); | 176 self.autofillManager.assertExpectations(autofillExpectations); |
| 177 | |
| 178 self.destroyPrefs(prefs); | |
| 179 }); | |
| 354 }); | 180 }); |
| 355 | 181 |
| 356 test('loadPasswordsAsync', function() { | 182 test('loadPasswordsAsync', function() { |
| 357 var element = self.createPasswordsAndFormsElement(); | 183 return self.createPrefs(true, true).then(function(prefs) { |
| 184 var element = self.createPasswordsAndFormsElement(prefs); | |
| 358 | 185 |
| 359 var list = [FakeDataMaker.passwordEntry(), FakeDataMaker.passwordEntry()]; | 186 var list = [ |
| 360 self.passwordManager.lastCallback.addSavedPasswordListChangedListener( | 187 FakeDataMaker.passwordEntry(), |
| 361 list); | 188 FakeDataMaker.passwordEntry() |
| 362 Polymer.dom.flush(); | 189 ]; |
| 363 | 190 |
| 364 assertEquals(list, element.savedPasswords); | 191 self.passwordManager.lastCallback.addSavedPasswordListChangedListener( |
| 192 list); | |
| 193 Polymer.dom.flush(); | |
| 365 | 194 |
| 366 // The callback is coming from the manager, so the element shouldn't have | 195 assertEquals(list, element.$$('#passwordSection').savedPasswords); |
| 367 // additional calls to the manager after the base expectations. | 196 |
| 368 self.passwordManager.assertExpectations(self.basePasswordExpectations()); | 197 // The callback is coming from the manager, so the element shouldn't |
| 369 self.autofillManager.assertExpectations(self.baseAutofillExpectations()); | 198 // have additional calls to the manager after the base expectations. |
| 199 self.passwordManager.assertExpectations( | |
| 200 self.basePasswordExpectations()); | |
| 201 self.autofillManager.assertExpectations( | |
| 202 self.baseAutofillExpectations()); | |
| 203 | |
| 204 self.destroyPrefs(prefs); | |
| 205 }); | |
| 370 }); | 206 }); |
| 371 | 207 |
| 372 test('loadExceptionsAsync', function() { | 208 test('loadExceptionsAsync', function() { |
| 373 var element = self.createPasswordsAndFormsElement(); | 209 return self.createPrefs(true, true).then(function(prefs) { |
| 210 var element = self.createPasswordsAndFormsElement(prefs); | |
| 374 | 211 |
| 375 var list = [FakeDataMaker.exceptionEntry(), | 212 var list = [FakeDataMaker.exceptionEntry(), |
| 376 FakeDataMaker.exceptionEntry()]; | 213 FakeDataMaker.exceptionEntry()]; |
| 377 self.passwordManager.lastCallback.addExceptionListChangedListener( | 214 self.passwordManager.lastCallback.addExceptionListChangedListener( |
| 378 list); | 215 list); |
| 379 Polymer.dom.flush(); | 216 Polymer.dom.flush(); |
| 380 | 217 |
| 381 assertEquals(list, element.passwordExceptions); | 218 assertEquals(list, element.$$('#passwordSection').passwordExceptions); |
| 382 | 219 |
| 383 // The callback is coming from the manager, so the element shouldn't have | 220 // The callback is coming from the manager, so the element shouldn't |
| 384 // additional calls to the manager after the base expectations. | 221 // have additional calls to the manager after the base expectations. |
| 385 self.passwordManager.assertExpectations(self.basePasswordExpectations()); | 222 self.passwordManager.assertExpectations( |
| 386 self.autofillManager.assertExpectations(self.baseAutofillExpectations()); | 223 self.basePasswordExpectations()); |
| 224 self.autofillManager.assertExpectations( | |
| 225 self.baseAutofillExpectations()); | |
| 226 | |
| 227 self.destroyPrefs(prefs); | |
| 228 }); | |
| 387 }); | 229 }); |
| 388 | 230 |
| 389 test('loadAddressesAsync', function() { | 231 test('loadAddressesAsync', function() { |
| 390 var element = self.createPasswordsAndFormsElement(); | 232 return self.createPrefs(true, true).then(function(prefs) { |
| 233 var element = self.createPasswordsAndFormsElement(prefs); | |
| 391 | 234 |
| 392 var list = [FakeDataMaker.addressEntry(), FakeDataMaker.addressEntry()]; | 235 var list = [FakeDataMaker.addressEntry(), FakeDataMaker.addressEntry()]; |
| 393 self.autofillManager.lastCallback.addAddressListChangedListener(list); | 236 self.autofillManager.lastCallback.addAddressListChangedListener(list); |
| 394 Polymer.dom.flush(); | 237 Polymer.dom.flush(); |
| 395 | 238 |
| 396 assertEquals(list, element.addresses); | 239 assertEquals(list, element.$$('#autofillSection').addresses); |
| 397 | 240 |
| 398 // The callback is coming from the manager, so the element shouldn't have | 241 // The callback is coming from the manager, so the element shouldn't |
| 399 // additional calls to the manager after the base expectations. | 242 // have additional calls to the manager after the base expectations. |
| 400 self.passwordManager.assertExpectations(self.basePasswordExpectations()); | 243 self.passwordManager.assertExpectations( |
| 401 self.autofillManager.assertExpectations(self.baseAutofillExpectations()); | 244 self.basePasswordExpectations()); |
| 245 self.autofillManager.assertExpectations( | |
| 246 self.baseAutofillExpectations()); | |
| 247 | |
| 248 self.destroyPrefs(prefs); | |
| 249 }); | |
| 402 }); | 250 }); |
| 403 | 251 |
| 404 test('loadCreditCardsAsync', function() { | 252 test('loadCreditCardsAsync', function() { |
| 405 var element = self.createPasswordsAndFormsElement(); | 253 return self.createPrefs(true, true).then(function(prefs) { |
| 254 var element = self.createPasswordsAndFormsElement(prefs); | |
| 406 | 255 |
| 407 var list = [FakeDataMaker.creditCardEntry(), | 256 var list = [FakeDataMaker.creditCardEntry(), |
| 408 FakeDataMaker.creditCardEntry()]; | 257 FakeDataMaker.creditCardEntry()]; |
| 409 self.autofillManager.lastCallback.addCreditCardListChangedListener(list); | 258 self.autofillManager.lastCallback.addCreditCardListChangedListener( |
| 410 Polymer.dom.flush(); | 259 list); |
| 260 Polymer.dom.flush(); | |
| 411 | 261 |
| 412 assertEquals(list, element.creditCards); | 262 assertEquals(list, element.$$('#autofillSection').creditCards); |
| 413 | 263 |
| 414 // The callback is coming from the manager, so the element shouldn't have | 264 // The callback is coming from the manager, so the element shouldn't |
| 415 // additional calls to the manager after the base expectations. | 265 // have additional calls to the manager after the base expectations. |
| 416 self.passwordManager.assertExpectations(self.basePasswordExpectations()); | 266 self.passwordManager.assertExpectations( |
| 417 self.autofillManager.assertExpectations(self.baseAutofillExpectations()); | 267 self.basePasswordExpectations()); |
| 268 self.autofillManager.assertExpectations( | |
| 269 self.baseAutofillExpectations()); | |
| 270 | |
| 271 self.destroyPrefs(prefs); | |
| 272 }); | |
| 418 }); | 273 }); |
| 419 | 274 |
| 420 test('testActionabilityNope', function() { | 275 test('testActionabilityNope', function() { |
| 421 return self.createPrefs(false, false).then(function(prefs) { | 276 return self.createPrefs(false, false).then(function(prefs) { |
| 422 var element = self.createPasswordsAndFormsElement(); | 277 |
| 423 element.prefs = prefs.prefs; | 278 var element = self.createPasswordsAndFormsElement(prefs); |
| 424 Polymer.dom.flush(); | |
| 425 | 279 |
| 426 assertFalse(element.$.autofillManagerButton.hasAttribute('actionable')); | 280 assertFalse(element.$.autofillManagerButton.hasAttribute('actionable')); |
| 427 assertFalse(element.$.passwordManagerButton.hasAttribute('actionable')); | 281 assertFalse(element.$.passwordManagerButton.hasAttribute('actionable')); |
| 428 | 282 |
| 429 self.destroyPrefs(prefs); | 283 self.destroyPrefs(prefs); |
| 430 }); | 284 }); |
| 431 }); | 285 }); |
| 432 | 286 |
| 433 test('testActionabilityYes', function() { | 287 test('testActionabilityYes', function() { |
| 434 return self.createPrefs(true, true).then(function(prefs) { | 288 return self.createPrefs(true, true).then(function(prefs) { |
| 435 var element = self.createPasswordsAndFormsElement(); | 289 var element = self.createPasswordsAndFormsElement(prefs); |
| 436 element.prefs = prefs.prefs; | |
| 437 Polymer.dom.flush(); | |
| 438 | 290 |
| 439 assertTrue(element.$.autofillManagerButton.hasAttribute('actionable')); | 291 assertTrue(element.$.autofillManagerButton.hasAttribute('actionable')); |
| 440 assertTrue(element.$.passwordManagerButton.hasAttribute('actionable')); | 292 assertTrue(element.$.passwordManagerButton.hasAttribute('actionable')); |
| 441 | 293 |
| 442 self.destroyPrefs(prefs); | 294 self.destroyPrefs(prefs); |
| 443 }); | 295 }); |
| 444 }); | 296 }); |
| 445 }); | 297 }); |
| 446 | 298 |
| 447 mocha.run(); | 299 mocha.run(); |
| 448 }); | 300 }); |
| OLD | NEW |