Chromium Code Reviews| Index: mojo/public/js/codec.js |
| diff --git a/mojo/public/js/codec.js b/mojo/public/js/codec.js |
| index ea4273a32ffd67e1398a1970a67ed1848f402e3f..5440abed92d3651e684a492f97673bee286d9d68 100644 |
| --- a/mojo/public/js/codec.js |
| +++ b/mojo/public/js/codec.js |
| @@ -8,6 +8,7 @@ define("mojo/public/js/codec", [ |
| ], function(unicode, buffer) { |
| var kErrorUnsigned = "Passing negative value to unsigned"; |
| + var kErrorArray = "Passing non-array-like to array"; |
| // Memory ------------------------------------------------------------------- |
| @@ -352,6 +353,9 @@ define("mojo/public/js/codec", [ |
| this.encodePointer(val); |
| return; |
| } |
| + if (val.length === undefined) { |
| + throw new Error(kErrorArray); |
|
hansmuller
2014/12/15 16:56:17
I suppose another indication that val isn't an arr
|
| + } |
| var numberOfElements = val.length; |
| var encodedSize = kArrayHeaderSize + ((cls === PackedBool) ? |
| Math.ceil(numberOfElements / 8) : cls.encodedSize * numberOfElements); |