mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Add html tests
This commit is contained in:
parent
f47f8d1a5c
commit
76d6685d7f
6 changed files with 408 additions and 0 deletions
59
tests/html/bluetooth_device_info.html
Normal file
59
tests/html/bluetooth_device_info.html
Normal file
|
@ -0,0 +1,59 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<title>Device Info</title>
|
||||
<body>
|
||||
<input id="service" type="text" autofocus placeholder="Bluetooth Service">
|
||||
<input id="name" type="text" placeholder="Device Name">
|
||||
<input id="namePrefix" type="text" placeholder="Device Name Prefix">
|
||||
<button type="button" onclick="onButtonClick()">Get Bluetooth Device Info</button>
|
||||
<pre id="log"></pre>
|
||||
<script>
|
||||
function onButtonClick() {
|
||||
clear();
|
||||
var options = {filters: [], optinalServices: []};
|
||||
|
||||
var filterService = document.getElementById('service').value;
|
||||
if (filterService.startsWith('0x'))
|
||||
filterService = parseInt(filterService, 16);
|
||||
|
||||
if (filterService)
|
||||
options.filters.push({services: [filterService]});
|
||||
|
||||
var filterName = document.getElementById('name').value;
|
||||
if (filterName)
|
||||
options.filters.push({name: filterName});
|
||||
|
||||
var filterNamePrefix = document.getElementById('namePrefix').value;
|
||||
if (filterNamePrefix)
|
||||
options.filters.push({namePrefix: filterNamePrefix});
|
||||
|
||||
try {
|
||||
log('Requesting Bluetooth Device...');
|
||||
var device = window.navigator.bluetooth.requestDevice(options);
|
||||
|
||||
log('Found a device!');
|
||||
log('> Name: ' + device.name);
|
||||
log('> Id: ' + device.id);
|
||||
log('> Device Class: ' + device.deviceClass);
|
||||
log('> Vendor Id Source: ' + device.vendorIDSource);
|
||||
log('> Vendor Id: ' + device.vendorID);
|
||||
log('> Product Id: ' + device.productID);
|
||||
log('> Product Version: ' + device.productVersion);
|
||||
log('> Appearance: ' + device.adData.appearance);
|
||||
log('> Tx Power: ' + device.adData.txPower + ' dBm');
|
||||
log('> RSSI: ' + device.adData.rssi + ' dBm');
|
||||
} catch(err) {
|
||||
log(err);
|
||||
}
|
||||
}
|
||||
|
||||
function clear() {
|
||||
document.getElementById("log").textContent = "";
|
||||
}
|
||||
|
||||
function log(line) {
|
||||
document.getElementById("log").textContent += line + '\n';
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue