Commit d6d63534 authored by dpapad's avatar dpapad Committed by Commit Bot

Settings WebUI: Fix default setting for content exceptions.

Because of Polymer 2's different observer dependencies semantics the default
setting was erroneously toggled when the user enter the subpage.

Bug: 897236
Change-Id: I83b8959734e85d39e35f0acd187062326143b876
Reviewed-on: https://chromium-review.googlesource.com/c/1297231Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602142}
parent 0b6f4735
...@@ -86,8 +86,12 @@ Polymer({ ...@@ -86,8 +86,12 @@ Polymer({
* @private * @private
*/ */
onChangePermissionControl_: function() { onChangePermissionControl_: function() {
if (this.category == undefined) if (this.category === undefined ||
this.controlParams_.value === undefined ||
this.subControlParams_.value === undefined) {
// Do nothing unless all dependencies are defined.
return; return;
}
// Don't override user settings with enforced settings. // Don't override user settings with enforced settings.
if (this.controlParams_.enforcement == if (this.controlParams_.enforcement ==
......
...@@ -26,11 +26,30 @@ suite('CategoryDefaultSetting', function() { ...@@ -26,11 +26,30 @@ suite('CategoryDefaultSetting', function() {
document.body.appendChild(testElement); document.body.appendChild(testElement);
}); });
test('getDefaultValueForContentType API used', function() { test('browserProxy APIs used on startup', function() {
testElement.category = settings.ContentSettingsTypes.GEOLOCATION; const category = settings.ContentSettingsTypes.COOKIES;
return browserProxy.whenCalled('getDefaultValueForContentType') testElement.category = category;
.then(function(contentType) { return Promise
assertEquals(settings.ContentSettingsTypes.GEOLOCATION, contentType); .all([
browserProxy.whenCalled('getDefaultValueForContentType'),
browserProxy.whenCalled('setDefaultValueForContentType'),
])
.then(args => {
// Test |getDefaultValueForContentType| args.
assertEquals(category, args[0]);
// Test |setDefaultValueForContentType| args. Ensure that on
// initialization the same value returned from
// |getDefaultValueForContentType| is passed to
// |setDefaultValueForContentType|.
// TODO(dpapad): Ideally 'category-default-setting' should not call
// |setDefaultValueForContentType| on startup. Until that is fixed, at
// least ensure that it does not accidentally change the default
// value, crbug.com/897236.
assertEquals(category, args[1][0]);
assertEquals(settings.ContentSetting.ALLOW, args[1][1]);
assertEquals(
1, browserProxy.getCallCount('setDefaultValueForContentType'));
}); });
}); });
......
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