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

Side by Side Diff: content/test/data/web_ui_mojo.js

Issue 268593002: Move existing Mojo JS <--> CPP tests out of webui test harness. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unused header include. 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('main', [ 5 define('main', [
6 'mojo/public/js/bindings/connection', 6 'mojo/public/js/bindings/connection',
7 'content/test/data/web_ui_test_mojo_bindings.mojom', 7 'content/test/data/web_ui_test_mojo_bindings.mojom',
8 ], function (connection, bindings) { 8 ], function (connection, bindings) {
9 var retainedConnection, kIterations = 100, kBadValue = 13; 9 var retainedConnection;
10 10
11 function RendererTargetTest(bindings) { 11 function RendererTargetTest(bindings) {
12 this.bindings_ = bindings; 12 this.bindings_ = bindings;
13 } 13 }
14 14
15 // TODO(aa): It is a bummer to need this stub object in JavaScript. We should 15 // TODO(aa): It is a bummer to need this stub object in JavaScript. We should
16 // have a 'client' object that contains both the sending and receiving bits of 16 // have a 'client' object that contains both the sending and receiving bits of
17 // the client side of the interface. Since JS is loosely typed, we do not need 17 // the client side of the interface. Since JS is loosely typed, we do not need
18 // a separate base class to inherit from to receive callbacks. 18 // a separate base class to inherit from to receive callbacks.
19 RendererTargetTest.prototype = 19 RendererTargetTest.prototype =
20 Object.create(bindings.RendererTargetStub.prototype); 20 Object.create(bindings.RendererTargetStub.prototype);
21 21
22 RendererTargetTest.prototype.ping = function () { 22 RendererTargetTest.prototype.ping = function () {
23 this.bindings_.pingResponse(); 23 this.bindings_.pingResponse();
24 }; 24 };
25 25
26 RendererTargetTest.prototype.echo = function (arg) {
27 var i;
28
29 // Ensure negative values are negative.
30 if (arg.si64 > 0)
31 arg.si64 = kBadValue;
32
33 if (arg.si32 > 0)
34 arg.si32 = kBadValue;
35
36 if (arg.si16 > 0)
37 arg.si16 = kBadValue;
38
39 if (arg.si8 > 0)
40 arg.si8 = kBadValue;
41
42 for (i = 0; i < kIterations; ++i) {
43 arg2 = new bindings.EchoArgs();
44 arg2.si64 = -1;
45 arg2.si32 = -1;
46 arg2.si16 = -1;
47 arg2.si8 = -1;
48 arg2.name = "going";
49 this.bindings_.echoResponse(arg, arg2);
50 }
51 };
52
53 return function(handle) { 26 return function(handle) {
54 retainedConnection = new connection.Connection( 27 retainedConnection = new connection.Connection(
55 handle, RendererTargetTest, bindings.BrowserTargetProxy); 28 handle, RendererTargetTest, bindings.BrowserTargetProxy);
56 }; 29 };
57 }); 30 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698