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

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

Issue 2766093002: MD Settings: validate home button url input (Closed)
Patch Set: fix formatting 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 * @constructor 6 * @constructor
7 * @implements {settings.AppearanceBrowserProxy} 7 * @implements {settings.AppearanceBrowserProxy}
8 * @extends {settings.TestBrowserProxy} 8 * @extends {settings.TestBrowserProxy}
9 */ 9 */
10 var TestAppearanceBrowserProxy = function() { 10 var TestAppearanceBrowserProxy = function() {
11 settings.TestBrowserProxy.call(this, [ 11 settings.TestBrowserProxy.call(this, [
12 'getDefaultZoom', 12 'getDefaultZoom',
13 'getThemeInfo', 13 'getThemeInfo',
14 'isSupervised', 14 'isSupervised',
15 'openWallpaperManager', 15 'openWallpaperManager',
16 'useDefaultTheme', 16 'useDefaultTheme',
17 'useSystemTheme', 17 'useSystemTheme',
18 'validateStartupPage',
18 ]); 19 ]);
19 20
20 /** @private */ 21 /** @private */
21 this.defaultZoom_ = 1; 22 this.defaultZoom_ = 1;
22 23
23 /** @private */ 24 /** @private */
24 this.isSupervised_ = false; 25 this.isSupervised_ = false;
26
27 /** @private */
28 this.isHomeUrlValid_ = true;
25 }; 29 };
26 30
27 TestAppearanceBrowserProxy.prototype = { 31 TestAppearanceBrowserProxy.prototype = {
28 __proto__: settings.TestBrowserProxy.prototype, 32 __proto__: settings.TestBrowserProxy.prototype,
29 33
30 /** @override */ 34 /** @override */
31 getDefaultZoom: function() { 35 getDefaultZoom: function() {
32 this.methodCalled('getDefaultZoom'); 36 this.methodCalled('getDefaultZoom');
33 return Promise.resolve(this.defaultZoom_); 37 return Promise.resolve(this.defaultZoom_);
34 }, 38 },
(...skipping 27 matching lines...) Expand all
62 66
63 /** @param {number} defaultZoom */ 67 /** @param {number} defaultZoom */
64 setDefaultZoom: function(defaultZoom) { 68 setDefaultZoom: function(defaultZoom) {
65 this.defaultZoom_ = defaultZoom; 69 this.defaultZoom_ = defaultZoom;
66 }, 70 },
67 71
68 /** @param {boolean} Whether the user is supervised */ 72 /** @param {boolean} Whether the user is supervised */
69 setIsSupervised: function(isSupervised) { 73 setIsSupervised: function(isSupervised) {
70 this.isSupervised_ = isSupervised; 74 this.isSupervised_ = isSupervised;
71 }, 75 },
76
77 /** @override */
78 validateStartupPage: function(value) {
79 this.methodCalled('validateStartupPage');
80 return Promise.resolve(this.isHomeUrlValid_);
81 },
82
83 /**
84 * @param {boolean} isValid
85 */
86 setValidStartupPageResponse: function(isValid) {
87 this.isHomeUrlValid_ = isValid;
88 }
72 }; 89 };
73 90
74 var appearancePage = null; 91 var appearancePage = null;
75 92
76 /** @type {?TestAppearanceBrowserProxy} */ 93 /** @type {?TestAppearanceBrowserProxy} */
77 var appearanceBrowserProxy = null; 94 var appearanceBrowserProxy = null;
78 95
79 function createAppearancePage() { 96 function createAppearancePage() {
80 appearanceBrowserProxy.reset(); 97 appearanceBrowserProxy.reset();
81 PolymerTest.clearBody(); 98 PolymerTest.clearBody();
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 }).then(function() { 234 }).then(function() {
218 assertEquals('110%', getDefaultZoomText()); 235 assertEquals('110%', getDefaultZoomText());
219 236
220 appearanceBrowserProxy.setDefaultZoom(1.7499999999999); 237 appearanceBrowserProxy.setDefaultZoom(1.7499999999999);
221 createAppearancePage(); 238 createAppearancePage();
222 return appearanceBrowserProxy.whenCalled('getDefaultZoom'); 239 return appearanceBrowserProxy.whenCalled('getDefaultZoom');
223 }).then(function() { 240 }).then(function() {
224 assertEquals('175%', getDefaultZoomText()); 241 assertEquals('175%', getDefaultZoomText());
225 }); 242 });
226 }); 243 });
244
245 test('show home button toggling', function() {
246 assertFalse(!!appearancePage.$$('.list-frame'));
247 appearancePage.set('prefs', {browser: {show_home_button: {value: true}}});
248
249 Polymer.dom.flush();
250
251 assertTrue(!!appearancePage.$$('.list-frame'));
252 });
253
254 test('home button urls', function() {
255 appearancePage.set('prefs', {
256 browser: {show_home_button: {value: true}},
257 homepage: {type: chrome.settingsPrivate.PrefType.URL, value: 'test'}
258 });
259
260 Polymer.dom.flush();
261
262 var input = appearancePage.$$('#customHomePage');
263 assertTrue(!!input);
264 assertFalse(input.invalid);
265 assertEquals(input.value, 'test');
266
267 input.value = '@@@';
268 appearanceBrowserProxy.setValidStartupPageResponse(false);
269 input.fire('input');
270
271 return appearanceBrowserProxy.whenCalled('validateStartupPage')
272 .then(function() {
273 Polymer.dom.flush();
274 assertEquals(input.value, '@@@');
275 assertTrue(input.invalid);
276
277 // Should reset to default value on change event.
278 input.$$('paper-input').fire('change');
279 Polymer.dom.flush();
280 assertEquals(input.value, 'test');
281 });
282 });
227 }); 283 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698