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

Side by Side Diff: chrome/renderer/resources/json_schema.js

Issue 5018002: Fixes a crash when entering a negative index with chrome.tabs.move .... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 10 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 // NOTE: If you change this file you need to touch renderer_resources.grd to 6 // NOTE: If you change this file you need to touch renderer_resources.grd to
7 // have your change take effect. 7 // have your change take effect.
8 // ----------------------------------------------------------------------------- 8 // -----------------------------------------------------------------------------
9 9
10 //============================================================================== 10 //==============================================================================
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 } 373 }
374 } 374 }
375 } 375 }
376 }; 376 };
377 377
378 /** 378 /**
379 * Validates a string and populates the errors property. 379 * Validates a string and populates the errors property.
380 */ 380 */
381 chromeHidden.JSONSchemaValidator.prototype.validateString = function( 381 chromeHidden.JSONSchemaValidator.prototype.validateString = function(
382 instance, schema, path) { 382 instance, schema, path) {
383 if (schema.minLength && instance.length < schema.minLength) 383 if ('minLength' in schema && instance.length < schema.minLength)
384 this.addError(path, "stringMinLength", [schema.minLength]); 384 this.addError(path, "stringMinLength", [schema.minLength]);
385 385
386 if (schema.maxLength && instance.length > schema.maxLength) 386 if ('maxLength' in schema && instance.length > schema.maxLength)
387 this.addError(path, "stringMaxLength", [schema.maxLength]); 387 this.addError(path, "stringMaxLength", [schema.maxLength]);
388 388
389 if (schema.pattern && !schema.pattern.test(instance)) 389 if (schema.pattern && !schema.pattern.test(instance))
390 this.addError(path, "stringPattern", [schema.pattern]); 390 this.addError(path, "stringPattern", [schema.pattern]);
391 }; 391 };
392 392
393 /** 393 /**
394 * Validates a number and populates the errors property. The instance is 394 * Validates a number and populates the errors property. The instance is
395 * assumed to be a number. 395 * assumed to be a number.
396 */ 396 */
397 chromeHidden.JSONSchemaValidator.prototype.validateNumber = function( 397 chromeHidden.JSONSchemaValidator.prototype.validateNumber = function(
398 instance, schema, path) { 398 instance, schema, path) {
399 399
400 // Forbid NaN, +Infinity, and -Infinity. Our APIs don't use them, and 400 // Forbid NaN, +Infinity, and -Infinity. Our APIs don't use them, and
401 // JSON serialization encodes them as 'null'. Re-evaluate supporting 401 // JSON serialization encodes them as 'null'. Re-evaluate supporting
402 // them if we add an API that could reasonably take them as a parameter. 402 // them if we add an API that could reasonably take them as a parameter.
403 if (isNaN(instance) || 403 if (isNaN(instance) ||
404 instance == Number.POSITIVE_INFINITY || 404 instance == Number.POSITIVE_INFINITY ||
405 instance == Number.NEGATIVE_INFINITY ) 405 instance == Number.NEGATIVE_INFINITY )
406 this.addError(path, "numberFiniteNotNan", [instance]); 406 this.addError(path, "numberFiniteNotNan", [instance]);
407 407
408 if (schema.minimum && instance < schema.minimum) 408 if ('minimum' in schema && instance < schema.minimum)
409 this.addError(path, "numberMinValue", [schema.minimum]); 409 this.addError(path, "numberMinValue", [schema.minimum]);
410 410
411 if (schema.maximum && instance > schema.maximum) 411 if ('maximum' in schema && instance > schema.maximum)
412 this.addError(path, "numberMaxValue", [schema.maximum]); 412 this.addError(path, "numberMaxValue", [schema.maximum]);
413 413
414 if (schema.maxDecimal && instance * Math.pow(10, schema.maxDecimal) % 1) 414 if (schema.maxDecimal && instance * Math.pow(10, schema.maxDecimal) % 1)
415 this.addError(path, "numberMaxDecimal", [schema.maxDecimal]); 415 this.addError(path, "numberMaxDecimal", [schema.maxDecimal]);
416 }; 416 };
417 417
418 /** 418 /**
419 * Validates the primitive type of an instance and populates the errors 419 * Validates the primitive type of an instance and populates the errors
420 * property. Returns true if the instance validates, false otherwise. 420 * property. Returns true if the instance validates, false otherwise.
421 */ 421 */
(...skipping 16 matching lines...) Expand all
438 */ 438 */
439 chromeHidden.JSONSchemaValidator.prototype.addError = function( 439 chromeHidden.JSONSchemaValidator.prototype.addError = function(
440 path, key, replacements) { 440 path, key, replacements) {
441 this.errors.push({ 441 this.errors.push({
442 path: path, 442 path: path,
443 message: chromeHidden.JSONSchemaValidator.formatError(key, replacements) 443 message: chromeHidden.JSONSchemaValidator.formatError(key, replacements)
444 }); 444 });
445 }; 445 };
446 446
447 })(); 447 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698