OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "gin/test/expect", | 6 "gin/test/expect", |
7 "mojo/bindings/js/core", | 7 "mojo/bindings/js/core", |
8 ], function(expect, core) { | 8 "gc", |
| 9 ], function(expect, core, gc) { |
9 runWithMessagePipe(testNop); | 10 runWithMessagePipe(testNop); |
10 runWithMessagePipe(testReadAndWriteMessage); | 11 runWithMessagePipe(testReadAndWriteMessage); |
11 runWithDataPipe(testNop); | 12 runWithDataPipe(testNop); |
12 runWithDataPipe(testReadAndWriteDataPipe); | 13 runWithDataPipe(testReadAndWriteDataPipe); |
| 14 gc.collectGarbage(); // should not crash |
13 this.result = "PASS"; | 15 this.result = "PASS"; |
14 | 16 |
15 function runWithMessagePipe(test) { | 17 function runWithMessagePipe(test) { |
16 var pipe = core.createMessagePipe(); | 18 var pipe = core.createMessagePipe(); |
17 | 19 |
18 test(pipe); | 20 test(pipe); |
19 | 21 |
20 expect(core.close(pipe.handle0)).toBe(core.RESULT_OK); | 22 expect(core.close(pipe.handle0)).toBe(core.RESULT_OK); |
21 expect(core.close(pipe.handle1)).toBe(core.RESULT_OK); | 23 expect(core.close(pipe.handle1)).toBe(core.RESULT_OK); |
22 } | 24 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 82 |
81 expect(read.result).toBe(core.RESULT_OK); | 83 expect(read.result).toBe(core.RESULT_OK); |
82 expect(read.buffer.byteLength).toBe(42); | 84 expect(read.buffer.byteLength).toBe(42); |
83 | 85 |
84 var memory = new Uint8Array(read.buffer); | 86 var memory = new Uint8Array(read.buffer); |
85 for (var i = 0; i < memory.length; ++i) | 87 for (var i = 0; i < memory.length; ++i) |
86 expect(memory[i]).toBe((i * i) & 0xFF); | 88 expect(memory[i]).toBe((i * i) & 0xFF); |
87 } | 89 } |
88 | 90 |
89 }); | 91 }); |
OLD | NEW |