| 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.PrivacyPageBrowserProxy} | 9 * @implements {settings.PrivacyPageBrowserProxy} |
| 10 */ | 10 */ |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 TestClearBrowsingDataBrowserProxy.prototype = { | 44 TestClearBrowsingDataBrowserProxy.prototype = { |
| 45 __proto__: settings.TestBrowserProxy.prototype, | 45 __proto__: settings.TestBrowserProxy.prototype, |
| 46 | 46 |
| 47 /** @param {!Promise} promise */ | 47 /** @param {!Promise} promise */ |
| 48 setClearBrowsingDataPromise: function(promise) { | 48 setClearBrowsingDataPromise: function(promise) { |
| 49 this.clearBrowsingDataPromise_ = promise; | 49 this.clearBrowsingDataPromise_ = promise; |
| 50 }, | 50 }, |
| 51 | 51 |
| 52 /** @override */ | 52 /** @override */ |
| 53 clearBrowsingData: function() { | 53 clearBrowsingData: function() { |
| 54 cr.webUIListenerCallback('browsing-data-removing', true); |
| 54 this.methodCalled('clearBrowsingData'); | 55 this.methodCalled('clearBrowsingData'); |
| 55 return this.clearBrowsingDataPromise_ !== null ? | 56 return this.clearBrowsingDataPromise_ !== null ? |
| 56 this.clearBrowsingDataPromise_ : Promise.resolve(); | 57 this.clearBrowsingDataPromise_ : Promise.resolve(); |
| 57 }, | 58 }, |
| 58 | 59 |
| 59 /** @override */ | 60 /** @override */ |
| 60 initialize: function() { | 61 initialize: function() { |
| 62 cr.webUIListenerCallback('browsing-data-removing', false); |
| 61 this.methodCalled('initialize'); | 63 this.methodCalled('initialize'); |
| 64 return Promise.resolve(); |
| 62 }, | 65 }, |
| 63 }; | 66 }; |
| 64 | 67 |
| 65 function registerNativeCertificateManagerTests() { | 68 function registerNativeCertificateManagerTests() { |
| 66 suite('NativeCertificateManager', function() { | 69 suite('NativeCertificateManager', function() { |
| 67 /** @type {settings.TestPrivacyPageBrowserProxy} */ | 70 /** @type {settings.TestPrivacyPageBrowserProxy} */ |
| 68 var testBrowserProxy; | 71 var testBrowserProxy; |
| 69 | 72 |
| 70 /** @type {SettingsPrivacyPageElement} */ | 73 /** @type {SettingsPrivacyPageElement} */ |
| 71 var page; | 74 var page; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 98 | 101 |
| 99 /** @type {SettingsClearBrowsingDataDialogElement} */ | 102 /** @type {SettingsClearBrowsingDataDialogElement} */ |
| 100 var element; | 103 var element; |
| 101 | 104 |
| 102 setup(function() { | 105 setup(function() { |
| 103 testBrowserProxy = new TestClearBrowsingDataBrowserProxy(); | 106 testBrowserProxy = new TestClearBrowsingDataBrowserProxy(); |
| 104 settings.ClearBrowsingDataBrowserProxyImpl.instance_ = testBrowserProxy; | 107 settings.ClearBrowsingDataBrowserProxyImpl.instance_ = testBrowserProxy; |
| 105 PolymerTest.clearBody(); | 108 PolymerTest.clearBody(); |
| 106 element = document.createElement('settings-clear-browsing-data-dialog'); | 109 element = document.createElement('settings-clear-browsing-data-dialog'); |
| 107 document.body.appendChild(element); | 110 document.body.appendChild(element); |
| 111 return testBrowserProxy.whenCalled('initialize'); |
| 108 }); | 112 }); |
| 109 | 113 |
| 110 teardown(function() { element.remove(); }); | 114 teardown(function() { element.remove(); }); |
| 111 | 115 |
| 112 test('ClearBrowsingDataTap', function() { | 116 test('ClearBrowsingDataTap', function() { |
| 113 assertTrue(element.$.dialog.opened); | 117 assertTrue(element.$.dialog.opened); |
| 114 | 118 |
| 115 var cancelButton = element.$$('.cancel-button'); | 119 var cancelButton = element.$$('.cancel-button'); |
| 116 assertTrue(!!cancelButton); | 120 assertTrue(!!cancelButton); |
| 117 var actionButton = element.$$('.action-button'); | 121 var actionButton = element.$$('.action-button'); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 129 | 133 |
| 130 return testBrowserProxy.whenCalled('clearBrowsingData').then( | 134 return testBrowserProxy.whenCalled('clearBrowsingData').then( |
| 131 function() { | 135 function() { |
| 132 assertTrue(element.$.dialog.opened); | 136 assertTrue(element.$.dialog.opened); |
| 133 assertTrue(cancelButton.disabled); | 137 assertTrue(cancelButton.disabled); |
| 134 assertTrue(actionButton.disabled); | 138 assertTrue(actionButton.disabled); |
| 135 assertTrue(spinner.active); | 139 assertTrue(spinner.active); |
| 136 | 140 |
| 137 // Simulate signal from browser indicating that clearing has | 141 // Simulate signal from browser indicating that clearing has |
| 138 // completed. | 142 // completed. |
| 143 cr.webUIListenerCallback('browsing-data-removing', false); |
| 139 promiseResolver.resolve(); | 144 promiseResolver.resolve(); |
| 140 // Yields to the message loop to allow the callback chain of the | 145 // Yields to the message loop to allow the callback chain of the |
| 141 // Promise that was just resolved to execute before the | 146 // Promise that was just resolved to execute before the |
| 142 // assertions. | 147 // assertions. |
| 143 }).then(function() { | 148 }).then(function() { |
| 144 assertFalse(element.$.dialog.opened); | 149 assertFalse(element.$.dialog.opened); |
| 145 assertFalse(cancelButton.disabled); | 150 assertFalse(cancelButton.disabled); |
| 146 assertFalse(actionButton.disabled); | 151 assertFalse(actionButton.disabled); |
| 147 assertFalse(spinner.active); | 152 assertFalse(spinner.active); |
| 148 assertFalse(!!element.$$('#notice')); | 153 assertFalse(!!element.$$('#notice')); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 232 |
| 228 return { | 233 return { |
| 229 registerTests: function() { | 234 registerTests: function() { |
| 230 if (cr.isMac || cr.isWin) | 235 if (cr.isMac || cr.isWin) |
| 231 registerNativeCertificateManagerTests(); | 236 registerNativeCertificateManagerTests(); |
| 232 | 237 |
| 233 registerClearBrowsingDataTests(); | 238 registerClearBrowsingDataTests(); |
| 234 }, | 239 }, |
| 235 }; | 240 }; |
| 236 }); | 241 }); |
| OLD | NEW |