Browser troubleshooting
Treat permission state as context-specific
The Permissions API can expose a supported permission’s state, but not every browser supports every descriptor. Query defensively and still handle the actual operation’s failure.
Worked example
Browser console example · use a disposable page on your own site
try {
const status = await navigator.permissions.query({name: "geolocation"});
console.log(status.state);
} catch (error) {
console.log("Permission query unavailable:", error.name);
}How it works
A state such as granted, prompt, or denied helps explain the current context. Querying does not itself obtain a location or necessarily trigger a permission prompt. The meaningful permission remains tied to the browser, origin, and embedding conditions.
Limits and mistakes
Permission states can change, and an unsupported descriptor can reject. Do not make permission prompts appear repeatedly before a user understands why a feature needs access. A granted permission also does not guarantee the underlying hardware or service succeeds.
Check the result
Run on the affected origin and note the state without requesting location data. Test the app’s actual feature only after a clear user action and verify denied access produces a useful explanation.
Sources
Reference documentation for the behavior used in this guide: