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

Unified Diff: mojo/public/js/codec_unittests.js

Issue 798163002: Add failure messages to gin and js mojom encoder (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« mojo/public/js/codec.js ('K') | « mojo/public/js/codec.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/js/codec_unittests.js
diff --git a/mojo/public/js/codec_unittests.js b/mojo/public/js/codec_unittests.js
index 5d6950763ee5fbd2d33ab1d0144d2c5c15f6f54c..82e7c5e3314da64140514f8d0bde85eb06a5f300 100644
--- a/mojo/public/js/codec_unittests.js
+++ b/mojo/public/js/codec_unittests.js
@@ -15,6 +15,7 @@ define([
testTypes();
testAlign();
testUtf8();
+ testArrayPointerValidation();
this.result = "PASS";
function testBar() {
@@ -255,4 +256,18 @@ define([
var str2 = reader.decoder.decodeStringPointer();
expect(str2).toEqual(str);
}
+
+ function testArrayPointerValidation() {
+ function DummyClass() {};
+ var builder = new codec.MessageBuilder(42, 24);
+ var encoder = builder.createEncoder(8);
+ expect(function() {
+ // Pass something that is not an array it should throw.
+ encoder.encodeArrayPointer(DummyClass, 75);
+ }).toThrow();
+
+ // An empty array or null should do nothing and be fine.
+ encoder.encodeArrayPointer(DummyClass, []);
+ encoder.encodeArrayPointer(DummyClass, null);
+ }
});
« mojo/public/js/codec.js ('K') | « mojo/public/js/codec.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698