idl-BluetoothDevice.https.window.js (1392B)
1 // META: script=/resources/testdriver.js?feature=bidi 2 // META: script=/resources/testdriver-vendor.js 3 // META: script=/bluetooth/resources/bluetooth-test.js 4 // META: script=/bluetooth/resources/bluetooth-fake-devices.js 5 // META: timeout=long 6 'use strict'; 7 const test_desc_idl = 'BluetoothDevice IDL test.'; 8 9 test(() => { 10 assert_throws_js( 11 TypeError, () => new BluetoothDevice(), 12 'the constructor should not be callable with "new"'); 13 assert_throws_js( 14 TypeError, () => BluetoothDevice(), 15 'the constructor should not be callable'); 16 }, test_desc_idl); 17 18 const test_desc_attr = 'BluetoothDevice attributes.'; 19 let device; 20 21 bluetooth_bidi_test(async () => { 22 let {device} = await getConnectedHealthThermometerDevice(); 23 24 assert_equals(device.constructor.name, 'BluetoothDevice'); 25 var old_device_id = device.id; 26 assert_throws_js( 27 TypeError, () => device.id = 'overwritten', 28 'the device id should not be writable'); 29 assert_throws_js( 30 TypeError, () => device.name = 'overwritten', 31 'the device name should not be writable'); 32 assert_throws_js( 33 TypeError, () => device.watchingAdvertisements = true, 34 'the device watchingAdvertisements should not be writable'); 35 assert_equals(device.id, old_device_id); 36 assert_equals(device.name, 'Health Thermometer'); 37 assert_equals(device.watchingAdvertisements, false); 38 }, test_desc_attr);