diff options
author | rafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-06 22:20:30 +0000 |
---|---|---|
committer | rafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-06 22:20:30 +0000 |
commit | d41661b5e24c8d774acea07c05ef2e5896587e56 (patch) | |
tree | f8bd3d8888f6a05efc15215915d755d86f549f3c /chrome/test | |
parent | cd8fa42ec2477735076c9e90c11f7a7ea7d19b9b (diff) | |
download | chromium_src-d41661b5e24c8d774acea07c05ef2e5896587e56.zip chromium_src-d41661b5e24c8d774acea07c05ef2e5896587e56.tar.gz chromium_src-d41661b5e24c8d774acea07c05ef2e5896587e56.tar.bz2 |
Reland: No longer accept 'null' as signifying unset optional object property in extension calls
This changes the json schema validation to treat a object property set to null as significant, rather than meaning the property is not specified.
original review: http://codereview.chromium.org/1558021/show
BUG=39465
TBR=oshima
TEST=all tests should pass
Review URL: http://codereview.chromium.org/1618005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43767 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r-- | chrome/test/data/extensions/json_schema_test.js | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/chrome/test/data/extensions/json_schema_test.js b/chrome/test/data/extensions/json_schema_test.js index 3f55c08..58fa8f3 100644 --- a/chrome/test/data/extensions/json_schema_test.js +++ b/chrome/test/data/extensions/json_schema_test.js @@ -189,8 +189,8 @@ function testObject() { } }; - assertValid("Object", {foo:"foo",bar:42}, schema); - assertNotValid("Object", {foo:"foo",bar:42,"extra":true}, schema, + assertValid("Object", {foo:"foo", bar:42}, schema); + assertNotValid("Object", {foo:"foo", bar:42,"extra":true}, schema, [formatError("unexpectedProperty")]); assertNotValid("Object", {foo:"foo"}, schema, [formatError("propertyRequired")]); @@ -198,19 +198,20 @@ function testObject() { [formatError("invalidType", ["integer", "string"])]); schema.additionalProperties = { type: "any" }; - assertValid("Object", {foo:"foo",bar:42,"extra":true}, schema); - assertValid("Object", {foo:"foo",bar:42,"extra":"foo"}, schema); + assertValid("Object", {foo:"foo", bar:42, "extra":true}, schema); + assertValid("Object", {foo:"foo", bar:42, "extra":"foo"}, schema); schema.additionalProperties = { type: "boolean" }; - assertValid("Object", {foo:"foo",bar:42,"extra":true}, schema); - assertNotValid("Object", {foo:"foo",bar:42,"extra":"foo"}, schema, + assertValid("Object", {foo:"foo", bar:42, "extra":true}, schema); + assertNotValid("Object", {foo:"foo", bar:42, "extra":"foo"}, schema, [formatError("invalidType", ["boolean", "string"])]); schema.properties.bar.optional = true; - assertValid("Object", {foo:"foo",bar:42}, schema); + assertValid("Object", {foo:"foo", bar:42}, schema); assertValid("Object", {foo:"foo"}, schema); - assertValid("Object", {foo:"foo",bar:null}, schema); - assertValid("Object", {foo:"foo",bar:undefined}, schema); + assertNotValid("Object", {foo:"foo", bar:null}, schema, + [formatError("invalidType", ["integer", "null"])]); + assertValid("Object", {foo:"foo", bar:undefined}, schema); assertNotValid("Object", {foo:"foo", bar:"42"}, schema, [formatError("invalidType", ["integer", "string"])]); @@ -234,7 +235,7 @@ function testObject() { assertValid("Object", b, classBSchema); assertValid("Object", b, classASchema); assertNotValid("Object", c, classASchema, - [formatError("notInstance", [classASchema.isInstanceOf])]); + [formatError("notInstance", [classASchema.isInstanceOf])]); } function testTypeReference() { @@ -288,7 +289,7 @@ function testTypeReference() { // Valida type references internally defined. assertValid("", {foo:"foo",bar:-4,baz:-2}, schemaInlineReference); - + // Failures in validation, but succesful schema reference. assertNotValid("", {foo:"foo",bar:4,baz:"a"}, schema, [formatError("stringMinLength", [2])], referencedTypes); |