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

Side by Side Diff: mojo/apps/js/test/js_to_cpp_unittest.js

Issue 282063003: Fix handling of null pointers in JS bindings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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('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 11 matching lines...) Expand all
22 this.cppSide_ = cppSide; 22 this.cppSide_ = cppSide;
23 cppSide.startTest(); 23 cppSide.startTest();
24 } 24 }
25 25
26 JsSideConnection.prototype = Object.create(jsToCpp.JsSideStub.prototype); 26 JsSideConnection.prototype = Object.create(jsToCpp.JsSideStub.prototype);
27 27
28 JsSideConnection.prototype.ping = function (arg) { 28 JsSideConnection.prototype.ping = function (arg) {
29 this.cppSide_.pingResponse(); 29 this.cppSide_.pingResponse();
30 }; 30 };
31 31
32 JsSideConnection.prototype.echo = function (numIterations, arg) { 32 JsSideConnection.prototype.echo = function (numIterations, list) {
33 var arg = list.item;
33 var arg2; 34 var arg2;
34 var dataPipe1; 35 var dataPipe1;
35 var dataPipe2; 36 var dataPipe2;
36 var i; 37 var i;
38 var list;
Matt Perry 2014/05/16 18:39:04 this looks unused
37 var messagePipe1; 39 var messagePipe1;
38 var messagePipe2; 40 var messagePipe2;
39 41
40 // Ensure expected negative values are negative. 42 // Ensure expected negative values are negative.
41 if (arg.si64 > 0) 43 if (arg.si64 > 0)
42 arg.si64 = BAD_VALUE; 44 arg.si64 = BAD_VALUE;
43 45
44 if (arg.si32 > 0) 46 if (arg.si32 > 0)
45 arg.si32 = BAD_VALUE; 47 arg.si32 = BAD_VALUE;
46 48
(...skipping 16 matching lines...) Expand all
63 arg2.si64 = -1; 65 arg2.si64 = -1;
64 arg2.si32 = -1; 66 arg2.si32 = -1;
65 arg2.si16 = -1; 67 arg2.si16 = -1;
66 arg2.si8 = -1; 68 arg2.si8 = -1;
67 arg2.name = 'going'; 69 arg2.name = 'going';
68 arg2.data_handle = dataPipe2.consumerHandle; 70 arg2.data_handle = dataPipe2.consumerHandle;
69 arg2.message_handle = messagePipe2.handle1; 71 arg2.message_handle = messagePipe2.handle1;
70 72
71 writeDataPipe(dataPipe1, senderData); 73 writeDataPipe(dataPipe1, senderData);
72 writeDataPipe(dataPipe2, senderData); 74 writeDataPipe(dataPipe2, senderData);
73 this.cppSide_.echoResponse(arg, arg2); 75
76 var list = new jsToCpp.EchoArgsList();
Matt Perry 2014/05/16 18:39:04 use a different variable name - this one shadows t
Tom Sepez 2014/05/16 18:57:17 Yeah, I noticed this soon after posting this. Done
77 list.next = new jsToCpp.EchoArgsList();
78 list.item = arg2;
79 list.next.item = arg;
80
81 this.cppSide_.echoResponse(list);
74 82
75 core.close(dataPipe1.producerHandle); 83 core.close(dataPipe1.producerHandle);
76 core.close(dataPipe2.producerHandle); 84 core.close(dataPipe2.producerHandle);
77 core.close(messagePipe1.handle0); 85 core.close(messagePipe1.handle0);
78 core.close(messagePipe2.handle0); 86 core.close(messagePipe2.handle0);
79 } 87 }
80 this.cppSide_.testFinished(); 88 this.cppSide_.testFinished();
81 }; 89 };
82 90
83 JsSideConnection.prototype.bitFlip = function (arg) { 91 JsSideConnection.prototype.bitFlip = function (arg) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 return function(handle) { 145 return function(handle) {
138 var i; 146 var i;
139 senderData = new Uint8Array(DATA_PIPE_PARAMS.capacityNumBytes); 147 senderData = new Uint8Array(DATA_PIPE_PARAMS.capacityNumBytes);
140 for (i = 0; i < senderData.length; ++i) 148 for (i = 0; i < senderData.length; ++i)
141 senderData[i] = i; 149 senderData[i] = i;
142 150
143 retainedConnection = new connection.Connection(handle, JsSideConnection, 151 retainedConnection = new connection.Connection(handle, JsSideConnection,
144 jsToCpp.CppSideProxy); 152 jsToCpp.CppSideProxy);
145 }; 153 };
146 }); 154 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698