| 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 ebfa056d981aa019747f9f439aaddad0d16ae614..965c644e7834801c1deecfd66c00ca8a6b8479b0 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 */
|
| @@ -249,9 +55,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;
|
| + element.$$('template[route-path="/autofill"]').if = true;
|
| Polymer.dom.flush();
|
| return element;
|
| },
|
| @@ -259,23 +68,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: 'credentials_enable_service',
|
| - type: chrome.settingsPrivate.PrefType.BOOLEAN,
|
| - value: passwords,
|
| - },
|
| + {
|
| + key: 'autofill.enabled',
|
| + type: chrome.settingsPrivate.PrefType.BOOLEAN,
|
| + value: autofill,
|
| + },
|
| + {
|
| + key: 'credentials_enable_service',
|
| + type: chrome.settingsPrivate.PrefType.BOOLEAN,
|
| + value: passwords,
|
| + },
|
| + {
|
| + key: 'credentials_enable_autosignin',
|
| + type: chrome.settingsPrivate.PrefType.BOOLEAN,
|
| + value: true,
|
| + },
|
| ]));
|
|
|
| CrSettingsPrefs.initialized.then(function() {
|
| @@ -329,95 +143,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'));
|
| @@ -428,9 +274,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'));
|
|
|