tor-browser

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

gen-get-same-object-with-uuid.https.window.js (1803B)


      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 to getPrimaryServices should return the same object.';
     11 let device;
     12 
     13 bluetooth_bidi_test(
     14    () => getHealthThermometerDevice({
     15            filters: [{services: ['health_thermometer']}],
     16            optionalServices: ['generic_access']
     17          })
     18              .then(({device}) => Promise.all([
     19                device.gatt.getPrimaryServices('health_thermometer'),
     20                device.gatt.getPrimaryServices('health_thermometer')
     21              ]))
     22              .then(([services_first_call, services_second_call]) => {
     23                // Convert to arrays if necessary.
     24                services_first_call = [].concat(services_first_call);
     25                services_second_call = [].concat(services_second_call);
     26 
     27                assert_equals(
     28                    services_first_call.length, services_second_call.length);
     29 
     30                let first_call_set = new Set(services_first_call);
     31                assert_equals(services_first_call.length, first_call_set.size);
     32                let second_call_set = new Set(services_second_call);
     33                assert_equals(
     34                    services_second_call.length, second_call_set.size);
     35 
     36                services_first_call.forEach(
     37                    service => {assert_true(second_call_set.has(service))});
     38 
     39                services_second_call.forEach(service => {
     40                  assert_true(first_call_set.has(service));
     41                });
     42              }),
     43    test_desc);