tor-browser

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

get-same-object.js (1594B)


      1 'use strict';
      2 const test_desc = 'Calls to FUNCTION_NAME should return the same object.';
      3 let device;
      4 
      5 bluetooth_bidi_test(
      6    () => getHealthThermometerDevice({
      7            filters: [{services: ['health_thermometer']}],
      8            optionalServices: ['generic_access']
      9          })
     10              .then(({device}) => Promise.all([
     11                device.gatt.CALLS(
     12                    [getPrimaryService('health_thermometer') |
     13                     getPrimaryServices() |
     14                     getPrimaryServices('health_thermometer')[UUID]]),
     15                device.gatt.PREVIOUS_CALL
     16              ]))
     17              .then(([services_first_call, services_second_call]) => {
     18                // Convert to arrays if necessary.
     19                services_first_call = [].concat(services_first_call);
     20                services_second_call = [].concat(services_second_call);
     21 
     22                assert_equals(
     23                    services_first_call.length, services_second_call.length);
     24 
     25                let first_call_set = new Set(services_first_call);
     26                assert_equals(services_first_call.length, first_call_set.size);
     27                let second_call_set = new Set(services_second_call);
     28                assert_equals(
     29                    services_second_call.length, second_call_set.size);
     30 
     31                services_first_call.forEach(
     32                    service => {assert_true(second_call_set.has(service))});
     33 
     34                services_second_call.forEach(service => {
     35                  assert_true(first_call_set.has(service));
     36                });
     37              }),
     38    test_desc);