gen-get-different-service-after-reconnection.https.window.js (2006B)
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 = 11 'Calls to getPrimaryService after a disconnection should return ' + 12 'a different object.'; 13 let device, services_first_connection, services_second_connection; 14 15 bluetooth_bidi_test( 16 () => getHealthThermometerDevice({ 17 filters: [{services: ['health_thermometer']}], 18 optionalServices: ['generic_access'] 19 }) 20 .then(_ => ({device} = _)) 21 .then(() => device.gatt.getPrimaryService('health_thermometer')) 22 .then(services => services_first_connection = services) 23 .then(() => device.gatt.disconnect()) 24 .then(() => device.gatt.connect()) 25 .then(() => device.gatt.getPrimaryService('health_thermometer')) 26 .then(services => services_second_connection = services) 27 .then(() => { 28 // Convert to arrays if necessary. 29 services_first_connection = 30 [].concat(services_first_connection); 31 services_second_connection = 32 [].concat(services_second_connection); 33 34 assert_equals( 35 services_first_connection.length, 36 services_second_connection.length); 37 38 let first_connection_set = new Set(services_first_connection); 39 let second_connection_set = new Set(services_second_connection); 40 41 // The two sets should be disjoint. 42 let common_services = services_first_connection.filter( 43 val => second_connection_set.has(val)); 44 assert_equals(common_services.length, 0); 45 }), 46 test_desc);