permissions.html (1574B)
1 <!DOCTYPE HTML> 2 <!-- This Source Code Form is subject to the terms of the Mozilla Public 3 - License, v. 2.0. If a copy of the MPL was not distributed with this 4 - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> 5 <html dir="ltr" xml:lang="en-US" lang="en-US"> 6 <head> 7 <meta charset="utf8"> 8 </head> 9 <script> 10 var gKeyDowns = 0; 11 var gKeyPresses = 0; 12 13 navigator.serviceWorker.register("dummy.js"); 14 15 function requestPush() { 16 return navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) { 17 serviceWorkerRegistration.pushManager.subscribe(); 18 }); 19 } 20 21 function requestGeo() { 22 return navigator.geolocation.getCurrentPosition(() => { 23 parent.postMessage("allow", "*"); 24 }, error => { 25 // PERMISSION_DENIED = 1 26 parent.postMessage(error.code == 1 ? "deny" : "allow", "*"); 27 }); 28 } 29 30 31 window.onmessage = function(event) { 32 switch (event.data) { 33 case "push": 34 requestPush(); 35 break; 36 } 37 }; 38 39 </script> 40 <body onkeydown="gKeyDowns++;" onkeypress="gKeyPresses++"> 41 <!-- This page could eventually request permissions from content 42 and make sure that chrome responds appropriately --> 43 <button id="geo" onclick="requestGeo()">Geolocation</button> 44 <button id="xr" onclick="navigator.getVRDisplays()">XR</button> 45 <button id="desktop-notification" onclick="Notification.requestPermission()">Notifications</button> 46 <button id="push" onclick="requestPush()">Push Notifications</button> 47 <button id="camera" onclick="navigator.mediaDevices.getUserMedia({video: true, fake: true})">Camera</button> 48 </body> 49 </html>