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

Issue 468713002: JavaScript bindings for Mojo message validation (Closed)

Created:
6 years, 4 months ago by hansmuller
Modified:
6 years, 4 months ago
CC:
chromium-reviews, qsr+mojo_chromium.org, viettrungluu+watch_chromium.org, yzshen+watch_chromium.org, abarth-chromium, Aaron Boodman, darin (slow to review), ben+mojo_chromium.org
Project:
chromium
Visibility:
Public.

Description

JavaScript bindings for Mojo message validation For each interface Foo, the Mojo JavaScript bindings now generate a pair of functions: |validateFooRequest(validator)| and |validateFooResponse(messageValidator)|. For each Mojo struct type, an additional |validate(validator)| method is generated. All of the validate methods return a validationError; validationError.NONE if the message is valid or not recognized. The JS validator class has been extended to validate structs, arrays, and handles. The generated methods are unit tested, in the same way as their C++ counterparts, by reading test messages and expected results from /mojo/public/interfaces/bindings/tests/data/validation/. Currently the two pointer overflow test cases are skipped because they depend on reading 64 uints, which the test message file parser can't handle at the moment. JS doesn't support 64 bit integers. 53 bits is the limit for integer Numbers. The message router still only checks the validity of incoming message headers. I'd like to integrate the router with the new validation code in a separate commit. BUG=386808 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=290104

Patch Set 1 #

Patch Set 2 : Merged #

Patch Set 3 : Removed a console import #

Total comments: 14

Patch Set 4 : Simplified the interface definition template #

Total comments: 15

Patch Set 5 : Updates to the unit test, bindings generator, and codec.js #

Patch Set 6 : Binding generator simplification for Arrays #

Total comments: 33

Patch Set 7 : Updates per yzshen's second round of feedback #

Total comments: 1

Patch Set 8 : Restored a blank link #

Patch Set 9 : Skip unexpected null tests" #

Unified diffs Side-by-side diffs Delta from patch set Stats (+352 lines, -46 lines) Patch
M mojo/public/js/bindings/codec.js View 1 2 3 4 6 chunks +10 lines, -3 lines 0 comments Download
M mojo/public/js/bindings/router.js View 1 chunk +1 line, -1 line 0 comments Download
M mojo/public/js/bindings/validation_unittests.js View 1 2 3 4 5 6 7 8 5 chunks +54 lines, -19 lines 0 comments Download
M mojo/public/js/bindings/validator.js View 1 2 3 4 5 6 5 chunks +150 lines, -6 lines 0 comments Download
M mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl View 1 2 3 4 5 6 1 chunk +49 lines, -0 lines 0 comments Download
M mojo/public/tools/bindings/generators/js_templates/module.js.tmpl View 2 chunks +4 lines, -1 line 0 comments Download
M mojo/public/tools/bindings/generators/js_templates/struct_definition.tmpl View 1 2 3 4 5 6 1 chunk +30 lines, -0 lines 0 comments Download
M mojo/public/tools/bindings/generators/mojom_cpp_generator.py View 1 2 3 4 5 6 7 8 2 chunks +1 line, -7 lines 0 comments Download
M mojo/public/tools/bindings/generators/mojom_js_generator.py View 1 2 3 4 5 6 7 chunks +45 lines, -9 lines 0 comments Download
M mojo/public/tools/bindings/pylib/mojom/generate/module.py View 1 2 3 4 5 6 7 1 chunk +8 lines, -0 lines 0 comments Download

Messages

Total messages: 19 (0 generated)
hansmuller
Generate the code for message validation and test it.
6 years, 4 months ago (2014-08-13 16:04:12 UTC) #1
Matt Perry
https://codereview.chromium.org/468713002/diff/40001/mojo/public/js/bindings/validator.js File mojo/public/js/bindings/validator.js (right): https://codereview.chromium.org/468713002/diff/40001/mojo/public/js/bindings/validator.js#newcode223 mojo/public/js/bindings/validator.js:223: var elementSize = codec.PointerTo.prototype.encodedSize; I'm confused about this one. ...
6 years, 4 months ago (2014-08-13 19:31:01 UTC) #2
hansmuller
Thanks for the review! https://codereview.chromium.org/468713002/diff/40001/mojo/public/js/bindings/validator.js File mojo/public/js/bindings/validator.js (right): https://codereview.chromium.org/468713002/diff/40001/mojo/public/js/bindings/validator.js#newcode223 mojo/public/js/bindings/validator.js:223: var elementSize = codec.PointerTo.prototype.encodedSize; On ...
6 years, 4 months ago (2014-08-13 21:23:41 UTC) #3
Matt Perry
https://codereview.chromium.org/468713002/diff/40001/mojo/public/js/bindings/validator.js File mojo/public/js/bindings/validator.js (right): https://codereview.chromium.org/468713002/diff/40001/mojo/public/js/bindings/validator.js#newcode223 mojo/public/js/bindings/validator.js:223: var elementSize = codec.PointerTo.prototype.encodedSize; On 2014/08/13 21:23:40, hansmuller wrote: ...
6 years, 4 months ago (2014-08-13 21:30:44 UTC) #4
hansmuller
https://codereview.chromium.org/468713002/diff/40001/mojo/public/js/bindings/validator.js File mojo/public/js/bindings/validator.js (right): https://codereview.chromium.org/468713002/diff/40001/mojo/public/js/bindings/validator.js#newcode223 mojo/public/js/bindings/validator.js:223: var elementSize = codec.PointerTo.prototype.encodedSize; On 2014/08/13 21:30:44, Matt Perry ...
6 years, 4 months ago (2014-08-13 21:53:21 UTC) #5
yzshen1
first part of comments. https://codereview.chromium.org/468713002/diff/60001/mojo/public/js/bindings/validation_unittests.js File mojo/public/js/bindings/validation_unittests.js (right): https://codereview.chromium.org/468713002/diff/60001/mojo/public/js/bindings/validation_unittests.js#newcode204 mojo/public/js/bindings/validation_unittests.js:204: if (testFiles[i].indexOf("overflow") != -1) It ...
6 years, 4 months ago (2014-08-14 00:06:32 UTC) #6
hansmuller
https://codereview.chromium.org/468713002/diff/60001/mojo/public/js/bindings/validation_unittests.js File mojo/public/js/bindings/validation_unittests.js (right): https://codereview.chromium.org/468713002/diff/60001/mojo/public/js/bindings/validation_unittests.js#newcode204 mojo/public/js/bindings/validation_unittests.js:204: if (testFiles[i].indexOf("overflow") != -1) On 2014/08/14 00:06:32, yzshen1 wrote: ...
6 years, 4 months ago (2014-08-14 00:57:57 UTC) #7
yzshen1
https://codereview.chromium.org/468713002/diff/60001/mojo/public/js/bindings/validator.js File mojo/public/js/bindings/validator.js (right): https://codereview.chromium.org/468713002/diff/60001/mojo/public/js/bindings/validator.js#newcode71 mojo/public/js/bindings/validator.js:71: this.handleIndex = index + 1; // safe because handle ...
6 years, 4 months ago (2014-08-14 18:02:22 UTC) #8
chromium-reviews
And +tsepez for security review. Thanks Tom! On Thu, Aug 14, 2014 at 11:02 AM, ...
6 years, 4 months ago (2014-08-14 18:06:50 UTC) #9
hansmuller
I believe I've addressed all of Yuzhu's feedback. https://codereview.chromium.org/468713002/diff/60001/mojo/public/js/bindings/validator.js File mojo/public/js/bindings/validator.js (right): https://codereview.chromium.org/468713002/diff/60001/mojo/public/js/bindings/validator.js#newcode71 mojo/public/js/bindings/validator.js:71: this.handleIndex ...
6 years, 4 months ago (2014-08-14 23:51:46 UTC) #10
yzshen1
LGTM, Thanks! (Please wait for others' LGs.) https://codereview.chromium.org/468713002/diff/100001/mojo/public/tools/bindings/generators/mojom_js_generator.py File mojo/public/tools/bindings/generators/mojom_js_generator.py (right): https://codereview.chromium.org/468713002/diff/100001/mojo/public/tools/bindings/generators/mojom_js_generator.py#newcode189 mojo/public/tools/bindings/generators/mojom_js_generator.py:189: def IsArrayPointerField(field): ...
6 years, 4 months ago (2014-08-15 16:26:37 UTC) #11
Tom Sepez
Security LGTM.
6 years, 4 months ago (2014-08-15 17:01:08 UTC) #12
Matt Perry
lgtm
6 years, 4 months ago (2014-08-15 19:23:22 UTC) #13
hansmuller
The CQ bit was checked by hansmuller@chromium.org
6 years, 4 months ago (2014-08-15 21:39:08 UTC) #14
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/hansmuller@chromium.org/468713002/140001
6 years, 4 months ago (2014-08-15 21:43:01 UTC) #15
hansmuller
The CQ bit was unchecked by hansmuller@chromium.org
6 years, 4 months ago (2014-08-15 21:45:01 UTC) #16
hansmuller
The CQ bit was checked by hansmuller@chromium.org
6 years, 4 months ago (2014-08-15 21:52:26 UTC) #17
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/hansmuller@chromium.org/468713002/160001
6 years, 4 months ago (2014-08-15 21:55:33 UTC) #18
commit-bot: I haz the power
6 years, 4 months ago (2014-08-16 06:09:28 UTC) #19
Message was sent while issue was closed.
Committed patchset #9 (160001) as 290104

Powered by Google App Engine
This is Rietveld 408576698