Commit 87007a51 authored by Friedrich Horschig's avatar Friedrich Horschig Committed by Commit Bot

[Passwords] Leak check clean-ups

This CL should have no user-visible changes at all.

This CL addresses post-commit comments from https://crrev.com/c/2087679
and applies some further recommended clean-ups recommended in
https://crrev.com/c/2087623 in all of password_check{,_test}.js:
 - drop params from observer functions
 - drop redundant 'test' prefix from all tests
 - replace uses of throw with assertNotReached()

Bug: 1047726
Change-Id: I93c075a218c6f7c97f4eedc56b39d741e8983b9c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2093445
Commit-Queue: Friedrich [CET] <fhorschig@chromium.org>
Reviewed-by: default avatarJan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#753623}
parent d72c6ea2
...@@ -138,7 +138,7 @@ Polymer({ ...@@ -138,7 +138,7 @@ Polymer({
const statusChangeListener = status => this.status_ = status; const statusChangeListener = status => this.status_ = status;
const setLeakedCredentialsListener = compromisedCredentials => { const setLeakedCredentialsListener = compromisedCredentials => {
this.updateList(compromisedCredentials); this.updateList_(compromisedCredentials);
settings.PluralStringProxyImpl.getInstance() settings.PluralStringProxyImpl.getInstance()
.getPluralString('compromisedPasswords', this.leakedPasswords.length) .getPluralString('compromisedPasswords', this.leakedPasswords.length)
...@@ -224,12 +224,11 @@ Polymer({ ...@@ -224,12 +224,11 @@ Polymer({
/** /**
* Returns true if there are any compromised credentials. * Returns true if there are any compromised credentials.
* @param {!Array<!PasswordManagerProxy.CompromisedCredential>} list
* @return {boolean} * @return {boolean}
* @private * @private
*/ */
hasLeakedCredentials_(list) { hasLeakedCredentials_() {
return !!list.length; return !!this.leakedPasswords.length;
}, },
/** /**
...@@ -284,17 +283,14 @@ Polymer({ ...@@ -284,17 +283,14 @@ Polymer({
/** /**
* Returns the icon (warning, info or error) indicating the check status. * Returns the icon (warning, info or error) indicating the check status.
* @param {!PasswordManagerProxy.PasswordCheckStatus} status
* @param {!Array<!PasswordManagerProxy.CompromisedCredential>}
* leakedPasswords
* @return {string} * @return {string}
* @private * @private
*/ */
getStatusIcon_(status, leakedPasswords) { getStatusIcon_() {
if (!this.hasLeaksOrErrors_(status, leakedPasswords)) { if (!this.hasLeaksOrErrors_()) {
return 'settings:check-circle'; return 'settings:check-circle';
} }
if (this.hasLeakedCredentials_(leakedPasswords)) { if (this.hasLeakedCredentials_()) {
return 'cr:warning'; return 'cr:warning';
} }
return 'cr:info'; return 'cr:info';
...@@ -302,17 +298,14 @@ Polymer({ ...@@ -302,17 +298,14 @@ Polymer({
/** /**
* Returns the CSS class used to style the icon (warning, info or error). * Returns the CSS class used to style the icon (warning, info or error).
* @param {!PasswordManagerProxy.PasswordCheckStatus} status
* @param {!Array<!PasswordManagerProxy.CompromisedCredential>}
* leakedPasswords
* @return {string} * @return {string}
* @private * @private
*/ */
getStatusIconClass_(status, leakedPasswords) { getStatusIconClass_() {
if (!this.hasLeaksOrErrors_(status, leakedPasswords)) { if (!this.hasLeaksOrErrors_()) {
return this.waitsForFirstCheck_() ? 'hidden' : 'no-leaks'; return this.waitsForFirstCheck_() ? 'hidden' : 'no-leaks';
} }
if (this.hasLeakedCredentials_(leakedPasswords)) { if (this.hasLeakedCredentials_()) {
return 'has-leaks'; return 'has-leaks';
} }
return ''; return '';
...@@ -355,33 +348,30 @@ Polymer({ ...@@ -355,33 +348,30 @@ Polymer({
/** /**
* Returns true iff a check is running right according to the given |status|. * Returns true iff a check is running right according to the given |status|.
* @param {!PasswordManagerProxy.PasswordCheckStatus} status
* @return {boolean} * @return {boolean}
* @private * @private
*/ */
isCheckInProgress_(status) { isCheckInProgress_() {
return status.state == CheckState.RUNNING; return this.status_.state == CheckState.RUNNING;
}, },
/** /**
* Returns true to show the timestamp when a check was completed successfully. * Returns true to show the timestamp when a check was completed successfully.
* @param {!PasswordManagerProxy.PasswordCheckStatus} status
* @return {boolean} * @return {boolean}
* @private * @private
*/ */
showsTimestamp_(status) { showsTimestamp_() {
return status.state == CheckState.IDLE && return this.status_.state == CheckState.IDLE &&
!!status.elapsedTimeSinceLastCheck; !!this.status_.elapsedTimeSinceLastCheck;
}, },
/** /**
* Returns the button caption indicating it's current functionality. * Returns the button caption indicating it's current functionality.
* @param {!PasswordManagerProxy.PasswordCheckStatus} status
* @return {string} * @return {string}
* @private * @private
*/ */
getButtonText_(status) { getButtonText_() {
switch (status.state) { switch (this.status_.state) {
case CheckState.IDLE: case CheckState.IDLE:
return this.waitsForFirstCheck_() ? this.i18n('checkPasswords') : return this.waitsForFirstCheck_() ? this.i18n('checkPasswords') :
this.i18n('checkPasswordsAgain'); this.i18n('checkPasswordsAgain');
...@@ -397,7 +387,8 @@ Polymer({ ...@@ -397,7 +387,8 @@ Polymer({
case CheckState.QUOTA_LIMIT: case CheckState.QUOTA_LIMIT:
return ''; // Undefined behavior. Don't show any misleading text. return ''; // Undefined behavior. Don't show any misleading text.
} }
assertNotReached('Can\'t find a button text for state: ' + status.state); assertNotReached(
'Can\'t find a button text for state: ' + this.status_.state);
}, },
/** /**
...@@ -453,27 +444,24 @@ Polymer({ ...@@ -453,27 +444,24 @@ Polymer({
* @private * @private
*/ */
shouldShowBanner_() { shouldShowBanner_() {
if (this.hasLeakedCredentials_(this.leakedPasswords)) { if (this.hasLeakedCredentials_()) {
return false; return false;
} }
return this.status_.state == CheckState.CANCELED || return this.status_.state == CheckState.CANCELED ||
!this.hasLeaksOrErrors_(this.status_, this.leakedPasswords); !this.hasLeaksOrErrors_();
}, },
/** /**
* Returns true if there are leaked credentials or the status is unexpected * Returns true if there are leaked credentials or the status is unexpected
* for a regular password check. * for a regular password check.
* @param {!PasswordManagerProxy.PasswordCheckStatus} status
* @param {!Array<PasswordManagerProxy.CompromisedCredential>}
* leakedPasswords
* @return {boolean} * @return {boolean}
* @private * @private
*/ */
hasLeaksOrErrors_(status, leakedPasswords) { hasLeaksOrErrors_() {
if (this.hasLeakedCredentials_(leakedPasswords)) { if (this.hasLeakedCredentials_()) {
return true; return true;
} }
switch (status.state) { switch (this.status_.state) {
case CheckState.IDLE: case CheckState.IDLE:
case CheckState.RUNNING: case CheckState.RUNNING:
return false; return false;
...@@ -485,7 +473,8 @@ Polymer({ ...@@ -485,7 +473,8 @@ Polymer({
case CheckState.OTHER_ERROR: case CheckState.OTHER_ERROR:
return true; return true;
} }
throw 'Not specified whether to state is an error: ' + status.state; assertNotReached(
'Not specified whether to state is an error: ' + this.status_.state);
}, },
/** /**
...@@ -495,7 +484,7 @@ Polymer({ ...@@ -495,7 +484,7 @@ Polymer({
* @private * @private
*/ */
showsPasswordsCount_() { showsPasswordsCount_() {
if (this.hasLeakedCredentials_(this.leakedPasswords)) { if (this.hasLeakedCredentials_()) {
return true; return true;
} }
switch (this.status_.state) { switch (this.status_.state) {
...@@ -559,7 +548,7 @@ Polymer({ ...@@ -559,7 +548,7 @@ Polymer({
* @param {!Array<!PasswordManagerProxy.CompromisedCredential>} newList * @param {!Array<!PasswordManagerProxy.CompromisedCredential>} newList
* @private * @private
*/ */
updateList(newList) { updateList_(newList) {
const oldList = this.leakedPasswords.slice(); const oldList = this.leakedPasswords.slice();
const map = new Map(); const map = new Map();
newList.forEach(item => map.set(item.id, item)); newList.forEach(item => map.set(item.id, item));
...@@ -605,8 +594,7 @@ Polymer({ ...@@ -605,8 +594,7 @@ Polymer({
// Return true if there was a successful check and no compromised passwords // Return true if there was a successful check and no compromised passwords
// were found. // were found.
return !this.hasLeakedCredentials_(this.leakedPasswords) && return !this.hasLeakedCredentials_() && this.showsTimestamp_();
this.showsTimestamp_(this.status_);
}, },
}); });
})(); })();
...@@ -132,7 +132,7 @@ cr.define('settings_passwords_check', function() { ...@@ -132,7 +132,7 @@ cr.define('settings_passwords_check', function() {
// Test verifies that clicking 'Check again' make proper function call to // Test verifies that clicking 'Check again' make proper function call to
// password manager // password manager
test('testCheckAgainButtonWhenIdleAfterFirstRun', async function() { test('checkAgainButtonWhenIdleAfterFirstRun', async function() {
const data = passwordManager.data; const data = passwordManager.data;
data.checkStatus = autofill_test_util.makePasswordCheckStatus( data.checkStatus = autofill_test_util.makePasswordCheckStatus(
/*state=*/ PasswordCheckState.IDLE, /*state=*/ PasswordCheckState.IDLE,
...@@ -156,7 +156,7 @@ cr.define('settings_passwords_check', function() { ...@@ -156,7 +156,7 @@ cr.define('settings_passwords_check', function() {
// Test verifies that clicking 'Start Check' make proper function call to // Test verifies that clicking 'Start Check' make proper function call to
// password manager // password manager
test('testStartCheckButtonWhenIdle', async function() { test('startCheckButtonWhenIdle', async function() {
assertEquals( assertEquals(
PasswordCheckState.IDLE, passwordManager.data.checkStatus.state); PasswordCheckState.IDLE, passwordManager.data.checkStatus.state);
const section = createCheckPasswordSection(); const section = createCheckPasswordSection();
...@@ -176,7 +176,7 @@ cr.define('settings_passwords_check', function() { ...@@ -176,7 +176,7 @@ cr.define('settings_passwords_check', function() {
// Test verifies that clicking 'Check again' make proper function call to // Test verifies that clicking 'Check again' make proper function call to
// password manager // password manager
test('testStopButtonWhenRunning', async function() { test('stopButtonWhenRunning', async function() {
passwordManager.data.checkStatus = passwordManager.data.checkStatus =
autofill_test_util.makePasswordCheckStatus( autofill_test_util.makePasswordCheckStatus(
/*state=*/ PasswordCheckState.RUNNING, /*state=*/ PasswordCheckState.RUNNING,
...@@ -199,7 +199,7 @@ cr.define('settings_passwords_check', function() { ...@@ -199,7 +199,7 @@ cr.define('settings_passwords_check', function() {
// Test verifies that sync users see only the link to account checkup and no // Test verifies that sync users see only the link to account checkup and no
// button to start the local leak check once they run out of quota. // button to start the local leak check once they run out of quota.
test('testOnlyCheckupLinkAfterHittingQuotaWhenSyncing', async function() { test('onlyCheckupLinkAfterHittingQuotaWhenSyncing', async function() {
passwordManager.data.checkStatus = passwordManager.data.checkStatus =
autofill_test_util.makePasswordCheckStatus( autofill_test_util.makePasswordCheckStatus(
/*state=*/ PasswordCheckState.QUOTA_LIMIT); /*state=*/ PasswordCheckState.QUOTA_LIMIT);
...@@ -216,7 +216,7 @@ cr.define('settings_passwords_check', function() { ...@@ -216,7 +216,7 @@ cr.define('settings_passwords_check', function() {
// Test verifies that non-sync users see neither the link to the account // Test verifies that non-sync users see neither the link to the account
// checkup nor a retry button once they run out of quota. // checkup nor a retry button once they run out of quota.
test('testNoCheckupLinkAfterHittingQuotaWhenSignedOut', async function() { test('noCheckupLinkAfterHittingQuotaWhenSignedOut', async function() {
passwordManager.data.checkStatus = passwordManager.data.checkStatus =
autofill_test_util.makePasswordCheckStatus( autofill_test_util.makePasswordCheckStatus(
PasswordCheckState.QUOTA_LIMIT); PasswordCheckState.QUOTA_LIMIT);
...@@ -234,7 +234,7 @@ cr.define('settings_passwords_check', function() { ...@@ -234,7 +234,7 @@ cr.define('settings_passwords_check', function() {
// Test verifies that custom passphrase users see neither the link to the // Test verifies that custom passphrase users see neither the link to the
// account checkup nor a retry button once they run out of quota. // account checkup nor a retry button once they run out of quota.
test('testNoCheckupLinkAfterHittingQuotaForEncryption', async function() { test('noCheckupLinkAfterHittingQuotaForEncryption', async function() {
passwordManager.data.checkStatus = passwordManager.data.checkStatus =
autofill_test_util.makePasswordCheckStatus( autofill_test_util.makePasswordCheckStatus(
PasswordCheckState.QUOTA_LIMIT); PasswordCheckState.QUOTA_LIMIT);
...@@ -253,7 +253,7 @@ cr.define('settings_passwords_check', function() { ...@@ -253,7 +253,7 @@ cr.define('settings_passwords_check', function() {
// Test verifies that 'Try again' visible and working when users encounter a // Test verifies that 'Try again' visible and working when users encounter a
// generic error. // generic error.
test('testShowRetryAfterGenericError', async function() { test('showRetryAfterGenericError', async function() {
passwordManager.data.checkStatus = passwordManager.data.checkStatus =
autofill_test_util.makePasswordCheckStatus( autofill_test_util.makePasswordCheckStatus(
/*state=*/ PasswordCheckState.OTHER_ERROR); /*state=*/ PasswordCheckState.OTHER_ERROR);
...@@ -274,7 +274,7 @@ cr.define('settings_passwords_check', function() { ...@@ -274,7 +274,7 @@ cr.define('settings_passwords_check', function() {
// Test verifies that 'Try again' is hidden when users encounter a // Test verifies that 'Try again' is hidden when users encounter a
// not-signed-in error. // not-signed-in error.
test('testHideRetryAfterSignOutErrorUntilSignedInAgain', async function() { test('hideRetryAfterSignOutErrorUntilSignedInAgain', async function() {
passwordManager.data.checkStatus = passwordManager.data.checkStatus =
autofill_test_util.makePasswordCheckStatus( autofill_test_util.makePasswordCheckStatus(
/*state=*/ PasswordCheckState.SIGNED_OUT); /*state=*/ PasswordCheckState.SIGNED_OUT);
...@@ -306,7 +306,7 @@ cr.define('settings_passwords_check', function() { ...@@ -306,7 +306,7 @@ cr.define('settings_passwords_check', function() {
// Test verifies that 'Try again' is hidden when users encounter a // Test verifies that 'Try again' is hidden when users encounter a
// no-saved-passwords error. // no-saved-passwords error.
test('testHideRetryAfterNoPasswordsError', async function() { test('hideRetryAfterNoPasswordsError', async function() {
passwordManager.data.checkStatus = passwordManager.data.checkStatus =
autofill_test_util.makePasswordCheckStatus( autofill_test_util.makePasswordCheckStatus(
/*state=*/ PasswordCheckState.NO_PASSWORDS); /*state=*/ PasswordCheckState.NO_PASSWORDS);
...@@ -317,7 +317,7 @@ cr.define('settings_passwords_check', function() { ...@@ -317,7 +317,7 @@ cr.define('settings_passwords_check', function() {
// Test verifies that 'Try again' visible and working when users encounter a // Test verifies that 'Try again' visible and working when users encounter a
// connection error. // connection error.
test('testShowRetryAfterNoConnectionError', async function() { test('showRetryAfterNoConnectionError', async function() {
passwordManager.data.checkStatus = passwordManager.data.checkStatus =
autofill_test_util.makePasswordCheckStatus( autofill_test_util.makePasswordCheckStatus(
/*state=*/ PasswordCheckState.OFFLINE); /*state=*/ PasswordCheckState.OFFLINE);
...@@ -338,7 +338,7 @@ cr.define('settings_passwords_check', function() { ...@@ -338,7 +338,7 @@ cr.define('settings_passwords_check', function() {
// Test verifies that if no compromised credentials found than list is not // Test verifies that if no compromised credentials found than list is not
// shown // shown
test('testNoCompromisedCredentials', async function() { test('noCompromisedCredentials', async function() {
const data = passwordManager.data; const data = passwordManager.data;
data.checkStatus = autofill_test_util.makePasswordCheckStatus( data.checkStatus = autofill_test_util.makePasswordCheckStatus(
/*state=*/ PasswordCheckState.IDLE, /*state=*/ PasswordCheckState.IDLE,
...@@ -365,7 +365,7 @@ cr.define('settings_passwords_check', function() { ...@@ -365,7 +365,7 @@ cr.define('settings_passwords_check', function() {
}); });
// Test verifies that compromised credentials are displayed in a proper way // Test verifies that compromised credentials are displayed in a proper way
test('testSomeCompromisedCredentials', async function() { test('someCompromisedCredentials', async function() {
const leakedPasswords = [ const leakedPasswords = [
autofill_test_util.makeCompromisedCredential( autofill_test_util.makeCompromisedCredential(
'one.com', 'test4', 'PHISHED', 1, 1), 'one.com', 'test4', 'PHISHED', 1, 1),
...@@ -382,7 +382,7 @@ cr.define('settings_passwords_check', function() { ...@@ -382,7 +382,7 @@ cr.define('settings_passwords_check', function() {
}); });
// Test verifies that credentials from mobile app shown correctly // Test verifies that credentials from mobile app shown correctly
test('testSomeCompromisedCredentials', function() { test('someCompromisedCredentials', function() {
const password = autofill_test_util.makeCompromisedCredential( const password = autofill_test_util.makeCompromisedCredential(
'one.com', 'test4', 'LEAKED'); 'one.com', 'test4', 'LEAKED');
password.changePasswordUrl = null; password.changePasswordUrl = null;
...@@ -394,7 +394,7 @@ cr.define('settings_passwords_check', function() { ...@@ -394,7 +394,7 @@ cr.define('settings_passwords_check', function() {
// Verify that a click on "Change password" opens the expected URL and // Verify that a click on "Change password" opens the expected URL and
// records a corresponding user action. // records a corresponding user action.
test('testChangePasswordOpensUrlAndRecordsAction', async function() { test('changePasswordOpensUrlAndRecordsAction', async function() {
const testOpenWindowProxy = new TestOpenWindowProxy(); const testOpenWindowProxy = new TestOpenWindowProxy();
settings.OpenWindowProxyImpl.instance_ = testOpenWindowProxy; settings.OpenWindowProxyImpl.instance_ = testOpenWindowProxy;
...@@ -413,7 +413,7 @@ cr.define('settings_passwords_check', function() { ...@@ -413,7 +413,7 @@ cr.define('settings_passwords_check', function() {
}); });
// Verify that the More Actions menu opens when the button is clicked. // Verify that the More Actions menu opens when the button is clicked.
test('testMoreActionsMenu', async function() { test('moreActionsMenu', async function() {
const leakedPasswords = [ const leakedPasswords = [
autofill_test_util.makeCompromisedCredential( autofill_test_util.makeCompromisedCredential(
'google.com', 'jdoerrie', 'LEAKED'), 'google.com', 'jdoerrie', 'LEAKED'),
...@@ -434,7 +434,7 @@ cr.define('settings_passwords_check', function() { ...@@ -434,7 +434,7 @@ cr.define('settings_passwords_check', function() {
// Test verifies that clicking remove button is calling proper // Test verifies that clicking remove button is calling proper
// proxy function. // proxy function.
test('testRemovePasswordConfirmationDialog', async function() { test('removePasswordConfirmationDialog', async function() {
const entry = autofill_test_util.makeCompromisedCredential( const entry = autofill_test_util.makeCompromisedCredential(
'one.com', 'test4', 'LEAKED', 0); 'one.com', 'test4', 'LEAKED', 0);
const removeDialog = createRemovePasswordDialog(entry); const removeDialog = createRemovePasswordDialog(entry);
...@@ -453,7 +453,7 @@ cr.define('settings_passwords_check', function() { ...@@ -453,7 +453,7 @@ cr.define('settings_passwords_check', function() {
}); });
// A changing status is immediately reflected in title, icon and banner. // A changing status is immediately reflected in title, icon and banner.
test('testUpdatesNumberOfCheckedPasswordsWhileRunning', async function() { test('updatesNumberOfCheckedPasswordsWhileRunning', async function() {
passwordManager.data.checkStatus = passwordManager.data.checkStatus =
autofill_test_util.makePasswordCheckStatus( autofill_test_util.makePasswordCheckStatus(
/*state=*/ PasswordCheckState.RUNNING, /*state=*/ PasswordCheckState.RUNNING,
...@@ -484,7 +484,7 @@ cr.define('settings_passwords_check', function() { ...@@ -484,7 +484,7 @@ cr.define('settings_passwords_check', function() {
}); });
// Tests that the status is queried right when the page loads. // Tests that the status is queried right when the page loads.
test('testQueriesCheckedStatusImmediately', async function() { test('queriesCheckedStatusImmediately', async function() {
const data = passwordManager.data; const data = passwordManager.data;
assertEquals(PasswordCheckState.IDLE, data.checkStatus.state); assertEquals(PasswordCheckState.IDLE, data.checkStatus.state);
assertEquals(0, data.leakedCredentials.length); assertEquals(0, data.leakedCredentials.length);
...@@ -496,7 +496,7 @@ cr.define('settings_passwords_check', function() { ...@@ -496,7 +496,7 @@ cr.define('settings_passwords_check', function() {
}); });
// Tests that the spinner is replaced with a checkmark on successful runs. // Tests that the spinner is replaced with a checkmark on successful runs.
test('testShowsCheckmarkIconWhenFinishedWithoutLeaks', async function() { test('showsCheckmarkIconWhenFinishedWithoutLeaks', async function() {
const data = passwordManager.data; const data = passwordManager.data;
assertEquals(0, data.leakedCredentials.length); assertEquals(0, data.leakedCredentials.length);
data.checkStatus = autofill_test_util.makePasswordCheckStatus( data.checkStatus = autofill_test_util.makePasswordCheckStatus(
...@@ -517,7 +517,7 @@ cr.define('settings_passwords_check', function() { ...@@ -517,7 +517,7 @@ cr.define('settings_passwords_check', function() {
}); });
// Tests that there is neither spinner nor icon if the check hasn't run yet. // Tests that there is neither spinner nor icon if the check hasn't run yet.
test('testIconWhenFirstRunIsPending', async function() { test('iconWhenFirstRunIsPending', async function() {
const data = passwordManager.data; const data = passwordManager.data;
assertEquals(0, data.leakedCredentials.length); assertEquals(0, data.leakedCredentials.length);
data.checkStatus = data.checkStatus =
...@@ -533,7 +533,7 @@ cr.define('settings_passwords_check', function() { ...@@ -533,7 +533,7 @@ cr.define('settings_passwords_check', function() {
}); });
// Tests that the spinner is replaced with a triangle if leaks were found. // Tests that the spinner is replaced with a triangle if leaks were found.
test('testShowsTriangleIconWhenFinishedWithLeaks', async function() { test('showsTriangleIconWhenFinishedWithLeaks', async function() {
const data = passwordManager.data; const data = passwordManager.data;
assertEquals(PasswordCheckState.IDLE, data.checkStatus.state); assertEquals(PasswordCheckState.IDLE, data.checkStatus.state);
data.leakedCredentials = [ data.leakedCredentials = [
...@@ -553,7 +553,7 @@ cr.define('settings_passwords_check', function() { ...@@ -553,7 +553,7 @@ cr.define('settings_passwords_check', function() {
}); });
// Tests that the spinner is replaced with a warning on errors. // Tests that the spinner is replaced with a warning on errors.
test('testShowsInfoIconWhenFinishedWithErrors', async function() { test('showsInfoIconWhenFinishedWithErrors', async function() {
passwordManager.data.checkStatus = passwordManager.data.checkStatus =
autofill_test_util.makePasswordCheckStatus( autofill_test_util.makePasswordCheckStatus(
/*state=*/ PasswordCheckState.OFFLINE, /*state=*/ PasswordCheckState.OFFLINE,
...@@ -572,7 +572,7 @@ cr.define('settings_passwords_check', function() { ...@@ -572,7 +572,7 @@ cr.define('settings_passwords_check', function() {
}); });
// Tests that the spinner replaces any icon while the check is running. // Tests that the spinner replaces any icon while the check is running.
test('testShowsSpinnerWhileRunning', async function() { test('showsSpinnerWhileRunning', async function() {
passwordManager.data.checkStatus = passwordManager.data.checkStatus =
autofill_test_util.makePasswordCheckStatus( autofill_test_util.makePasswordCheckStatus(
/*state=*/ PasswordCheckState.RUNNING, /*state=*/ PasswordCheckState.RUNNING,
...@@ -589,7 +589,7 @@ cr.define('settings_passwords_check', function() { ...@@ -589,7 +589,7 @@ cr.define('settings_passwords_check', function() {
}); });
// While running, the check should show the processed and total passwords. // While running, the check should show the processed and total passwords.
test('testShowOnlyProgressWhileRunningWithoutLeaks', async function() { test('showOnlyProgressWhileRunningWithoutLeaks', async function() {
passwordManager.data.checkStatus = passwordManager.data.checkStatus =
autofill_test_util.makePasswordCheckStatus( autofill_test_util.makePasswordCheckStatus(
/*state=*/ PasswordCheckState.RUNNING, /*state=*/ PasswordCheckState.RUNNING,
...@@ -626,7 +626,7 @@ cr.define('settings_passwords_check', function() { ...@@ -626,7 +626,7 @@ cr.define('settings_passwords_check', function() {
}); });
// While running, show progress and already found leak count. // While running, show progress and already found leak count.
test('testShowProgressAndLeaksWhileRunning', async function() { test('showProgressAndLeaksWhileRunning', async function() {
const data = passwordManager.data; const data = passwordManager.data;
data.checkStatus = autofill_test_util.makePasswordCheckStatus( data.checkStatus = autofill_test_util.makePasswordCheckStatus(
/*state=*/ PasswordCheckState.RUNNING, /*state=*/ PasswordCheckState.RUNNING,
...@@ -650,7 +650,7 @@ cr.define('settings_passwords_check', function() { ...@@ -650,7 +650,7 @@ cr.define('settings_passwords_check', function() {
// When canceled, show string explaining that and already found leak // When canceled, show string explaining that and already found leak
// count. // count.
test('testShowProgressAndLeaksAfterCanceled', async function() { test('showProgressAndLeaksAfterCanceled', async function() {
const data = passwordManager.data; const data = passwordManager.data;
data.checkStatus = autofill_test_util.makePasswordCheckStatus( data.checkStatus = autofill_test_util.makePasswordCheckStatus(
/*state=*/ PasswordCheckState.CANCELED, /*state=*/ PasswordCheckState.CANCELED,
...@@ -672,7 +672,7 @@ cr.define('settings_passwords_check', function() { ...@@ -672,7 +672,7 @@ cr.define('settings_passwords_check', function() {
}); });
// Before the first run, show only a description of what the check does. // Before the first run, show only a description of what the check does.
test('testShowOnlyDescriptionIfNotRun', async function() { test('showOnlyDescriptionIfNotRun', async function() {
const section = createCheckPasswordSection(); const section = createCheckPasswordSection();
await passwordManager.whenCalled('getPasswordCheckStatus'); await passwordManager.whenCalled('getPasswordCheckStatus');
Polymer.dom.flush(); Polymer.dom.flush();
...@@ -684,7 +684,7 @@ cr.define('settings_passwords_check', function() { ...@@ -684,7 +684,7 @@ cr.define('settings_passwords_check', function() {
}); });
// After running, show confirmation, timestamp and number of leaks. // After running, show confirmation, timestamp and number of leaks.
test('testShowLeakCountAndTimeStampWhenIdle', async function() { test('showLeakCountAndTimeStampWhenIdle', async function() {
const data = passwordManager.data; const data = passwordManager.data;
data.checkStatus = autofill_test_util.makePasswordCheckStatus( data.checkStatus = autofill_test_util.makePasswordCheckStatus(
/*state=*/ PasswordCheckState.IDLE, /*state=*/ PasswordCheckState.IDLE,
...@@ -708,7 +708,7 @@ cr.define('settings_passwords_check', function() { ...@@ -708,7 +708,7 @@ cr.define('settings_passwords_check', function() {
}); });
// When offline, only show an error. // When offline, only show an error.
test('testShowOnlyErrorWhenOffline', async function() { test('showOnlyErrorWhenOffline', async function() {
passwordManager.data.checkStatus = passwordManager.data.checkStatus =
autofill_test_util.makePasswordCheckStatus( autofill_test_util.makePasswordCheckStatus(
PasswordCheckState.OFFLINE); PasswordCheckState.OFFLINE);
...@@ -723,7 +723,7 @@ cr.define('settings_passwords_check', function() { ...@@ -723,7 +723,7 @@ cr.define('settings_passwords_check', function() {
}); });
// When signed out, only show an error. // When signed out, only show an error.
test('testShowOnlyErrorWhenSignedOut', async function() { test('showOnlyErrorWhenSignedOut', async function() {
passwordManager.data.checkStatus = passwordManager.data.checkStatus =
autofill_test_util.makePasswordCheckStatus( autofill_test_util.makePasswordCheckStatus(
PasswordCheckState.SIGNED_OUT); PasswordCheckState.SIGNED_OUT);
...@@ -739,7 +739,7 @@ cr.define('settings_passwords_check', function() { ...@@ -739,7 +739,7 @@ cr.define('settings_passwords_check', function() {
}); });
// When no passwords are saved, only show an error. // When no passwords are saved, only show an error.
test('testShowOnlyErrorWithoutPasswords', async function() { test('showOnlyErrorWithoutPasswords', async function() {
passwordManager.data.checkStatus = passwordManager.data.checkStatus =
autofill_test_util.makePasswordCheckStatus( autofill_test_util.makePasswordCheckStatus(
PasswordCheckState.NO_PASSWORDS); PasswordCheckState.NO_PASSWORDS);
...@@ -755,7 +755,7 @@ cr.define('settings_passwords_check', function() { ...@@ -755,7 +755,7 @@ cr.define('settings_passwords_check', function() {
}); });
// When users run out of quota, only show an error. // When users run out of quota, only show an error.
test('testShowOnlyErrorWhenQuotaIsHit', async function() { test('showOnlyErrorWhenQuotaIsHit', async function() {
passwordManager.data.checkStatus = passwordManager.data.checkStatus =
autofill_test_util.makePasswordCheckStatus( autofill_test_util.makePasswordCheckStatus(
PasswordCheckState.QUOTA_LIMIT); PasswordCheckState.QUOTA_LIMIT);
...@@ -770,7 +770,7 @@ cr.define('settings_passwords_check', function() { ...@@ -770,7 +770,7 @@ cr.define('settings_passwords_check', function() {
}); });
// When a general error occurs, only show the message. // When a general error occurs, only show the message.
test('testShowOnlyGenericError', async function() { test('showOnlyGenericError', async function() {
passwordManager.data.checkStatus = passwordManager.data.checkStatus =
autofill_test_util.makePasswordCheckStatus( autofill_test_util.makePasswordCheckStatus(
PasswordCheckState.OTHER_ERROR); PasswordCheckState.OTHER_ERROR);
...@@ -785,7 +785,7 @@ cr.define('settings_passwords_check', function() { ...@@ -785,7 +785,7 @@ cr.define('settings_passwords_check', function() {
}); });
// Transform check-button to stop-button if a check is running. // Transform check-button to stop-button if a check is running.
test('testButtonChangesTextAccordingToStatus', async function() { test('buttonChangesTextAccordingToStatus', async function() {
passwordManager.data.checkStatus = passwordManager.data.checkStatus =
autofill_test_util.makePasswordCheckStatus(PasswordCheckState.IDLE); autofill_test_util.makePasswordCheckStatus(PasswordCheckState.IDLE);
...@@ -811,7 +811,7 @@ cr.define('settings_passwords_check', function() { ...@@ -811,7 +811,7 @@ cr.define('settings_passwords_check', function() {
// Test that the banner is in a state that shows the positive confirmation // Test that the banner is in a state that shows the positive confirmation
// after a leak check finished. // after a leak check finished.
test('testShowsPositiveBannerWhenIdle', async function() { test('showsPositiveBannerWhenIdle', async function() {
const data = passwordManager.data; const data = passwordManager.data;
assertEquals(0, data.leakedCredentials.length); assertEquals(0, data.leakedCredentials.length);
data.checkStatus = autofill_test_util.makePasswordCheckStatus( data.checkStatus = autofill_test_util.makePasswordCheckStatus(
...@@ -830,7 +830,7 @@ cr.define('settings_passwords_check', function() { ...@@ -830,7 +830,7 @@ cr.define('settings_passwords_check', function() {
}); });
// Test that the banner indicates a neutral state if no check was run yet. // Test that the banner indicates a neutral state if no check was run yet.
test('testShowsNeutralBannerBeforeFirstRun', async function() { test('showsNeutralBannerBeforeFirstRun', async function() {
const data = passwordManager.data; const data = passwordManager.data;
assertEquals(PasswordCheckState.IDLE, data.checkStatus.state); assertEquals(PasswordCheckState.IDLE, data.checkStatus.state);
assertEquals(0, data.leakedCredentials.length); assertEquals(0, data.leakedCredentials.length);
...@@ -846,7 +846,7 @@ cr.define('settings_passwords_check', function() { ...@@ -846,7 +846,7 @@ cr.define('settings_passwords_check', function() {
// Test that the banner is in a state that shows that the leak check is // Test that the banner is in a state that shows that the leak check is
// in progress but hasn't found anything yet. // in progress but hasn't found anything yet.
test('testShowsNeutralBannerWhenRunning', async function() { test('showsNeutralBannerWhenRunning', async function() {
const data = passwordManager.data; const data = passwordManager.data;
assertEquals(0, data.leakedCredentials.length); assertEquals(0, data.leakedCredentials.length);
data.checkStatus = autofill_test_util.makePasswordCheckStatus( data.checkStatus = autofill_test_util.makePasswordCheckStatus(
...@@ -864,7 +864,7 @@ cr.define('settings_passwords_check', function() { ...@@ -864,7 +864,7 @@ cr.define('settings_passwords_check', function() {
// Test that the banner is in a state that shows that the leak check is // Test that the banner is in a state that shows that the leak check is
// in progress but hasn't found anything yet. // in progress but hasn't found anything yet.
test('testShowsNeutralBannerWhenCanceled', async function() { test('showsNeutralBannerWhenCanceled', async function() {
const data = passwordManager.data; const data = passwordManager.data;
assertEquals(0, data.leakedCredentials.length); assertEquals(0, data.leakedCredentials.length);
data.checkStatus = autofill_test_util.makePasswordCheckStatus( data.checkStatus = autofill_test_util.makePasswordCheckStatus(
...@@ -880,7 +880,7 @@ cr.define('settings_passwords_check', function() { ...@@ -880,7 +880,7 @@ cr.define('settings_passwords_check', function() {
}); });
// Test that the banner isn't visible as soon as the first leak is detected. // Test that the banner isn't visible as soon as the first leak is detected.
test('testLeaksHideBannerWhenRunning', async function() { test('leaksHideBannerWhenRunning', async function() {
const data = passwordManager.data; const data = passwordManager.data;
data.checkStatus = autofill_test_util.makePasswordCheckStatus( data.checkStatus = autofill_test_util.makePasswordCheckStatus(
/*state=*/ PasswordCheckState.RUNNING, /*checked=*/ 1, /*state=*/ PasswordCheckState.RUNNING, /*checked=*/ 1,
...@@ -897,7 +897,7 @@ cr.define('settings_passwords_check', function() { ...@@ -897,7 +897,7 @@ cr.define('settings_passwords_check', function() {
}); });
// Test that the banner isn't visible if a leak is detected after a check. // Test that the banner isn't visible if a leak is detected after a check.
test('testLeaksHideBannerWhenIdle', async function() { test('leaksHideBannerWhenIdle', async function() {
const data = passwordManager.data; const data = passwordManager.data;
data.checkStatus = autofill_test_util.makePasswordCheckStatus( data.checkStatus = autofill_test_util.makePasswordCheckStatus(
/*state=*/ PasswordCheckState.IDLE); /*state=*/ PasswordCheckState.IDLE);
...@@ -913,7 +913,7 @@ cr.define('settings_passwords_check', function() { ...@@ -913,7 +913,7 @@ cr.define('settings_passwords_check', function() {
}); });
// Test that the banner isn't visible if a leak is detected after canceling. // Test that the banner isn't visible if a leak is detected after canceling.
test('testLeaksHideBannerWhenCanceled', async function() { test('leaksHideBannerWhenCanceled', async function() {
const data = passwordManager.data; const data = passwordManager.data;
data.checkStatus = autofill_test_util.makePasswordCheckStatus( data.checkStatus = autofill_test_util.makePasswordCheckStatus(
/*state=*/ PasswordCheckState.CANCELED); /*state=*/ PasswordCheckState.CANCELED);
...@@ -929,7 +929,7 @@ cr.define('settings_passwords_check', function() { ...@@ -929,7 +929,7 @@ cr.define('settings_passwords_check', function() {
}); });
// Test verifies that new credentials are added to the bottom // Test verifies that new credentials are added to the bottom
test('testAppendCompromisedCredentials', function() { test('appendCompromisedCredentials', function() {
const leakedPasswords = [ const leakedPasswords = [
autofill_test_util.makeCompromisedCredential( autofill_test_util.makeCompromisedCredential(
'one.com', 'test4', 'LEAKED', 1, 0), 'one.com', 'test4', 'LEAKED', 1, 0),
...@@ -937,7 +937,7 @@ cr.define('settings_passwords_check', function() { ...@@ -937,7 +937,7 @@ cr.define('settings_passwords_check', function() {
'two.com', 'test3', 'LEAKED', 2, 0), 'two.com', 'test3', 'LEAKED', 2, 0),
]; ];
const checkPasswordSection = createCheckPasswordSection(); const checkPasswordSection = createCheckPasswordSection();
checkPasswordSection.updateList(leakedPasswords); checkPasswordSection.updateList_(leakedPasswords);
Polymer.dom.flush(); Polymer.dom.flush();
validateLeakedPasswordsList(checkPasswordSection, leakedPasswords); validateLeakedPasswordsList(checkPasswordSection, leakedPasswords);
...@@ -948,13 +948,13 @@ cr.define('settings_passwords_check', function() { ...@@ -948,13 +948,13 @@ cr.define('settings_passwords_check', function() {
'four.com', 'test1', 'LEAKED', 4, 5)); 'four.com', 'test1', 'LEAKED', 4, 5));
leakedPasswords.push(autofill_test_util.makeCompromisedCredential( leakedPasswords.push(autofill_test_util.makeCompromisedCredential(
'five.com', 'test0', 'LEAKED', 5, 4)); 'five.com', 'test0', 'LEAKED', 5, 4));
checkPasswordSection.updateList(shuffleArray(leakedPasswords)); checkPasswordSection.updateList_(shuffleArray(leakedPasswords));
Polymer.dom.flush(); Polymer.dom.flush();
validateLeakedPasswordsList(checkPasswordSection, leakedPasswords); validateLeakedPasswordsList(checkPasswordSection, leakedPasswords);
}); });
// Test verifies that deleting and adding works as it should // Test verifies that deleting and adding works as it should
test('testDeleteComrpomisedCredemtials', function() { test('deleteComrpomisedCredemtials', function() {
const leakedPasswords = [ const leakedPasswords = [
autofill_test_util.makeCompromisedCredential( autofill_test_util.makeCompromisedCredential(
'one.com', 'test4', 'PHISHED', 0, 0), 'one.com', 'test4', 'PHISHED', 0, 0),
...@@ -966,7 +966,7 @@ cr.define('settings_passwords_check', function() { ...@@ -966,7 +966,7 @@ cr.define('settings_passwords_check', function() {
'four.com', 'test2', 'LEAKED', 3, 2), 'four.com', 'test2', 'LEAKED', 3, 2),
]; ];
const checkPasswordSection = createCheckPasswordSection(); const checkPasswordSection = createCheckPasswordSection();
checkPasswordSection.updateList(leakedPasswords); checkPasswordSection.updateList_(leakedPasswords);
Polymer.dom.flush(); Polymer.dom.flush();
validateLeakedPasswordsList(checkPasswordSection, leakedPasswords); validateLeakedPasswordsList(checkPasswordSection, leakedPasswords);
...@@ -975,14 +975,14 @@ cr.define('settings_passwords_check', function() { ...@@ -975,14 +975,14 @@ cr.define('settings_passwords_check', function() {
leakedPasswords.push(autofill_test_util.makeCompromisedCredential( leakedPasswords.push(autofill_test_util.makeCompromisedCredential(
'five.com', 'test2', 'LEAKED', 4, 3)); 'five.com', 'test2', 'LEAKED', 4, 3));
checkPasswordSection.updateList(shuffleArray(leakedPasswords)); checkPasswordSection.updateList_(shuffleArray(leakedPasswords));
Polymer.dom.flush(); Polymer.dom.flush();
validateLeakedPasswordsList(checkPasswordSection, leakedPasswords); validateLeakedPasswordsList(checkPasswordSection, leakedPasswords);
}); });
// Verify that the edit dialog is not shown if a plaintext password could // Verify that the edit dialog is not shown if a plaintext password could
// not be obtained. // not be obtained.
test('testEditDialogWithoutPlaintextPassword', async function() { test('editDialogWithoutPlaintextPassword', async function() {
passwordManager.data.leakedCredentials = [ passwordManager.data.leakedCredentials = [
autofill_test_util.makeCompromisedCredential( autofill_test_util.makeCompromisedCredential(
'google.com', 'jdoerrie', 'LEAKED'), 'google.com', 'jdoerrie', 'LEAKED'),
...@@ -1010,7 +1010,7 @@ cr.define('settings_passwords_check', function() { ...@@ -1010,7 +1010,7 @@ cr.define('settings_passwords_check', function() {
}); });
// Verify edit a password on the edit dialog. // Verify edit a password on the edit dialog.
test('testEditDialogWithPlaintextPassword', async function() { test('editDialogWithPlaintextPassword', async function() {
passwordManager.data.leakedCredentials = [ passwordManager.data.leakedCredentials = [
autofill_test_util.makeCompromisedCredential( autofill_test_util.makeCompromisedCredential(
'google.com', 'jdoerrie', 'LEAKED'), 'google.com', 'jdoerrie', 'LEAKED'),
...@@ -1040,7 +1040,7 @@ cr.define('settings_passwords_check', function() { ...@@ -1040,7 +1040,7 @@ cr.define('settings_passwords_check', function() {
expectFalse(checkPasswordSection.$.moreActionsMenu.open); expectFalse(checkPasswordSection.$.moreActionsMenu.open);
}); });
test('testEditDialogChangePassword', async function() { test('editDialogChangePassword', async function() {
const leakedPassword = autofill_test_util.makeCompromisedCredential( const leakedPassword = autofill_test_util.makeCompromisedCredential(
'google.com', 'jdoerrie', 'LEAKED'); 'google.com', 'jdoerrie', 'LEAKED');
leakedPassword.password = 'mybirthday'; leakedPassword.password = 'mybirthday';
...@@ -1060,7 +1060,7 @@ cr.define('settings_passwords_check', function() { ...@@ -1060,7 +1060,7 @@ cr.define('settings_passwords_check', function() {
assertEquals('yadhtribym', newPassword); assertEquals('yadhtribym', newPassword);
}); });
test('testEditDialogCancel', function() { test('editDialogCancel', function() {
const leakedPassword = autofill_test_util.makeCompromisedCredential( const leakedPassword = autofill_test_util.makeCompromisedCredential(
'google.com', 'jdoerrie', 'LEAKED'); 'google.com', 'jdoerrie', 'LEAKED');
leakedPassword.password = 'mybirthday'; leakedPassword.password = 'mybirthday';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment