blob: a6d13ec5582e0eb95ebf67b10d186ea4ed0e8193 [file] [log] [blame]
<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../../resources/testdriver.js"></script>
<script src="../../resources/testdriver-vendor.js"></script>
<script src="../../external/wpt/bluetooth/resources/bluetooth-helpers.js"></script>
<script src="../../external/wpt/bluetooth/resources/bluetooth-scanning-helpers.js"></script>
<script>
'use strict';
const test_desc = 'requestLEScan with uuid filter.';
bluetooth_test(async (t) => {
const fake_central =
await navigator.bluetooth.test.simulateCentral({state: 'powered-on'});
await callWithTrustedClick(async () => {
await navigator.bluetooth.requestLEScan({filters: [{services: [health_uuid]}]})
});
const eventWatcher = new EventWatcher(t,
navigator.bluetooth, ['advertisementreceived']);
let promise = eventWatcher.wait_for('advertisementreceived').then(e => {
// Note that the simulated scan used 'generic_access' which is defined by
// https://www.bluetooth.com/specifications/gatt/services. WebBluetooth returns
// the actual uuid value which is used below.
assert_array_equals(e.uuids, ["00001800-0000-1000-8000-00805f9b34fb", health_uuid]);
});
let scan = {
deviceAddress: '09:09:09:09:09:09',
rssi: 100,
scanRecord: {
txPower: 20,
},
};
// This scan is missing the uuids that the filters is looking for.
fake_central.simulateAdvertisementReceived(scan);
// Our filter is looking for one of these uuids
scan.scanRecord.uuids = ['generic_access', health_uuid];
fake_central.simulateAdvertisementReceived(scan);
return promise;
}, test_desc);
</script>