Commit a690f286 authored by Demetrios Papadopoulos's avatar Demetrios Papadopoulos Committed by Commit Bot

Fix and re-enable CrSettingsSiteSettingsPageTest.All test.

It was previously failing because it was asserting on the value of a
cr-link-row's sublabel before it was actually updated in the prod code.

Introducing a 'site-settings-list-labels-updated-for-testing' event to give a
singal on the test code on when to assert fixes the issue.

Bug: 1061249
Change-Id: Ia9c31229da79ac83acb38254ccee053b26f3ec1e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2111778
Commit-Queue: Sean Harrison <harrisonsean@chromium.org>
Auto-Submit: dpapad <dpapad@chromium.org>
Reviewed-by: default avatarSean Harrison <harrisonsean@chromium.org>
Cr-Commit-Position: refs/heads/master@{#751988}
parent c9ca74b9
......@@ -64,15 +64,12 @@ cr.define('settings', function() {
this.browserProxy_ =
settings.SiteSettingsPrefsBrowserProxyImpl.getInstance();
for (const item of this.categoryList) {
// Default labels are not applicable to ZOOM_LEVELS or PDF.
if (item.id === settings.ContentSettingsTypes.ZOOM_LEVELS ||
item.id === 'pdfDocuments') {
continue;
}
this.refreshDefaultValueLabel_(item.id);
}
Promise
.all(this.categoryList.map(
item => this.refreshDefaultValueLabel_(item.id)))
.then(() => {
this.fire('site-settings-list-labels-updated-for-testing');
});
this.addWebUIListener(
'contentSettingCategoryChanged',
......@@ -111,16 +108,25 @@ cr.define('settings', function() {
/**
* @param {!settings.ContentSettingsTypes} category The category to refresh
* (fetch current value + update UI)
* @return {!Promise<void>} A promise firing after the label has been
* updated.
* @private
*/
refreshDefaultValueLabel_(category) {
// Default labels are not applicable to ZOOM_LEVELS or PDF.
if (category === settings.ContentSettingsTypes.ZOOM_LEVELS ||
category === 'pdfDocuments') {
return Promise.resolve();
}
if (category == settings.ContentSettingsTypes.COOKIES &&
loadTimeData.getBoolean('privacySettingsRedesignEnabled')) {
// Updates to the cookies label are handled by the
// cookieSettingDescriptionChanged event listener.
return;
return Promise.resolve();
}
this.browserProxy_.getDefaultValueForContentType(category).then(
return this.browserProxy_.getDefaultValueForContentType(category).then(
defaultValue => {
this.updateDefaultValueLabel_(category, defaultValue.setting);
});
......
......@@ -1185,7 +1185,7 @@ CrSettingsSiteSettingsPageTest.prototype = {
])
};
TEST_F('CrSettingsSiteSettingsPageTest', 'DISABLED_All', function() {
TEST_F('CrSettingsSiteSettingsPageTest', 'All', function() {
mocha.run();
});
......
......@@ -69,15 +69,17 @@ suite('SiteSettingsPage', function() {
settings.ContentSetting.IMPORTANT_CONTENT, 'a', 'b', 'c'));
});
test('CookiesLinkRowSublabel', function() {
test('CookiesLinkRowSublabel', async function() {
loadTimeData.overrideValues({
privacySettingsRedesignEnabled: false,
});
setupPage();
const allSettingsList = page.$$('#allSettingsList');
await test_util.eventToPromise(
'site-settings-list-labels-updated-for-testing', allSettingsList);
assertEquals(
allSettingsList.$$('#cookies').subLabel,
allSettingsList.i18n('siteSettingsCookiesAllowed'));
allSettingsList.i18n('siteSettingsCookiesAllowed'),
allSettingsList.$$('#cookies').subLabel);
});
test('CookiesLinkRowSublabel_Redesign', async function() {
......@@ -88,9 +90,9 @@ suite('SiteSettingsPage', function() {
await siteSettingsBrowserProxy.whenCalled('getCookieSettingDescription');
Polymer.dom.flush();
const cookiesLinkRow = page.$$('#basicContentList').$$('#cookies');
assertEquals(cookiesLinkRow.subLabel, testLabels[0]);
assertEquals(testLabels[0], cookiesLinkRow.subLabel);
cr.webUIListenerCallback('cookieSettingDescriptionChanged', testLabels[1]);
assertEquals(cookiesLinkRow.subLabel, testLabels[1]);
assertEquals(testLabels[1], cookiesLinkRow.subLabel);
});
});
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