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

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

Issue 11968028: Remove connect message from Native Messaging API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 (c) 2012 The Chromium Authors. All rights reserved. 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 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 chrome.test.getConfig(function(config) { 5 chrome.test.getConfig(function(config) {
6 chrome.test.runTests([ 6 chrome.test.runTests([
7 7
8 function sendMessageWithCallback() { 8 function sendMessageWithCallback() {
9 var message = {"text": "Hi there!", "number": 3}; 9 var message = {"text": "Hi there!", "number": 3};
10 chrome.runtime.sendNativeMessage( 10 chrome.runtime.sendNativeMessage(
(...skipping 13 matching lines...) Expand all
24 24
25 function connect() { 25 function connect() {
26 var messagesToSend = [{"text": "foo"}, 26 var messagesToSend = [{"text": "foo"},
27 {"text": "bar", "funCount": 9001}, 27 {"text": "bar", "funCount": 9001},
28 {}]; 28 {}];
29 var expectedResponses = [{"id": 1, "echo": messagesToSend[0]}, 29 var expectedResponses = [{"id": 1, "echo": messagesToSend[0]},
30 {"id": 2, "echo": messagesToSend[1]}, 30 {"id": 2, "echo": messagesToSend[1]},
31 {"id": 3, "echo": messagesToSend[2]}]; 31 {"id": 3, "echo": messagesToSend[2]}];
32 var currentMessage = 0; 32 var currentMessage = 0;
33 33
34 port = chrome.runtime.connectNative('echo.py', 34 port = chrome.runtime.connectNative('echo.py');
35 messagesToSend[currentMessage]); 35 port.postMessage(messagesToSend[currentMessage]);
36
36 port.onMessage.addListener(function(message) { 37 port.onMessage.addListener(function(message) {
37 chrome.test.assertEq(expectedResponses[currentMessage], message); 38 chrome.test.assertEq(expectedResponses[currentMessage], message);
38 currentMessage++; 39 currentMessage++;
39 40
40 if (currentMessage == expectedResponses.length) 41 if (currentMessage == expectedResponses.length)
41 chrome.test.notifyPass(); 42 chrome.test.notifyPass();
42 else 43 else
43 port.postMessage(messagesToSend[currentMessage]); 44 port.postMessage(messagesToSend[currentMessage]);
44 }); 45 });
45 } 46 }
46 ]); 47 ]);
47 }); 48 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698