OLD | NEW |
---|---|
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 var otherId = 'ljhhihhmjomkjokmknellgbidphmahkh'; | 5 var otherId = 'ljhhihhmjomkjokmknellgbidphmahkh'; |
6 | 6 |
7 chrome.test.sendMessage('Launched'); | |
8 | |
9 chrome.runtime.onConnectExternal.addListener(function(port) { | 7 chrome.runtime.onConnectExternal.addListener(function(port) { |
10 port.onMessage.addListener(function(msg) { | 8 port.onMessage.addListener(function(msg) { |
11 if (msg == 'ok_to_disconnect') { | 9 if (msg == 'ok_to_disconnect') { |
12 port.disconnect(); | 10 port.disconnect(); |
13 } else { | 11 } else { |
14 port.postMessage(msg + '_reply'); | 12 port.postMessage(msg + '_reply'); |
15 } | 13 } |
16 }); | 14 }); |
17 }); | 15 }); |
18 | 16 |
19 chrome.runtime.onMessageExternal.addListener(function(msg, sender, callback) { | 17 chrome.runtime.onMessageExternal.addListener(function(msg, sender, callback) { |
20 chrome.test.assertEq({id: otherId}, sender); | 18 chrome.test.assertEq({id: otherId}, sender); |
21 if (msg == 'hello') | 19 if (msg == 'hello') |
22 callback('hello_response'); | 20 callback('hello_response'); |
23 else | 21 else |
24 callback(); | 22 callback(); |
25 }); | 23 }); |
24 | |
25 chrome.test.sendMessage('Ready'); | |
Matt Giuca
2014/08/06 05:20:03
// Must ensure that the listeners are active befor
benwells
2014/08/06 05:41:39
Done.
| |
OLD | NEW |