https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 2302b20508e95573c2256cd4d4f3b5193759cc67 authored by Jim Evans on 15 March 2018, 19:56:59 UTC
Changing WebDriver test_parent_htmldocument to expect error
Tip revision: 2302b20
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(() =>
        fake_peripheral.setNextGATTDiscoveryResponse({code: HCI_SUCCESS}))
    .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