summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fenced-frame/resources/web-bluetooth-inner.html
blob: 3236886b978995dc37a16cee1d1725d6555233a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<!DOCTYPE html>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="utils.js"></script>
<title>Fenced frame content to test Web Bluetooth</title>

<body>
<button id="button">Button</button>
<script>
(async () => {
  await simulateGesture();
  const [bluetooth_request_device_key] = parseKeylist();
  try {
    await navigator.bluetooth.requestDevice({filters: [{name: 'device'}]});
    writeValueToServer(bluetooth_request_device_key,
                      'Web Bluetooth requestDevice() succeeded');
  } catch(e) {
    if (e.name == 'NotAllowedError' &&
        e.message.includes(
          'Web Bluetooth is not allowed in a fenced frame tree.')) {
      writeValueToServer(bluetooth_request_device_key,
                        'Web Bluetooth requestDevice() failed');
    } else {
      writeValueToServer(
          bluetooth_request_device_key,
          'Web Bluetooth requestDevice() failed with unknown error - ' +
          `${e.name}: ${e.message}`);
    }
  }
})();
</script>
</body>