Closed Bug 1857187 Opened 1 year ago Closed 1 year ago

Call to requestStorageAccess() having a granted "storage-access" permission fails

Categories

(Core :: Privacy: Anti-Tracking, defect, P2)

Firefox 118
defect

Tracking

()

RESOLVED DUPLICATE of bug 1837168

People

(Reporter: esroyo, Assigned: bvandersloot)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/118.0

Steps to reproduce:

According to the MDN docs [0], when we query for "storage-access" permissions and it resolves to an state of "granted", It should be possible to directly call document.requestStorageAccess() without user interaction. However, I get an error on that scenario.

        const permission = await navigator.permissions.query({
          name: "storage-access",
        });

        if (permission.state === "granted") {
          // If so, you can just call requestStorageAccess() without a user interaction,
          // and it will resolve automatically.
          // But this throws...
          await document.requestStorageAccess();
        }

I have prepared a demo to reproduce the case:
https://esroyo.github.io/storage-access-api-firefox/

1 . On a first visit permission.state has a value of "prompt", thus need user interaction. User grants permission. All ok.
2. On a second visit permission.state has a value of "granted", thus we should be able to call document.requestStorageAccess() without user interaction. If we try so, then we get the error.


[0] https://developer.mozilla.org/en-US/docs/Web/API/Storage_Access_API/Using#checking_and_requesting_storage_access

Actual results:

Even though permission query resolve to state="granted", a call to document.requestStorageAccess() throws:

document.requestStorageAccess() may only be requested from inside a short running user-generated event handler.

DOMException: requestStorageAccess not allowed

Expected results:

It should not throw.

Situation on a first load of the demo site, just after user has been prompted and accepted to grant access.

Situation on a second load, after having a result of state="granted" and calling document.requestStorageAccess() without user interation.

The Bugbug bot thinks this bug should belong to the 'Core::Privacy: Anti-Tracking' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Privacy: Anti-Tracking
Product: Firefox → Core
Assignee: nobody → bvandersloot
Severity: -- → S2
Priority: -- → P2

This will be resolved with Fx119, due to Bug 1837168 being resolved.

You can confirm with the latest Nightly or Beta release of Firefox that this is no longer observed.

Status: UNCONFIRMED → RESOLVED
Closed: 1 year ago
Duplicate of bug: 1837168
Resolution: --- → DUPLICATE

I confirm the problem has been solved on Firefox 119.
Thanks a lot @bvandersloot and everyone.
Regards.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: