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

Side by Side Diff: ios/web/test/data/mojo_test.js

Issue 2028013003: [ios Mojo] Integration test for Mojo WebUI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Created 4 years, 6 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
« no previous file with comments | « ios/web/test/data/mojo_test.html ('k') | ios/web/test/test_resources.grd » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // This module provides the test page for WebUIMojoTest. Once the page is
6 // loaded it sends "syn" message to the native code. Once page receives "ack"
7 // from the native code, the page then sends "fin". Test succeeds only when
8 // "fin" is received by the native page. Refer to
9 // ios/web/webui/web_ui_mojo_inttest.mm for testing code.
10
11 define('main', [
12 'mojo/public/js/bindings',
13 'mojo/public/js/core',
14 'mojo/public/js/connection',
15 'ios/web/test/mojo_test.mojom',
16 'content/public/renderer/service_provider',
17 ], function(bindings, core, connection, browser, serviceProvider) {
18
19 var page;
20
21 function TestPageImpl(browser) {
22 this.browser_ = browser;
23 };
24
25 TestPageImpl.prototype = Object.create(browser.TestPage.stubClass.prototype);
26
27 /**
28 * Sends message as a string to the native code.
29 *
30 * @param {string} message Message to send.
31 */
32 TestPageImpl.prototype.sendMessage = function(message) {
33 var pipe = core.createMessagePipe();
34 var stub = connection.bindHandleToStub(pipe.handle0, browser.TestPage);
35 bindings.StubBindings(stub).delegate = page;
36 page.stub_ = stub;
37 this.browser_.handleJsMessage(message, pipe.handle1);
38 };
39
40 /**
41 * Called by native code with "ack" message.
42 *
43 * @param {!NativeMessageResultMojo} result Object received from the native
44 code.
45 */
46 TestPageImpl.prototype.handleNativeMessage = function(result) {
47 if (result.message == 'ack') {
48 // Native code has replied with "ack", send "fin" to complete the test.
49 this.sendMessage('fin');
50 }
51 };
52
53 return function() {
54 var browserProxy = connection.bindHandleToProxy(
55 serviceProvider.connectToService(browser.TestUIHandlerMojo.name),
56 browser.TestUIHandlerMojo);
57
58 page = new TestPageImpl(browserProxy);
59
60 // Send "syn" so native code should reply with "ack".
61 page.sendMessage('syn');
62 };
63 });
OLDNEW
« no previous file with comments | « ios/web/test/data/mojo_test.html ('k') | ios/web/test/test_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698