blob: 9bf8beb66aa1c2514b591db508014572d1ec6b7e (
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-vendor.js"></script>
<body>
<button>Fake user gesture</button>
</body>
<script>
'use strict';
test_driver.set_test_context(parent);
window.onmessage = messageEvent => {
switch (messageEvent.data.type) {
case 'GetPorts':
navigator.serial.getPorts()
.then(ports => parent.postMessage('Success', '*'))
.catch(err => parent.postMessage(`FAIL: ${err}`, '*'));
break;
case 'RequestPort':
test_driver.click(document.getElementsByTagName('button')[0])
.then(() => navigator.serial.requestPort({filters: []}))
.then(port => parent.postMessage('Success', '*'))
.catch(err => parent.postMessage(`FAIL: ${err}`, '*'));
break;
default:
parent.postMessage(
`FAIL: Bad message type: ${messageEvent.data}`, '*');
};
};
</script>
|