- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / api_test / messaging / connect_external / test.js
1 // Copyright (c) 2011 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 testId = "bjafgdebaacbbbecmhlhpofkepfkgcpa";
6
7 // Call with |api| as either chrome.runtime or chrome.extension, so that both
8 // get tested (extension is aliased to runtime).
9 function connectExternalTest(api) {
10   var port = api.connect(testId, {name: "extern"});
11   port.postMessage({testConnectExternal: true});
12   port.onMessage.addListener(chrome.test.callbackPass(function(msg) {
13     chrome.test.assertTrue(msg.success, "Message failed.");
14     chrome.test.assertEq(msg.senderId, location.host,
15                          "Sender ID doesn't match.");
16   }));
17 }
18
19 chrome.test.runTests([
20   function connectExternal_extension() {
21     connectExternalTest(chrome.extension);
22   },
23   function connectExternal_runtime() {
24     connectExternalTest(chrome.runtime);
25   }
26 ]);