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

Side by Side Diff: chrome/test/data/extensions/json_schema_test.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 function assert(truth) { 5 function assert(truth) {
6 if (!truth) 6 if (!truth)
7 throw new Error("Assertion failed."); 7 throw new Error("Assertion failed.");
8 } 8 }
9 9
10 function assertValid(type, instance, schema, types) { 10 function assertValid(type, instance, schema, types) {
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 412
413 assertNotValid("Number", Number.POSITIVE_INFINITY, schema, 413 assertNotValid("Number", Number.POSITIVE_INFINITY, schema,
414 [formatError("numberFiniteNotNan", ["Infinity"]), 414 [formatError("numberFiniteNotNan", ["Infinity"]),
415 formatError("numberMaxValue", [schema.maximum]) 415 formatError("numberMaxValue", [schema.maximum])
416 ]); 416 ]);
417 417
418 assertNotValid("Number", Number.NEGATIVE_INFINITY, schema, 418 assertNotValid("Number", Number.NEGATIVE_INFINITY, schema,
419 [formatError("numberFiniteNotNan", ["-Infinity"]), 419 [formatError("numberFiniteNotNan", ["-Infinity"]),
420 formatError("numberMinValue", [schema.minimum]) 420 formatError("numberMinValue", [schema.minimum])
421 ]); 421 ]);
422
423 // 0 casts to bool differently, so it's important to test
424 // BUG=53990.
425 var zero_min_schema = {
426 'minimum': 0,
427 'maximum': 100
428 };
429 assertNotValid("Number", -1, zero_min_schema,
430 [formatError("numberMinValue", [zero_min_schema.minimum])]);
431 assertValid("Number", 0, zero_min_schema);
432
433 var zero_max_schema = {
434 'minimum': -20,
435 'maximum': '0'
436 };
437 assertNotValid("Number", 1, zero_max_schema,
438 [formatError("numberMaxValue", [zero_max_schema.maximum])]);
439 assertValid("Number", 0, zero_max_schema);
440
422 } 441 }
423 442
424 function testType() { 443 function testType() {
425 // valid 444 // valid
426 assertValid("Type", {}, {type:"object"}); 445 assertValid("Type", {}, {type:"object"});
427 assertValid("Type", [], {type:"array"}); 446 assertValid("Type", [], {type:"array"});
428 assertValid("Type", function(){}, {type:"function"}); 447 assertValid("Type", function(){}, {type:"function"});
429 assertValid("Type", "foobar", {type:"string"}); 448 assertValid("Type", "foobar", {type:"string"});
430 assertValid("Type", "", {type:"string"}); 449 assertValid("Type", "", {type:"string"});
431 assertValid("Type", 88.8, {type:"number"}); 450 assertValid("Type", 88.8, {type:"number"});
(...skipping 22 matching lines...) Expand all
454 assertNotValid("Type", 88.8, {type: "integer"}, 473 assertNotValid("Type", 88.8, {type: "integer"},
455 [formatError("invalidType", ["integer", "number"])]); 474 [formatError("invalidType", ["integer", "number"])]);
456 assertNotValid("Type", 1, {type: "boolean"}, 475 assertNotValid("Type", 1, {type: "boolean"},
457 [formatError("invalidType", ["boolean", "integer"])]); 476 [formatError("invalidType", ["boolean", "integer"])]);
458 assertNotValid("Type", false, {type: "null"}, 477 assertNotValid("Type", false, {type: "null"},
459 [formatError("invalidType", ["null", "boolean"])]); 478 [formatError("invalidType", ["null", "boolean"])]);
460 assertNotValid("Type", undefined, {type: "null"}, 479 assertNotValid("Type", undefined, {type: "null"},
461 [formatError("invalidType", ["null", "undefined"])]); 480 [formatError("invalidType", ["null", "undefined"])]);
462 assertNotValid("Type", {}, {type: "function"}, 481 assertNotValid("Type", {}, {type: "function"},
463 [formatError("invalidType", ["function", "object"])]); 482 [formatError("invalidType", ["function", "object"])]);
483 // Values outside of the range of an integer weren't being tested
484 // BUG=53990.
485 assertNotValid("Type", 1e10, {type: "integer"},
486 [formatError("invalidType", ["integer", "number"])]);
487 assertNotValid("Type", -1e10, {type: "integer"},
488 [formatError("invalidType", ["integer", "number"])]);
464 } 489 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698