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

Add missing flush() calls to passwords_section_test

This CL adds missing flush() calls to the tests, especially after calls
to setIsOptedInForAccountStorageAndNotify(). It also removes unnecessary
calls from other sites, as well as fixes a build dependency for
chrome/test/data/webui/settings/passwords_and_autofill_fake_data.js.

Bug: 1090931
Change-Id: I53e152a2aa7655c1961b638d3e3d9095504588fd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2267038Reviewed-by: default avatarFriedrich [CET] <fhorschig@chromium.org>
Commit-Queue: Victor Vianna <victorvianna@google.com>
Cr-Commit-Position: refs/heads/master@{#782874}
parent f136b13d
...@@ -239,6 +239,7 @@ js_library("passwords_and_autofill_fake_data") { ...@@ -239,6 +239,7 @@ js_library("passwords_and_autofill_fake_data") {
"//chrome/browser/resources/settings:lazy_load", "//chrome/browser/resources/settings:lazy_load",
"//chrome/browser/resources/settings:settings", "//chrome/browser/resources/settings:settings",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/js:assert.m",
] ]
externs_list = [ externs_list = [
"$externs_path/autofill_private.js", "$externs_path/autofill_private.js",
......
...@@ -29,6 +29,7 @@ export function runExportFlowFastTest(exportDialog, passwordManager, done) { ...@@ -29,6 +29,7 @@ export function runExportFlowFastTest(exportDialog, passwordManager, done) {
assertTrue(exportDialog.$$('#dialog_start').open); assertTrue(exportDialog.$$('#dialog_start').open);
exportDialog.$$('#exportPasswordsButton').click(); exportDialog.$$('#exportPasswordsButton').click();
flush();
assertTrue(exportDialog.$$('#dialog_start').open); assertTrue(exportDialog.$$('#dialog_start').open);
progressCallback( progressCallback(
{status: chrome.passwordsPrivate.ExportProgressStatus.IN_PROGRESS}); {status: chrome.passwordsPrivate.ExportProgressStatus.IN_PROGRESS});
...@@ -123,25 +124,30 @@ export function runExportFlowSlowTest(exportDialog, passwordManager, done) { ...@@ -123,25 +124,30 @@ export function runExportFlowSlowTest(exportDialog, passwordManager, done) {
// in-progress state. // in-progress state.
assertTrue(exportDialog.$$('#dialog_start').open); assertTrue(exportDialog.$$('#dialog_start').open);
exportDialog.$$('#exportPasswordsButton').click(); exportDialog.$$('#exportPasswordsButton').click();
flush();
assertTrue(exportDialog.$$('#dialog_start').open); assertTrue(exportDialog.$$('#dialog_start').open);
progressCallback( progressCallback(
{status: chrome.passwordsPrivate.ExportProgressStatus.IN_PROGRESS}); {status: chrome.passwordsPrivate.ExportProgressStatus.IN_PROGRESS});
flush();
assertTrue(exportDialog.$$('#dialog_start').open); assertTrue(exportDialog.$$('#dialog_start').open);
// After 100ms of not having completed, the dialog switches to the // After 100ms of not having completed, the dialog switches to the
// progress bar. Chrome will continue to show the progress bar for 1000ms, // progress bar. Chrome will continue to show the progress bar for 1000ms,
// despite a completion event. // despite a completion event.
mockTimer.tick(99); mockTimer.tick(99);
flush();
assertTrue(exportDialog.$$('#dialog_start').open); assertTrue(exportDialog.$$('#dialog_start').open);
mockTimer.tick(1); mockTimer.tick(1);
flush(); flush();
assertTrue(exportDialog.$$('#dialog_progress').open); assertTrue(exportDialog.$$('#dialog_progress').open);
progressCallback( progressCallback(
{status: chrome.passwordsPrivate.ExportProgressStatus.SUCCEEDED}); {status: chrome.passwordsPrivate.ExportProgressStatus.SUCCEEDED});
flush();
assertTrue(exportDialog.$$('#dialog_progress').open); assertTrue(exportDialog.$$('#dialog_progress').open);
// After 1000ms, Chrome will display the completion event. // After 1000ms, Chrome will display the completion event.
mockTimer.tick(999); mockTimer.tick(999);
flush();
assertTrue(exportDialog.$$('#dialog_progress').open); assertTrue(exportDialog.$$('#dialog_progress').open);
mockTimer.tick(1); mockTimer.tick(1);
flush(); flush();
......
...@@ -156,6 +156,8 @@ function simulateAccountStorageUser(passwordManager) { ...@@ -156,6 +156,8 @@ function simulateAccountStorageUser(passwordManager) {
email: 'john@gmail.com', email: 'john@gmail.com',
}]); }]);
passwordManager.setIsOptedInForAccountStorageAndNotify(true); passwordManager.setIsOptedInForAccountStorageAndNotify(true);
flush();
} }
suite('PasswordsSection', function() { suite('PasswordsSection', function() {
...@@ -513,7 +515,6 @@ suite('PasswordsSection', function() { ...@@ -513,7 +515,6 @@ suite('PasswordsSection', function() {
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
passwordManager, passwordList, []); passwordManager, passwordList, []);
flush();
getFirstPasswordListItem(passwordsSection).$.moreActionsButton.click(); getFirstPasswordListItem(passwordsSection).$.moreActionsButton.click();
flush(); flush();
...@@ -529,7 +530,6 @@ suite('PasswordsSection', function() { ...@@ -529,7 +530,6 @@ suite('PasswordsSection', function() {
]; ];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
passwordManager, passwordList, []); passwordManager, passwordList, []);
flush();
getFirstPasswordListItem(passwordsSection).$.moreActionsButton.click(); getFirstPasswordListItem(passwordsSection).$.moreActionsButton.click();
flush(); flush();
...@@ -588,6 +588,7 @@ suite('PasswordsSection', function() { ...@@ -588,6 +588,7 @@ suite('PasswordsSection', function() {
// Simulate removal of three.com/show // Simulate removal of three.com/show
passwordList.splice(2, 1); passwordList.splice(2, 1);
flush();
expectedList = [ expectedList = [
createPasswordEntry({url: 'one.com', username: 'SHOW', id: 0}), createPasswordEntry({url: 'one.com', username: 'SHOW', id: 0}),
...@@ -720,10 +721,10 @@ suite('PasswordsSection', function() { ...@@ -720,10 +721,10 @@ suite('PasswordsSection', function() {
// Simulate 'mail.com' being removed from the list. // Simulate 'mail.com' being removed from the list.
passwordsSection.splice('passwordExceptions', 1, 1); passwordsSection.splice('passwordExceptions', 1, 1);
flush();
assertFalse(exceptionsListContainsUrl( assertFalse(exceptionsListContainsUrl(
passwordsSection.passwordExceptions, 'mail.com')); passwordsSection.passwordExceptions, 'mail.com'));
assertFalse(exceptionsListContainsUrl(exceptionList, 'mail.com')); assertFalse(exceptionsListContainsUrl(exceptionList, 'mail.com'));
flush();
const expectedExceptionList = [ const expectedExceptionList = [
createExceptionEntry({url: 'docs.google.com', id: 0}), createExceptionEntry({url: 'docs.google.com', id: 0}),
...@@ -810,8 +811,6 @@ suite('PasswordsSection', function() { ...@@ -810,8 +811,6 @@ suite('PasswordsSection', function() {
{federationText: 'with chromium.org', username: 'bart', deviceId: 42}); {federationText: 'with chromium.org', username: 'bart', deviceId: 42});
const passwordDialog = elementFactory.createPasswordEditDialog(item); const passwordDialog = elementFactory.createPasswordEditDialog(item);
flush();
assertEquals(item.federationText, passwordDialog.$.passwordInput.value); assertEquals(item.federationText, passwordDialog.$.passwordInput.value);
// Text should be readable. // Text should be readable.
assertEquals('text', passwordDialog.$.passwordInput.type); assertEquals('text', passwordDialog.$.passwordInput.type);
...@@ -825,7 +824,6 @@ suite('PasswordsSection', function() { ...@@ -825,7 +824,6 @@ suite('PasswordsSection', function() {
{url: 'goo.gl', username: 'bart', accountId: 42}); {url: 'goo.gl', username: 'bart', accountId: 42});
const accountPasswordDialog = const accountPasswordDialog =
elementFactory.createPasswordEditDialog(accountPassword); elementFactory.createPasswordEditDialog(accountPassword);
flush();
// By default no message is displayed. // By default no message is displayed.
assertTrue(accountPasswordDialog.$.storageDetails.hidden); assertTrue(accountPasswordDialog.$.storageDetails.hidden);
...@@ -846,7 +844,6 @@ suite('PasswordsSection', function() { ...@@ -846,7 +844,6 @@ suite('PasswordsSection', function() {
{url: 'goo.gl', username: 'bart', deviceId: 42}); {url: 'goo.gl', username: 'bart', deviceId: 42});
const devicePasswordDialog = const devicePasswordDialog =
elementFactory.createPasswordEditDialog(devicePassword); elementFactory.createPasswordEditDialog(devicePassword);
flush();
// By default no message is displayed. // By default no message is displayed.
assertTrue(devicePasswordDialog.$.storageDetails.hidden); assertTrue(devicePasswordDialog.$.storageDetails.hidden);
...@@ -868,7 +865,6 @@ suite('PasswordsSection', function() { ...@@ -868,7 +865,6 @@ suite('PasswordsSection', function() {
{url: 'goo.gl', username: 'bart', deviceId: 42, accountId: 43}); {url: 'goo.gl', username: 'bart', deviceId: 42, accountId: 43});
const accountAndDevicePasswordDialog = const accountAndDevicePasswordDialog =
elementFactory.createPasswordEditDialog(accountAndDevicePassword); elementFactory.createPasswordEditDialog(accountAndDevicePassword);
flush();
// By default no message is displayed. // By default no message is displayed.
assertTrue(accountAndDevicePasswordDialog.$.storageDetails.hidden); assertTrue(accountAndDevicePasswordDialog.$.storageDetails.hidden);
...@@ -973,7 +969,7 @@ suite('PasswordsSection', function() { ...@@ -973,7 +969,7 @@ suite('PasswordsSection', function() {
}); });
}); });
test('closingPasswordsSectionHidesUndoToast', function(done) { test('closingPasswordsSectionHidesUndoToast', function() {
const passwordEntry = const passwordEntry =
createPasswordEntry({url: 'goo.gl', username: 'bart'}); createPasswordEntry({url: 'goo.gl', username: 'bart'});
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
...@@ -990,13 +986,12 @@ suite('PasswordsSection', function() { ...@@ -990,13 +986,12 @@ suite('PasswordsSection', function() {
// Remove the passwords section from the DOM and check that this closes // Remove the passwords section from the DOM and check that this closes
// the undo toast. // the undo toast.
document.body.removeChild(passwordsSection); document.body.removeChild(passwordsSection);
flush();
assertFalse(toastManager.open); assertFalse(toastManager.open);
done();
}); });
// 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() {
const passwordList = [ const passwordList = [
createPasswordEntry({url: 'googoo.com', username: 'Larry'}), createPasswordEntry({url: 'googoo.com', username: 'Larry'}),
]; ];
...@@ -1005,19 +1000,17 @@ suite('PasswordsSection', function() { ...@@ -1005,19 +1000,17 @@ suite('PasswordsSection', function() {
validatePasswordList(passwordsSection, passwordList); validatePasswordList(passwordsSection, passwordList);
assertFalse(passwordsSection.$.menuExportPassword.hidden); assertFalse(passwordsSection.$.menuExportPassword.hidden);
done();
}); });
// Chrome shouldn't offer the option to export passwords if there are no // Chrome shouldn't offer the option to export passwords if there are no
// passwords. // passwords.
test('noExportIfNoPasswords', function(done) { test('noExportIfNoPasswords', function() {
const passwordList = []; const passwordList = [];
const passwordsSection = elementFactory.createPasswordsSection( const passwordsSection = elementFactory.createPasswordsSection(
passwordManager, passwordList, []); passwordManager, passwordList, []);
validatePasswordList(passwordsSection, passwordList); validatePasswordList(passwordsSection, passwordList);
assertTrue(passwordsSection.$.menuExportPassword.hidden); assertTrue(passwordsSection.$.menuExportPassword.hidden);
done();
}); });
// Test that clicking the Export Passwords menu item opens the export // Test that clicking the Export Passwords menu item opens the export
...@@ -1122,6 +1115,7 @@ suite('PasswordsSection', function() { ...@@ -1122,6 +1115,7 @@ suite('PasswordsSection', function() {
email: 'john@gmail.com', email: 'john@gmail.com',
}]); }]);
passwordManager.setIsOptedInForAccountStorageAndNotify(false); passwordManager.setIsOptedInForAccountStorageAndNotify(false);
flush();
assertTrue( assertTrue(
isDisplayed(passwordsSection.$.accountStorageButtonsContainer)); isDisplayed(passwordsSection.$.accountStorageButtonsContainer));
assertTrue(isDisplayed(passwordsSection.$.optInToAccountStorageButton)); assertTrue(isDisplayed(passwordsSection.$.optInToAccountStorageButton));
...@@ -1131,6 +1125,7 @@ suite('PasswordsSection', function() { ...@@ -1131,6 +1125,7 @@ suite('PasswordsSection', function() {
// Opt in. // Opt in.
passwordManager.setIsOptedInForAccountStorageAndNotify(true); passwordManager.setIsOptedInForAccountStorageAndNotify(true);
flush();
assertTrue( assertTrue(
isDisplayed(passwordsSection.$.accountStorageButtonsContainer)); isDisplayed(passwordsSection.$.accountStorageButtonsContainer));
assertFalse(isDisplayed(passwordsSection.$.optInToAccountStorageButton)); assertFalse(isDisplayed(passwordsSection.$.optInToAccountStorageButton));
...@@ -1176,6 +1171,7 @@ suite('PasswordsSection', function() { ...@@ -1176,6 +1171,7 @@ suite('PasswordsSection', function() {
flush(); flush();
passwordManager.setIsOptedInForAccountStorageAndNotify(false); passwordManager.setIsOptedInForAccountStorageAndNotify(false);
flush();
assertEquals('john@gmail.com', passwordsSection.$.accountEmail.innerText); assertEquals('john@gmail.com', passwordsSection.$.accountEmail.innerText);
const bg = passwordsSection.$.profileIcon.style.backgroundImage; const bg = passwordsSection.$.profileIcon.style.backgroundImage;
assertTrue(bg.includes(iconDataUrl)); assertTrue(bg.includes(iconDataUrl));
...@@ -1190,14 +1186,7 @@ suite('PasswordsSection', function() { ...@@ -1190,14 +1186,7 @@ suite('PasswordsSection', function() {
const passwordsSection = const passwordsSection =
elementFactory.createPasswordsSection(passwordManager, [], []); elementFactory.createPasswordsSection(passwordManager, [], []);
simulateSyncStatus({signedIn: false}); simulateAccountStorageUser(passwordManager);
simulateStoredAccounts([{
fullName: 'john doe',
givenName: 'john',
email: 'john@gmail.com',
}]);
passwordManager.setIsOptedInForAccountStorageAndNotify(true);
const isDisplayed = element => !!element && !element.hidden; const isDisplayed = element => !!element && !element.hidden;
assertTrue( assertTrue(
isDisplayed(passwordsSection.$.accountStorageButtonsContainer)); isDisplayed(passwordsSection.$.accountStorageButtonsContainer));
...@@ -1230,6 +1219,7 @@ suite('PasswordsSection', function() { ...@@ -1230,6 +1219,7 @@ suite('PasswordsSection', function() {
// Opting in still doesn't display it because the user has no device // Opting in still doesn't display it because the user has no device
// passwords yet. // passwords yet.
passwordManager.setIsOptedInForAccountStorageAndNotify(true); passwordManager.setIsOptedInForAccountStorageAndNotify(true);
flush();
assertTrue(passwordsSection.$.devicePasswordsLink.hidden); assertTrue(passwordsSection.$.devicePasswordsLink.hidden);
// Add a device password. The button shows up, with the text in singular // Add a device password. The button shows up, with the text in singular
...@@ -1377,7 +1367,7 @@ suite('PasswordsSection', function() { ...@@ -1377,7 +1367,7 @@ suite('PasswordsSection', function() {
} }
// The export dialog is dismissable. // The export dialog is dismissable.
test('exportDismissable', function(done) { test('exportDismissable', function() {
const exportDialog = const exportDialog =
elementFactory.createExportPasswordsDialog(passwordManager); elementFactory.createExportPasswordsDialog(passwordManager);
...@@ -1385,8 +1375,6 @@ suite('PasswordsSection', function() { ...@@ -1385,8 +1375,6 @@ suite('PasswordsSection', function() {
exportDialog.$$('#cancelButton').click(); exportDialog.$$('#cancelButton').click();
flush(); flush();
assertFalse(!!exportDialog.$$('#dialog_start')); assertFalse(!!exportDialog.$$('#dialog_start'));
done();
}); });
test('fires close event when canceled', () => { test('fires close event when canceled', () => {
...@@ -1633,8 +1621,8 @@ suite('PasswordsSection', function() { ...@@ -1633,8 +1621,8 @@ suite('PasswordsSection', function() {
assertFalse(passwordsSection.$$('#checkPasswordsBannerContainer').hidden); assertFalse(passwordsSection.$$('#checkPasswordsBannerContainer').hidden);
assertFalse(passwordsSection.$$('#checkPasswordsButtonRow').hidden); assertFalse(passwordsSection.$$('#checkPasswordsButtonRow').hidden);
assertTrue(passwordsSection.$$('#checkPasswordsLinkRow').hidden); assertTrue(passwordsSection.$$('#checkPasswordsLinkRow').hidden);
simulateSyncStatus({signedIn: false}); simulateSyncStatus({signedIn: false});
flush();
assertTrue(passwordsSection.$$('#checkPasswordsBannerContainer').hidden); assertTrue(passwordsSection.$$('#checkPasswordsBannerContainer').hidden);
assertTrue(passwordsSection.$$('#checkPasswordsButtonRow').hidden); assertTrue(passwordsSection.$$('#checkPasswordsButtonRow').hidden);
assertFalse(passwordsSection.$$('#checkPasswordsLinkRow').hidden); assertFalse(passwordsSection.$$('#checkPasswordsLinkRow').hidden);
......
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