diff options
author | rafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-05 21:45:35 +0000 |
---|---|---|
committer | rafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-05 21:45:35 +0000 |
commit | 5504541dd0a2e96ad8c4effa7f1de812c33a40ce (patch) | |
tree | da534afe1d18bf0e5c746513be9aa6482038a000 /chrome | |
parent | e91d7d0f624bcd491ff5d848ce6862646aa00c83 (diff) | |
download | chromium_src-5504541dd0a2e96ad8c4effa7f1de812c33a40ce.zip chromium_src-5504541dd0a2e96ad8c4effa7f1de812c33a40ce.tar.gz chromium_src-5504541dd0a2e96ad8c4effa7f1de812c33a40ce.tar.bz2 |
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.
BUG=39465
TEST=all tests should pass
Review URL: http://codereview.chromium.org/1558021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43655 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/renderer/resources/json_schema.js | 3 | ||||
-rw-r--r-- | chrome/test/data/extensions/json_schema_test.js | 19 |
2 files changed, 11 insertions, 11 deletions
diff --git a/chrome/renderer/resources/json_schema.js b/chrome/renderer/resources/json_schema.js index 6d0ef53..d119724 100644 --- a/chrome/renderer/resources/json_schema.js +++ b/chrome/renderer/resources/json_schema.js @@ -267,8 +267,7 @@ chromeHidden.JSONSchemaValidator.prototype.validateObject = function( var propPath = path ? path + "." + prop : prop; if (schema.properties[prop] == undefined) { this.addError(propPath, "invalidPropertyType"); - } else if (prop in instance && instance[prop] !== null && - instance[prop] !== undefined) { + } else if (prop in instance && instance[prop] !== undefined) { this.validate(instance[prop], schema.properties[prop], propPath); } else if (!schema.properties[prop].optional) { this.addError(propPath, "propertyRequired"); diff --git a/chrome/test/data/extensions/json_schema_test.js b/chrome/test/data/extensions/json_schema_test.js index 3f55c08..8f18d35 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"])]); |