Commit bc9d644e authored by Victor Hugo Vianna Silva's avatar Victor Hugo Vianna Silva Committed by Commit Bot

[Settings] Refactor: change createPasswordEntry(); set id's in tests

With the addition of new fields to the PasswordUiEntry type over time,
this helper function (used to create mock data for tests) was modified
to set default values to these fields, since they were not relevant for
most tests. Once deduplication happens in passwords_section though,
only duplicates will be allowed to share the value of frontendId, which
is problematic.

In order to avoid having several optional parameters in an fixed order,
this CL changes the signature to receive them in a key/value manner.
When no frontendId is passed, it assumes the value of the id. This
allows tests that do not care about duplicate entries to simply set the
id value.

Besides that, the CL also touches existing tests that did not set id
values (which was inconsistent with the production code anyway). This
will allow adding the deduplication functionality in crrev.com/c/2219503
without touching these tests, but rather focusing on adding tests for
the new behavior.

Bug: 1049141
Change-Id: If773b2684eda844dc025fea6255288215cd66bdf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2218055
Commit-Queue: Victor Vianna <victorvianna@google.com>
Reviewed-by: default avatarFriedrich [CET] <fhorschig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#773095}
parent e4cb2d91
...@@ -46,7 +46,7 @@ document.body.appendChild(settingsUi); ...@@ -46,7 +46,7 @@ document.body.appendChild(settingsUi);
whenReady.then(() => { whenReady.then(() => {
const fakePasswords = []; const fakePasswords = [];
for (let i = 0; i < 10; i++) { for (let i = 0; i < 10; i++) {
fakePasswords.push(createPasswordEntry()); fakePasswords.push(createPasswordEntry({id: i, user: i.toString()}));
} }
// Set list of passwords. // Set list of passwords.
passwordManager.lastCallback.addSavedPasswordListChangedListener( passwordManager.lastCallback.addSavedPasswordListChangedListener(
......
...@@ -181,7 +181,10 @@ suite('PasswordsAndForms', function() { ...@@ -181,7 +181,10 @@ suite('PasswordsAndForms', function() {
return createPrefs(true, true).then(function(prefs) { return createPrefs(true, true).then(function(prefs) {
const element = createAutofillElement(prefs); const element = createAutofillElement(prefs);
const list = [createPasswordEntry(), createPasswordEntry()]; const list = [
createPasswordEntry({url: 'one.com', username: 'user1', id: 0}),
createPasswordEntry({url: 'two.com', username: 'user1', id: 1})
];
passwordManager.lastCallback.addSavedPasswordListChangedListener(list); passwordManager.lastCallback.addSavedPasswordListChangedListener(list);
flush(); flush();
......
...@@ -11,10 +11,10 @@ import {createPasswordEntry} from 'chrome://test/settings/passwords_and_autofill ...@@ -11,10 +11,10 @@ import {createPasswordEntry} from 'chrome://test/settings/passwords_and_autofill
suite('MultiStorePasswordUiEntry', function() { suite('MultiStorePasswordUiEntry', function() {
test('verifyIds', function() { test('verifyIds', function() {
const deviceEntry = createPasswordEntry('g.com', 'user', 0); const deviceEntry = createPasswordEntry(
deviceEntry.fromAccountStore = false; {url: 'g.com', username: 'user', id: 0, fromAccountStore: false});
const accountEntry = createPasswordEntry('g.com', 'user', 1); const accountEntry = createPasswordEntry(
accountEntry.fromAccountStore = true; {url: 'g.com', username: 'user', id: 1, fromAccountStore: true});
const multiStoreDeviceEntry = new MultiStorePasswordUiEntry(deviceEntry); const multiStoreDeviceEntry = new MultiStorePasswordUiEntry(deviceEntry);
expectTrue(multiStoreDeviceEntry.isPresentOnDevice()); expectTrue(multiStoreDeviceEntry.isPresentOnDevice());
......
...@@ -13,28 +13,41 @@ import {TestPasswordManagerProxy} from './test_password_manager_proxy.js'; ...@@ -13,28 +13,41 @@ import {TestPasswordManagerProxy} from './test_password_manager_proxy.js';
// clang-format on // clang-format on
/** /**
* Creates a single item for the list of passwords. * Creates a single item for the list of passwords, in the format sent by the
* @param {string=} url * password manager native code. If no |id| is passed, it is set to a default,
* @param {string=} username * value so this should probably not be done in tests with multiple entries
* @param {number=} id * (|id| is unique). If no |frontendId| is passed, it is set to the same value
* as |id|.
* @param {{ url: (string|undefined),
* username: (string|undefined),
* federationText: (string|undefined),
* id: (number|undefined),
* frontendId: (number|undefined),
* fromAccountStore: (boolean|undefined)
* }=} params
* @return {chrome.passwordsPrivate.PasswordUiEntry} * @return {chrome.passwordsPrivate.PasswordUiEntry}
*/ */
export function createPasswordEntry(url, username, id) { export function createPasswordEntry(params) {
// Generate fake data if param is undefined. // Generate fake data if param is undefined.
url = url || patternMaker_('www.xxxxxx.com', 16); params = params || {};
username = username || patternMaker_('user_xxxxx', 16); params.url = params.url !== undefined ? params.url : 'www.foo.com';
id = id || 0; params.username = params.username || 'user';
params.id = params.id !== undefined ? params.id : 42;
params.frontendId =
params.frontendId !== undefined ? params.frontendId : params.id;
params.fromAccountStore = params.fromAccountStore || false;
return { return {
urls: { urls: {
origin: 'http://' + url + '/login', origin: 'http://' + params.url + '/login',
shown: url, shown: params.url,
link: 'http://' + url + '/login', link: 'http://' + params.url + '/login',
}, },
username: username, username: params.username,
id: id, federationText: params.federationText,
frontendId: id, id: params.id,
fromAccountStore: false, frontendId: params.frontendId,
fromAccountStore: params.fromAccountStore,
}; };
} }
......
...@@ -170,12 +170,12 @@ suite('PasswordsSection', function() { ...@@ -170,12 +170,12 @@ suite('PasswordsSection', function() {
test('verifySavedPasswordLength', function() { test('verifySavedPasswordLength', function() {
const passwordList = [ const passwordList = [
createPasswordEntry('site1.com', 'luigi'), createPasswordEntry({url: 'site1.com', username: 'luigi', id: 0}),
createPasswordEntry('longwebsite.com', 'peach'), createPasswordEntry({url: 'longwebsite.com', username: 'peach', id: 1}),
createPasswordEntry('site2.com', 'mario'), createPasswordEntry({url: 'site2.com', username: 'mario', id: 2}),
createPasswordEntry('site1.com', 'peach'), createPasswordEntry({url: 'site1.com', username: 'peach', id: 3}),
createPasswordEntry('google.com', 'mario'), createPasswordEntry({url: 'google.com', username: 'mario', id: 4}),
createPasswordEntry('site2.com', 'luigi'), createPasswordEntry({url: 'site2.com', username: 'luigi', id: 5}),
]; ];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
...@@ -196,9 +196,10 @@ suite('PasswordsSection', function() { ...@@ -196,9 +196,10 @@ suite('PasswordsSection', function() {
// Test verifies that removing a password will update the elements. // Test verifies that removing a password will update the elements.
test('verifyPasswordListRemove', function() { test('verifyPasswordListRemove', function() {
const passwordList = [ const passwordList = [
createPasswordEntry('anotherwebsite.com', 'luigi', 0), createPasswordEntry(
createPasswordEntry('longwebsite.com', 'peach', 1), {url: 'anotherwebsite.com', username: 'luigi', id: 0}),
createPasswordEntry('website.com', 'mario', 2) createPasswordEntry({url: 'longwebsite.com', username: 'peach', id: 1}),
createPasswordEntry({url: 'website.com', username: 'mario', id: 2})
]; ];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
...@@ -221,8 +222,9 @@ suite('PasswordsSection', function() { ...@@ -221,8 +222,9 @@ suite('PasswordsSection', function() {
// Test verifies that adding a password will update the elements. // Test verifies that adding a password will update the elements.
test('verifyPasswordListAdd', function() { test('verifyPasswordListAdd', function() {
const passwordList = [ const passwordList = [
createPasswordEntry('anotherwebsite.com', 'luigi', 0), createPasswordEntry(
createPasswordEntry('longwebsite.com', 'peach', 1), {url: 'anotherwebsite.com', username: 'luigi', id: 0}),
createPasswordEntry({url: 'longwebsite.com', username: 'peach', id: 1}),
]; ];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
...@@ -230,7 +232,8 @@ suite('PasswordsSection', function() { ...@@ -230,7 +232,8 @@ suite('PasswordsSection', function() {
validatePasswordList(passwordsSection, passwordList); validatePasswordList(passwordsSection, passwordList);
// Simulate 'website.com' being added to the list. // Simulate 'website.com' being added to the list.
passwordList.unshift(createPasswordEntry('website.com', 'mario', 2)); passwordList.unshift(
createPasswordEntry({url: 'website.com', username: 'mario', id: 2}));
passwordManager.lastCallback.addSavedPasswordListChangedListener( passwordManager.lastCallback.addSavedPasswordListChangedListener(
passwordList); passwordList);
flush(); flush();
...@@ -246,8 +249,8 @@ suite('PasswordsSection', function() { ...@@ -246,8 +249,8 @@ suite('PasswordsSection', function() {
// Set-up initial list. // Set-up initial list.
let passwordList = [ let passwordList = [
createPasswordEntry('website.com', 'mario', 0), createPasswordEntry({url: 'website.com', username: 'mario', id: 0}),
createPasswordEntry('website.com', 'luigi', 1) createPasswordEntry({url: 'website.com', username: 'luigi', id: 1})
]; ];
passwordManager.lastCallback.addSavedPasswordListChangedListener( passwordManager.lastCallback.addSavedPasswordListChangedListener(
...@@ -274,12 +277,12 @@ suite('PasswordsSection', function() { ...@@ -274,12 +277,12 @@ suite('PasswordsSection', function() {
// event. Does not actually remove any passwords. // event. Does not actually remove any passwords.
test('verifyPasswordItemRemoveButton', async function() { test('verifyPasswordItemRemoveButton', async function() {
const passwordList = [ const passwordList = [
createPasswordEntry('one', 'six'), createPasswordEntry({url: 'one', username: 'six', id: 0}),
createPasswordEntry('two', 'five'), createPasswordEntry({url: 'two', username: 'five', id: 1}),
createPasswordEntry('three', 'four'), createPasswordEntry({url: 'three', username: 'four', id: 2}),
createPasswordEntry('four', 'three'), createPasswordEntry({url: 'four', username: 'three', id: 3}),
createPasswordEntry('five', 'two'), createPasswordEntry({url: 'five', username: 'two', id: 4}),
createPasswordEntry('six', 'one'), createPasswordEntry({url: 'six', username: 'one', id: 5}),
]; ];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
...@@ -305,9 +308,8 @@ suite('PasswordsSection', function() { ...@@ -305,9 +308,8 @@ suite('PasswordsSection', function() {
// (passwordless) credentials. Does not test Copy button. // (passwordless) credentials. Does not test Copy button.
test('verifyCopyAbsentForFederatedPasswordInMenu', function() { test('verifyCopyAbsentForFederatedPasswordInMenu', function() {
const passwordList = [ const passwordList = [
createPasswordEntry('one.com', 'hey'), createPasswordEntry({federationText: 'with chromium.org'}),
]; ];
passwordList[0].federationText = 'with chromium.org';
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
passwordManager, passwordList, []); passwordManager, passwordList, []);
...@@ -321,7 +323,7 @@ suite('PasswordsSection', function() { ...@@ -321,7 +323,7 @@ suite('PasswordsSection', function() {
// credentials. Does not test Copy button. // credentials. Does not test Copy button.
test('verifyCopyPresentInMenu', function() { test('verifyCopyPresentInMenu', function() {
const passwordList = [ const passwordList = [
createPasswordEntry('one.com', 'hey'), createPasswordEntry({url: 'one.com', username: 'hey'}),
]; ];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
passwordManager, passwordList, []); passwordManager, passwordList, []);
...@@ -333,12 +335,12 @@ suite('PasswordsSection', function() { ...@@ -333,12 +335,12 @@ suite('PasswordsSection', function() {
test('verifyFilterPasswords', function() { test('verifyFilterPasswords', function() {
const passwordList = [ const passwordList = [
createPasswordEntry('one.com', 'SHOW'), createPasswordEntry({url: 'one.com', username: 'SHOW', id: 0}),
createPasswordEntry('two.com', 'shower'), createPasswordEntry({url: 'two.com', username: 'shower', id: 1}),
createPasswordEntry('three.com/show', 'four'), createPasswordEntry({url: 'three.com/show', username: 'four', id: 2}),
createPasswordEntry('four.com', 'three'), createPasswordEntry({url: 'four.com', username: 'three', id: 3}),
createPasswordEntry('five.com', 'two'), createPasswordEntry({url: 'five.com', username: 'two', id: 4}),
createPasswordEntry('six-show.com', 'one'), createPasswordEntry({url: 'six-show.com', username: 'one', id: 5}),
]; ];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
...@@ -347,10 +349,10 @@ suite('PasswordsSection', function() { ...@@ -347,10 +349,10 @@ suite('PasswordsSection', function() {
flush(); flush();
const expectedList = [ const expectedList = [
createPasswordEntry('one.com', 'SHOW'), createPasswordEntry({url: 'one.com', username: 'SHOW', id: 0}),
createPasswordEntry('two.com', 'shower'), createPasswordEntry({url: 'two.com', username: 'shower', id: 1}),
createPasswordEntry('three.com/show', 'four'), createPasswordEntry({url: 'three.com/show', username: 'four', id: 2}),
createPasswordEntry('six-show.com', 'one'), createPasswordEntry({url: 'six-show.com', username: 'one', id: 5}),
]; ];
validatePasswordList(passwordsSection, expectedList); validatePasswordList(passwordsSection, expectedList);
...@@ -358,12 +360,12 @@ suite('PasswordsSection', function() { ...@@ -358,12 +360,12 @@ suite('PasswordsSection', function() {
test('verifyFilterPasswordsWithRemoval', function() { test('verifyFilterPasswordsWithRemoval', function() {
const passwordList = [ const passwordList = [
createPasswordEntry('one.com', 'SHOW', 0), createPasswordEntry({url: 'one.com', username: 'SHOW', id: 0}),
createPasswordEntry('two.com', 'shower', 1), createPasswordEntry({url: 'two.com', username: 'shower', id: 1}),
createPasswordEntry('three.com/show', 'four', 2), createPasswordEntry({url: 'three.com/show', username: 'four', id: 2}),
createPasswordEntry('four.com', 'three', 3), createPasswordEntry({url: 'four.com', username: 'three', id: 3}),
createPasswordEntry('five.com', 'two', 4), createPasswordEntry({url: 'five.com', username: 'two', id: 4}),
createPasswordEntry('six-show.com', 'one', 5), createPasswordEntry({url: 'six-show.com', username: 'one', id: 5}),
]; ];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
...@@ -372,10 +374,10 @@ suite('PasswordsSection', function() { ...@@ -372,10 +374,10 @@ suite('PasswordsSection', function() {
flush(); flush();
let expectedList = [ let expectedList = [
createPasswordEntry('one.com', 'SHOW', 0), createPasswordEntry({url: 'one.com', username: 'SHOW', id: 0}),
createPasswordEntry('two.com', 'shower', 1), createPasswordEntry({url: 'two.com', username: 'shower', id: 1}),
createPasswordEntry('three.com/show', 'four', 2), createPasswordEntry({url: 'three.com/show', username: 'four', id: 2}),
createPasswordEntry('six-show.com', 'one', 5), createPasswordEntry({url: 'six-show.com', username: 'one', id: 5}),
]; ];
validatePasswordList(passwordsSection, expectedList); validatePasswordList(passwordsSection, expectedList);
...@@ -384,9 +386,9 @@ suite('PasswordsSection', function() { ...@@ -384,9 +386,9 @@ suite('PasswordsSection', function() {
passwordList.splice(2, 1); passwordList.splice(2, 1);
expectedList = [ expectedList = [
createPasswordEntry('one.com', 'SHOW', 0), createPasswordEntry({url: 'one.com', username: 'SHOW', id: 0}),
createPasswordEntry('two.com', 'shower', 1), createPasswordEntry({url: 'two.com', username: 'shower', id: 1}),
createPasswordEntry('six-show.com', 'one', 5), createPasswordEntry({url: 'six-show.com', username: 'one', id: 5}),
]; ];
passwordManager.lastCallback.addSavedPasswordListChangedListener( passwordManager.lastCallback.addSavedPasswordListChangedListener(
...@@ -529,8 +531,8 @@ suite('PasswordsSection', function() { ...@@ -529,8 +531,8 @@ suite('PasswordsSection', function() {
}); });
test('verifyFederatedPassword', function() { test('verifyFederatedPassword', function() {
const item = createPasswordEntry('goo.gl', 'bart'); const item = createPasswordEntry(
item.federationText = 'with chromium.org'; {url: 'goo.gl', username: 'bart', federationText: 'with chromium.org'});
const passwordDialog = elementFactory.createPasswordEditDialog(item); const passwordDialog = elementFactory.createPasswordEditDialog(item);
flush(); flush();
...@@ -542,8 +544,8 @@ suite('PasswordsSection', function() { ...@@ -542,8 +544,8 @@ suite('PasswordsSection', function() {
}); });
test('verifyStorageDetailsInEditDialogForAccountPassword', function() { test('verifyStorageDetailsInEditDialogForAccountPassword', function() {
const accountPassword = createPasswordEntry('goo.gl', 'bart'); const accountPassword = createPasswordEntry(
accountPassword.fromAccountStore = true; {url: 'goo.gl', username: 'bart', fromAccountStore: true});
const accountPasswordDialog = const accountPasswordDialog =
elementFactory.createPasswordEditDialog(accountPassword); elementFactory.createPasswordEditDialog(accountPassword);
flush(); flush();
...@@ -562,8 +564,8 @@ suite('PasswordsSection', function() { ...@@ -562,8 +564,8 @@ suite('PasswordsSection', function() {
}); });
test('verifyStorageDetailsInEditDialogForDevicePassword', function() { test('verifyStorageDetailsInEditDialogForDevicePassword', function() {
const devicePassword = createPasswordEntry('goo.gl', 'bart'); const devicePassword = createPasswordEntry(
devicePassword.fromAccountStore = false; {url: 'goo.gl', username: 'bart', fromAccountStore: false});
const devicePasswordDialog = const devicePasswordDialog =
elementFactory.createPasswordEditDialog(devicePassword); elementFactory.createPasswordEditDialog(devicePassword);
flush(); flush();
...@@ -583,7 +585,7 @@ suite('PasswordsSection', function() { ...@@ -583,7 +585,7 @@ suite('PasswordsSection', function() {
test('showSavedPasswordEditDialog', function() { test('showSavedPasswordEditDialog', function() {
const PASSWORD = 'bAn@n@5'; const PASSWORD = 'bAn@n@5';
const item = createPasswordEntry('goo.gl', 'bart'); const item = createPasswordEntry({url: 'goo.gl', username: 'bart'});
const passwordDialog = elementFactory.createPasswordEditDialog(item); const passwordDialog = elementFactory.createPasswordEditDialog(item);
assertFalse(passwordDialog.$.showPasswordButton.hidden); assertFalse(passwordDialog.$.showPasswordButton.hidden);
...@@ -599,7 +601,7 @@ suite('PasswordsSection', function() { ...@@ -599,7 +601,7 @@ suite('PasswordsSection', function() {
test('showSavedPasswordListItem', function() { test('showSavedPasswordListItem', function() {
const PASSWORD = 'bAn@n@5'; const PASSWORD = 'bAn@n@5';
const item = createPasswordEntry('goo.gl', 'bart'); const item = createPasswordEntry({url: 'goo.gl', username: 'bart'});
const passwordListItem = elementFactory.createPasswordListItem(item); const passwordListItem = elementFactory.createPasswordListItem(item);
// Hidden passwords should be disabled. // Hidden passwords should be disabled.
assertTrue(passwordListItem.$$('#password').disabled); assertTrue(passwordListItem.$$('#password').disabled);
...@@ -621,7 +623,8 @@ suite('PasswordsSection', function() { ...@@ -621,7 +623,8 @@ suite('PasswordsSection', function() {
// Tests that invoking the plaintext password sets the corresponding // Tests that invoking the plaintext password sets the corresponding
// password. // password.
test('onShowSavedPasswordEditDialog', function() { test('onShowSavedPasswordEditDialog', function() {
const expectedItem = createPasswordEntry('goo.gl', 'bart', 1); const expectedItem =
createPasswordEntry({url: 'goo.gl', username: 'bart', id: 1});
const passwordDialog = const passwordDialog =
elementFactory.createPasswordEditDialog(expectedItem); elementFactory.createPasswordEditDialog(expectedItem);
assertEquals('', passwordDialog.password); assertEquals('', passwordDialog.password);
...@@ -637,7 +640,8 @@ suite('PasswordsSection', function() { ...@@ -637,7 +640,8 @@ suite('PasswordsSection', function() {
}); });
test('onShowSavedPasswordListItem', function() { test('onShowSavedPasswordListItem', function() {
const expectedItem = createPasswordEntry('goo.gl', 'bart', 1); const expectedItem =
createPasswordEntry({url: 'goo.gl', username: 'bart', id: 1});
const passwordListItem = const passwordListItem =
elementFactory.createPasswordListItem(expectedItem); elementFactory.createPasswordListItem(expectedItem);
assertEquals('', passwordListItem.password); assertEquals('', passwordListItem.password);
...@@ -653,7 +657,8 @@ suite('PasswordsSection', function() { ...@@ -653,7 +657,8 @@ suite('PasswordsSection', function() {
}); });
test('onCopyPasswordListItem', function() { test('onCopyPasswordListItem', function() {
const expectedItem = createPasswordEntry('goo.gl', 'bart', 1); const expectedItem =
createPasswordEntry({url: 'goo.gl', username: 'bart', id: 1});
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
passwordManager, [expectedItem], []); passwordManager, [expectedItem], []);
...@@ -668,7 +673,8 @@ suite('PasswordsSection', function() { ...@@ -668,7 +673,8 @@ suite('PasswordsSection', function() {
}); });
test('closingPasswordsSectionHidesUndoToast', function(done) { test('closingPasswordsSectionHidesUndoToast', function(done) {
const passwordEntry = createPasswordEntry('goo.gl', 'bart'); const passwordEntry =
createPasswordEntry({url: 'goo.gl', username: 'bart'});
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
passwordManager, [passwordEntry], []); passwordManager, [passwordEntry], []);
const toastManager = getToastManager(); const toastManager = getToastManager();
...@@ -690,7 +696,7 @@ suite('PasswordsSection', function() { ...@@ -690,7 +696,7 @@ suite('PasswordsSection', function() {
// Chrome offers the export option when there are passwords. // Chrome offers the export option when there are passwords.
test('offerExportWhenPasswords', function(done) { test('offerExportWhenPasswords', function(done) {
const passwordList = [ const passwordList = [
createPasswordEntry('googoo.com', 'Larry'), createPasswordEntry({url: 'googoo.com', username: 'Larry'}),
]; ];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
passwordManager, passwordList, []); passwordManager, passwordList, []);
...@@ -716,7 +722,7 @@ suite('PasswordsSection', function() { ...@@ -716,7 +722,7 @@ suite('PasswordsSection', function() {
// dialog. // dialog.
test('exportOpen', function(done) { test('exportOpen', function(done) {
const passwordList = [ const passwordList = [
createPasswordEntry('googoo.com', 'Larry'), createPasswordEntry({url: 'googoo.com', username: 'Larry'}),
]; ];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
passwordManager, passwordList, []); passwordManager, passwordList, []);
...@@ -852,12 +858,15 @@ suite('PasswordsSection', function() { ...@@ -852,12 +858,15 @@ suite('PasswordsSection', function() {
// Feature flag enabled. // Feature flag enabled.
loadTimeData.overrideValues({enableAccountStorage: true}); loadTimeData.overrideValues({enableAccountStorage: true});
const accountPassword = createPasswordEntry('foo.com', 'account', 0);
accountPassword.fromAccountStore = true;
const localPassword = createPasswordEntry('foo.com', 'local', 1);
localPassword.fromAccountStore = false;
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
passwordManager, [accountPassword, localPassword], []); passwordManager,
[
createPasswordEntry(
{username: 'account', id: 0, fromAccountStore: true}),
createPasswordEntry(
{username: 'local', id: 1, fromAccountStore: false})
],
[]);
// Setup user in account storage mode: sync disabled, user signed in // Setup user in account storage mode: sync disabled, user signed in
// and opted in. // and opted in.
...@@ -949,7 +958,7 @@ suite('PasswordsSection', function() { ...@@ -949,7 +958,7 @@ suite('PasswordsSection', function() {
passwordManager.data.checkStatus.elapsedTimeSinceLastCheck, passwordManager.data.checkStatus.elapsedTimeSinceLastCheck,
undefined); undefined);
const passwordList = [ const passwordList = [
createPasswordEntry('site1.com', 'luigi'), createPasswordEntry({url: 'site1.com', username: 'luigi'}),
]; ];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
passwordManager, passwordList, []); passwordManager, passwordList, []);
...@@ -971,8 +980,8 @@ suite('PasswordsSection', function() { ...@@ -971,8 +980,8 @@ suite('PasswordsSection', function() {
passwordManager.data.checkStatus.elapsedTimeSinceLastCheck, passwordManager.data.checkStatus.elapsedTimeSinceLastCheck,
undefined); undefined);
const passwordList = [ const passwordList = [
createPasswordEntry('site1.com', 'luigi'), createPasswordEntry({url: 'site1.com', username: 'luigi', id: 0}),
createPasswordEntry('site2.com', 'luigi'), createPasswordEntry({url: 'site2.com', username: 'luigi', id: 1}),
]; ];
passwordManager.data.checkStatus.state = PasswordCheckState.CANCELED; passwordManager.data.checkStatus.state = PasswordCheckState.CANCELED;
passwordManager.data.leakedCredentials = [ passwordManager.data.leakedCredentials = [
...@@ -1002,7 +1011,7 @@ suite('PasswordsSection', function() { ...@@ -1002,7 +1011,7 @@ suite('PasswordsSection', function() {
assertEquals( assertEquals(
passwordManager.data.checkStatus.elapsedTimeSinceLastCheck, undefined); passwordManager.data.checkStatus.elapsedTimeSinceLastCheck, undefined);
const passwordList = [ const passwordList = [
createPasswordEntry('site1.com', 'luigi'), createPasswordEntry({url: 'site1.com', username: 'luigi'}),
]; ];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
passwordManager, passwordList, []); passwordManager, passwordList, []);
...@@ -1038,7 +1047,7 @@ suite('PasswordsSection', function() { ...@@ -1038,7 +1047,7 @@ suite('PasswordsSection', function() {
passwordManager.data.checkStatus.elapsedTimeSinceLastCheck = passwordManager.data.checkStatus.elapsedTimeSinceLastCheck =
'5 min ago'; '5 min ago';
const passwordList = [ const passwordList = [
createPasswordEntry('site1.com', 'luigi'), createPasswordEntry({url: 'site1.com', username: 'luigi'}),
]; ];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
passwordManager, passwordList, []); passwordManager, passwordList, []);
...@@ -1066,7 +1075,7 @@ suite('PasswordsSection', function() { ...@@ -1066,7 +1075,7 @@ suite('PasswordsSection', function() {
passwordManager.data.checkStatus.elapsedTimeSinceLastCheck = passwordManager.data.checkStatus.elapsedTimeSinceLastCheck =
'5 min ago'; '5 min ago';
const passwordList = [ const passwordList = [
createPasswordEntry('site1.com', 'luigi'), createPasswordEntry({url: 'site1.com', username: 'luigi'}),
]; ];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
passwordManager, passwordList, []); passwordManager, passwordList, []);
...@@ -1091,8 +1100,8 @@ suite('PasswordsSection', function() { ...@@ -1091,8 +1100,8 @@ suite('PasswordsSection', function() {
passwordManager.data.leakedCredentials = []; passwordManager.data.leakedCredentials = [];
passwordManager.data.checkStatus.elapsedTimeSinceLastCheck = '5 min ago'; passwordManager.data.checkStatus.elapsedTimeSinceLastCheck = '5 min ago';
const passwordList = [ const passwordList = [
createPasswordEntry('one.com', 'test4'), createPasswordEntry({url: 'one.com', username: 'test4', id: 0}),
createPasswordEntry('two.com', 'test3'), createPasswordEntry({url: 'two.com', username: 'test3', id: 1}),
]; ];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
passwordManager, passwordList, []); passwordManager, passwordList, []);
...@@ -1135,8 +1144,8 @@ suite('PasswordsSection', function() { ...@@ -1135,8 +1144,8 @@ suite('PasswordsSection', function() {
// Suppose no leaks detected initially, non-empty list of passwords, // Suppose no leaks detected initially, non-empty list of passwords,
// signed in. // signed in.
const passwordList = [ const passwordList = [
createPasswordEntry('one.com', 'test4'), createPasswordEntry({url: 'one.com', username: 'test4', id: 0}),
createPasswordEntry('two.com', 'test3'), createPasswordEntry({url: 'two.com', username: 'test3', id: 1}),
]; ];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
passwordManager, passwordList, []); passwordManager, passwordList, []);
......
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