Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / api_test / bluetooth_low_energy / get_removed_service / runtest.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 chrome.bluetoothLowEnergy.onServiceAdded.addListener(function (result) {
6   // getService should return this service.
7   chrome.bluetoothLowEnergy.getService(result.instanceId, function (service) {
8     if (chrome.runtime.lastError) {
9       chrome.test.sendMessage(chrome.runtime.lastError.message);
10     }
11
12     chrome.test.assertEq(result.instanceId, service.instanceId);
13
14     chrome.test.sendMessage('getServiceSuccess');
15   });
16 });
17
18 chrome.bluetoothLowEnergy.onServiceRemoved.addListener(function (result) {
19   // getService should return error.
20   chrome.bluetoothLowEnergy.getService(result.instanceId, function (service) {
21     if (service || !chrome.runtime.lastError) {
22       chrome.test.sendMessage('Call to getService should have failed.');
23     }
24
25     chrome.test.sendMessage('getServiceFail', function (message) {
26       chrome.test.succeed();
27     });
28   });
29 });