Skip to content

Commit

Permalink
Add hasUnpartitionedCookieAccess (#33329)
Browse files Browse the repository at this point in the history
Co-authored-by: Vadim Makeev <[email protected]>
  • Loading branch information
arichiv and pepelsbey authored May 22, 2024
1 parent e794475 commit b97c61b
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 4 deletions.
6 changes: 5 additions & 1 deletion files/en-us/web/api/document/hasstorageaccess/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ The **`hasStorageAccess()`** method of the {{domxref("Document")}} interface ret

This method is part of the [Storage Access API](/en-US/docs/Web/API/Storage_Access_API).

> **Note:** This method is another name for {{DOMxRef("Document.hasUnpartitionedCookieAccess()")}}. There are no current plans to remove this method in favor of {{DOMxRef("Document.hasUnpartitionedCookieAccess()")}}.
## Syntax

```js-nolint
Expand Down Expand Up @@ -44,9 +46,11 @@ The result returned by this method can be inaccurate in a couple of circumstance
document.hasStorageAccess().then((hasAccess) => {
if (hasAccess) {
// storage access has been granted already.
console.log("cookie access granted");
} else {
// storage access hasn't been granted already;
// you may want to call requestStorageAccess().
console.log("cookie access denied");
}
});
```
Expand All @@ -63,6 +67,6 @@ document.hasStorageAccess().then((hasAccess) => {

## See also

- {{domxref("Document.requestStorageAccess()")}}, {{domxref("Document.requestStorageAccessFor()")}}
- {{domxref("Document.hasUnpartitionedCookieAccess()")}}, {{domxref("Document.requestStorageAccess()")}}, {{domxref("Document.requestStorageAccessFor()")}}
- [Using the Storage Access API](/en-US/docs/Web/API/Storage_Access_API/Using)
- [Introducing Storage Access API](https://webkit.org/blog/8124/introducing-storage-access-api/) (WebKit blog)
67 changes: 67 additions & 0 deletions files/en-us/web/api/document/hasunpartitionedcookieaccess/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
title: "Document: hasUnpartitionedCookieAccess() method"
short-title: hasUnpartitionedCookieAccess()
slug: Web/API/Document/hasUnpartitionedCookieAccess
page-type: web-api-instance-method
browser-compat: api.Document.hasUnpartitionedCookieAccess
---

{{APIRef("Storage Access API")}}

The **`hasUnpartitionedCookieAccess()`** method of the {{domxref("Document")}} interface returns a {{jsxref("Promise")}} that resolves with a boolean value indicating whether the document has access to [third-party](/en-US/docs/Web/HTTP/Cookies#third-party_cookies), [unpartitioned](/en-US/docs/Web/API/Storage_Access_API#unpartitioned_versus_partitioned_cookies) cookies.

This method is part of the [Storage Access API](/en-US/docs/Web/API/Storage_Access_API).

This method is a new name for {{DOMxRef("Document.hasStorageAccess()")}}.

## Syntax

```js-nolint
hasUnpartitionedCookieAccess()
```

### Parameters

None.

### Return value

A {{jsxref("Promise")}} that resolves with a boolean value indicating whether the document has access to third-party cookies — `true` if it does, and `false` if not.

See {{DOMxRef("Document.hasStorageAccess()")}} for more details.

### Exceptions

- `InvalidStateError` {{domxref("DOMException")}}
- : Thrown if the current {{domxref("Document")}} is not yet active.

## Examples

```js
document.hasUnpartitionedCookieAccess().then((hasAccess) => {
if (hasAccess) {
// storage access has been granted already.
console.log("cookie access granted");
} else {
// storage access hasn't been granted already;
// you may want to call requestStorageAccess().
console.log("cookie access denied");
}
});
```

> **Note:** See [Using the Storage Access API](/en-US/docs/Web/API/Storage_Access_API/Using) for a more complete example.
## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{domxref("Document.hasStorageAccess()")}}, {{domxref("Document.requestStorageAccess()")}}, {{domxref("Document.requestStorageAccessFor()")}}
- [Using the Storage Access API](/en-US/docs/Web/API/Storage_Access_API/Using)
- [Introducing Storage Access API](https://webkit.org/blog/8124/introducing-storage-access-api/) (WebKit blog)
2 changes: 2 additions & 0 deletions files/en-us/web/api/document/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ _This interface also inherits from the {{DOMxRef("Node")}} and {{DOMxRef("EventT
- : Returns a {{DOMxRef('Selection')}} object representing the range of text selected by the user, or the current position of the caret.
- {{DOMxRef("Document.hasStorageAccess()")}}
- : Returns a {{jsxref("Promise")}} that resolves with a boolean value indicating whether the document has access to unpartitioned cookies.
- {{DOMxRef("Document.hasUnpartitionedCookieAccess()")}}
- : New name for {{DOMxRef("Document.hasStorageAccess()")}}.
- {{DOMxRef("Document.importNode()")}}
- : Returns a clone of a node from an external document.
- {{DOMxRef("Document.mozSetImageElement()")}} {{Non-standard_Inline}}
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/document/requeststorageaccess/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ document.requestStorageAccess().then(

## See also

- {{domxref("Document.hasStorageAccess()")}}, {{domxref("Document.requestStorageAccessFor()")}}
- {{domxref("Document.hasStorageAccess()")}}, {{domxref("Document.hasUnpartitionedCookieAccess()")}}, {{domxref("Document.requestStorageAccessFor()")}}
- [Using the Storage Access API](/en-US/docs/Web/API/Storage_Access_API/Using)
- [Introducing Storage Access API](https://webkit.org/blog/8124/introducing-storage-access-api/) (WebKit blog)
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,6 @@ function checkCookie() {

## See also

- {{domxref("Document.hasStorageAccess()")}}, {{domxref("Document.requestStorageAccess()")}}
- {{domxref("Document.hasStorageAccess()")}}, {{domxref("Document.hasUnpartitionedCookieAccess()")}}, {{domxref("Document.requestStorageAccess()")}}
- [Using the Storage Access API](/en-US/docs/Web/API/Storage_Access_API/Using)
- [Introducing Storage Access API](https://webkit.org/blog/8124/introducing-storage-access-api/) (WebKit blog)
7 changes: 6 additions & 1 deletion files/en-us/web/api/storage_access_api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ slug: Web/API/Storage_Access_API
page-type: web-api-overview
browser-compat:
- api.Document.hasStorageAccess
- api.Document.hasUnpartitionedCookieAccess
- api.Document.requestStorageAccess
- api.Document.requestStorageAccessFor
- api.Permissions.permission_storage-access
spec-urls: https://privacycg.github.io/storage-access/
spec-urls:
- https://privacycg.github.io/storage-access/
- https://privacycg.github.io/saa-non-cookie-storage/
---

{{DefaultAPISidebar("Storage Access API")}}
Expand Down Expand Up @@ -118,6 +121,8 @@ Documentation for Firefox's new storage access policy for blocking tracking cook

- {{domxref("Document.hasStorageAccess()")}}
- : Returns a {{jsxref("Promise")}} that resolves with a boolean value indicating whether the document has access to third-party cookies.
- {{domxref("Document.hasUnpartitionedCookieAccess()")}}
- : New name for {{domxref("Document.hasStorageAccess()")}}.
- {{domxref("Document.requestStorageAccess()")}}
- : Allows content loaded in a third-party context (i.e., embedded in an {{htmlelement("iframe")}}) to request access to third-party cookies; returns a {{jsxref("Promise")}} that resolves if the access was granted, and rejects if access was denied.
- {{domxref("Document.requestStorageAccessFor()")}} {{experimental_inline}}
Expand Down
1 change: 1 addition & 0 deletions files/jsondata/GroupData.json
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,7 @@
"interfaces": [],
"methods": [
"Document.hasStorageAccess()",
"Document.hasUnpartitionedCookieAccess()",
"Document.requestStorageAccess()",
"Document.requestStorageAccessFor()"
],
Expand Down

0 comments on commit b97c61b

Please sign in to comment.