| 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 b983bc103f6ffa95d17fb4daf0dc479a84f87e73..56600d11343a76ed256338fd9a4bf4f415ac4636 100644
|
| --- a/chrome/test/data/webui/settings/passwords_and_forms_browsertest.js
|
| +++ b/chrome/test/data/webui/settings/passwords_and_forms_browsertest.js
|
| @@ -223,7 +223,10 @@ PasswordsAndFormsBrowserTest.prototype = {
|
| 'passwords_and_forms_page.html',
|
|
|
| /** @override */
|
| - extraLibraries: PolymerTest.getLibraries(ROOT_PATH),
|
| + extraLibraries: PolymerTest.getLibraries(ROOT_PATH).concat([
|
| + '../fake_chrome_event.js',
|
| + 'fake_settings_private.js',
|
| + ]),
|
|
|
| /** @override */
|
| setUp: function() {
|
| @@ -241,6 +244,11 @@ PasswordsAndFormsBrowserTest.prototype = {
|
| AutofillManagerImpl.instance_ = this.autofillManager;
|
| },
|
|
|
| + /** @override */
|
| + tearDown: function() {
|
| + PolymerTest.clearBody();
|
| + },
|
| +
|
| /**
|
| * Creates a new passwords and forms element.
|
| * @return {!Object}
|
| @@ -253,6 +261,45 @@ 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.
|
| + */
|
| + createPrefs: function(autofill, passwords) {
|
| + return new Promise(function(resolve) {
|
| + CrSettingsPrefs.deferInitialization = true;
|
| + var prefs = document.createElement('settings-prefs');
|
| + document.body.appendChild(prefs);
|
| + prefs.initializeForTesting(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,
|
| + },
|
| + ]));
|
| +
|
| + CrSettingsPrefs.initialized.then(function() {
|
| + resolve(prefs);
|
| + });
|
| + });
|
| + },
|
| +
|
| + /**
|
| + * Cleans up prefs so tests can continue to run.
|
| + * @param {!Element} prefs The prefs element.
|
| + */
|
| + destroyPrefs: function(prefs) {
|
| + CrSettingsPrefs.resetForTesting();
|
| + CrSettingsPrefs.deferInitialization = false;
|
| + prefs.resetForTesting();
|
| + },
|
| +
|
| + /**
|
| * Creates PasswordManagerExpectations with the values expected after first
|
| * creating the element.
|
| * @return {!PasswordManagerExpectations}
|
| @@ -372,6 +419,32 @@ TEST_F('PasswordsAndFormsBrowserTest', 'uiTests', function() {
|
| self.passwordManager.assertExpectations(self.basePasswordExpectations());
|
| self.autofillManager.assertExpectations(self.baseAutofillExpectations());
|
| });
|
| +
|
| + test('testActionabilityNope', function() {
|
| + return self.createPrefs(false, false).then(function(prefs) {
|
| + var element = self.createPasswordsAndFormsElement();
|
| + element.prefs = prefs.prefs;
|
| + Polymer.dom.flush();
|
| +
|
| + assertFalse(element.$.autofillManagerButton.hasAttribute('actionable'));
|
| + assertFalse(element.$.passwordManagerButton.hasAttribute('actionable'));
|
| +
|
| + self.destroyPrefs(prefs);
|
| + });
|
| + });
|
| +
|
| + test('testActionabilityYes', function() {
|
| + return self.createPrefs(true, true).then(function(prefs) {
|
| + var element = self.createPasswordsAndFormsElement();
|
| + element.prefs = prefs.prefs;
|
| + Polymer.dom.flush();
|
| +
|
| + assertTrue(element.$.autofillManagerButton.hasAttribute('actionable'));
|
| + assertTrue(element.$.passwordManagerButton.hasAttribute('actionable'));
|
| +
|
| + self.destroyPrefs(prefs);
|
| + });
|
| + });
|
| });
|
|
|
| mocha.run();
|
|
|