navigator.permissions.query() (The Web Platform APIs) reports granted, denied or prompt without prompting, so use it to decide whether to show an "Enable location" button. Names are not portable. Headless Chrome 152 1 at http://localhost answered:
for (const name of ['geolocation', 'accelerometer', 'bluetooth']) {
try { console.log(name, (await navigator.permissions.query({ name })).state); }
catch (e) { console.log(name, e.name); }
}Output
geolocation prompt accelerometer granted bluetooth TypeError
Wrap query() in try, and listen for the status object's change event to update your UI.