| OLD | NEW |
| 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 Loading... |
| 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) Temporarily skipping array pointer overflow tests |
| 229 // - array pointer overflow tests; | 229 // because JS numbers are limited to 53 bits. |
| 230 // - struct versioning tests (tests with "mthd11" in the name). | 230 // TODO(yzshen) Skipping struct versioning tests (tests with "mthd11" |
| 231 // in the name) because the feature is not supported in JS yet. |
| 232 // TODO(rudominer): Temporarily skipping 'no-such-method', |
| 233 // 'invalid_request_flags', and 'invalid_response_flags' until additional |
| 234 // logic in *RequestValidator and *ResponseValidator is ported from |
| 235 // cpp to js. |
| 231 if (testFiles[i].indexOf("overflow") != -1 || | 236 if (testFiles[i].indexOf("overflow") != -1 || |
| 232 testFiles[i].indexOf("mthd11") != -1) { | 237 testFiles[i].indexOf("mthd11") != -1 || |
| 238 testFiles[i].indexOf("no_such_method") != -1 || |
| 239 testFiles[i].indexOf("invalid_request_flags") != -1 || |
| 240 testFiles[i].indexOf("invalid_response_flags") != -1) { |
| 233 console.log("[Skipping " + testFiles[i] + "]"); | 241 console.log("[Skipping " + testFiles[i] + "]"); |
| 234 continue; | 242 continue; |
| 235 } | 243 } |
| 236 | 244 |
| 237 var testMessage = readTestMessage(testFiles[i]); | 245 var testMessage = readTestMessage(testFiles[i]); |
| 238 var handles = new Array(testMessage.handleCount); | 246 var handles = new Array(testMessage.handleCount); |
| 239 var message = new codec.Message(testMessage.buffer, handles); | 247 var message = new codec.Message(testMessage.buffer, handles); |
| 240 var messageValidator = new validator.Validator(message); | 248 var messageValidator = new validator.Validator(message); |
| 241 | 249 |
| 242 var err = messageValidator.validateMessageHeader(); | 250 var err = messageValidator.validateMessageHeader(); |
| 243 for (var j = 0; err === noError && j < filters.length; ++j) | 251 for (var j = 0; err === noError && j < filters.length; ++j) |
| 244 err = filters[j](messageValidator); | 252 err = filters[j](messageValidator); |
| 245 | 253 |
| 246 checkValidationResult(testFiles[i], err); | 254 checkValidationResult(testFiles[i], err); |
| 247 } | 255 } |
| 248 } | 256 } |
| 249 | 257 |
| 250 function testConformanceMessageValidation() { | 258 function testConformanceMessageValidation() { |
| 251 testMessageValidation("conformance_", [ | 259 testMessageValidation("conformance_", [ |
| 252 testInterface.ConformanceTestInterface.validateRequest]); | 260 testInterface.ConformanceTestInterface.validateRequest]); |
| 253 } | 261 } |
| 254 | 262 |
| 255 function testIntegratedMessageValidation(testFilesPattern) { | 263 function testIntegratedMessageValidation(testFilesPattern) { |
| 256 var testFiles = getMessageTestFiles(testFilesPattern); | 264 var testFiles = getMessageTestFiles(testFilesPattern); |
| 257 expect(testFiles.length).toBeGreaterThan(0); | 265 expect(testFiles.length).toBeGreaterThan(0); |
| 258 | 266 |
| 259 for (var i = 0; i < testFiles.length; i++) { | 267 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]); | 268 var testMessage = readTestMessage(testFiles[i]); |
| 267 var handles = new Array(testMessage.handleCount); | 269 var handles = new Array(testMessage.handleCount); |
| 268 var testMessagePipe = new core.createMessagePipe(); | 270 var testMessagePipe = new core.createMessagePipe(); |
| 269 expect(testMessagePipe.result).toBe(core.RESULT_OK); | 271 expect(testMessagePipe.result).toBe(core.RESULT_OK); |
| 270 | 272 |
| 271 var writeMessageValue = core.writeMessage( | 273 var writeMessageValue = core.writeMessage( |
| 272 testMessagePipe.handle0, | 274 testMessagePipe.handle0, |
| 273 new Uint8Array(testMessage.buffer.arrayBuffer), | 275 new Uint8Array(testMessage.buffer.arrayBuffer), |
| 274 new Array(testMessage.handleCount), | 276 new Array(testMessage.handleCount), |
| 275 core.WRITE_MESSAGE_FLAG_NONE); | 277 core.WRITE_MESSAGE_FLAG_NONE); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 305 testIntegratedMessageValidation("integration_intf_resp"); | 307 testIntegratedMessageValidation("integration_intf_resp"); |
| 306 } | 308 } |
| 307 | 309 |
| 308 expect(checkTestMessageParser()).toBeNull(); | 310 expect(checkTestMessageParser()).toBeNull(); |
| 309 testConformanceMessageValidation(); | 311 testConformanceMessageValidation(); |
| 310 testIntegratedMessageHeaderValidation(); | 312 testIntegratedMessageHeaderValidation(); |
| 311 testIntegratedResponseMessageValidation(); | 313 testIntegratedResponseMessageValidation(); |
| 312 testIntegratedRequestMessageValidation(); | 314 testIntegratedRequestMessageValidation(); |
| 313 this.result = "PASS"; | 315 this.result = "PASS"; |
| 314 }); | 316 }); |
| OLD | NEW |