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

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

Issue 11745015: Update references to the extension messaging APIs to point to the "runtime" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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.extension.sendNativeMessage( 10 chrome.runtime.sendNativeMessage(
11 'echo.py', message, 11 'echo.py', message,
12 chrome.test.callbackPass(function(nativeResponse) { 12 chrome.test.callbackPass(function(nativeResponse) {
13 var expectedResponse = {"id": 1, "echo": message}; 13 var expectedResponse = {"id": 1, "echo": message};
14 chrome.test.assertEq(expectedResponse, nativeResponse); 14 chrome.test.assertEq(expectedResponse, nativeResponse);
15 })); 15 }));
16 }, 16 },
17 17
18 // The goal of this test, is just not to crash. 18 // The goal of this test, is just not to crash.
19 function sendMessageWithoutCallback() { 19 function sendMessageWithoutCallback() {
20 var message = {"text": "Hi there!", "number": 3}; 20 var message = {"text": "Hi there!", "number": 3};
21 chrome.extension.sendNativeMessage('echo.py', message); 21 chrome.runtime.sendNativeMessage('echo.py', message);
22 chrome.test.succeed(); // Mission Complete 22 chrome.test.succeed(); // Mission Complete
23 }, 23 },
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.extension.connectNative('echo.py', 34 port = chrome.runtime.connectNative('echo.py',
35 messagesToSend[currentMessage]); 35 messagesToSend[currentMessage]);
36 port.onMessage.addListener(function(message) { 36 port.onMessage.addListener(function(message) {
37 chrome.test.assertEq(expectedResponses[currentMessage], message); 37 chrome.test.assertEq(expectedResponses[currentMessage], message);
38 currentMessage++; 38 currentMessage++;
39 39
40 if (currentMessage == expectedResponses.length) 40 if (currentMessage == expectedResponses.length)
41 chrome.test.notifyPass(); 41 chrome.test.notifyPass();
42 else 42 else
43 port.postMessage(messagesToSend[currentMessage]); 43 port.postMessage(messagesToSend[currentMessage]);
44 }); 44 });
45 } 45 }
46 ]); 46 ]);
47 }); 47 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698