Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 cr.define('settings_privacy_page', function() { | 5 cr.define('settings_privacy_page', function() { |
| 6 /** | 6 /** |
| 7 * @constructor | 7 * @constructor |
| 8 * @extends {TestBrowserProxy} | 8 * @extends {TestBrowserProxy} |
| 9 * @implements {settings.ClearBrowsingDataBrowserProxy} | 9 * @implements {settings.ClearBrowsingDataBrowserProxy} |
| 10 */ | 10 */ |
| 11 function TestClearBrowsingDataBrowserProxy() { | 11 function TestClearBrowsingDataBrowserProxy() { |
| 12 settings.TestBrowserProxy.call(this, [ | 12 settings.TestBrowserProxy.call(this, [ |
| 13 'initialize', | 13 'initialize', |
| 14 'clearBrowsingData', | 14 'clearBrowsingData', |
| 15 'shouldShowBrowsingHistoryRows', | |
| 15 ]); | 16 ]); |
| 16 | 17 |
| 17 /** | 18 /** |
| 18 * The promise to return from |clearBrowsingData|. | 19 * The promise to return from |clearBrowsingData|. |
| 19 * Allows testing code to test what happens after the call is made, and | 20 * Allows testing code to test what happens after the call is made, and |
| 20 * before the browser responds. | 21 * before the browser responds. |
| 21 * @private {?Promise} | 22 * @private {?Promise} |
| 22 */ | 23 */ |
| 23 this.clearBrowsingDataPromise_ = null; | 24 this.clearBrowsingDataPromise_ = null; |
| 25 | |
| 26 /** @private */ | |
| 27 this.shouldShowBrowsingHistoryRows_ = true; | |
| 24 } | 28 } |
| 25 | 29 |
| 26 TestClearBrowsingDataBrowserProxy.prototype = { | 30 TestClearBrowsingDataBrowserProxy.prototype = { |
| 27 __proto__: settings.TestBrowserProxy.prototype, | 31 __proto__: settings.TestBrowserProxy.prototype, |
| 28 | 32 |
| 29 /** @param {!Promise} promise */ | 33 /** @param {!Promise} promise */ |
| 30 setClearBrowsingDataPromise: function(promise) { | 34 setClearBrowsingDataPromise: function(promise) { |
| 31 this.clearBrowsingDataPromise_ = promise; | 35 this.clearBrowsingDataPromise_ = promise; |
| 32 }, | 36 }, |
| 33 | 37 |
| 38 /** @param {boolean} shouldShow */ | |
| 39 setShouldShowBrowsingHistoryRows: function(shouldShow) { | |
| 40 this.shouldShowBrowsingHistoryRows_ = shouldShow; | |
| 41 }, | |
| 42 | |
| 34 /** @override */ | 43 /** @override */ |
| 35 clearBrowsingData: function() { | 44 clearBrowsingData: function() { |
| 36 this.methodCalled('clearBrowsingData'); | 45 this.methodCalled('clearBrowsingData'); |
| 37 cr.webUIListenerCallback('browsing-data-removing', true); | 46 cr.webUIListenerCallback('browsing-data-removing', true); |
| 38 return this.clearBrowsingDataPromise_ !== null ? | 47 return this.clearBrowsingDataPromise_ !== null ? |
| 39 this.clearBrowsingDataPromise_ : Promise.resolve(); | 48 this.clearBrowsingDataPromise_ : Promise.resolve(); |
| 40 }, | 49 }, |
| 41 | 50 |
| 42 /** @override */ | 51 /** @override */ |
| 43 initialize: function() { | 52 initialize: function() { |
| 44 this.methodCalled('initialize'); | 53 this.methodCalled('initialize'); |
| 45 return Promise.resolve(false); | 54 return Promise.resolve(false); |
| 46 }, | 55 }, |
| 56 | |
| 57 /** @override */ | |
| 58 shouldShowBrowsingHistoryRows: function() { | |
| 59 return this.shouldShowBrowsingHistoryRows_; | |
| 60 }, | |
| 47 }; | 61 }; |
| 48 | 62 |
| 49 function registerNativeCertificateManagerTests() { | 63 function registerNativeCertificateManagerTests() { |
| 50 suite('NativeCertificateManager', function() { | 64 suite('NativeCertificateManager', function() { |
| 51 /** @type {settings.TestPrivacyPageBrowserProxy} */ | 65 /** @type {settings.TestPrivacyPageBrowserProxy} */ |
| 52 var testBrowserProxy; | 66 var testBrowserProxy; |
| 53 | 67 |
| 54 /** @type {SettingsPrivacyPageElement} */ | 68 /** @type {SettingsPrivacyPageElement} */ |
| 55 var page; | 69 var page; |
| 56 | 70 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 }); | 236 }); |
| 223 var checkbox = element.$$('settings-checkbox'); | 237 var checkbox = element.$$('settings-checkbox'); |
| 224 assertEquals('browser.clear_data.browsing_history', checkbox.pref.key); | 238 assertEquals('browser.clear_data.browsing_history', checkbox.pref.key); |
| 225 | 239 |
| 226 // Simulate a browsing data counter result for history. This checkbox's | 240 // Simulate a browsing data counter result for history. This checkbox's |
| 227 // sublabel should be updated. | 241 // sublabel should be updated. |
| 228 cr.webUIListenerCallback( | 242 cr.webUIListenerCallback( |
| 229 'update-counter-text', checkbox.pref.key, 'result'); | 243 'update-counter-text', checkbox.pref.key, 'result'); |
| 230 assertEquals('result', checkbox.subLabel); | 244 assertEquals('result', checkbox.subLabel); |
| 231 }); | 245 }); |
| 246 | |
| 247 test('history rows are hidden for supervised users', function() { | |
| 248 assertTrue(!!element.$$('#browsingCheckbox')); | |
| 249 assertTrue(!!element.$$('#downloadCheckbox')); | |
| 250 | |
| 251 element.remove(); | |
| 252 testBrowserProxy.reset(); | |
| 253 testBrowserProxy.setShouldShowBrowsingHistoryRows(false); | |
| 254 | |
| 255 element = document.createElement('settings-clear-browsing-data-dialog'); | |
|
dpapad
2017/05/04 22:43:02
If we are going to recreate the element anyway, ju
Dan Beam
2017/05/04 23:21:28
Done. (thanks for reminding me about overrideValue
| |
| 256 document.body.appendChild(element); | |
| 257 Polymer.dom.flush(); | |
| 258 | |
| 259 return testBrowserProxy.whenCalled('initialize').then(function() { | |
| 260 assertFalse(!!element.$$('#browsingCheckbox')); | |
| 261 assertFalse(!!element.$$('#downloadCheckbox')); | |
| 262 }); | |
| 263 }); | |
| 232 }); | 264 }); |
| 233 } | 265 } |
| 234 | 266 |
| 235 function registerSafeBrowsingExtendedReportingTests() { | 267 function registerSafeBrowsingExtendedReportingTests() { |
| 236 suite('SafeBrowsingExtendedReporting', function() { | 268 suite('SafeBrowsingExtendedReporting', function() { |
| 237 /** @type {settings.TestPrivacyPageBrowserProxy} */ | 269 /** @type {settings.TestPrivacyPageBrowserProxy} */ |
| 238 var testBrowserProxy; | 270 var testBrowserProxy; |
| 239 | 271 |
| 240 /** @type {SettingsPrivacyPageElement} */ | 272 /** @type {SettingsPrivacyPageElement} */ |
| 241 var page; | 273 var page; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 277 registerTests: function() { | 309 registerTests: function() { |
| 278 if (cr.isMac || cr.isWin) | 310 if (cr.isMac || cr.isWin) |
| 279 registerNativeCertificateManagerTests(); | 311 registerNativeCertificateManagerTests(); |
| 280 | 312 |
| 281 registerClearBrowsingDataTests(); | 313 registerClearBrowsingDataTests(); |
| 282 registerPrivacyPageTests(); | 314 registerPrivacyPageTests(); |
| 283 registerSafeBrowsingExtendedReportingTests(); | 315 registerSafeBrowsingExtendedReportingTests(); |
| 284 }, | 316 }, |
| 285 }; | 317 }; |
| 286 }); | 318 }); |
| OLD | NEW |