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

Side by Side Diff: mojo/public/js/validation_unittests.js

Issue 921223002: Cpp bindings: Return false from Validator::Accept() on unrecognized message or invalid flags (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebased. Fixes spelling of UNKOWN. Created 5 years, 9 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 define([ 5 define([
6 "console", 6 "console",
7 "file", 7 "file",
8 "gin/test/expect", 8 "gin/test/expect",
9 "mojo/public/interfaces/bindings/tests/validation_test_interfaces.mojom", 9 "mojo/public/interfaces/bindings/tests/validation_test_interfaces.mojom",
10 "mojo/public/js/buffer", 10 "mojo/public/js/buffer",
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 if (actualResult != expectedResult) 218 if (actualResult != expectedResult)
219 console.log("[Test message validation failed: " + testFile + " ]"); 219 console.log("[Test message validation failed: " + testFile + " ]");
220 expect(actualResult).toEqual(expectedResult); 220 expect(actualResult).toEqual(expectedResult);
221 } 221 }
222 222
223 function testMessageValidation(key, filters) { 223 function testMessageValidation(key, filters) {
224 var testFiles = getMessageTestFiles(key); 224 var testFiles = getMessageTestFiles(key);
225 expect(testFiles.length).toBeGreaterThan(0); 225 expect(testFiles.length).toBeGreaterThan(0);
226 226
227 for (var i = 0; i < testFiles.length; i++) { 227 for (var i = 0; i < testFiles.length; i++) {
228 // TODO(hansmuller, yzshen): Temporarily skipping: 228 // TODO(hansmuller, yzshen, rudominer): Temporarily skipping:
229 // - array pointer overflow tests; 229 // - array pointer overflow tests;
230 // - struct versioning tests (tests with "mthd11" in the name). 230 // - struct versioning tests (tests with "mthd11" in the name).
231 // - no-such-method validation check tests.
231 if (testFiles[i].indexOf("overflow") != -1 || 232 if (testFiles[i].indexOf("overflow") != -1 ||
232 testFiles[i].indexOf("mthd11") != -1) { 233 testFiles[i].indexOf("mthd11") != -1 ||
234 testFiles[i].indexOf("no_such_method") != -1 ||
235 testFiles[i].indexOf("invalid_request_flags") != -1) {
hansmuller1 2015/03/04 21:55:20 The comment no longer covers all the tests being s
rudominer 2015/03/04 23:05:48 I modified the comment. ptal.
233 console.log("[Skipping " + testFiles[i] + "]"); 236 console.log("[Skipping " + testFiles[i] + "]");
234 continue; 237 continue;
235 } 238 }
236 239
237 var testMessage = readTestMessage(testFiles[i]); 240 var testMessage = readTestMessage(testFiles[i]);
238 var handles = new Array(testMessage.handleCount); 241 var handles = new Array(testMessage.handleCount);
239 var message = new codec.Message(testMessage.buffer, handles); 242 var message = new codec.Message(testMessage.buffer, handles);
240 var messageValidator = new validator.Validator(message); 243 var messageValidator = new validator.Validator(message);
241 244
242 var err = messageValidator.validateMessageHeader(); 245 var err = messageValidator.validateMessageHeader();
243 for (var j = 0; err === noError && j < filters.length; ++j) 246 for (var j = 0; err === noError && j < filters.length; ++j)
244 err = filters[j](messageValidator); 247 err = filters[j](messageValidator);
245 248
246 checkValidationResult(testFiles[i], err); 249 checkValidationResult(testFiles[i], err);
247 } 250 }
248 } 251 }
249 252
250 function testConformanceMessageValidation() { 253 function testConformanceMessageValidation() {
251 testMessageValidation("conformance_", [ 254 testMessageValidation("conformance_", [
252 testInterface.ConformanceTestInterface.validateRequest]); 255 testInterface.ConformanceTestInterface.validateRequest]);
253 } 256 }
254 257
255 function testIntegratedMessageValidation(testFilesPattern) { 258 function testIntegratedMessageValidation(testFilesPattern) {
256 var testFiles = getMessageTestFiles(testFilesPattern); 259 var testFiles = getMessageTestFiles(testFilesPattern);
257 expect(testFiles.length).toBeGreaterThan(0); 260 expect(testFiles.length).toBeGreaterThan(0);
258 261
259 for (var i = 0; i < testFiles.length; i++) { 262 for (var i = 0; i < testFiles.length; i++) {
260 // TODO(hansmuller): Temporarily skipping array pointer overflow tests.
261 if (testFiles[i].indexOf("overflow") != -1) {
262 console.log("[Skipping " + testFiles[i] + "]");
263 continue;
264 }
265
266 var testMessage = readTestMessage(testFiles[i]); 263 var testMessage = readTestMessage(testFiles[i]);
267 var handles = new Array(testMessage.handleCount); 264 var handles = new Array(testMessage.handleCount);
268 var testMessagePipe = new core.createMessagePipe(); 265 var testMessagePipe = new core.createMessagePipe();
269 expect(testMessagePipe.result).toBe(core.RESULT_OK); 266 expect(testMessagePipe.result).toBe(core.RESULT_OK);
270 267
271 var writeMessageValue = core.writeMessage( 268 var writeMessageValue = core.writeMessage(
272 testMessagePipe.handle0, 269 testMessagePipe.handle0,
273 new Uint8Array(testMessage.buffer.arrayBuffer), 270 new Uint8Array(testMessage.buffer.arrayBuffer),
274 new Array(testMessage.handleCount), 271 new Array(testMessage.handleCount),
275 core.WRITE_MESSAGE_FLAG_NONE); 272 core.WRITE_MESSAGE_FLAG_NONE);
(...skipping 29 matching lines...) Expand all
305 testIntegratedMessageValidation("integration_intf_resp"); 302 testIntegratedMessageValidation("integration_intf_resp");
306 } 303 }
307 304
308 expect(checkTestMessageParser()).toBeNull(); 305 expect(checkTestMessageParser()).toBeNull();
309 testConformanceMessageValidation(); 306 testConformanceMessageValidation();
310 testIntegratedMessageHeaderValidation(); 307 testIntegratedMessageHeaderValidation();
311 testIntegratedResponseMessageValidation(); 308 testIntegratedResponseMessageValidation();
312 testIntegratedRequestMessageValidation(); 309 testIntegratedRequestMessageValidation();
313 this.result = "PASS"; 310 this.result = "PASS";
314 }); 311 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698