blob: c16752b0792699c4a59ede0478e774c893fdeed9 [file] [log] [blame]
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="../resources/bluetooth/bluetooth-helpers.js"></script>
<script>
test(() => {
assert_throws(null, () => new BluetoothDevice(),
'the constructor should not be callable with "new"');
assert_throws(null, () => BluetoothDevice(),
'the constructor should not be callable');
}, 'BluetoothDevice IDL test');
test(t => { assert_true(window.testRunner instanceof Object); t.done(); },
'window.testRunner is required for the following tests.');
promise_test(() => {
return setBluetoothFakeAdapter('GlucoseHeartRateAdapter')
.then(() => requestDeviceWithKeyDown({
filters: [{services: ['heart_rate']}]}))
.then(device => {
assert_equals(device.constructor.name, 'BluetoothDevice');
// Attempt (and fail) to overwrite all members, verifying they are
// readonly.
var old_device_id = device.id;
device.id = 'overwritten';
device.name = 'overwritten';
device.uuids = 'overwritten';
assert_equals(device.id, old_device_id);
assert_equals(device.name, 'Heart Rate Device');
assert_equals(device.uuids.length, 1);
assert_equals(device.uuids[0], heart_rate.uuid);
});
}, 'BluetoothDevice attributes.');
</script>