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('mojo/apps/js/test/js_to_cpp_unittest', [ | 5 define('mojo/apps/js/test/js_to_cpp_unittest', [ |
6 'console', | 6 'console', |
7 'mojo/apps/js/test/js_to_cpp.mojom', | 7 'mojo/apps/js/test/js_to_cpp.mojom', |
8 'mojo/public/js/bindings/connection', | 8 'mojo/public/js/bindings/connection', |
9 'mojo/public/js/bindings/connector', | 9 'mojo/public/js/bindings/connector', |
10 'mojo/public/js/bindings/core', | 10 'mojo/public/js/bindings/core', |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 var proto = connector.Connector.prototype; | 91 var proto = connector.Connector.prototype; |
92 var stopSignalled = false; | 92 var stopSignalled = false; |
93 | 93 |
94 proto.realAccept = proto.accept; | 94 proto.realAccept = proto.accept; |
95 proto.accept = function (message) { | 95 proto.accept = function (message) { |
96 var offset = iteration / 8; | 96 var offset = iteration / 8; |
97 var mask; | 97 var mask; |
98 var value; | 98 var value; |
99 if (offset < message.buffer.arrayBuffer.byteLength) { | 99 if (offset < message.buffer.arrayBuffer.byteLength) { |
100 mask = 1 << (iteration % 8); | 100 mask = 1 << (iteration % 8); |
101 value = message.buffer.dataView.getUint8(offset) ^ mask; | 101 value = message.buffer.getUint8(offset) ^ mask; |
102 message.buffer.dataView.setUint8(offset, value); | 102 message.buffer.setUint8(offset, value); |
103 return this.realAccept(message); | 103 return this.realAccept(message); |
104 } | 104 } |
105 stopSignalled = true; | 105 stopSignalled = true; |
106 return false; | 106 return false; |
107 }; | 107 }; |
108 | 108 |
109 while (!stopSignalled) { | 109 while (!stopSignalled) { |
110 dataPipe = core.createDataPipe(DATA_PIPE_PARAMS); | 110 dataPipe = core.createDataPipe(DATA_PIPE_PARAMS); |
111 messagePipe = core.createMessagePipe(); | 111 messagePipe = core.createMessagePipe(); |
112 writeDataPipe(dataPipe, sampleData); | 112 writeDataPipe(dataPipe, sampleData); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 sampleData[i] = i; | 211 sampleData[i] = i; |
212 } | 212 } |
213 sampleMessage = new Uint8Array(DATA_PIPE_PARAMS.capacityNumBytes); | 213 sampleMessage = new Uint8Array(DATA_PIPE_PARAMS.capacityNumBytes); |
214 for (i = 0; i < sampleMessage.length; ++i) { | 214 for (i = 0; i < sampleMessage.length; ++i) { |
215 sampleMessage[i] = 255 - i; | 215 sampleMessage[i] = 255 - i; |
216 } | 216 } |
217 retainedConnection = new connection.Connection(handle, JsSideConnection, | 217 retainedConnection = new connection.Connection(handle, JsSideConnection, |
218 jsToCpp.CppSideProxy); | 218 jsToCpp.CppSideProxy); |
219 }; | 219 }; |
220 }); | 220 }); |
OLD | NEW |