Commit 0cf209e5 authored by Dmitry Gozman's avatar Dmitry Gozman Committed by Commit Bot

Revert "Reland "Settings: Content settings can now be reset for a group of origins in All Sites.""

This reverts commit 11240791.

Reason for revert: CrSettingsSiteDetailsTest.All consistently fails on linux-chromeos-dbg:
https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/linux-chromeos-dbg

Original change's description:
> Reland "Settings: Content settings can now be reset for a group of origins in All Sites."
> 
> This is a reland of e2cac39f
> 
> Original change's description:
> > Settings: Content settings can now be reset for a group of origins in All Sites.
> > 
> > Add a three-dot / overflow menu to groups of origins in All Sites. This overflow
> > menu allows the entire list of origins to have all their content settings reset
> > in one go. This will be preceded with a confirmation dialog.
> > 
> > Manual test - With #enable-site-settings turned on, change a content setting via
> > Page Info > Site settings on both https://permission.site and
> > http://permission.site. Navigate to chrome://settings/content/all and see that
> > both sites are listed under 'permission.site'. Verify there is an overflow menu
> > on this entry and that inside the overflow menu, there is a 'Reset permissions'
> > option. Clicking this should bring up a reset permission dialog and confirming
> > the dialog should remove this entry from All Sites.
> > 
> > Bug: 835712, 717468
> > Cq-Include-Trybots: luci.chromium.try:closure_compilation
> > Change-Id: I777f759c26bf0fe7f8da086fa887969897cf9833
> > Reviewed-on: https://chromium-review.googlesource.com/1098577
> > Commit-Queue: Patti <patricialor@chromium.org>
> > Reviewed-by: Dave Schuyler <dschuyler@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#568742}
> 
> Bug: 835712, 717468
> Change-Id: I7825326b8fa133d54971180bfd37494b19c5e86c
> Cq-Include-Trybots: luci.chromium.try:closure_compilation
> Reviewed-on: https://chromium-review.googlesource.com/1113037
> Commit-Queue: Patti <patricialor@chromium.org>
> Reviewed-by: Dave Schuyler <dschuyler@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#570309}

TBR=dschuyler@chromium.org,patricialor@chromium.org

Change-Id: Ia270a380442ebdd75014034a1ee980341a9b0f1f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 835712, 717468
Cq-Include-Trybots: luci.chromium.try:closure_compilation
Reviewed-on: https://chromium-review.googlesource.com/1115179Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Commit-Queue: Dmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570427}
parent 82ba5f3a
......@@ -2987,12 +2987,6 @@
<message name="IDS_SETTINGS_SITE_SETTINGS_SITE_CLEAR_STORAGE_CONFIRMATION" desc="Text for the dialog that warns about clearing storage used by a site (excluding cookies).">
All data stored by <ph name="SITE">$1<ex>www.example.com</ex></ph> will be deleted, except for cookies.
</message>
<message name="IDS_SETTINGS_SITE_SETTINGS_SITE_GROUP_RESET_DIALOG_TITLE" desc="Title of the dialog that warns about resetting all permissions for a group of sites.">
Reset site permissions?
</message>
<message name="IDS_SETTINGS_SITE_SETTINGS_SITE_GROUP_RESET_CONFIRMATION" desc="Text for the dialog that warns about resetting all permissions for a group of sites.">
Sites under <ph name="SITE_GROUP_NAME">$1<ex>google.co.uk</ex></ph> will also be reset.
</message>
<message name="IDS_SETTINGS_SITE_SETTINGS_COOKIE_REMOVE_MULTIPLE" desc="Text for the dialog that warns about deleting all site data.">
This will delete any data stored on your device for all the sites shown. Do you want to continue?
</message>
......
......@@ -19,7 +19,6 @@ js_type_check("closure_compile") {
":site_data_details_subpage",
":site_details",
":site_details_permission",
":site_entry",
":site_list",
":site_settings_behavior",
":site_settings_prefs_browser_proxy",
......@@ -171,20 +170,6 @@ js_library("site_details_permission") {
]
}
js_library("site_entry") {
deps = [
":constants",
":site_settings_behavior",
"..:route",
"//third_party/polymer/v1_0/components-chromium/iron-collapse:iron-collapse-extracted",
"//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu",
"//ui/webui/resources/cr_elements/cr_lazy_render:cr_lazy_render",
"//ui/webui/resources/js:assert",
"//ui/webui/resources/js:cr",
"//ui/webui/resources/js:load_time_data",
]
}
js_library("site_list") {
deps = [
":constants",
......
......@@ -40,11 +40,42 @@ Polymer({
*/
populateList_: function() {
/** @type {!Array<settings.ContentSettingsTypes>} */
const contentTypes = this.getCategoryList();
// Make sure to include cookies, because All Sites handles data storage +
// cookies as well as regular settings.ContentSettingsTypes.
if (!contentTypes.includes(settings.ContentSettingsTypes.COOKIES))
contentTypes.push(settings.ContentSettingsTypes.COOKIES);
let contentTypes = [];
const types = Object.values(settings.ContentSettingsTypes);
for (let i = 0; i < types.length; ++i) {
const type = types[i];
// <if expr="not chromeos">
if (type == settings.ContentSettingsTypes.PROTECTED_CONTENT)
continue;
// </if>
// Some categories store their data in a custom way.
if (type == settings.ContentSettingsTypes.PROTOCOL_HANDLERS ||
type == settings.ContentSettingsTypes.ZOOM_LEVELS) {
continue;
}
// These categories are gated behind flags.
if (type == settings.ContentSettingsTypes.SENSORS &&
!loadTimeData.getBoolean('enableSensorsContentSetting')) {
continue;
}
if (type == settings.ContentSettingsTypes.ADS &&
!loadTimeData.getBoolean('enableSafeBrowsingSubresourceFilter')) {
continue;
}
if (type == settings.ContentSettingsTypes.SOUND &&
!loadTimeData.getBoolean('enableSoundContentSetting')) {
continue;
}
if (type == settings.ContentSettingsTypes.CLIPBOARD &&
!loadTimeData.getBoolean('enableClipboardContentSetting')) {
continue;
}
if (type == settings.ContentSettingsTypes.PAYMENT_HANDLER &&
!loadTimeData.getBoolean('enablePaymentHandlerContentSetting')) {
continue;
}
contentTypes.push(type);
}
this.browserProxy_.getAllSites(contentTypes).then((response) => {
this.siteGroupList = response;
......
......@@ -116,7 +116,8 @@
<site-details-permission
category="{{ContentSettingsTypes.SENSORS}}"
icon="settings:sensors" id="sensors"
label="$i18n{siteSettingsSensors}">
label="$i18n{siteSettingsSensors}"
hidden$="[[!enableSensorsContentSetting_]]">
</site-details-permission>
<site-details-permission category="{{ContentSettingsTypes.NOTIFICATIONS}}"
icon="settings:notifications" id="notifications"
......@@ -138,7 +139,8 @@
<site-details-permission
category="{{ContentSettingsTypes.ADS}}"
icon="settings:ads" id="ads"
label="$i18n{siteSettingsAds}">
label="$i18n{siteSettingsAds}"
hidden$="[[!enableSafeBrowsingSubresourceFilter_]]">
</site-details-permission>
<site-details-permission
category="{{ContentSettingsTypes.BACKGROUND_SYNC}}"
......@@ -147,7 +149,8 @@
</site-details-permission>
<site-details-permission category="{{ContentSettingsTypes.SOUND}}"
icon="settings:volume-up" id="sound"
label="$i18n{siteSettingsSound}">
label="$i18n{siteSettingsSound}"
hidden$="[[!enableSoundContentSetting_]]">
</site-details-permission>
<site-details-permission
category="{{ContentSettingsTypes.AUTOMATIC_DOWNLOADS}}"
......@@ -177,12 +180,14 @@
<site-details-permission
category="{{ContentSettingsTypes.CLIPBOARD}}"
icon="settings:clipboard" id="clipboard"
label="$i18n{siteSettingsClipboard}">
label="$i18n{siteSettingsClipboard}"
hidden$="[[!enableClipboardContentSetting_]]">
</site-details-permission>
<site-details-permission
category="{{ContentSettingsTypes.PAYMENT_HANDLER}}"
icon="settings:payment-handler" id="paymentHandler"
label="$i18n{siteSettingsPaymentHandler}">
label="$i18n{siteSettingsPaymentHandler}"
hidden$="[[!enablePaymentHandlerContentSetting_]]">
</site-details-permission>
</div>
......
......@@ -51,6 +51,47 @@ Polymer({
},
},
/** @private */
enableSafeBrowsingSubresourceFilter_: {
type: Boolean,
value: function() {
return loadTimeData.getBoolean('enableSafeBrowsingSubresourceFilter');
},
},
/** @private */
enableSoundContentSetting_: {
type: Boolean,
value: function() {
return loadTimeData.getBoolean('enableSoundContentSetting');
},
},
/** @private */
enableClipboardContentSetting_: {
type: Boolean,
value: function() {
return loadTimeData.getBoolean('enableClipboardContentSetting');
},
},
/** @private */
enableSensorsContentSetting_: {
type: Boolean,
readOnly: true,
value: function() {
return loadTimeData.getBoolean('enableSensorsContentSetting');
},
},
/** @private */
enablePaymentHandlerContentSetting_: {
type: Boolean,
value: function() {
return loadTimeData.getBoolean('enablePaymentHandlerContentSetting');
},
},
/**
* The type of storage for the origin.
* @private
......@@ -103,7 +144,7 @@ Polymer({
if (this.enableSiteSettings_)
this.$.usageApi.fetchUsageTotal(this.toUrl(this.origin).hostname);
this.updatePermissions_(this.getCategoryList());
this.updatePermissions_(this.getCategoryList_());
}
});
},
......@@ -121,7 +162,7 @@ Polymer({
origin === undefined || origin == '') {
return;
}
if (!this.getCategoryList().includes(category))
if (!this.getCategoryList_().includes(category))
return;
// Site details currently doesn't support embedded origins, so ignore it and
......@@ -198,20 +239,20 @@ Polymer({
* Resets all permissions for the current origin.
* @private
*/
onResetSettings_: function(e) {
onResetSettings_: function() {
this.browserProxy.setOriginPermissions(
this.origin, this.getCategoryList(), settings.ContentSetting.DEFAULT);
if (this.getCategoryList().includes(settings.ContentSettingsTypes.PLUGINS))
this.origin, this.getCategoryList_(), settings.ContentSetting.DEFAULT);
if (this.getCategoryList_().includes(settings.ContentSettingsTypes.PLUGINS))
this.browserProxy.clearFlashPref(this.origin);
this.onCloseDialog_(e);
this.$.confirmResetSettings.close();
},
/**
* Clears all data stored, except cookies, for the current origin.
* @private
*/
onClearStorage_: function(e) {
onClearStorage_: function() {
// Since usage is only shown when "Site Settings" is enabled, don't clear it
// when it's not shown.
if (this.enableSiteSettings_ && this.storedData_ != '') {
......@@ -219,7 +260,7 @@ Polymer({
this.toUrl(this.origin).href, this.storageType_);
}
this.onCloseDialog_(e);
this.$.confirmClearStorage.close();
},
/**
......@@ -233,6 +274,20 @@ Polymer({
this.storedData_ = '';
},
/**
* Returns list of categories for each permission displayed in <site-details>.
* @return {!Array<!settings.ContentSettingsTypes>}
* @private
*/
getCategoryList_: function() {
const categoryList = [];
this.root.querySelectorAll('site-details-permission').forEach((element) => {
if (!element.hidden)
categoryList.push(element.category);
});
return categoryList;
},
/**
* Checks whether the permission list is standalone or has a heading.
* @return {string} CSS class applied when the permission list has no heading.
......
......@@ -12,7 +12,7 @@
<dom-module id="site-details-permission">
<template>
<style include="settings-shared md-select"></style>
<div id="details" hidden$="[[shouldHideCategory_(category)]]">
<div id="details">
<div id="permissionItem"
class$="list-item [[permissionInfoStringClass_(site.source, category,
site.setting)]]">
......
......@@ -36,10 +36,6 @@ Polymer({
this.onDefaultSettingChanged_.bind(this));
},
shouldHideCategory_: function(category) {
return !this.getCategoryList().includes(category);
},
/**
* Updates the drop-down value after |site| has changed.
* @param {!RawSiteException} site The site to display.
......
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_elements/cr_action_menu/cr_action_menu.html">
<link rel="import" href="chrome://resources/cr_elements/cr_lazy_render/cr_lazy_render.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-collapse/iron-collapse.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html">
<link rel="import" href="../route.html">
<link rel="import" href="../settings_shared_css.html">
<link rel="import" href="site_settings_behavior.html">
<dom-module id="site-entry">
<template>
<style include="settings-shared">
.row-aligned {
display: flex;
flex-direction: row;
}
</style>
<style include="settings-shared"></style>
<div id="collapseParent">
<div class="settings-box list-item">
<div id="toggleButton" class="start row-aligned"
on-click="toggleCollapsible_" actionable aria-expanded="false">
<div class="favicon-image"
style$="[[getSiteGroupIcon_(siteGroup)]]">
</div>
<div class="middle text-elide" id="displayName">
[[displayName_]]
</div>
<div hidden$="[[!grouped_(siteGroup)]]">
<paper-icon-button-light id="expandIcon" class="icon-expand-more">
<button aria-label$="[[displayName_]]"
aria-describedby="displayName"></button>
</paper-icon-button-light>
</div>
<div hidden$="[[grouped_(siteGroup)]]">
<paper-icon-button-light class="subpage-arrow">
<button aria-label$="[[displayName_]]"
aria-describedby="displayName"></button>
</paper-icon-button-light>
</div>
<div id="toggleButton" class="settings-box list-item"
on-click="toggleCollapsible_" actionable aria-expanded="false">
<div class="favicon-image"
style$="[[getSiteGroupIcon_(siteGroup)]]">
</div>
<div class="row-aligned" hidden$="[[!grouped_(siteGroup)]]">
<div class="separator"></div>
<paper-icon-button-light class="icon-more-vert">
<button id="overflowMenuButton" title="$i18n{moreActions}"
on-click="showOverflowMenu_">
</button>
</paper-icon-button-light>
<div class="middle text-elide" id="displayName">
[[displayName_(siteGroup)]]
</div>
<paper-icon-button-light class="subpage-arrow">
<button aria-label$="[[displayName_(siteGroup)]]"
aria-describedby="displayName"></button>
</paper-icon-button-light>
</div>
<iron-collapse id="collapseChild" no-animation>
......@@ -57,7 +31,7 @@
<div class="favicon-image"
style$="[[computeSiteIcon(item)]]">
</div>
<div class="middle text-elide">
<div class="middle text-elide" data-index="[[index]]">
[[item]]
</div>
</div>
......@@ -65,38 +39,6 @@
</div>
</iron-collapse>
</div>
<!-- Overflow menu. -->
<cr-lazy-render id="menu">
<template>
<cr-action-menu>
<button slot="item" class="dropdown-item" role="menuitem"
on-click="onConfirmResetSettings_">
Reset permissions
</button>
</cr-action-menu>
</template>
</cr-lazy-render>
<!-- Confirm reset settings dialog. -->
<cr-dialog id="confirmResetSettings" close-text="$i18n{close}">
<div slot="title">
$i18n{siteSettingsSiteGroupResetDialogTitle}
</div>
<div slot="body">
[[getFormatString_(
'$i18nPolymer{siteSettingsSiteGroupResetConfirmation}',
displayName_)]]
</div>
<div slot="button-container">
<paper-button class="cancel-button" on-click="onCloseDialog_">
$i18n{cancel}
</paper-button>
<paper-button class="action-button" on-click="onResetSettings_">
$i18n{siteSettingsSiteResetAll}
</paper-button>
</div>
</cr-dialog>
</template>
<script src="site_entry.js"></script>
</dom-module>
......@@ -17,25 +17,13 @@ Polymer({
* An object representing a group of sites with the same eTLD+1.
* @typedef {!SiteGroup}
*/
siteGroup: {
type: Object,
observer: 'onSiteGroupChanged_',
},
/**
* The name to display beside the icon. If grouped_() is true, it will be
* the eTLD+1 for all the origins, otherwise, it will match the origin more
* closely in an appropriate site representation.
* @typedef {!string}
* @private
*/
displayName_: String,
siteGroup: Object,
},
/**
* Whether the list of origins displayed in this site-entry is a group of
* eTLD+1 origins or not.
* @param {SiteGroup} siteGroup The eTLD+1 group of origins.
* @param {Array<Object>} siteGroup The eTLD+1 group of origins.
* @return {boolean}
* @private
*/
......@@ -44,20 +32,25 @@ Polymer({
},
/**
* @param {SiteGroup} siteGroup The eTLD+1 group of origins.
* The name to display beside the icon. If grouped_() is true, it will return
* the eTLD+1 for all the origins, otherwise, it will return the origin in an
* appropriate site representation.
* @param {Array<Object>} siteGroup The eTLD+1 group of origins.
* @return {string} The name to display.
* @private
*/
onSiteGroupChanged_: function(siteGroup) {
// TODO(https://crbug.com/835712): Present the origin in a user-friendly
// site representation when ungrouped.
this.displayName_ =
this.grouped_(siteGroup) ? siteGroup.etldPlus1 : siteGroup.origins[0];
displayName_: function(siteGroup) {
if (this.grouped_(siteGroup))
return siteGroup.etldPlus1;
// TODO(https://crbug.com/835712): Return the origin in a user-friendly site
// representation.
return siteGroup.origins[0];
},
/**
* Get an appropriate favicon that represents this group of eTLD+1 sites as a
* whole.
* @param {SiteGroup} siteGroup The eTLD+1 group of origins.
* @param {Array<Object>} siteGroup The eTLD+1 group of origins.
* @return {string} CSS to apply to show the appropriate favicon.
* @private
*/
......@@ -81,95 +74,28 @@ Polymer({
/**
* A handler for selecting a site (by clicking on the origin).
* @param {!{model: !{index: !number}}} e
* @param {!{model: !{index: !number}}} event
* @private
*/
onOriginTap_: function(e) {
this.navigateToSiteDetails_(this.siteGroup.origins[e.model.index]);
onOriginTap_: function(event) {
this.navigateToSiteDetails_(this.siteGroup.origins[event.model.index]);
},
/**
* Toggles open and closed the list of origins if there is more than one, and
* directly navigates to Site Details if there is only one site.
* @param {!Object} e
* @param {!Object} event
* @private
*/
toggleCollapsible_: function(e) {
toggleCollapsible_: function(event) {
// Individual origins don't expand - just go straight to Site Details.
if (!this.grouped_(this.siteGroup)) {
this.navigateToSiteDetails_(this.siteGroup.origins[0]);
return;
}
let collapseChild =
/** @type {IronCollapseElement} */ (this.$.collapseChild);
let collapseChild = this.$.collapseChild;
collapseChild.toggle();
this.$.toggleButton.setAttribute('aria-expanded', collapseChild.opened);
this.$.expandIcon.toggleClass('icon-expand-more');
this.$.expandIcon.toggleClass('icon-expand-less');
},
/**
* Retrieves the overflow menu.
* @private
*/
getOverflowMenu_: function() {
let menu = /** @type {?CrActionMenuElement} */ (this.$.menu.getIfExists());
if (!menu)
menu = /** @type {!CrActionMenuElement} */ (this.$.menu.get());
return menu;
},
/**
* Opens the overflow menu at event target.
* @param {!{target: Element}} e
* @private
*/
showOverflowMenu_: function(e) {
this.getOverflowMenu_().showAt(e.target);
},
/** @private */
onCloseDialog_: function(e) {
e.target.closest('cr-dialog').close();
this.getOverflowMenu_().close();
},
/**
* Confirms the resetting of all content settings for an origin.
* @param {!{target: !Element}} e
* @private
*/
onConfirmResetSettings_: function(e) {
e.preventDefault();
this.$.confirmResetSettings.showModal();
},
/**
* Resets all permissions for all origins listed in |siteGroup.origins|.
* @param {!Event} e
* @private
*/
onResetSettings_: function(e) {
const contentSettingsTypes = this.getCategoryList();
for (let i = 0; i < this.siteGroup.origins.length; ++i) {
const origin = this.siteGroup.origins[i];
this.browserProxy.setOriginPermissions(
origin, contentSettingsTypes, settings.ContentSetting.DEFAULT);
if (contentSettingsTypes.includes(settings.ContentSettingsTypes.PLUGINS))
this.browserProxy.clearFlashPref(origin);
}
this.onCloseDialog_(e);
},
/**
* Formats the |label| string with |name|, using $<num> as markers.
* @param {string} label
* @param {string} name
* @return {string}
* @private
*/
getFormatString_: function(label, name) {
return loadTimeData.substituteString(label, name);
},
});
......@@ -31,18 +31,6 @@ const SiteSettingsBehaviorImpl = {
*/
category: String,
/**
* A cached list of ContentSettingsTypes with a standard allow-block-ask
* pattern that are currently enabled for use. This property is the same
* across all elements with SiteSettingsBehavior ('static').
* @type {Array<settings.ContentSettingsTypes>}
* @private
*/
contentTypes_: {
type: Array,
value: [],
},
/**
* The browser proxy used to retrieve and change information about site
* settings categories and the sites within.
......@@ -110,6 +98,7 @@ const SiteSettingsBehaviorImpl = {
* Returns the icon to use for a given site.
* @param {string} site The url of the site to fetch the icon for.
* @return {string} The background-image style with the favicon.
* @private
*/
computeSiteIcon: function(site) {
site = this.removePatternWildcard(site);
......@@ -181,56 +170,6 @@ const SiteSettingsBehaviorImpl = {
};
},
/**
* Returns list of categories for each setting.ContentSettingsTypes that are
* currently enabled.
* @return {!Array<!settings.ContentSettingsTypes>}
*/
getCategoryList: function() {
if (this.contentTypes_.length == 0) {
/** @type {!Array<settings.ContentSettingsTypes>} */
for (let typeName in settings.ContentSettingsTypes) {
const contentType = settings.ContentSettingsTypes[typeName];
// <if expr="not chromeos">
if (contentType == settings.ContentSettingsTypes.PROTECTED_CONTENT)
continue;
// </if>
// Some categories store their data in a custom way.
if (contentType == settings.ContentSettingsTypes.COOKIES ||
contentType == settings.ContentSettingsTypes.PROTOCOL_HANDLERS ||
contentType == settings.ContentSettingsTypes.ZOOM_LEVELS) {
continue;
}
this.contentTypes_.push(contentType);
}
}
const addOrRemoveSettingWithFlag = (type, flag) => {
if (loadTimeData.getBoolean(flag)) {
if (!this.contentTypes_.includes(type))
this.contentTypes_.push(type);
} else {
if (this.contentTypes_.includes(type))
this.contentTypes_.splice(this.contentTypes_.indexOf(type), 1);
}
};
// These categories are gated behind flags.
addOrRemoveSettingWithFlag(
settings.ContentSettingsTypes.SENSORS, 'enableSensorsContentSetting');
addOrRemoveSettingWithFlag(
settings.ContentSettingsTypes.ADS,
'enableSafeBrowsingSubresourceFilter');
addOrRemoveSettingWithFlag(
settings.ContentSettingsTypes.SOUND, 'enableSoundContentSetting');
addOrRemoveSettingWithFlag(
settings.ContentSettingsTypes.CLIPBOARD,
'enableClipboardContentSetting');
addOrRemoveSettingWithFlag(
settings.ContentSettingsTypes.PAYMENT_HANDLER,
'enablePaymentHandlerContentSetting');
return this.contentTypes_.slice(0);
},
};
/** @polymerBehavior */
......
......@@ -2354,10 +2354,6 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_SITE_SETTINGS_SITE_CLEAR_STORAGE_CONFIRMATION},
{"siteSettingsSiteClearStorageDialogTitle",
IDS_SETTINGS_SITE_SETTINGS_SITE_CLEAR_STORAGE_DIALOG_TITLE},
{"siteSettingsSiteGroupResetDialogTitle",
IDS_SETTINGS_SITE_SETTINGS_SITE_GROUP_RESET_DIALOG_TITLE},
{"siteSettingsSiteGroupResetConfirmation",
IDS_SETTINGS_SITE_SETTINGS_SITE_GROUP_RESET_CONFIRMATION},
{"siteSettingsSiteResetAll", IDS_SETTINGS_SITE_SETTINGS_SITE_RESET_ALL},
{"siteSettingsSiteResetConfirmation",
IDS_SETTINGS_SITE_SETTINGS_SITE_RESET_CONFIRMATION},
......
......@@ -974,9 +974,7 @@ CrSettingsSiteEntryTest.prototype = {
/** @override */
extraLibraries: CrSettingsBrowserTest.prototype.extraLibraries.concat([
'../test_browser_proxy.js',
'test_util.js',
'test_site_settings_prefs_browser_proxy.js',
'site_entry_tests.js',
]),
};
......
......@@ -244,7 +244,6 @@ suite('SiteDetailsPermission', function() {
test('info string correct for drm disabled source', function() {
const origin = 'https://www.example.com';
testElement.category = settings.ContentSettingsTypes.PROTECTED_CONTENT;
testElement.$.details.hidden = false;
testElement.site = {
origin: origin,
embeddingOrigin: origin,
......
......@@ -158,7 +158,7 @@ suite('SiteDetails', function() {
loadTimeData.overrideValues(loadTimeDataOverride);
testElement = createSiteDetails('https://foo.com:443');
assertEquals(
numContentSettings + 1, testElement.getCategoryList().length);
numContentSettings + 1, testElement.getCategoryList_().length);
// Check for setting = off at the end to ensure that the setting does
// not carry over for the next iteration.
......@@ -166,7 +166,7 @@ suite('SiteDetails', function() {
[optionalSiteDetailsContentSettingsTypes[contentSetting]] = false;
loadTimeData.overrideValues(loadTimeDataOverride);
testElement = createSiteDetails('https://foo.com:443');
assertEquals(numContentSettings, testElement.getCategoryList().length);
assertEquals(numContentSettings, testElement.getCategoryList_().length);
}
});
......@@ -319,7 +319,7 @@ suite('SiteDetails', function() {
// Accepting the dialog will make a call to setOriginPermissions.
return browserProxy.whenCalled('setOriginPermissions').then((args) => {
assertEquals(testElement.origin, args[0]);
assertDeepEquals(testElement.getCategoryList(), args[1]);
assertDeepEquals(testElement.getCategoryList_(), args[1]);
assertEquals(settings.ContentSetting.DEFAULT, args[2]);
});
});
......
......@@ -21,12 +21,6 @@ suite('SiteEntry', function() {
'https://login.foo.com',
]);
/**
* The mock proxy object to use during test.
* @type {TestSiteSettingsPrefsBrowserProxy}
*/
let browserProxy;
/**
* A site list element created before each test.
* @type {SiteList}
......@@ -41,9 +35,6 @@ suite('SiteEntry', function() {
// Initialize a site-list before each test.
setup(function() {
browserProxy = new TestSiteSettingsPrefsBrowserProxy();
settings.SiteSettingsPrefsBrowserProxyImpl.instance_ = browserProxy;
PolymerTest.clearBody();
testElement = document.createElement('site-entry');
assertTrue(!!testElement);
......@@ -115,49 +106,4 @@ suite('SiteEntry', function() {
TEST_MULTIPLE_SITE_GROUP.origins[1],
settings.getQueryParameters().get('site'));
});
test('with single origin does not show overflow menu', function() {
testElement.siteGroup = TEST_SINGLE_SITE_GROUP;
Polymer.dom.flush();
const overflowMenuButton = testElement.$.overflowMenuButton;
assertTrue(overflowMenuButton.closest('.row-aligned').hidden);
});
test(
'with multiple origins can reset settings via overflow menu', function() {
testElement.siteGroup = TEST_MULTIPLE_SITE_GROUP;
Polymer.dom.flush();
const overflowMenuButton = testElement.$.overflowMenuButton;
assertFalse(overflowMenuButton.closest('.row-aligned').hidden);
// Open the reset settings dialog and make sure both cancelling the
// action and resetting all permissions work.
const overflowMenu = testElement.$.menu.get();
const menuItems = overflowMenu.querySelectorAll('.dropdown-item');
['cancel-button', 'action-button'].forEach(buttonType => {
// Test clicking on the overflow menu button opens the menu.
assertFalse(overflowMenu.open);
overflowMenuButton.click();
assertTrue(overflowMenu.open);
// Open the reset settings dialog and tap the |buttonType| button.
assertFalse(testElement.$.confirmResetSettings.open);
menuItems[0].click();
assertTrue(testElement.$.confirmResetSettings.open);
const actionButtonList =
testElement.$.confirmResetSettings.getElementsByClassName(
buttonType);
assertEquals(1, actionButtonList.length);
actionButtonList[0].click();
// Check the dialog and overflow menu are now both closed.
assertFalse(testElement.$.confirmResetSettings.open);
assertFalse(overflowMenu.open);
});
// Ensure a call was made to setOriginPermissions for each origin.
assertEquals(
TEST_MULTIPLE_SITE_GROUP.origins.length,
browserProxy.getCallCount('setOriginPermissions'));
});
});
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