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

Issue 803173003: Add more type validation to codec.js (Closed)

Created:
6 years ago by eseidel
Modified:
5 years, 11 months ago
Reviewers:
hansmuller, Ryan Sleevi
CC:
mojo-reviews_chromium.org, qsr+mojo_chromium.org, viettrungluu+watch_chromium.org, yzshen+watch_chromium.org, abarth-chromium, Aaron Boodman, darin (slow to review), ben+mojo_chromium.org, dcheng
Base URL:
git@github.com:domokit/mojo.git@master
Target Ref:
refs/heads/master
Project:
mojo
Visibility:
Public.

Description

Add more type validation to codec.js Also fixed array validation to use instanceof per Hans' request in https://codereview.chromium.org/798163002/ R=hansmuller@chromium.org BUG= Committed: https://chromium.googlesource.com/external/mojo/+/1a12b3f231de825a06be026528cc43c2049be7d6

Patch Set 1 #

Total comments: 2

Patch Set 2 : Updated comment #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+41 lines, -14 lines) Patch
M mojo/public/js/codec.js View 1 4 chunks +11 lines, -2 lines 2 comments Download
M mojo/public/js/codec_unittests.js View 2 chunks +30 lines, -12 lines 0 comments Download

Messages

Total messages: 11 (1 generated)
eseidel
6 years ago (2014-12-15 23:49:23 UTC) #1
eseidel
Hopefully my test case is not too complex. I was trying to avoid copy/pasta but ...
6 years ago (2014-12-15 23:49:46 UTC) #2
hansmuller
LGTM with a nit. https://codereview.chromium.org/803173003/diff/1/mojo/public/js/codec.js File mojo/public/js/codec.js (right): https://codereview.chromium.org/803173003/diff/1/mojo/public/js/codec.js#newcode375 mojo/public/js/codec.js:375: if (typeof(val) !== "string") { ...
6 years ago (2014-12-16 01:10:41 UTC) #3
eseidel
https://codereview.chromium.org/803173003/diff/1/mojo/public/js/codec.js File mojo/public/js/codec.js (right): https://codereview.chromium.org/803173003/diff/1/mojo/public/js/codec.js#newcode375 mojo/public/js/codec.js:375: if (typeof(val) !== "string") { On 2014/12/16 01:10:41, hansmuller ...
6 years ago (2014-12-16 01:13:04 UTC) #4
eseidel
Committed patchset #2 (id:20001) manually as 1a12b3f231de825a06be026528cc43c2049be7d6 (presubmit successful).
6 years ago (2014-12-16 01:18:16 UTC) #5
hansmuller
On 2014/12/16 01:13:04, eseidel wrote: > https://codereview.chromium.org/803173003/diff/1/mojo/public/js/codec.js > File mojo/public/js/codec.js (right): > > https://codereview.chromium.org/803173003/diff/1/mojo/public/js/codec.js#newcode375 > ...
6 years ago (2014-12-16 15:38:27 UTC) #6
eseidel
OK. Will fix the comment. Thanks!
6 years ago (2014-12-16 17:09:45 UTC) #7
eseidel
Done: https://codereview.chromium.org/807873002
6 years ago (2014-12-16 17:13:37 UTC) #8
Ryan Sleevi
+dcheng, since this blocked a Chromium roll of Mojo (which as depending on this behaviour) ...
5 years, 11 months ago (2014-12-30 04:54:17 UTC) #10
hansmuller1
5 years, 11 months ago (2014-12-30 16:08:18 UTC) #11
Message was sent while issue was closed.
On 2014/12/30 04:54:17, Ryan Sleevi wrote:
> +dcheng, since this blocked a Chromium roll of Mojo (which as depending on
this
> behaviour)
> 
> In this case, the broken test was doing
>
https://code.google.com/p/chromium/codesearch#chromium/src/extensions/test/da...
> 
> 
> This worked in previous iterations because ArrayBufferView is an array-like
> object, but fails now due to the more stringent requirements.
> 
> https://codereview.chromium.org/803173003/diff/20001/mojo/public/js/codec.js
> File mojo/public/js/codec.js (right):
> 
>
https://codereview.chromium.org/803173003/diff/20001/mojo/public/js/codec.js#...
> mojo/public/js/codec.js:360: }
> The original code had the benefit that it properly handled ES6 array-like
> objects, such as the ArrayBufferView family. This change loses this property,
> which has prevented rolling an updated Mojo into Chrome (see
> https://codereview.chromium.org/795593004 )
> 
> This may be what you desired, but it's certainly not intuitive when using JS
> bindings.
> 
>
https://people.mozilla.org/~jorendorff/es6-draft.html#sec-createlistfromarray...
> is the canonical ES6 algorithm for handling array-like objects into sequenced
> lists, and it seems useful here when talking about IDL bindings.
> 
>
https://codereview.chromium.org/803173003/diff/20001/mojo/public/js/codec.js#...
> mojo/public/js/codec.js:403: if (!(val instanceof Map)) {
> This is another surprising change, as it prevents map-like objects and
iterables
> from working. Again, this may be desirable, but it certainly strikes as
> surprising.

The surprising changes you're referring to were made because the failures caused
by providing map/array values that were insufficiently map or array "like" were
difficult to diagnose. Surprising even.

I agree that it would be useful to loosen the requirements for map and array
values. 

This CL wasn't supposed to be backwards incompatible, so for now I'll just
weaken the type checking a little.

Powered by Google App Engine
This is Rietveld 408576698