summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webusb/resources/open-in-iframe.html
blob: 730db24902964282a9ff2b87c0a1c0ec566449bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<!DOCTYPE html>
<!-- Intentionally use relative paths here because this file is also used by blink/web_tests/usb/usbDevice-iframe.html. -->
<script src="../../resources/test-only-api.js"></script>
<script src="usb-helpers.js"></script>
<script>
'use strict';
window.onmessage = messageEvent => {
  if (messageEvent.data === 'Ready') {
    navigator.usb.addEventListener('connect', connectEvent => {
      connectEvent.device.open().then(() => {
        parent.postMessage('Success', '*');
      }).catch(error => {
        parent.postMessage('FAIL: open rejected ' + error, '*');
      });
    });
    parent.postMessage('Ready', '*');
  }
};
</script>