- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / api_test / rtc_private / events / 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 action_counter = 0;
6
7 chrome.rtcPrivate.onLaunch.addListener(function(launchData) {
8   if(!launchData) {
9     console.log('HANDLER: got default action');
10     action_counter++;
11     return;
12   }
13
14   var action = launchData.intent.action;
15   if (action == 'chat' || action == 'video' || action == 'voice') {
16     console.log('HANDLER: Received ' + action +
17       ', data = ' + launchData.intent.data);
18     var data = launchData.intent.data;
19     var type = launchData.intent.type;
20     if (type != 'application/vnd.chromium.contact' ||
21         data.name != 'Test Contact' ||
22         data.phone.length != 2 ||
23         data.phone[0] != '(555) 111-2222' ||
24         data.phone[1] != '(555) 333-4444' ||
25         data.email.length != 2 ||
26         data.email[0] != 'test_1@something.com' ||
27         data.email[1] != 'test_2@something.com') {
28       chrome.test.fail('HANDLER: Invalid data!');
29       return;
30     }
31     action_counter++;
32     if (action_counter == 4)
33       chrome.test.sendMessage('received_all');
34   } else {
35     console.log('HANDLER: unknown action - ' + action);
36     chrome.test.fail('HANDLER: No content changed!');
37     return;
38   }
39 });