tor-browser

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

disconnect-invalidates-objects.js (1848B)


      1 'use strict';
      2 const test_desc = 'Calls on services after we disconnect and connect again. ' +
      3    'Should reject with InvalidStateError.';
      4 let device, services;
      5 
      6 bluetooth_bidi_test(
      7    () => getHealthThermometerDevice(
      8              {filters: [{services: ['health_thermometer']}]})
      9              .then(_ => ({device} = _))
     10              .then(() => device.gatt.CALLS([
     11                getPrimaryService('health_thermometer') | getPrimaryServices() |
     12                getPrimaryServices('health_thermometer')[UUID]
     13              ]))
     14              // Convert to array if necessary.
     15              .then(s => services = [].concat(s))
     16              .then(() => device.gatt.disconnect())
     17              .then(() => device.gatt.connect())
     18              .then(() => {
     19                let promises = Promise.resolve();
     20                for (let service of services) {
     21                  let error = new DOMException(
     22                      `Service with UUID ${
     23                          service.uuid} is no longer valid. Remember ` +
     24                          `to retrieve the service again after reconnecting.`,
     25                      'InvalidStateError');
     26                  promises = promises.then(
     27                      () => assert_promise_rejects_with_message(
     28                          service.getCharacteristic('measurement_interval'),
     29                          error));
     30                  promises = promises.then(
     31                      () => assert_promise_rejects_with_message(
     32                          service.getCharacteristics(), error));
     33                  promises = promises.then(
     34                      () => assert_promise_rejects_with_message(
     35                          service.getCharacteristics('measurement_interval'),
     36                          error));
     37                }
     38                return promises;
     39              }),
     40    test_desc);