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( |
13 'initialize', | 13 this, ['initialize', 'clearBrowsingData', 'getImportantSites']); |
14 'clearBrowsingData', | |
15 ]); | |
16 | 14 |
17 /** | 15 /** |
18 * The promise to return from |clearBrowsingData|. | 16 * The promise to return from |clearBrowsingData|. |
19 * Allows testing code to test what happens after the call is made, and | 17 * Allows testing code to test what happens after the call is made, and |
20 * before the browser responds. | 18 * before the browser responds. |
21 * @private {?Promise} | 19 * @private {?Promise} |
22 */ | 20 */ |
23 this.clearBrowsingDataPromise_ = null; | 21 this.clearBrowsingDataPromise_ = null; |
| 22 |
| 23 /** |
| 24 * Response for |getImportantSites|. |
| 25 * @private {!Array<!ImportantSite>} |
| 26 */ |
| 27 this.importantSites_ = []; |
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 |
34 /** @override */ | 38 /** @override */ |
35 clearBrowsingData: function() { | 39 clearBrowsingData: function(importantSites) { |
36 this.methodCalled('clearBrowsingData'); | 40 this.methodCalled('clearBrowsingData', importantSites); |
37 cr.webUIListenerCallback('browsing-data-removing', true); | 41 cr.webUIListenerCallback('browsing-data-removing', true); |
38 return this.clearBrowsingDataPromise_ !== null ? | 42 return this.clearBrowsingDataPromise_ !== null ? |
39 this.clearBrowsingDataPromise_ : Promise.resolve(); | 43 this.clearBrowsingDataPromise_ : Promise.resolve(); |
40 }, | 44 }, |
41 | 45 |
| 46 /** @param {!Array<!ImportantSite>} sites */ |
| 47 setImportantSites: function(sites) { |
| 48 this.importantSites_ = sites; |
| 49 }, |
| 50 |
| 51 /** @override */ |
| 52 getImportantSites: function() { |
| 53 this.methodCalled('getImportantSites'); |
| 54 return Promise.resolve(this.importantSites_); |
| 55 }, |
| 56 |
42 /** @override */ | 57 /** @override */ |
43 initialize: function() { | 58 initialize: function() { |
44 this.methodCalled('initialize'); | 59 this.methodCalled('initialize'); |
45 return Promise.resolve(false); | 60 return Promise.resolve(false); |
46 }, | 61 }, |
47 }; | 62 }; |
48 | 63 |
49 function registerNativeCertificateManagerTests() { | 64 function registerNativeCertificateManagerTests() { |
50 suite('NativeCertificateManager', function() { | 65 suite('NativeCertificateManager', function() { |
51 /** @type {settings.TestPrivacyPageBrowserProxy} */ | 66 /** @type {settings.TestPrivacyPageBrowserProxy} */ |
52 var testBrowserProxy; | 67 var testBrowserProxy; |
53 | 68 |
54 /** @type {SettingsPrivacyPageElement} */ | 69 /** @type {SettingsPrivacyPageElement} */ |
55 var page; | 70 var page; |
56 | 71 |
57 setup(function() { | 72 setup(function() { |
58 testBrowserProxy = new TestPrivacyPageBrowserProxy(); | 73 testBrowserProxy = new TestPrivacyPageBrowserProxy(); |
59 settings.PrivacyPageBrowserProxyImpl.instance_ = testBrowserProxy; | 74 settings.PrivacyPageBrowserProxyImpl.instance_ = testBrowserProxy; |
60 PolymerTest.clearBody(); | 75 PolymerTest.clearBody(); |
61 page = document.createElement('settings-privacy-page'); | 76 page = document.createElement('settings-privacy-page'); |
62 document.body.appendChild(page); | 77 document.body.appendChild(page); |
63 }); | 78 }); |
64 | 79 |
65 teardown(function() { page.remove(); }); | 80 teardown(function() { page.remove(); }); |
66 | 81 |
67 test('NativeCertificateManager', function() { | 82 test('NativeCertificateManager', function() { |
68 MockInteractions.tap(page.$.manageCertificates); | 83 MockInteractions.tap(page.$$('#manageCertificates')); |
69 return testBrowserProxy.whenCalled('showManageSSLCertificates'); | 84 return testBrowserProxy.whenCalled('showManageSSLCertificates'); |
70 }); | 85 }); |
71 }); | 86 }); |
72 } | 87 } |
73 | 88 |
74 function registerPrivacyPageTests() { | 89 function registerPrivacyPageTests() { |
75 suite('PrivacyPage', function() { | 90 suite('PrivacyPage', function() { |
76 /** @type {SettingsPrivacyPageElement} */ | 91 /** @type {SettingsPrivacyPageElement} */ |
77 var page; | 92 var page; |
78 | 93 |
79 setup(function() { | 94 setup(function() { |
80 page = document.createElement('settings-privacy-page'); | 95 page = document.createElement('settings-privacy-page'); |
81 document.body.appendChild(page); | 96 document.body.appendChild(page); |
82 }); | 97 }); |
83 | 98 |
84 teardown(function() { page.remove(); }); | 99 teardown(function() { page.remove(); }); |
85 | 100 |
86 test('showClearBrowsingDataDialog', function() { | 101 test('showClearBrowsingDataDialog', function() { |
87 assertFalse(!!page.$$('settings-clear-browsing-data-dialog')); | 102 assertFalse(!!page.$$('settings-clear-browsing-data-dialog')); |
88 MockInteractions.tap(page.$.clearBrowsingData); | 103 MockInteractions.tap(page.$$('#clearBrowsingData')); |
89 Polymer.dom.flush(); | 104 Polymer.dom.flush(); |
90 | 105 |
91 var dialog = page.$$('settings-clear-browsing-data-dialog'); | 106 var dialog = page.$$('settings-clear-browsing-data-dialog'); |
92 assertTrue(!!dialog); | 107 assertTrue(!!dialog); |
93 | 108 |
94 // Ensure that the dialog is fully opened before returning from this | 109 // Ensure that the dialog is fully opened before returning from this |
95 // test, otherwise asynchronous code run in attached() can cause flaky | 110 // test, otherwise asynchronous code run in attached() can cause flaky |
96 // errors. | 111 // errors. |
97 return test_util.whenAttributeIs(dialog.$.dialog, 'open', ''); | 112 return test_util.whenAttributeIs( |
| 113 dialog.$$('#clearBrowsingDataDialog'), 'open', ''); |
98 }); | 114 }); |
99 }); | 115 }); |
100 } | 116 } |
101 | 117 |
102 function registerClearBrowsingDataTests() { | 118 function registerClearBrowsingDataTests() { |
103 suite('ClearBrowsingData', function() { | 119 suite('ClearBrowsingData', function() { |
104 /** @type {settings.TestClearBrowsingDataBrowserProxy} */ | 120 /** @type {settings.TestClearBrowsingDataBrowserProxy} */ |
105 var testBrowserProxy; | 121 var testBrowserProxy; |
106 | 122 |
107 /** @type {SettingsClearBrowsingDataDialogElement} */ | 123 /** @type {SettingsClearBrowsingDataDialogElement} */ |
108 var element; | 124 var element; |
109 | 125 |
110 setup(function() { | 126 setup(function() { |
111 testBrowserProxy = new TestClearBrowsingDataBrowserProxy(); | 127 testBrowserProxy = new TestClearBrowsingDataBrowserProxy(); |
112 settings.ClearBrowsingDataBrowserProxyImpl.instance_ = testBrowserProxy; | 128 settings.ClearBrowsingDataBrowserProxyImpl.instance_ = testBrowserProxy; |
113 PolymerTest.clearBody(); | 129 PolymerTest.clearBody(); |
114 element = document.createElement('settings-clear-browsing-data-dialog'); | 130 element = document.createElement('settings-clear-browsing-data-dialog'); |
115 document.body.appendChild(element); | 131 document.body.appendChild(element); |
116 return testBrowserProxy.whenCalled('initialize'); | 132 return testBrowserProxy.whenCalled('initialize'); |
117 }); | 133 }); |
118 | 134 |
119 teardown(function() { element.remove(); }); | 135 teardown(function() { element.remove(); }); |
120 | 136 |
121 test('ClearBrowsingDataTap', function() { | 137 test('ClearBrowsingDataTap', function() { |
122 assertTrue(element.$.dialog.open); | 138 assertTrue(element.$$('#clearBrowsingDataDialog').open); |
| 139 assertFalse(element.showImportantSitesDialog_); |
123 | 140 |
124 var cancelButton = element.$$('.cancel-button'); | 141 var cancelButton = element.$$('.cancel-button'); |
125 assertTrue(!!cancelButton); | 142 assertTrue(!!cancelButton); |
126 var actionButton = element.$$('.action-button'); | 143 var actionButton = element.$$('.action-button'); |
127 assertTrue(!!actionButton); | 144 assertTrue(!!actionButton); |
128 var spinner = element.$$('paper-spinner'); | 145 var spinner = element.$$('paper-spinner'); |
129 assertTrue(!!spinner); | 146 assertTrue(!!spinner); |
130 | 147 |
131 assertFalse(cancelButton.disabled); | 148 assertFalse(cancelButton.disabled); |
132 assertFalse(actionButton.disabled); | 149 assertFalse(actionButton.disabled); |
133 assertFalse(spinner.active); | 150 assertFalse(spinner.active); |
134 | 151 |
135 var promiseResolver = new PromiseResolver(); | 152 var promiseResolver = new PromiseResolver(); |
136 testBrowserProxy.setClearBrowsingDataPromise(promiseResolver.promise); | 153 testBrowserProxy.setClearBrowsingDataPromise(promiseResolver.promise); |
137 MockInteractions.tap(actionButton); | 154 MockInteractions.tap(actionButton); |
138 | 155 |
139 return testBrowserProxy.whenCalled('clearBrowsingData').then( | 156 return testBrowserProxy.whenCalled('clearBrowsingData') |
140 function() { | 157 .then(function(importantSites) { |
141 assertTrue(element.$.dialog.open); | 158 assertTrue(element.$$('#clearBrowsingDataDialog').open); |
142 assertTrue(cancelButton.disabled); | 159 assertTrue(cancelButton.disabled); |
143 assertTrue(actionButton.disabled); | 160 assertTrue(actionButton.disabled); |
144 assertTrue(spinner.active); | 161 assertTrue(spinner.active); |
| 162 assertTrue(importantSites.length == 0); |
145 | 163 |
146 // Simulate signal from browser indicating that clearing has | 164 // Simulate signal from browser indicating that clearing has |
147 // completed. | 165 // completed. |
148 cr.webUIListenerCallback('browsing-data-removing', false); | 166 cr.webUIListenerCallback('browsing-data-removing', false); |
149 promiseResolver.resolve(); | 167 promiseResolver.resolve(); |
150 // Yields to the message loop to allow the callback chain of the | 168 // Yields to the message loop to allow the callback chain of the |
151 // Promise that was just resolved to execute before the | 169 // Promise that was just resolved to execute before the |
152 // assertions. | 170 // assertions. |
153 }).then(function() { | 171 }) |
154 assertFalse(element.$.dialog.open); | 172 .then(function() { |
| 173 assertFalse(element.$$('#clearBrowsingDataDialog').open); |
155 assertFalse(cancelButton.disabled); | 174 assertFalse(cancelButton.disabled); |
156 assertFalse(actionButton.disabled); | 175 assertFalse(actionButton.disabled); |
157 assertFalse(spinner.active); | 176 assertFalse(spinner.active); |
158 assertFalse(!!element.$$('#notice')); | 177 assertFalse(!!element.$$('#notice')); |
| 178 // Check that the dialog didn't switch to important sites. |
| 179 assertFalse(element.showImportantSitesDialog_); |
159 }); | 180 }); |
160 }); | 181 }); |
161 | 182 |
162 test('showHistoryDeletionDialog', function() { | 183 test('showHistoryDeletionDialog', function() { |
163 assertTrue(element.$.dialog.open); | 184 assertTrue(element.$$('#clearBrowsingDataDialog').open); |
164 var actionButton = element.$$('.action-button'); | 185 var actionButton = element.$$('.action-button'); |
165 assertTrue(!!actionButton); | 186 assertTrue(!!actionButton); |
166 | 187 |
167 var promiseResolver = new PromiseResolver(); | 188 var promiseResolver = new PromiseResolver(); |
168 testBrowserProxy.setClearBrowsingDataPromise(promiseResolver.promise); | 189 testBrowserProxy.setClearBrowsingDataPromise(promiseResolver.promise); |
169 MockInteractions.tap(actionButton); | 190 MockInteractions.tap(actionButton); |
170 | 191 |
171 return testBrowserProxy.whenCalled('clearBrowsingData').then( | 192 return testBrowserProxy.whenCalled('clearBrowsingData').then( |
172 function() { | 193 function() { |
173 // Passing showNotice = true should trigger the notice about other | 194 // Passing showNotice = true should trigger the notice about other |
174 // forms of browsing history to open, and the dialog to stay open. | 195 // forms of browsing history to open, and the dialog to stay open. |
175 promiseResolver.resolve(true /* showNotice */); | 196 promiseResolver.resolve(true /* showNotice */); |
176 | 197 |
177 // Yields to the message loop to allow the callback chain of the | 198 // Yields to the message loop to allow the callback chain of the |
178 // Promise that was just resolved to execute before the | 199 // Promise that was just resolved to execute before the |
179 // assertions. | 200 // assertions. |
180 }).then(function() { | 201 }).then(function() { |
181 Polymer.dom.flush(); | 202 Polymer.dom.flush(); |
182 var notice = element.$$('#notice'); | 203 var notice = element.$$('#notice'); |
183 assertTrue(!!notice); | 204 assertTrue(!!notice); |
184 var noticeActionButton = notice.$$('.action-button'); | 205 var noticeActionButton = notice.$$('.action-button'); |
185 assertTrue(!!noticeActionButton); | 206 assertTrue(!!noticeActionButton); |
186 | 207 |
187 assertTrue(element.$.dialog.open); | 208 assertTrue(element.$$('#clearBrowsingDataDialog').open); |
188 assertTrue(notice.$.dialog.open); | 209 assertTrue(notice.$$('#dialog').open); |
189 | 210 |
190 MockInteractions.tap(noticeActionButton); | 211 MockInteractions.tap(noticeActionButton); |
191 | 212 |
192 return new Promise(function(resolve, reject) { | 213 return new Promise(function(resolve, reject) { |
193 // Tapping the action button will close the notice. Move to the | 214 // Tapping the action button will close the notice. Move to the |
194 // end of the message loop to allow the closing event to | 215 // end of the message loop to allow the closing event to |
195 // propagate to the parent dialog. The parent dialog should | 216 // propagate to the parent dialog. The parent dialog should |
196 // subsequently close as well. | 217 // subsequently close as well. |
197 setTimeout(function() { | 218 setTimeout(function() { |
198 var notice = element.$$('#notice'); | 219 var notice = element.$$('#notice'); |
199 assertFalse(!!notice); | 220 assertFalse(!!notice); |
200 assertFalse(element.$.dialog.open); | 221 assertFalse(element.$$('#clearBrowsingDataDialog').open); |
201 resolve(); | 222 resolve(); |
202 }, 0); | 223 }, 0); |
203 }); | 224 }); |
204 }); | 225 }); |
205 }); | 226 }); |
206 | 227 |
207 test('Counters', function() { | 228 test('Counters', function() { |
208 assertTrue(element.$.dialog.open); | 229 assertTrue(element.$$('#clearBrowsingDataDialog').open); |
209 | 230 |
210 // Initialize the browsing history pref, which should belong to the | 231 // Initialize the browsing history pref, which should belong to the |
211 // first checkbox in the dialog. | 232 // first checkbox in the dialog. |
212 element.set('prefs', { | 233 element.set('prefs', { |
213 browser: { | 234 browser: { |
214 clear_data: { | 235 clear_data: { |
215 browsing_history: { | 236 browsing_history: { |
216 key: 'browser.clear_data.browsing_history', | 237 key: 'browser.clear_data.browsing_history', |
217 type: chrome.settingsPrivate.PrefType.BOOLEAN, | 238 type: chrome.settingsPrivate.PrefType.BOOLEAN, |
218 value: true, | 239 value: true, |
219 } | 240 } |
220 } | 241 } |
221 } | 242 } |
222 }); | 243 }); |
223 var checkbox = element.$$('settings-checkbox'); | 244 var checkbox = element.$$('settings-checkbox'); |
224 assertEquals('browser.clear_data.browsing_history', checkbox.pref.key); | 245 assertEquals('browser.clear_data.browsing_history', checkbox.pref.key); |
225 | 246 |
226 // Simulate a browsing data counter result for history. This checkbox's | 247 // Simulate a browsing data counter result for history. This checkbox's |
227 // sublabel should be updated. | 248 // sublabel should be updated. |
228 cr.webUIListenerCallback( | 249 cr.webUIListenerCallback( |
229 'update-counter-text', checkbox.pref.key, 'result'); | 250 'update-counter-text', checkbox.pref.key, 'result'); |
230 assertEquals('result', checkbox.subLabel); | 251 assertEquals('result', checkbox.subLabel); |
231 }); | 252 }); |
232 | 253 |
233 test('history rows are hidden for supervised users', function() { | 254 test('history rows are hidden for supervised users', function() { |
234 assertFalse(loadTimeData.getBoolean('isSupervised')); | 255 assertFalse(loadTimeData.getBoolean('isSupervised')); |
235 assertFalse(element.$.browsingCheckbox.hidden); | 256 assertFalse(element.$$('#browsingCheckbox').hidden); |
236 assertFalse(element.$.downloadCheckbox.hidden); | 257 assertFalse(element.$$('#downloadCheckbox').hidden); |
237 | 258 |
238 element.remove(); | 259 element.remove(); |
239 testBrowserProxy.reset(); | 260 testBrowserProxy.reset(); |
240 loadTimeData.overrideValues({isSupervised: true}); | 261 loadTimeData.overrideValues({isSupervised: true}); |
241 | 262 |
242 element = document.createElement('settings-clear-browsing-data-dialog'); | 263 element = document.createElement('settings-clear-browsing-data-dialog'); |
243 document.body.appendChild(element); | 264 document.body.appendChild(element); |
244 Polymer.dom.flush(); | 265 Polymer.dom.flush(); |
245 | 266 |
246 return testBrowserProxy.whenCalled('initialize').then(function() { | 267 return testBrowserProxy.whenCalled('initialize').then(function() { |
247 assertTrue(element.$.browsingCheckbox.hidden); | 268 assertTrue(element.$$('#browsingCheckbox').hidden); |
248 assertTrue(element.$.downloadCheckbox.hidden); | 269 assertTrue(element.$$('#downloadCheckbox').hidden); |
249 }); | 270 }); |
250 }); | 271 }); |
251 }); | 272 }); |
252 } | 273 } |
253 | 274 |
| 275 suite('ImportantSites', function() { |
| 276 /** @type {settings.TestClearBrowsingDataBrowserProxy} */ |
| 277 var testBrowserProxy; |
| 278 |
| 279 /** @type {SettingsClearBrowsingDataDialogElement} */ |
| 280 var element; |
| 281 |
| 282 /** @type {Array<ImportantSite>} */ |
| 283 var importantSites = [ |
| 284 {registerableDomain: 'google.com', isChecked: true}, |
| 285 {registerableDomain: 'yahoo.com', isChecked: true} |
| 286 ]; |
| 287 |
| 288 setup(function() { |
| 289 loadTimeData.overrideValues({importantSitesInCbd: true}); |
| 290 testBrowserProxy = new TestClearBrowsingDataBrowserProxy(); |
| 291 testBrowserProxy.setImportantSites(importantSites); |
| 292 settings.ClearBrowsingDataBrowserProxyImpl.instance_ = testBrowserProxy; |
| 293 PolymerTest.clearBody(); |
| 294 element = document.createElement('settings-clear-browsing-data-dialog'); |
| 295 document.body.appendChild(element); |
| 296 return testBrowserProxy.whenCalled('initialize').then(function() { |
| 297 return testBrowserProxy.whenCalled('getImportantSites'); |
| 298 }); |
| 299 }); |
| 300 |
| 301 teardown(function() { |
| 302 element.remove(); |
| 303 }); |
| 304 |
| 305 test('getImportantSites', function() { |
| 306 assertTrue(element.$$('#clearBrowsingDataDialog').open); |
| 307 assertFalse(element.showImportantSitesDialog_); |
| 308 // Select an entry that can have important storage. |
| 309 element.$$('#cookiesCheckbox').checked = true; |
| 310 // Clear browsing data. |
| 311 MockInteractions.tap(element.$$('#clearBrowsingDataConfirm')); |
| 312 Polymer.dom.flush(); |
| 313 assertFalse(element.$$('#clearBrowsingDataDialog').open); |
| 314 assertTrue(element.showImportantSitesDialog_); |
| 315 return new Promise(function(resolve) { element.async(resolve); }) |
| 316 .then(function() { |
| 317 assertTrue(element.$$('#importantSitesDialog').open); |
| 318 var firstImportantSite = element.$$('important-site-checkbox') |
| 319 assertTrue(!!firstImportantSite); |
| 320 assertEquals( |
| 321 firstImportantSite.site.registerableDomain, 'google.com'); |
| 322 assertTrue(firstImportantSite.site.isChecked) |
| 323 // Choose to keep storage for google.com. |
| 324 MockInteractions.tap(firstImportantSite.$$('#checkbox')); |
| 325 assertFalse(firstImportantSite.site.isChecked) |
| 326 // Confirm deletion. |
| 327 MockInteractions.tap(element.$$('#importantSitesConfirm')); |
| 328 return testBrowserProxy.whenCalled('clearBrowsingData') |
| 329 .then(function(sites) { |
| 330 assertEquals(sites.length, 2); |
| 331 assertEquals(sites[0].registerableDomain, 'google.com'); |
| 332 assertFalse(sites[0].isChecked); |
| 333 assertEquals(sites[1].registerableDomain, 'yahoo.com'); |
| 334 assertTrue(sites[1].isChecked); |
| 335 }); |
| 336 }); |
| 337 }); |
| 338 }); |
| 339 |
254 function registerSafeBrowsingExtendedReportingTests() { | 340 function registerSafeBrowsingExtendedReportingTests() { |
255 suite('SafeBrowsingExtendedReporting', function() { | 341 suite('SafeBrowsingExtendedReporting', function() { |
256 /** @type {settings.TestPrivacyPageBrowserProxy} */ | 342 /** @type {settings.TestPrivacyPageBrowserProxy} */ |
257 var testBrowserProxy; | 343 var testBrowserProxy; |
258 | 344 |
259 /** @type {SettingsPrivacyPageElement} */ | 345 /** @type {SettingsPrivacyPageElement} */ |
260 var page; | 346 var page; |
261 | 347 |
262 setup(function() { | 348 setup(function() { |
263 testBrowserProxy = new TestPrivacyPageBrowserProxy(); | 349 testBrowserProxy = new TestPrivacyPageBrowserProxy(); |
264 settings.PrivacyPageBrowserProxyImpl.instance_ = testBrowserProxy; | 350 settings.PrivacyPageBrowserProxyImpl.instance_ = testBrowserProxy; |
265 PolymerTest.clearBody(); | 351 PolymerTest.clearBody(); |
266 page = document.createElement('settings-privacy-page'); | 352 page = document.createElement('settings-privacy-page'); |
267 }); | 353 }); |
268 | 354 |
269 teardown(function() { page.remove(); }); | 355 teardown(function() { page.remove(); }); |
270 | 356 |
271 test('test whether extended reporting is enabled/managed', function() { | 357 test('test whether extended reporting is enabled/managed', function() { |
272 return testBrowserProxy.whenCalled( | 358 return testBrowserProxy.whenCalled( |
273 'getSafeBrowsingExtendedReporting').then(function() { | 359 'getSafeBrowsingExtendedReporting').then(function() { |
274 Polymer.dom.flush(); | 360 Polymer.dom.flush(); |
275 | 361 |
276 // Control starts checked by default | 362 // Control starts checked by default |
277 var control = page.$.safeBrowsingExtendedReportingControl; | 363 var control = page.$$('#safeBrowsingExtendedReportingControl'); |
278 assertEquals(true, control.checked); | 364 assertEquals(true, control.checked); |
279 | 365 |
280 // Notification from browser can uncheck the box | 366 // Notification from browser can uncheck the box |
281 cr.webUIListenerCallback('safe-browsing-extended-reporting-change', | 367 cr.webUIListenerCallback('safe-browsing-extended-reporting-change', |
282 false); | 368 false); |
283 Polymer.dom.flush(); | 369 Polymer.dom.flush(); |
284 assertEquals(false, control.checked); | 370 assertEquals(false, control.checked); |
285 | 371 |
286 // Tapping on the box will check it again. | 372 // Tapping on the box will check it again. |
287 MockInteractions.tap(control); | 373 MockInteractions.tap(control); |
288 return testBrowserProxy.whenCalled('getSafeBrowsingExtendedReporting', | 374 return testBrowserProxy.whenCalled('getSafeBrowsingExtendedReporting', |
289 true); | 375 true); |
290 }); | 376 }); |
291 }); | 377 }); |
292 }); | 378 }); |
293 } | 379 } |
294 | 380 |
295 return { | 381 return { |
296 registerTests: function() { | 382 registerTests: function() { |
297 if (cr.isMac || cr.isWin) | 383 if (cr.isMac || cr.isWin) |
298 registerNativeCertificateManagerTests(); | 384 registerNativeCertificateManagerTests(); |
299 | 385 |
300 registerClearBrowsingDataTests(); | 386 registerClearBrowsingDataTests(); |
301 registerPrivacyPageTests(); | 387 registerPrivacyPageTests(); |
302 registerSafeBrowsingExtendedReportingTests(); | 388 registerSafeBrowsingExtendedReportingTests(); |
303 }, | 389 }, |
304 }; | 390 }; |
305 }); | 391 }); |
OLD | NEW |