document.requestStorageAccessFor() is a Deprecated & Non-standard instance method that lets a top-level page request third-party cookie access on behalf of another origin in the same related website set (see MDN Document: requestStorageAccessFor()). Learn how it differs from requestStorageAccess(), the top-level-storage-access permission name, gesture rules, and five try-it labs.
01
Kind
Instance method
02
Caller
Top-level page
03
Arg
requestedOrigin
04
Returns
Promise
05
Status
Deprecated
06
Also
Non-standard
Fundamentals
Introduction
Some top-level sites embed cross-site images or scripts that need cookies, but those resources cannot run requestStorageAccess() themselves. MDN describes requestStorageAccessFor() as a proposed extension so the top-level site can request access for another origin in the same related website set.
Think: “I am the top page; please unlock cookies for this related origin”
1) Confirm you are the top-level document 2) Optionally query top-level-storage-access (MDN) 3) On a click, call requestStorageAccessFor("https://partner.example") 4) On grant, fetch with credentials: "include" (MDN)
⚠️
Learning only — not for new products
Because MDN marks this API Deprecated and Non-standard, treat labs as literacy. Outside Chromium + a valid related-site setup, the Promise usually rejects.
An instance method on Document (proposed Storage Access extension).
Caller — top-level site (not a nested iframe) (MDN).
Argument — requestedOrigin string URL (MDN).
Returns — Promise that fulfills with undefined on grant, rejects on deny (MDN).
Related sites — top-level and embedded sites must be in the same related website set (MDN).
Permission name — "top-level-storage-access" (different from "storage-access") (MDN).
Secure context — required (MDN).
Status — Deprecated & Non-standard; not defined in a specification (MDN).
Foundation
📝 Syntax
General form of Document.requestStorageAccessFor (MDN):
JavaScript
requestStorageAccessFor(requestedOrigin)
Parameters
requestedOrigin — a string representing the URL of the origin you are requesting third-party cookie access for (MDN).
Return value
A Promise that fulfills with undefined if access to third-party cookies was granted, and rejects if access was denied (MDN).
Exceptions
InvalidStateErrorDOMException — Document not yet active (MDN).
NotAllowedErrorDOMException — not a secure context; not the top-level document; null / opaque origin; sites not in the same related website set; sandbox missing allow-storage-access-by-user-activation; blocked by Permissions Policy; or the user agent denies permission (MDN).
TypeError — requestedOrigin is not a valid URL (MDN).
MDN sample
JavaScript
function rSAFor() {
if ("requestStorageAccessFor" in document) {
document.requestStorageAccessFor("https://example.com").then(
(res) => {
// Use storage access
doThingsWithCookies();
},
(err) => {
// Handle errors
},
);
}
}
Compare
⚖️ requestStorageAccessFor vs requestStorageAccess
requestStorageAccessFor()
requestStorageAccess()
Who calls
Top-level page (MDN)
Third-party embed (MDN)
For whom
Another origin you pass in
The embed’s own origin
Typical resources
Cross-site <img> / scripts that cannot ask themselves (MDN)
Document.requestStorageAccessFor() is Deprecated and Non-standard on MDN and is not defined in a specification. Historical support is Chromium-oriented (Chrome / Edge / Opera). Firefox and Safari do not implement it. Logos use the shared browser-image-sprite.png sprite from this project.
✓ Deprecated · Non-standard
Document.requestStorageAccessFor()
Top-level request for third-party cookie access on behalf of a related origin. Feature-detect; prefer Baseline requestStorageAccess() for embeds.
NarrowDeprecated
Google Chrome119+
Yes*
Microsoft Edge119+
Yes*
Opera105+
Yes*
Mozilla FirefoxNot supported
No
Apple SafariNot supported
No
Internet ExplorerNot supported
No
requestStorageAccessFor()Chromium-leaning
Bottom line: Use only for legacy literacy. New embed flows should prefer Document.requestStorageAccess(). Expect denials without Related Website Sets.
Wrap Up
Conclusion
document.requestStorageAccessFor() is a Deprecated, Non-standard way for a top-level page to request cookie access on behalf of a related origin. Learn the MDN shape for literacy, then build new embed experiences with Baseline requestStorageAccess() when that fits.
Prefer requestStorageAccess() inside embeds for new work
Call from a user gesture when permission is prompt (MDN)
Use credentials: "include" after a grant (MDN)
Plan a non-cookie fallback UX
❌ Don’t
Build new products on this Deprecated API (MDN)
Call it from nested iframes (must be top-level) (MDN)
Assume Firefox / Safari support
Loop requests after a reject (gesture consumed) (MDN)
Confuse top-level-storage-access with storage-access
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about requestStorageAccessFor()
Deprecated top-level Storage Access request for a related origin.
5
Core concepts
📝01
Returns
Promise
MDN
🏠02
Caller
top-level
MDN
🔗03
Arg
origin URL
MDN
⚠️04
Status
Deprecated
MDN
🛡05
Also
Non-std
MDN
❓ Frequently Asked Questions
MDN: Document.requestStorageAccessFor() allows top-level sites to request third-party cookie access on behalf of embedded content originating from another site in the same related website set. It returns a Promise that resolves if access was granted and rejects if denied.
MDN marks Document.requestStorageAccessFor() as Deprecated and Non-standard. It does not appear to be defined in any specification. Prefer Document.requestStorageAccess() inside embeds when that fits your use case, and avoid building new products on this API.
requestStorageAccess() is called by third-party embedded content to request access for itself. requestStorageAccessFor() is called by the top-level page to request access on behalf of another origin (for resources that cannot call the API themselves, such as cross-site images or scripts) (MDN).
A string requestedOrigin — the URL of the origin you are requesting third-party cookie access for (MDN). Invalid URLs throw TypeError.
MDN: call Permissions.query() with name "top-level-storage-access" and a requestedOrigin. That feature name is different from "storage-access" used with requestStorageAccess().
Yes in the common case. MDN: requests are automatically denied unless the top-level content is processing a user gesture (transient activation), or permission was already granted previously.
Did you know?
MDN uses a different Permissions API feature name for this method: "top-level-storage-access". The embed-facing requestStorageAccess() method uses "storage-access" instead — mixing them up is a common beginner mistake.