Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3894)

Unified Diff: chrome/test/data/webui/settings/privacy_page_test.js

Issue 2716333002: Implement important sites dialog for desktop. (Closed)
Patch Set: change element.$.someId to element.$$(#someId) Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/chrome_features.cc ('k') | ui/webui/resources/cr_elements/cr_dialog/cr_dialog.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 01be42c02ee239116813900ab42517ed646967e1..50bd74907d577eb8a79c0978b97c54c1fdcbbaf8 100644
--- a/chrome/test/data/webui/settings/privacy_page_test.js
+++ b/chrome/test/data/webui/settings/privacy_page_test.js
@@ -9,10 +9,8 @@ cr.define('settings_privacy_page', function() {
* @implements {settings.ClearBrowsingDataBrowserProxy}
*/
function TestClearBrowsingDataBrowserProxy() {
- settings.TestBrowserProxy.call(this, [
- 'initialize',
- 'clearBrowsingData',
- ]);
+ settings.TestBrowserProxy.call(
+ this, ['initialize', 'clearBrowsingData', 'getImportantSites']);
/**
* The promise to return from |clearBrowsingData|.
@@ -21,6 +19,12 @@ cr.define('settings_privacy_page', function() {
* @private {?Promise}
*/
this.clearBrowsingDataPromise_ = null;
+
+ /**
+ * Response for |getImportantSites|.
+ * @private {!Array<!ImportantSite>}
+ */
+ this.importantSites_ = [];
}
TestClearBrowsingDataBrowserProxy.prototype = {
@@ -32,13 +36,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 {!Array<!ImportantSite>} sites */
+ setImportantSites: function(sites) {
+ this.importantSites_ = sites;
+ },
+
+ /** @override */
+ getImportantSites: function() {
+ this.methodCalled('getImportantSites');
+ return Promise.resolve(this.importantSites_);
+ },
+
/** @override */
initialize: function() {
this.methodCalled('initialize');
@@ -65,7 +80,7 @@ cr.define('settings_privacy_page', function() {
teardown(function() { page.remove(); });
test('NativeCertificateManager', function() {
- MockInteractions.tap(page.$.manageCertificates);
+ MockInteractions.tap(page.$$('#manageCertificates'));
return testBrowserProxy.whenCalled('showManageSSLCertificates');
});
});
@@ -85,7 +100,7 @@ cr.define('settings_privacy_page', function() {
test('showClearBrowsingDataDialog', function() {
assertFalse(!!page.$$('settings-clear-browsing-data-dialog'));
- MockInteractions.tap(page.$.clearBrowsingData);
+ MockInteractions.tap(page.$$('#clearBrowsingData'));
Polymer.dom.flush();
var dialog = page.$$('settings-clear-browsing-data-dialog');
@@ -94,7 +109,8 @@ cr.define('settings_privacy_page', function() {
// Ensure that the dialog is fully opened before returning from this
// test, otherwise asynchronous code run in attached() can cause flaky
// errors.
- return test_util.whenAttributeIs(dialog.$.dialog, 'open', '');
+ return test_util.whenAttributeIs(
+ dialog.$$('#clearBrowsingDataDialog'), 'open', '');
});
});
}
@@ -119,7 +135,8 @@ cr.define('settings_privacy_page', function() {
teardown(function() { element.remove(); });
test('ClearBrowsingDataTap', function() {
- assertTrue(element.$.dialog.open);
+ assertTrue(element.$$('#clearBrowsingDataDialog').open);
+ assertFalse(element.showImportantSitesDialog_);
var cancelButton = element.$$('.cancel-button');
assertTrue(!!cancelButton);
@@ -136,12 +153,13 @@ cr.define('settings_privacy_page', function() {
testBrowserProxy.setClearBrowsingDataPromise(promiseResolver.promise);
MockInteractions.tap(actionButton);
- return testBrowserProxy.whenCalled('clearBrowsingData').then(
- function() {
- assertTrue(element.$.dialog.open);
+ return testBrowserProxy.whenCalled('clearBrowsingData')
+ .then(function(importantSites) {
+ assertTrue(element.$$('#clearBrowsingDataDialog').open);
assertTrue(cancelButton.disabled);
assertTrue(actionButton.disabled);
assertTrue(spinner.active);
+ assertTrue(importantSites.length == 0);
// Simulate signal from browser indicating that clearing has
// completed.
@@ -150,17 +168,20 @@ cr.define('settings_privacy_page', function() {
// Yields to the message loop to allow the callback chain of the
// Promise that was just resolved to execute before the
// assertions.
- }).then(function() {
- assertFalse(element.$.dialog.open);
+ })
+ .then(function() {
+ assertFalse(element.$$('#clearBrowsingDataDialog').open);
assertFalse(cancelButton.disabled);
assertFalse(actionButton.disabled);
assertFalse(spinner.active);
assertFalse(!!element.$$('#notice'));
+ // Check that the dialog didn't switch to important sites.
+ assertFalse(element.showImportantSitesDialog_);
});
});
test('showHistoryDeletionDialog', function() {
- assertTrue(element.$.dialog.open);
+ assertTrue(element.$$('#clearBrowsingDataDialog').open);
var actionButton = element.$$('.action-button');
assertTrue(!!actionButton);
@@ -184,8 +205,8 @@ cr.define('settings_privacy_page', function() {
var noticeActionButton = notice.$$('.action-button');
assertTrue(!!noticeActionButton);
- assertTrue(element.$.dialog.open);
- assertTrue(notice.$.dialog.open);
+ assertTrue(element.$$('#clearBrowsingDataDialog').open);
+ assertTrue(notice.$$('#dialog').open);
MockInteractions.tap(noticeActionButton);
@@ -197,7 +218,7 @@ cr.define('settings_privacy_page', function() {
setTimeout(function() {
var notice = element.$$('#notice');
assertFalse(!!notice);
- assertFalse(element.$.dialog.open);
+ assertFalse(element.$$('#clearBrowsingDataDialog').open);
resolve();
}, 0);
});
@@ -205,7 +226,7 @@ cr.define('settings_privacy_page', function() {
});
test('Counters', function() {
- assertTrue(element.$.dialog.open);
+ assertTrue(element.$$('#clearBrowsingDataDialog').open);
// Initialize the browsing history pref, which should belong to the
// first checkbox in the dialog.
@@ -232,8 +253,8 @@ cr.define('settings_privacy_page', function() {
test('history rows are hidden for supervised users', function() {
assertFalse(loadTimeData.getBoolean('isSupervised'));
- assertFalse(element.$.browsingCheckbox.hidden);
- assertFalse(element.$.downloadCheckbox.hidden);
+ assertFalse(element.$$('#browsingCheckbox').hidden);
+ assertFalse(element.$$('#downloadCheckbox').hidden);
element.remove();
testBrowserProxy.reset();
@@ -244,13 +265,78 @@ cr.define('settings_privacy_page', function() {
Polymer.dom.flush();
return testBrowserProxy.whenCalled('initialize').then(function() {
- assertTrue(element.$.browsingCheckbox.hidden);
- assertTrue(element.$.downloadCheckbox.hidden);
+ assertTrue(element.$$('#browsingCheckbox').hidden);
+ assertTrue(element.$$('#downloadCheckbox').hidden);
});
});
});
}
+ 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() {
+ loadTimeData.overrideValues({importantSitesInCbd: true});
+ testBrowserProxy = new TestClearBrowsingDataBrowserProxy();
+ testBrowserProxy.setImportantSites(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('getImportantSites');
+ });
+ });
+
+ teardown(function() {
+ element.remove();
+ });
+
+ test('getImportantSites', function() {
+ assertTrue(element.$$('#clearBrowsingDataDialog').open);
+ assertFalse(element.showImportantSitesDialog_);
+ // Select an entry that can have important storage.
+ element.$$('#cookiesCheckbox').checked = true;
+ // Clear browsing data.
+ MockInteractions.tap(element.$$('#clearBrowsingDataConfirm'));
+ Polymer.dom.flush();
+ assertFalse(element.$$('#clearBrowsingDataDialog').open);
+ assertTrue(element.showImportantSitesDialog_);
+ return new Promise(function(resolve) { element.async(resolve); })
+ .then(function() {
+ assertTrue(element.$$('#importantSitesDialog').open);
+ 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(element.$$('#importantSitesConfirm'));
+ 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} */
@@ -274,7 +360,7 @@ cr.define('settings_privacy_page', function() {
Polymer.dom.flush();
// Control starts checked by default
- var control = page.$.safeBrowsingExtendedReportingControl;
+ var control = page.$$('#safeBrowsingExtendedReportingControl');
assertEquals(true, control.checked);
// Notification from browser can uncheck the box
« no previous file with comments | « chrome/common/chrome_features.cc ('k') | ui/webui/resources/cr_elements/cr_dialog/cr_dialog.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698