Files
tubestation/servo/tests/html/permission-test.html
Zakor Gyula 12efa26e3a servo: Merge #15314 - Permissions API and WebBluetooth integration (from szeged:permissions-api); r=jdm
<!-- Please describe your changes on the following line: -->
This implements the [Permissions API](https://w3c.github.io/permissions/) spec.
Also includes the WebBluetooth related implementation for this.

There are some know issues:
- [ ] If the descriptor name is invalid [this](https://gist.github.com/dati91/7a6a0a563d90f49ba5a351e48c5b626b#file-permissionstatusbindings-rs-L323) will throw an error, rather that return it and we could handle it.
- [x] The [environment settings object](https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object) is not implemented in servo and the spec rely on it.
- [x] There is a popup in the implementation which prevent us to add wpt test, we should figure out a way to make it work
- [ ] The allowedDevice's allowed_services attribute is not used in our implementation, because we store these in the lower level, not in the dom side.
- [ ] We think the bluetooth revoke function will need some more work, but the problem is the spec needs clarifications on that part.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: a537cf48b18d9bba3453b924a4453f5e19dea4ed
2017-02-14 08:09:22 -08:00

38 lines
1.6 KiB
HTML

<!DOCTYPE html>
<html>
<title>Permission Test</title>
<body>
<button type="button" onclick="onQueryButtonClick()">query</button>
<button type="button" onclick="onRequestButtonClick()">request</button>
<button type="button" onclick="onRevokeButtonClick()">revoke</button>
<input type="text" id="permissionName" value="geolocation"></input>
<pre id="log"></pre>
<script>
function onQueryButtonClick() {
let permissionName = document.getElementById('permissionName').value;
let permissionDescriptor = {name: permissionName};
window.navigator.permissions.query(permissionDescriptor)
.then(status => log("permission status of " + permissionName + " is: " + status.state))
.catch(err => log(err));
}
function onRequestButtonClick() {
let permissionName = document.getElementById('permissionName').value;
let permissionDescriptor = {name: permissionName};
window.navigator.permissions.request(permissionDescriptor)
.then(status => log("permission status of " + permissionName + " is: " + status.state))
.catch(err => log(err));
}
function onRevokeButtonClick() {
let permissionName = document.getElementById('permissionName').value;
let permissionDescriptor = {name: permissionName};
window.navigator.permissions.revoke(permissionDescriptor)
.then(status => log("permission status of " + permissionName + " is: " + status.state))
.catch(err => log(err));
}
function log(line) {
document.getElementById("log").textContent += line + '\n';
}
</script>
</body>
</html>