| <!DOCTYPE html> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| <script src="/resources/testdriver.js"></script> |
| <script src="/resources/testdriver-vendor.js"></script> |
| <script src="/bluetooth/resources/bluetooth-test.js"></script> |
| <script src="/bluetooth/resources/bluetooth-fake-devices.js"></script> |
| <script> |
| 'use strict'; |
| const test_desc = 'Characteristic with exclude-writes fullfills read and ' + |
| 'rejects write.'; |
| const expected = new DOMException( |
| 'writeValue() called on blocklisted object marked exclude-writes. ' + |
| 'https://goo.gl/4NeimX', |
| 'SecurityError'); |
| let characteristic, fake_characteristic; |
| |
| // 1. Connect to the device and retrieve the GATT characteristic. |
| bluetooth_test(() => getBlocklistExcludeWritesCharacteristic() |
| .then(_ => ({characteristic, fake_characteristic} = _)) |
| // 2. Attempt to write and read the characteristic. |
| .then(() => fake_characteristic.setNextReadResponse(HCI_SUCCESS, 'foo')) |
| .then(() => characteristic.readValue()) |
| .then(() => assert_promise_rejects_with_message( |
| characteristic.writeValue(new Uint8Array(1 /* length */)), |
| expected, |
| 'writeValue() should reject.')), |
| test_desc); |
| </script> |