gen-descriptor-get-same-object.https.window.js (1653B)
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 getDescriptor should return the same object.'; 11 let characteristic; 12 13 bluetooth_bidi_test( 14 () => getMeasurementIntervalCharacteristic() 15 .then(_ => ({characteristic} = _)) 16 .then(() => Promise.all([ 17 characteristic.getDescriptor(user_description.alias), 18 characteristic.getDescriptor(user_description.name), 19 characteristic.getDescriptor(user_description.uuid) 20 ])) 21 .then(descriptors_arrays => { 22 assert_true(descriptors_arrays.length > 0) 23 24 // Convert to arrays if necessary. 25 for (let i = 0; i < descriptors_arrays.length; i++) { 26 descriptors_arrays[i] = [].concat(descriptors_arrays[i]); 27 } 28 29 for (let i = 1; i < descriptors_arrays.length; i++) { 30 assert_equals( 31 descriptors_arrays[0].length, 32 descriptors_arrays[i].length); 33 } 34 35 let base_set = new Set(descriptors_arrays[0]); 36 for (let descriptors of descriptors_arrays) { 37 descriptors.forEach( 38 descriptor => assert_true(base_set.has(descriptor))); 39 } 40 }), 41 test_desc);