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

Side by Side Diff: chrome/test/data/webui/settings/test_site_settings_prefs_browser_proxy.js

Issue 2769863006: [MD settings] unit test for incognito activation (Closed)
Patch Set: js format Created 3 years, 9 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 unified diff | Download patch
OLDNEW
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 /** 5 /**
6 * An example empty pref. 6 * An example empty pref.
7 * @type {SiteSettingsPref} 7 * @type {SiteSettingsPref}
8 */ 8 */
9 var prefsEmpty = { 9 var prefsEmpty = {
10 defaults: { 10 defaults: {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 'removeCookie', 60 'removeCookie',
61 'removeProtocolHandler', 61 'removeProtocolHandler',
62 'removeUsbDevice', 62 'removeUsbDevice',
63 'removeZoomLevel', 63 'removeZoomLevel',
64 'resetCategoryPermissionForOrigin', 64 'resetCategoryPermissionForOrigin',
65 'setCategoryPermissionForOrigin', 65 'setCategoryPermissionForOrigin',
66 'setDefaultValueForContentType', 66 'setDefaultValueForContentType',
67 'setProtocolDefault' 67 'setProtocolDefault'
68 ]); 68 ]);
69 69
70 /** @private {boolean} */
71 this.hasIncognito = false;
Dan Beam 2017/03/30 04:50:43 hasIncognito_
dschuyler 2017/03/30 21:06:16 See https://codereview.chromium.org/2787923002/
72
70 /** @private {!SiteSettingsPref} */ 73 /** @private {!SiteSettingsPref} */
71 this.prefs_ = prefsEmpty; 74 this.prefs_ = prefsEmpty;
72 75
73 /** @private {!Array<ZoomLevelEntry>} */ 76 /** @private {!Array<ZoomLevelEntry>} */
74 this.zoomList_ = []; 77 this.zoomList_ = [];
75 78
76 /** @private {!Array<!UsbDeviceEntry>} */ 79 /** @private {!Array<!UsbDeviceEntry>} */
77 this.usbDevices_ = []; 80 this.usbDevices_ = [];
78 81
79 /** @private {!Array<!ProtocolEntry>} */ 82 /** @private {!Array<!ProtocolEntry>} */
80 this.protocolHandlers_ = []; 83 this.protocolHandlers_ = [];
81 84
82 /** @private {?CookieList} */ 85 /** @private {?CookieList} */
83 this.cookieDetails_ = null; 86 this.cookieDetails_ = null;
84 87
85 /** @private {boolean} */ 88 /** @private {boolean} */
86 this.isPatternValid_ = true; 89 this.isPatternValid_ = true;
87 }; 90 };
88 91
89 TestSiteSettingsPrefsBrowserProxy.prototype = { 92 TestSiteSettingsPrefsBrowserProxy.prototype = {
90 __proto__: settings.TestBrowserProxy.prototype, 93 __proto__: settings.TestBrowserProxy.prototype,
91 94
92 /** 95 /**
96 * Pretends an incognito session started or ended.
97 * @param {boolean} hasIncognito True for session started.
98 */
99 setIncognito: function(hasIncognito) {
100 this.hasIncognito = hasIncognito;
101 cr.webUIListenerCallback('onIncognitoStatusChanged', hasIncognito);
102 },
103
104 /**
93 * Sets the prefs to use when testing. 105 * Sets the prefs to use when testing.
94 * @param {!SiteSettingsPref} prefs The prefs to set. 106 * @param {!SiteSettingsPref} prefs The prefs to set.
95 */ 107 */
96 setPrefs: function(prefs) { 108 setPrefs: function(prefs) {
97 this.prefs_ = prefs; 109 this.prefs_ = prefs;
98 110
99 // Notify all listeners that their data may be out of date. 111 // Notify all listeners that their data may be out of date.
100 for (var type in settings.ContentSettingsTypes) { 112 for (var type in settings.ContentSettingsTypes) {
101 cr.webUIListenerCallback( 113 cr.webUIListenerCallback(
102 'contentSettingSitePermissionChanged', 114 'contentSettingSitePermissionChanged',
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 else if (contentType == settings.ContentSettingsTypes.PROTECTED_CONTENT) 236 else if (contentType == settings.ContentSettingsTypes.PROTECTED_CONTENT)
225 pref = this.prefs_.exceptions.protectedContent; 237 pref = this.prefs_.exceptions.protectedContent;
226 else if (contentType == settings.ContentSettingsTypes.POPUPS) 238 else if (contentType == settings.ContentSettingsTypes.POPUPS)
227 pref = this.prefs_.exceptions.popups; 239 pref = this.prefs_.exceptions.popups;
228 else if (contentType == settings.ContentSettingsTypes.UNSANDBOXED_PLUGINS) 240 else if (contentType == settings.ContentSettingsTypes.UNSANDBOXED_PLUGINS)
229 pref = this.prefs_.exceptions.unsandboxed_plugins; 241 pref = this.prefs_.exceptions.unsandboxed_plugins;
230 else 242 else
231 console.log('getExceptionList received unknown category: ' + contentType); 243 console.log('getExceptionList received unknown category: ' + contentType);
232 244
233 assert(pref != undefined, 'Pref is missing for ' + contentType); 245 assert(pref != undefined, 'Pref is missing for ' + contentType);
246
247 if (this.hasIncognito) {
248 var incognitoElements = [];
249 for (var i = 0; i < pref.length; ++i)
250 incognitoElements.push(Object.assign({incognito: true}, pref[i]));
251 pref = pref.concat(incognitoElements);
252 }
253
234 return Promise.resolve(pref); 254 return Promise.resolve(pref);
235 }, 255 },
236 256
237 /** @override */ 257 /** @override */
238 isPatternValid: function(pattern) { 258 isPatternValid: function(pattern) {
239 this.methodCalled('isPatternValid', pattern); 259 this.methodCalled('isPatternValid', pattern);
240 return Promise.resolve(this.isPatternValid_); 260 return Promise.resolve(this.isPatternValid_);
241 }, 261 },
242 262
243 /** 263 /**
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 /** @override */ 331 /** @override */
312 setProtocolDefault: function() { 332 setProtocolDefault: function() {
313 this.methodCalled('setProtocolDefault', arguments); 333 this.methodCalled('setProtocolDefault', arguments);
314 }, 334 },
315 335
316 /** @override */ 336 /** @override */
317 removeProtocolHandler: function() { 337 removeProtocolHandler: function() {
318 this.methodCalled('removeProtocolHandler', arguments); 338 this.methodCalled('removeProtocolHandler', arguments);
319 } 339 }
320 }; 340 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698