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

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

Issue 795593004: Update mojo sdk to rev cc531b32182099a5a034a99daff35ed5d38a61c8 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More workarounds for MSVC 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
« no previous file with comments | « mojo/public/js/codec.js ('k') | mojo/public/js/connection.js » ('j') | 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..3d3ac9cab13fb5bbcd061ef8a0fa17c167dbbdea 100644
--- a/mojo/public/js/codec_unittests.js
+++ b/mojo/public/js/codec_unittests.js
@@ -15,6 +15,7 @@ define([
testTypes();
testAlign();
testUtf8();
+ testTypedPointerValidation();
this.result = "PASS";
function testBar() {
@@ -255,4 +256,37 @@ define([
var str2 = reader.decoder.decodeStringPointer();
expect(str2).toEqual(str);
}
+
+ function testTypedPointerValidation() {
+ var encoder = new codec.MessageBuilder(42, 24).createEncoder(8);
+ function DummyClass() {};
+ var testCases = [
+ // method, args, invalid examples, valid examples
+ [encoder.encodeArrayPointer, [DummyClass], [75],
+ [[], null, undefined, new Uint8Array([])]],
+ [encoder.encodeStringPointer, [], [75, new String("foo")],
+ ["", "bar", null, undefined]],
+ [encoder.encodeMapPointer, [DummyClass, DummyClass], [75],
+ [new Map(), null, undefined]],
+ ];
+
+ testCases.forEach(function(test) {
+ var method = test[0];
+ var baseArgs = test[1];
+ var invalidExamples = test[2];
+ var validExamples = test[3];
+
+ var encoder = new codec.MessageBuilder(42, 24).createEncoder(8);
+ invalidExamples.forEach(function(invalid) {
+ expect(function() {
+ method.apply(encoder, baseArgs.concat(invalid));
+ }).toThrow();
+ });
+
+ validExamples.forEach(function(valid) {
+ var encoder = new codec.MessageBuilder(42, 24).createEncoder(8);
+ method.apply(encoder, baseArgs.concat(valid));
+ });
+ });
+ }
});
« no previous file with comments | « mojo/public/js/codec.js ('k') | mojo/public/js/connection.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698