mdn / browser-compat-data

This repository contains compatibility data for Web technologies as displayed on MDN
https://developer.mozilla.org
Creative Commons Zero v1.0 Universal
5.01k stars 2.01k forks source link

api.PermissionStatus - Safari always return "prompt" as value for permissionStatus.state #25032

Open jop-io opened 2 weeks ago

jop-io commented 2 weeks ago

What type of issue is this?

Browser bug (a bug with a feature that may impact site compatibility)

What information was incorrect, unhelpful, or incomplete?

For geolocation, PermissionStatus.state is always prompt even if permission previously has been granted or denied.

What browsers does this problem apply to, if applicable?

Safari

What did you expect to see?

The corrected state for permission, i.e. prompt, granted (when user previously have granted permission) or denied (when user previously have denied permission).

Did you test this? If so, how?

  1. First run this code. It will prompt the user a request for permission to use geolocation:

    navigator.geolocation.getCurrentPosition(
    (geolocationPositionObject) => {
        console.log("Permission granted", geolocationPositionObject);
    },
    (error) => {
        console.error("An error occurred, including denied permission", error);
    }
    );

    Choose to grant or deny permission when prompted.

  2. Reload the page and run the following code:

    navigator.permissions
    .query({ name: "geolocation" })
    .then((permissionStatus) => {
        console.log(permissionStatus.state); // Will always log "prompt"
    }
    );
  3. After the page reload, if running the code in the first block again, no prompt will be shown to user and getCurrentPosition will immediately either succeed (if permission previously was granted) or fail (if permission previously was denied).

Can you link to any release notes, bugs, pull requests, or MDN pages related to this?

Do you have anything more you want to share?

No response

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/PermissionStatus

MDN metadata

MDN page report details * Query: `api.PermissionStatus` * Report started: 2024-11-11T13:07:44.669Z
github-actions[bot] commented 2 weeks ago

This issue was automatically closed because the title was left as the default, and a summary was not added.

If this is not a spam issue, please replace the <SUMMARIZE THE PROBLEM> part of the title with a short summary of the reported issue, and then post a follow-up comment. A maintainer will review your issue and reopen it if needed.

jop-io commented 2 weeks ago

Missed the summary in title.

queengooborg commented 2 weeks ago

I don't know why this was just closed by the mdn-bot... (CC @caugner)

caugner commented 2 weeks ago

@queengooborg This looks like a race condition. I have a GitHub project set up with automation that sets the project item status to Done if an issue is closed, and closes the issue if the project item status is set to Done. To avoid this going forward, I have disabled the second automation.