summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/bluetooth/adapter/adapter-added-getAvailability.https.window.js
blob: f8e25b2ac2fc48b865ce7f9e3702a7688f89dbc3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// META: script=/resources/testdriver.js
// META: script=/resources/testdriver-vendor.js
// META: script=/bluetooth/resources/bluetooth-test.js
// META: script=/bluetooth/resources/bluetooth-fake-devices.js
'use strict';
const test_desc = 'getAvailability() resolves with true after adapter is ' +
    'inserted into a system with a platform that supports Bluetooth LE.';

bluetooth_test(async () => {
  const fake_central =
      await navigator.bluetooth.test.simulateCentral({state: 'absent'});
  let availability = await navigator.bluetooth.getAvailability();
  assert_false(
      availability,
      'getAvailability() resolves promise with false when adapter is absent.');

  await fake_central.setState('powered-on');
  availability = await navigator.bluetooth.getAvailability();
  assert_true(
      availability,
      'getAvailability() resolves promise with true after Bluetooth LE ' +
          'capable adapter has been has been added.');
}, test_desc);