| 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/bindings", | 10 "mojo/public/js/bindings", |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 } | 271 } |
| 272 | 272 |
| 273 function testIntegratedMessageValidation(testFilesPattern, endpoint) { | 273 function testIntegratedMessageValidation(testFilesPattern, endpoint) { |
| 274 var testFiles = getMessageTestFiles(testFilesPattern); | 274 var testFiles = getMessageTestFiles(testFilesPattern); |
| 275 expect(testFiles.length).toBeGreaterThan(0); | 275 expect(testFiles.length).toBeGreaterThan(0); |
| 276 | 276 |
| 277 var testMessagePipe = core.createMessagePipe(); | 277 var testMessagePipe = core.createMessagePipe(); |
| 278 expect(testMessagePipe.result).toBe(core.RESULT_OK); | 278 expect(testMessagePipe.result).toBe(core.RESULT_OK); |
| 279 | 279 |
| 280 endpoint.bind(testMessagePipe.handle1); | 280 endpoint.bind(testMessagePipe.handle1); |
| 281 var observer = validator.ValidationErrorObserverForTesting.getInstance(); | 281 var testingController = endpoint.enableTestingMode(); |
| 282 |
| 283 var validationError; |
| 284 testingController.setInvalidIncomingMessageHandler(function(error) { |
| 285 validationError = error; |
| 286 }); |
| 282 | 287 |
| 283 for (var i = 0; i < testFiles.length; i++) { | 288 for (var i = 0; i < testFiles.length; i++) { |
| 289 validationError = noError; |
| 284 var testMessage = readTestMessage(testFiles[i]); | 290 var testMessage = readTestMessage(testFiles[i]); |
| 285 var handles = new Array(testMessage.handleCount); | 291 var handles = new Array(testMessage.handleCount); |
| 286 | 292 |
| 287 var writeMessageValue = core.writeMessage( | 293 var writeMessageValue = core.writeMessage( |
| 288 testMessagePipe.handle0, | 294 testMessagePipe.handle0, |
| 289 new Uint8Array(testMessage.buffer.arrayBuffer), | 295 new Uint8Array(testMessage.buffer.arrayBuffer), |
| 290 new Array(testMessage.handleCount), | 296 new Array(testMessage.handleCount), |
| 291 core.WRITE_MESSAGE_FLAG_NONE); | 297 core.WRITE_MESSAGE_FLAG_NONE); |
| 292 expect(writeMessageValue).toBe(core.RESULT_OK); | 298 expect(writeMessageValue).toBe(core.RESULT_OK); |
| 293 | 299 |
| 294 endpoint.waitForNextMessageForTesting(); | 300 testingController.waitForNextMessage(); |
| 295 checkValidationResult(testFiles[i], observer.lastError); | 301 checkValidationResult(testFiles[i], validationError); |
| 296 observer.reset(); | |
| 297 } | 302 } |
| 298 | 303 |
| 299 expect(core.close(testMessagePipe.handle0)).toBe(core.RESULT_OK); | 304 expect(core.close(testMessagePipe.handle0)).toBe(core.RESULT_OK); |
| 300 } | 305 } |
| 301 | 306 |
| 302 function testIntegratedMessageHeaderValidation() { | 307 function testIntegratedMessageHeaderValidation() { |
| 303 testIntegratedMessageValidation( | 308 testIntegratedMessageValidation( |
| 304 "integration_msghdr", | 309 "integration_msghdr", |
| 305 new bindings.Binding(testInterface.IntegrationTestInterface, {})); | 310 new bindings.Binding(testInterface.IntegrationTestInterface, {})); |
| 306 testIntegratedMessageValidation( | 311 testIntegratedMessageValidation( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 321 } | 326 } |
| 322 | 327 |
| 323 expect(checkTestMessageParser()).toBeNull(); | 328 expect(checkTestMessageParser()).toBeNull(); |
| 324 testConformanceMessageValidation(); | 329 testConformanceMessageValidation(); |
| 325 testBoundsCheckMessageValidation(); | 330 testBoundsCheckMessageValidation(); |
| 326 testResponseConformanceMessageValidation(); | 331 testResponseConformanceMessageValidation(); |
| 327 testResponseBoundsCheckMessageValidation(); | 332 testResponseBoundsCheckMessageValidation(); |
| 328 testIntegratedMessageHeaderValidation(); | 333 testIntegratedMessageHeaderValidation(); |
| 329 testIntegratedResponseMessageValidation(); | 334 testIntegratedResponseMessageValidation(); |
| 330 testIntegratedRequestMessageValidation(); | 335 testIntegratedRequestMessageValidation(); |
| 331 validator.clearTestingMode(); | |
| 332 | 336 |
| 333 this.result = "PASS"; | 337 this.result = "PASS"; |
| 334 }); | 338 }); |
| OLD | NEW |