Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / api_test / gcd_private / api / session.js
1 // Copyright 2014 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 onload = function() {
6   chrome.test.runTests([
7     function session() {
8       function onConfirmCode(sessionId, status, confirmationInfo) {
9         chrome.test.assertEq("success", status);
10         chrome.test.assertEq("1234", confirmationInfo.code);
11         chrome.test.assertEq("displayCode", confirmationInfo.type);
12
13         chrome.gcdPrivate.confirmCode(sessionId,
14                                       "1234",
15                                       onSessionEstablished.bind(null,
16                                                                 sessionId));
17       }
18
19       function onSessionEstablished(sessionId, status) {
20         chrome.test.assertEq("success", status);
21
22         chrome.gcdPrivate.sendMessage(sessionId, "/privet/ping", {},
23                                       onMessageSent);
24       }
25
26       function onMessageSent(status, output) {
27         chrome.test.assertEq("success", status);
28         chrome.test.assertEq("pong", output.response);
29
30         chrome.test.notifyPass();
31       }
32
33       chrome.gcdPrivate.establishSession("1.2.3.4", 9090, onConfirmCode);
34     }
35   ]);
36 };