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

Side by Side Diff: chrome/test/data/extensions/api_test/native_messaging/test.js

Issue 10818013: Native Messaging! (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: nit Created 8 years, 3 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 | « chrome/test/data/extensions/api_test/native_messaging/manifest.json ('k') | no next file » | 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 (c) 2012 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 chrome.test.getConfig(function(config) {
6 chrome.test.runTests([
7
8 function sendMessageWithCallback() {
9 var message = {"text": "Hi there!", "number": 3};
10 chrome.extension.sendNativeMessage(
11 'echo.py', message,
12 chrome.test.callbackPass(function(nativeResponse) {
13 var expectedResponse = {"id": 1, "echo": message};
14 chrome.test.assertEq(expectedResponse, nativeResponse);
15 }));
16 },
17
18 // The goal of this test, is just not to crash.
19 function sendMessageWithoutCallback() {
20 var message = {"text": "Hi there!", "number": 3};
21 chrome.extension.sendNativeMessage('echo.py', message);
22 chrome.test.succeed(); // Mission Complete
23 },
24
25 function connect() {
26 var messagesToSend = [{"text": "foo"},
27 {"text": "bar", "funCount": 9001},
28 {}];
29 var expectedResponses = [{"id": 1, "echo": messagesToSend[0]},
30 {"id": 2, "echo": messagesToSend[1]},
31 {"id": 3, "echo": messagesToSend[2]}];
32 var currentMessage = 0;
33
34 port = chrome.extension.connectNative('echo.py',
35 messagesToSend[currentMessage]);
36 port.onMessage.addListener(function(message) {
37 chrome.test.assertEq(expectedResponses[currentMessage], message);
38 currentMessage++;
39
40 if (currentMessage == expectedResponses.length)
41 chrome.test.notifyPass();
42 else
43 port.postMessage(messagesToSend[currentMessage]);
44 });
45 }
46 ]);
47 });
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/api_test/native_messaging/manifest.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698