-
Notifications
You must be signed in to change notification settings - Fork 0
/
gum_and_notification.html
36 lines (33 loc) · 1.02 KB
/
gum_and_notification.html
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
34
35
36
<html>
<meta charset=utf-8>
<video id="video" width="320" height="200" autoplay muted></video><br>
<button id="button">Join meeting (not really)</button>
<div id="div"></div>
<script>
const console = {log: msg => div.innerHTML += `${msg}<br>`};
const wait = ms => new Promise(r => setTimeout(r, ms));
button.onclick = async () => {
try {
const [stream, permission] = await Promise.all([
navigator.mediaDevices.getUserMedia({video: true, audio: true}),
Notification.requestPermission()
]);
video.srcObject = stream;
console.log(`notification request: ${permission}`);
let notification = new Notification("Hi there!");
await dumpState();
await wait(5000);
notification = new Notification("Am I bugging you?");
await dumpState();
} catch(e) {
console.log(e);
}
};
async function dumpState() {
if (navigator.permissions?.query) {
const {state} = await navigator.permissions.query({name: "notifications"});
console.log(`notification query: ${state}`);
}
}
</script>
</html>