- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / platform_apps / messaging / app2 / background.js
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 var otherId = 'ljhhihhmjomkjokmknellgbidphmahkh';
6
7 chrome.runtime.onConnectExternal.addListener(function(port) {
8   port.onMessage.addListener(function(msg) {
9     if (msg == 'ok_to_disconnect') {
10       port.disconnect();
11     } else {
12       port.postMessage(msg + '_reply');
13     }
14   });
15 });
16
17 chrome.runtime.onMessageExternal.addListener(function(msg, sender, callback) {
18   chrome.test.assertEq({id: otherId}, sender);
19   if (msg == 'hello')
20     callback('hello_response');
21   else
22     callback();
23 });