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

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
Aaron Boodman 2010/11/16 20:21:28 Space after "//". Add a period to the end of the c
424 var zero_min_schema = {
425 'minimum': 0,
426 'maximum': 100
427 };
428 assertNotValid("Number", -1, zero_min_schema,
429 [formatError("numberMinValue", [zero_min_schema.minimum])]);
430 assertValid("Number", 0, zero_min_schema);
431
432 var zero_max_schema = {
433 'minimum': -20,
434 'maximum': '0'
435 };
436 assertNotValid("Number", 1, zero_max_schema,
437 [formatError("numberMaxValue", [zero_max_schema.maximum])]);
438 assertValid("Number", 0, zero_max_schema);
439
422 } 440 }
423 441
424 function testType() { 442 function testType() {
425 // valid 443 // valid
426 assertValid("Type", {}, {type:"object"}); 444 assertValid("Type", {}, {type:"object"});
427 assertValid("Type", [], {type:"array"}); 445 assertValid("Type", [], {type:"array"});
428 assertValid("Type", function(){}, {type:"function"}); 446 assertValid("Type", function(){}, {type:"function"});
429 assertValid("Type", "foobar", {type:"string"}); 447 assertValid("Type", "foobar", {type:"string"});
430 assertValid("Type", "", {type:"string"}); 448 assertValid("Type", "", {type:"string"});
431 assertValid("Type", 88.8, {type:"number"}); 449 assertValid("Type", 88.8, {type:"number"});
(...skipping 23 matching lines...) Expand all
455 [formatError("invalidType", ["integer", "number"])]); 473 [formatError("invalidType", ["integer", "number"])]);
456 assertNotValid("Type", 1, {type: "boolean"}, 474 assertNotValid("Type", 1, {type: "boolean"},
457 [formatError("invalidType", ["boolean", "integer"])]); 475 [formatError("invalidType", ["boolean", "integer"])]);
458 assertNotValid("Type", false, {type: "null"}, 476 assertNotValid("Type", false, {type: "null"},
459 [formatError("invalidType", ["null", "boolean"])]); 477 [formatError("invalidType", ["null", "boolean"])]);
460 assertNotValid("Type", undefined, {type: "null"}, 478 assertNotValid("Type", undefined, {type: "null"},
461 [formatError("invalidType", ["null", "undefined"])]); 479 [formatError("invalidType", ["null", "undefined"])]);
462 assertNotValid("Type", {}, {type: "function"}, 480 assertNotValid("Type", {}, {type: "function"},
463 [formatError("invalidType", ["function", "object"])]); 481 [formatError("invalidType", ["function", "object"])]);
464 } 482 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698