- From: L. David Baron via GitHub <sysbot+gh@w3.org>
- Date: Thu, 19 Dec 2019 23:20:33 +0000
- To: public-web-nfc@w3.org
dbaron has just created a new issue for https://github.com/w3c/web-nfc: == permissions-related example in explainer encourages bad assumptions about browser behavior == The permissions-related example in [the explainer](https://github.com/w3c/web-nfc/blob/gh-pages/EXPLAINER.md) currently has this code: ```js const nfcPermissionStatus = await navigator.permissions.query({ name: "nfc" }); if (permissionStatus.state === "granted") { // NFC access was previously granted, so we can start NFC scanning now. startScanning(); } else { // Show a "scan" button. document.querySelector("button").style.display = "block"; document.querySelector("button").onclick = event => { // Prompt user to allow UA to send and receive info when they tap NFC devices. startScanning(); }; } ``` This makes a bunch of assumptions about browser behavior that probably shouldn't be encouraged: in particular, that all browsers require user activation before being willing to show a permission prompt. (This particular variation between browsers exists in the real world: Chrome requires user activation for its WebRTC audio/video permission prompt (and then I think persists the permission); Firefox does not (but does not persist the permission by default).) It would be better if this example were written so the code took actions based on whether activation was actually required. Unfortunately, this can't be done today; it depends on enhancements to the Permissions API for which w3c/permissions#189 has been filed. I'm hoping it will be doable not too far in the future, though... (I got here from w3ctag/design-reviews#461.) Please view or discuss this issue at https://github.com/w3c/web-nfc/issues/482 using your GitHub account
Received on Thursday, 19 December 2019 23:20:34 UTC