| Index: chrome/test/data/webui/settings/privacy_page_test.js
|
| diff --git a/chrome/test/data/webui/settings/privacy_page_test.js b/chrome/test/data/webui/settings/privacy_page_test.js
|
| index 0488099c61caf12b4cc1e8dd97dfd7fcc128c55a..7acbb70855e3b668652d09a74d05459c45801c70 100644
|
| --- a/chrome/test/data/webui/settings/privacy_page_test.js
|
| +++ b/chrome/test/data/webui/settings/privacy_page_test.js
|
| @@ -12,6 +12,7 @@ cr.define('settings_privacy_page', function() {
|
| settings.TestBrowserProxy.call(this, [
|
| 'initialize',
|
| 'clearBrowsingData',
|
| + 'fetchImportantSites'
|
| ]);
|
|
|
| /**
|
| @@ -21,6 +22,16 @@ cr.define('settings_privacy_page', function() {
|
| * @private {?Promise}
|
| */
|
| this.clearBrowsingDataPromise_ = null;
|
| +
|
| + /**
|
| + * Default response for fetchImportantSites. It tells the ui that important
|
| + * sites are disabled.
|
| + * @private {!ImportantSitesResponse}
|
| + */
|
| + this.importantSitesResponse_ = {
|
| + dialogDisabled: true,
|
| + importantSites: [{registerableDomain: "test.com", isChecked: true}]
|
| + };
|
| }
|
|
|
| TestClearBrowsingDataBrowserProxy.prototype = {
|
| @@ -32,13 +43,24 @@ cr.define('settings_privacy_page', function() {
|
| },
|
|
|
| /** @override */
|
| - clearBrowsingData: function() {
|
| - this.methodCalled('clearBrowsingData');
|
| + clearBrowsingData: function(importantSites) {
|
| + this.methodCalled('clearBrowsingData', importantSites);
|
| cr.webUIListenerCallback('browsing-data-removing', true);
|
| return this.clearBrowsingDataPromise_ !== null ?
|
| this.clearBrowsingDataPromise_ : Promise.resolve();
|
| },
|
|
|
| + /** @param {!ImportantSitesResponse} response */
|
| + setImportantSitesResponse: function(response) {
|
| + this.importantSitesResponse_ = response;
|
| + },
|
| +
|
| + /** @override */
|
| + fetchImportantSites: function() {
|
| + this.methodCalled('fetchImportantSites');
|
| + return Promise.resolve(this.importantSitesResponse_);
|
| + },
|
| +
|
| /** @override */
|
| initialize: function() {
|
| this.methodCalled('initialize');
|
| @@ -113,13 +135,17 @@ cr.define('settings_privacy_page', function() {
|
| PolymerTest.clearBody();
|
| element = document.createElement('settings-clear-browsing-data-dialog');
|
| document.body.appendChild(element);
|
| - return testBrowserProxy.whenCalled('initialize');
|
| + return testBrowserProxy.whenCalled('initialize').then(function() {
|
| + return testBrowserProxy.whenCalled('fetchImportantSites');
|
| + });
|
| });
|
|
|
| teardown(function() { element.remove(); });
|
|
|
| test('ClearBrowsingDataTap', function() {
|
| assertTrue(element.$.dialog.open);
|
| + assertTrue(element.importantSitesDialogDisabled_);
|
| + assertEquals(element.dialogState_, "clearBrowsingData");
|
|
|
| var cancelButton = element.$$('.cancel-button');
|
| assertTrue(!!cancelButton);
|
| @@ -137,11 +163,12 @@ cr.define('settings_privacy_page', function() {
|
| MockInteractions.tap(actionButton);
|
|
|
| return testBrowserProxy.whenCalled('clearBrowsingData').then(
|
| - function() {
|
| + function(importantSites) {
|
| assertTrue(element.$.dialog.open);
|
| assertTrue(cancelButton.disabled);
|
| assertTrue(actionButton.disabled);
|
| assertTrue(spinner.active);
|
| + assertTrue(importantSites.length == 0);
|
|
|
| // Simulate signal from browser indicating that clearing has
|
| // completed.
|
| @@ -156,6 +183,8 @@ cr.define('settings_privacy_page', function() {
|
| assertFalse(actionButton.disabled);
|
| assertFalse(spinner.active);
|
| assertFalse(!!element.$$('#notice'));
|
| + // Check that the dialog didn't switch to important sites.
|
| + assertEquals(element.dialogState_, "clearBrowsingData");
|
| });
|
| });
|
|
|
| @@ -232,6 +261,66 @@ cr.define('settings_privacy_page', function() {
|
| });
|
| }
|
|
|
| + suite('ImportantSites', function() {
|
| + /** @type {settings.TestClearBrowsingDataBrowserProxy} */
|
| + var testBrowserProxy;
|
| +
|
| + /** @type {SettingsClearBrowsingDataDialogElement} */
|
| + var element;
|
| +
|
| + /** @type {Array<ImportantSite>} */
|
| + var importantSites = [{registerableDomain: "google.com",isChecked: true},
|
| + {registerableDomain: "yahoo.com",isChecked: true}]
|
| +
|
| + setup(function() {
|
| + testBrowserProxy = new TestClearBrowsingDataBrowserProxy();
|
| + testBrowserProxy.setImportantSitesResponse({
|
| + dialogDisabled: false,
|
| + importantSites: importantSites,
|
| + });
|
| + settings.ClearBrowsingDataBrowserProxyImpl.instance_ = testBrowserProxy;
|
| + PolymerTest.clearBody();
|
| + element = document.createElement('settings-clear-browsing-data-dialog');
|
| + document.body.appendChild(element);
|
| + return testBrowserProxy.whenCalled('initialize').then(function() {
|
| + return testBrowserProxy.whenCalled('fetchImportantSites');
|
| + });
|
| + });
|
| +
|
| + teardown(function() { element.remove(); });
|
| +
|
| + test('fetchImportantSites', function() {
|
| + assertTrue(element.$.dialog.open);
|
| + assertEquals(element.dialogState_, "clearBrowsingData");
|
| + // Select an entry that can have important storage.
|
| + element.$.cookiesCheckbox.checked = true;
|
| + var actionButton = element.$$('.action-button');
|
| + assertTrue(!!actionButton);
|
| + // Clear browsing data.
|
| + MockInteractions.tap(actionButton);
|
| + assertEquals(element.dialogState_, "importantSites");
|
| +
|
| + Polymer.dom.flush();
|
| + var firstImportantSite = element.$$("important-site-checkbox")
|
| + assertTrue(!!firstImportantSite);
|
| + assertEquals(firstImportantSite.site.registerableDomain, "google.com");
|
| + assertTrue(firstImportantSite.site.isChecked)
|
| + // Choose to keep storage for google.com.
|
| + MockInteractions.tap(firstImportantSite.$.checkbox);
|
| + assertFalse(firstImportantSite.site.isChecked)
|
| + // Confirm deletion.
|
| + MockInteractions.tap(actionButton);
|
| + return testBrowserProxy.whenCalled('clearBrowsingData').then(
|
| + function(sites) {
|
| + assertEquals(sites.length, 2);
|
| + assertEquals(sites[0].registerableDomain, "google.com");
|
| + assertFalse(sites[0].isChecked);
|
| + assertEquals(sites[1].registerableDomain, "yahoo.com");
|
| + assertTrue(sites[1].isChecked);
|
| + });
|
| + });
|
| + });
|
| +
|
| function registerSafeBrowsingExtendedReportingTests() {
|
| suite('SafeBrowsingExtendedReporting', function() {
|
| /** @type {settings.TestPrivacyPageBrowserProxy} */
|
|
|