tor-browser

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

gen-disconnect-invalidates-objects-with-uuid.https.window.js (2040B)


      1 // META: script=/resources/testdriver.js?feature=bidi
      2 // META: script=/resources/testdriver-vendor.js
      3 // META: script=/common/gc.js
      4 // META: script=/bluetooth/resources/bluetooth-test.js
      5 // META: script=/bluetooth/resources/bluetooth-fake-devices.js
      6 // META: timeout=long
      7 // Generated by
      8 // //bluetooth/bidi/generate.py
      9 'use strict';
     10 const test_desc = 'Calls on services after we disconnect and connect again. ' +
     11    'Should reject with InvalidStateError.';
     12 let device, services;
     13 
     14 bluetooth_bidi_test(
     15    () => getHealthThermometerDevice(
     16              {filters: [{services: ['health_thermometer']}]})
     17              .then(_ => ({device} = _))
     18              .then(() => device.gatt.getPrimaryServices('health_thermometer'))
     19              // Convert to array if necessary.
     20              .then(s => services = [].concat(s))
     21              .then(() => device.gatt.disconnect())
     22              .then(() => device.gatt.connect())
     23              .then(() => {
     24                let promises = Promise.resolve();
     25                for (let service of services) {
     26                  let error = new DOMException(
     27                      `Service with UUID ${
     28                          service.uuid} is no longer valid. Remember ` +
     29                          `to retrieve the service again after reconnecting.`,
     30                      'InvalidStateError');
     31                  promises = promises.then(
     32                      () => assert_promise_rejects_with_message(
     33                          service.getCharacteristic('measurement_interval'),
     34                          error));
     35                  promises = promises.then(
     36                      () => assert_promise_rejects_with_message(
     37                          service.getCharacteristics(), error));
     38                  promises = promises.then(
     39                      () => assert_promise_rejects_with_message(
     40                          service.getCharacteristics('measurement_interval'),
     41                          error));
     42                }
     43                return promises;
     44              }),
     45    test_desc);