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'; |
| 6 |
5 chrome.runtime.onConnectExternal.addListener(function(port) { | 7 chrome.runtime.onConnectExternal.addListener(function(port) { |
6 port.onMessage.addListener(function(msg) { | 8 port.onMessage.addListener(function(msg) { |
7 if (msg == 'ok_to_disconnect') { | 9 if (msg == 'ok_to_disconnect') { |
8 port.disconnect(); | 10 port.disconnect(); |
9 } else { | 11 } else { |
10 port.postMessage(msg + '_reply'); | 12 port.postMessage(msg + '_reply'); |
11 } | 13 } |
12 }); | 14 }); |
13 }); | 15 }); |
14 | 16 |
15 chrome.runtime.onMessageExternal.addListener(function(msg, sender, callback) { | 17 chrome.runtime.onMessageExternal.addListener(function(msg, sender, callback) { |
| 18 chrome.test.assertEq({id: otherId}, sender); |
16 if (msg == 'hello') | 19 if (msg == 'hello') |
17 callback('hello_response'); | 20 callback('hello_response'); |
18 else | 21 else |
19 callback(); | 22 callback(); |
20 }); | 23 }); |
OLD | NEW |