https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 6f869cd68557949f12ca6b640ddbd8c505a4decb authored by L. David Baron on 09 April 2018, 04:44:44 UTC
Sync Mozilla tests as of https://hg.mozilla.org/mozilla-central/rev/b4bc6b2401738b78fd47127a4c716bb9178e1a09 .
Tip revision: 6f869cd
blocklisted-service-in-optionalServices.https.html
<!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-helpers.js"></script>
<script>
'use strict';
const test_desc = 'Blocklisted UUID in optionalServices is removed and ' +
    'access not granted.';
const expected = new DOMException('Origin is not allowed to access the ' +
    'service. Tip: Add the service UUID to \'optionalServices\' in ' +
    'requestDevice() options. https://goo.gl/HxfxSQ',
    'SecurityError');
let device, fake_peripheral;

bluetooth_test(() => getDiscoveredHealthThermometerDevice({
  filters: [{services: ['health_thermometer']}],
  optionalServices: ['human_interface_device']
})
    .then(_ => ({device, fake_peripheral} = _))
    .then(() =>
        fake_peripheral.setNextGATTConnectionResponse({code: HCI_SUCCESS}))
    .then(() => device.gatt.connect())
    .then(() => Promise.all([
      assert_promise_rejects_with_message(
        device.gatt.getPrimaryService('human_interface_device'),
        expected, 'Blocklisted service not accessible.'),
      assert_promise_rejects_with_message(
        device.gatt.getPrimaryServices('human_interface_device'),
        expected, 'Blocklisted services not accessible.')])),
    test_desc);
</script>
back to top