tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

simulate_characteristic.https.html (1903B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8" />
      3 <meta name="timeout" content="long">
      4 <title>TestDriver bidi.bluetooth.simulate_characteristic method</title>
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <script src="/resources/testdriver.js?feature=bidi"></script>
      8 <script src="/resources/testdriver-vendor.js"></script>
      9 <script src="resources/bidi-bluetooth-helper.js"></script>
     10 
     11 <script>
     12    promise_setup(async () => {
     13        await test_driver.bidi.bluetooth.request_device_prompt_updated.subscribe();
     14        await test_driver.bidi.bluetooth.gatt_connection_attempted.subscribe();
     15    });
     16 
     17    bluetooth_test(async (t) => {
     18        const handle_prompt_promise = selectFirstDeviceOnDevicePromptUpdated();
     19        const [device] = await Promise.all([requestDeviceWithTrustedClick({
     20            acceptAllDevices: true,
     21            optionalServices: [HEART_RATE_SERVICE_UUID]
     22        }), handle_prompt_promise]);
     23 
     24        await createGattConnection(device);
     25        await test_driver.bidi.bluetooth.simulate_service({
     26            address: DEVICE_ADDRESS,
     27            uuid: HEART_RATE_SERVICE_UUID,
     28            type: 'add',
     29        });
     30        await test_driver.bidi.bluetooth.simulate_characteristic({
     31            address: DEVICE_ADDRESS,
     32            serviceUuid: HEART_RATE_SERVICE_UUID,
     33            characteristicUuid: DATE_TIME_CHARACTERISTIC_UUID,
     34            characteristicProperties: {
     35                'read': true
     36            },
     37            type: 'add',
     38        });
     39        service = await device.gatt.getPrimaryService(HEART_RATE_SERVICE_UUID);
     40        characteristics = await service.getCharacteristics();
     41        assert_equals(
     42            JSON.stringify(characteristics.map(characteristic => characteristic.uuid)),
     43            JSON.stringify([DATE_TIME_CHARACTERISTIC_UUID])
     44        );
     45    }, "simulate a GATT characteristic.");
     46 </script>