Index: chrome/test/data/webui/settings/passwords_and_forms_browsertest.js |
diff --git a/chrome/test/data/webui/settings/passwords_and_forms_browsertest.js b/chrome/test/data/webui/settings/passwords_and_forms_browsertest.js |
index 09c34408c0594bc3df378e1c840d0d32fb5ba4e1..f57994b37d7aff208c4b2e2729855b3b5971b1ab 100644 |
--- a/chrome/test/data/webui/settings/passwords_and_forms_browsertest.js |
+++ b/chrome/test/data/webui/settings/passwords_and_forms_browsertest.js |
@@ -15,200 +15,6 @@ GEN_INCLUDE( |
GEN_INCLUDE([ROOT_PATH + |
'chrome/test/data/webui/settings/passwords_and_autofill_fake_data.js']); |
-function PasswordManagerExpectations() {}; |
-PasswordManagerExpectations.prototype = { |
- requested: { |
- passwords: 0, |
- exceptions: 0, |
- plaintextPassword: 0, |
- }, |
- |
- removed: { |
- passwords: 0, |
- exceptions: 0, |
- }, |
- |
- listening: { |
- passwords: 0, |
- exceptions: 0, |
- }, |
-}; |
- |
-/** |
- * Test implementation |
- * @implements {PasswordManager} |
- * @constructor |
- */ |
-function TestPasswordManager() { |
- this.actual_ = new PasswordManagerExpectations(); |
-}; |
-TestPasswordManager.prototype = { |
- /** @override */ |
- addSavedPasswordListChangedListener: function(listener) { |
- this.actual_.listening.passwords++; |
- this.lastCallback.addSavedPasswordListChangedListener = listener; |
- }, |
- |
- /** @override */ |
- removeSavedPasswordListChangedListener: function(listener) { |
- this.actual_.listening.passwords--; |
- }, |
- |
- /** @override */ |
- getSavedPasswordList: function(callback) { |
- this.actual_.requested.passwords++; |
- callback(this.data.passwords); |
- }, |
- |
- /** @override */ |
- removeSavedPassword: function(loginPair) { |
- this.actual_.removed.passwords++; |
- }, |
- |
- /** @override */ |
- addExceptionListChangedListener: function(listener) { |
- this.actual_.listening.exceptions++; |
- this.lastCallback.addExceptionListChangedListener = listener; |
- }, |
- |
- /** @override */ |
- removeExceptionListChangedListener: function(listener) { |
- this.actual_.listening.exceptions--; |
- }, |
- |
- /** @override */ |
- getExceptionList: function(callback) { |
- this.actual_.requested.exceptions++; |
- callback(this.data.exceptions); |
- }, |
- |
- /** @override */ |
- removeException: function(exception) { |
- this.actual_.removed.exceptions++; |
- }, |
- |
- /** @override */ |
- getPlaintextPassword: function(loginPair, callback) { |
- this.actual_.requested.plaintextPassword++; |
- this.lastCallback.getPlaintextPassword = callback; |
- }, |
- |
- /** |
- * Verifies expectations. |
- * @param {!PasswordManagerExpectations} expected |
- */ |
- assertExpectations: function(expected) { |
- var actual = this.actual_; |
- |
- assertEquals(expected.requested.passwords, actual.requested.passwords); |
- assertEquals(expected.requested.exceptions, actual.requested.exceptions); |
- assertEquals(expected.requested.plaintextPassword, |
- actual.requested.plaintextPassword); |
- |
- assertEquals(expected.removed.passwords, actual.removed.passwords); |
- assertEquals(expected.removed.exceptions, actual.removed.exceptions); |
- |
- assertEquals(expected.listening.passwords, actual.listening.passwords); |
- assertEquals(expected.listening.exceptions, actual.listening.exceptions); |
- }, |
- |
- // Set these to have non-empty data. |
- data: { |
- passwords: [], |
- exceptions: [], |
- }, |
- |
- // Holds the last callbacks so they can be called when needed/ |
- lastCallback: { |
- addSavedPasswordListChangedListener: null, |
- addExceptionListChangedListener: null, |
- getPlaintextPassword: null, |
- }, |
-}; |
- |
-function AutofillManagerExpectations() {}; |
-AutofillManagerExpectations.prototype = { |
- requested: { |
- addresses: 0, |
- creditCards: 0, |
- }, |
- |
- listening: { |
- addresses: 0, |
- creditCards: 0, |
- }, |
-}; |
- |
-/** |
- * Test implementation |
- * @implements {AutofillManager} |
- * @constructor |
- */ |
-function TestAutofillManager() { |
- this.actual_ = new AutofillManagerExpectations(); |
-}; |
-TestAutofillManager.prototype = { |
- /** @override */ |
- addAddressListChangedListener: function(listener) { |
- this.actual_.listening.addresses++; |
- this.lastCallback.addAddressListChangedListener = listener; |
- }, |
- |
- /** @override */ |
- removeAddressListChangedListener: function(listener) { |
- this.actual_.listening.addresses--; |
- }, |
- |
- /** @override */ |
- getAddressList: function(callback) { |
- this.actual_.requested.addresses++; |
- callback(this.data.addresses); |
- }, |
- |
- /** @override */ |
- addCreditCardListChangedListener: function(listener) { |
- this.actual_.listening.creditCards++; |
- this.lastCallback.addCreditCardListChangedListener = listener; |
- }, |
- |
- /** @override */ |
- removeCreditCardListChangedListener: function(listener) { |
- this.actual_.listening.creditCards--; |
- }, |
- |
- /** @override */ |
- getCreditCardList: function(callback) { |
- this.actual_.requested.creditCards++; |
- callback(this.data.creditCards); |
- }, |
- |
- /** |
- * Verifies expectations. |
- * @param {!AutofillManagerExpectations} expected |
- */ |
- assertExpectations: function(expected) { |
- var actual = this.actual_; |
- |
- assertEquals(expected.requested.addresses, actual.requested.addresses); |
- assertEquals(expected.requested.creditCards, actual.requested.creditCards); |
- |
- assertEquals(expected.listening.addresses, actual.listening.addresses); |
- assertEquals(expected.listening.creditCards, actual.listening.creditCards); |
- }, |
- |
- // Set these to have non-empty data. |
- data: { |
- addresses: [], |
- creditCards: [], |
- }, |
- |
- // Holds the last callbacks so they can be called when needed/ |
- lastCallback: { |
- addAddressListChangedListener: null, |
- addCreditCardListChangedListener: null, |
- }, |
-}; |
- |
/** |
* @constructor |
* @extends {PolymerTest} |
@@ -220,12 +26,12 @@ PasswordsAndFormsBrowserTest.prototype = { |
/** @override */ |
browsePreload: 'chrome://md-settings/passwords_and_forms_page/' + |
- 'passwords_and_forms_page.html', |
+ 'passwords_and_forms_page.html', |
/** @override */ |
extraLibraries: PolymerTest.getLibraries(ROOT_PATH).concat([ |
- '../fake_chrome_event.js', |
- 'fake_settings_private.js', |
+ '../fake_chrome_event.js', |
+ 'fake_settings_private.js', |
]), |
/** @override */ |
@@ -253,9 +59,12 @@ PasswordsAndFormsBrowserTest.prototype = { |
* Creates a new passwords and forms element. |
* @return {!Object} |
*/ |
- createPasswordsAndFormsElement: function() { |
+ createPasswordsAndFormsElement: function(prefsElement) { |
var element = document.createElement('settings-passwords-and-forms-page'); |
+ element.prefs = prefsElement.prefs; |
document.body.appendChild(element); |
+ element.$$('template[route-path="/passwords"').if = true; |
Dan Beam
2017/01/26 19:10:44
did you run this? there should be a ] at the end
hcarmona
2017/01/26 21:34:47
Fixed... but it finds the right element, you can a
Dan Beam
2017/01/27 01:11:32
well, there's no difference, because returning nul
hcarmona
2017/01/27 18:28:16
Removed asserts to keep cleaner.
|
+ element.$$('template[route-path="/autofill"').if = true; |
Polymer.dom.flush(); |
return element; |
}, |
@@ -263,23 +72,28 @@ PasswordsAndFormsBrowserTest.prototype = { |
/** |
* @pram {boolean} autofill Whether autofill is enabled or not. |
* @param {boolean} passwords Whether passwords are enabled or not. |
- * @return {!Promise<!Element>} The |prefs| object. |
+ * @return {!Promise<!Element>} The |prefs| element. |
*/ |
createPrefs: function(autofill, passwords) { |
return new Promise(function(resolve) { |
CrSettingsPrefs.deferInitialization = true; |
var prefs = document.createElement('settings-prefs'); |
prefs.initialize(new settings.FakeSettingsPrivate([ |
- { |
- key: 'autofill.enabled', |
- type: chrome.settingsPrivate.PrefType.BOOLEAN, |
- value: autofill, |
- }, |
- { |
- key: 'profile.password_manager_enabled', |
- type: chrome.settingsPrivate.PrefType.BOOLEAN, |
- value: passwords, |
- }, |
+ { |
+ key: 'autofill.enabled', |
+ type: chrome.settingsPrivate.PrefType.BOOLEAN, |
+ value: autofill, |
+ }, |
+ { |
+ key: 'credentials_enable_autosignin', |
+ type: chrome.settingsPrivate.PrefType.BOOLEAN, |
+ value: true, |
+ }, |
+ { |
+ key: 'profile.password_manager_enabled', |
+ type: chrome.settingsPrivate.PrefType.BOOLEAN, |
+ value: passwords, |
+ }, |
])); |
CrSettingsPrefs.initialized.then(function() { |
@@ -333,95 +147,127 @@ TEST_F('PasswordsAndFormsBrowserTest', 'uiTests', function() { |
suite('PasswordsAndForms', function() { |
test('baseLoadAndRemove', function() { |
- var element = self.createPasswordsAndFormsElement(); |
+ return self.createPrefs(true, true).then(function(prefs) { |
+ var element = self.createPasswordsAndFormsElement(prefs); |
+ |
+ var passwordsExpectations = self.basePasswordExpectations(); |
+ self.passwordManager.assertExpectations(passwordsExpectations); |
- var passwordsExpectations = self.basePasswordExpectations(); |
- self.passwordManager.assertExpectations(passwordsExpectations); |
+ var autofillExpectations = self.baseAutofillExpectations(); |
+ self.autofillManager.assertExpectations(autofillExpectations); |
- var autofillExpectations = self.baseAutofillExpectations(); |
- self.autofillManager.assertExpectations(autofillExpectations); |
+ element.remove(); |
+ Polymer.dom.flush(); |
- element.remove(); |
- Polymer.dom.flush(); |
+ passwordsExpectations.listening.passwords = 0; |
+ passwordsExpectations.listening.exceptions = 0; |
+ self.passwordManager.assertExpectations(passwordsExpectations); |
- passwordsExpectations.listening.passwords = 0; |
- passwordsExpectations.listening.exceptions = 0; |
- self.passwordManager.assertExpectations(passwordsExpectations); |
+ autofillExpectations.listening.addresses = 0; |
+ autofillExpectations.listening.creditCards = 0; |
+ self.autofillManager.assertExpectations(autofillExpectations); |
- autofillExpectations.listening.addresses = 0; |
- autofillExpectations.listening.creditCards = 0; |
- self.autofillManager.assertExpectations(autofillExpectations); |
+ self.destroyPrefs(prefs); |
+ }); |
}); |
test('loadPasswordsAsync', function() { |
- var element = self.createPasswordsAndFormsElement(); |
+ return self.createPrefs(true, true).then(function(prefs) { |
+ var element = self.createPasswordsAndFormsElement(prefs); |
- var list = [FakeDataMaker.passwordEntry(), FakeDataMaker.passwordEntry()]; |
- self.passwordManager.lastCallback.addSavedPasswordListChangedListener( |
- list); |
- Polymer.dom.flush(); |
+ var list = [ |
+ FakeDataMaker.passwordEntry(), |
+ FakeDataMaker.passwordEntry() |
+ ]; |
+ |
+ self.passwordManager.lastCallback.addSavedPasswordListChangedListener( |
+ list); |
+ Polymer.dom.flush(); |
- assertEquals(list, element.savedPasswords); |
+ assertEquals(list, element.$$('#passwordSection').savedPasswords); |
- // The callback is coming from the manager, so the element shouldn't have |
- // additional calls to the manager after the base expectations. |
- self.passwordManager.assertExpectations(self.basePasswordExpectations()); |
- self.autofillManager.assertExpectations(self.baseAutofillExpectations()); |
+ // The callback is coming from the manager, so the element shouldn't |
+ // have additional calls to the manager after the base expectations. |
+ self.passwordManager.assertExpectations( |
+ self.basePasswordExpectations()); |
+ self.autofillManager.assertExpectations( |
+ self.baseAutofillExpectations()); |
+ |
+ self.destroyPrefs(prefs); |
+ }); |
}); |
test('loadExceptionsAsync', function() { |
- var element = self.createPasswordsAndFormsElement(); |
+ return self.createPrefs(true, true).then(function(prefs) { |
+ var element = self.createPasswordsAndFormsElement(prefs); |
- var list = [FakeDataMaker.exceptionEntry(), |
- FakeDataMaker.exceptionEntry()]; |
- self.passwordManager.lastCallback.addExceptionListChangedListener( |
- list); |
- Polymer.dom.flush(); |
+ var list = [FakeDataMaker.exceptionEntry(), |
+ FakeDataMaker.exceptionEntry()]; |
+ self.passwordManager.lastCallback.addExceptionListChangedListener( |
+ list); |
+ Polymer.dom.flush(); |
+ |
+ assertEquals(list, element.$$('#passwordSection').passwordExceptions); |
- assertEquals(list, element.passwordExceptions); |
+ // The callback is coming from the manager, so the element shouldn't |
+ // have additional calls to the manager after the base expectations. |
+ self.passwordManager.assertExpectations( |
+ self.basePasswordExpectations()); |
+ self.autofillManager.assertExpectations( |
+ self.baseAutofillExpectations()); |
- // The callback is coming from the manager, so the element shouldn't have |
- // additional calls to the manager after the base expectations. |
- self.passwordManager.assertExpectations(self.basePasswordExpectations()); |
- self.autofillManager.assertExpectations(self.baseAutofillExpectations()); |
+ self.destroyPrefs(prefs); |
+ }); |
}); |
test('loadAddressesAsync', function() { |
- var element = self.createPasswordsAndFormsElement(); |
+ return self.createPrefs(true, true).then(function(prefs) { |
+ var element = self.createPasswordsAndFormsElement(prefs); |
+ |
+ var list = [FakeDataMaker.addressEntry(), FakeDataMaker.addressEntry()]; |
+ self.autofillManager.lastCallback.addAddressListChangedListener(list); |
+ Polymer.dom.flush(); |
- var list = [FakeDataMaker.addressEntry(), FakeDataMaker.addressEntry()]; |
- self.autofillManager.lastCallback.addAddressListChangedListener(list); |
- Polymer.dom.flush(); |
+ assertEquals(list, element.$$('#autofillSection').addresses); |
- assertEquals(list, element.addresses); |
+ // The callback is coming from the manager, so the element shouldn't |
+ // have additional calls to the manager after the base expectations. |
+ self.passwordManager.assertExpectations( |
+ self.basePasswordExpectations()); |
+ self.autofillManager.assertExpectations( |
+ self.baseAutofillExpectations()); |
- // The callback is coming from the manager, so the element shouldn't have |
- // additional calls to the manager after the base expectations. |
- self.passwordManager.assertExpectations(self.basePasswordExpectations()); |
- self.autofillManager.assertExpectations(self.baseAutofillExpectations()); |
+ self.destroyPrefs(prefs); |
+ }); |
}); |
test('loadCreditCardsAsync', function() { |
- var element = self.createPasswordsAndFormsElement(); |
+ return self.createPrefs(true, true).then(function(prefs) { |
+ var element = self.createPasswordsAndFormsElement(prefs); |
- var list = [FakeDataMaker.creditCardEntry(), |
- FakeDataMaker.creditCardEntry()]; |
- self.autofillManager.lastCallback.addCreditCardListChangedListener(list); |
- Polymer.dom.flush(); |
+ var list = [FakeDataMaker.creditCardEntry(), |
+ FakeDataMaker.creditCardEntry()]; |
+ self.autofillManager.lastCallback.addCreditCardListChangedListener( |
+ list); |
+ Polymer.dom.flush(); |
+ |
+ assertEquals(list, element.$$('#autofillSection').creditCards); |
- assertEquals(list, element.creditCards); |
+ // The callback is coming from the manager, so the element shouldn't |
+ // have additional calls to the manager after the base expectations. |
+ self.passwordManager.assertExpectations( |
+ self.basePasswordExpectations()); |
+ self.autofillManager.assertExpectations( |
+ self.baseAutofillExpectations()); |
- // The callback is coming from the manager, so the element shouldn't have |
- // additional calls to the manager after the base expectations. |
- self.passwordManager.assertExpectations(self.basePasswordExpectations()); |
- self.autofillManager.assertExpectations(self.baseAutofillExpectations()); |
+ self.destroyPrefs(prefs); |
+ }); |
}); |
test('testActionabilityNope', function() { |
return self.createPrefs(false, false).then(function(prefs) { |
- var element = self.createPasswordsAndFormsElement(); |
- element.prefs = prefs.prefs; |
- Polymer.dom.flush(); |
+ |
+ var element = self.createPasswordsAndFormsElement(prefs); |
assertFalse(element.$.autofillManagerButton.hasAttribute('actionable')); |
assertFalse(element.$.passwordManagerButton.hasAttribute('actionable')); |
@@ -432,9 +278,7 @@ TEST_F('PasswordsAndFormsBrowserTest', 'uiTests', function() { |
test('testActionabilityYes', function() { |
return self.createPrefs(true, true).then(function(prefs) { |
- var element = self.createPasswordsAndFormsElement(); |
- element.prefs = prefs.prefs; |
- Polymer.dom.flush(); |
+ var element = self.createPasswordsAndFormsElement(prefs); |
assertTrue(element.$.autofillManagerButton.hasAttribute('actionable')); |
assertTrue(element.$.passwordManagerButton.hasAttribute('actionable')); |