diff --git a/files/en-us/web/api/document/hasstorageaccess/index.md b/files/en-us/web/api/document/hasstorageaccess/index.md index aee20517132304d..2d1dfd5d7b946b2 100644 --- a/files/en-us/web/api/document/hasstorageaccess/index.md +++ b/files/en-us/web/api/document/hasstorageaccess/index.md @@ -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 @@ -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"); } }); ``` @@ -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) diff --git a/files/en-us/web/api/document/hasunpartitionedcookieaccess/index.md b/files/en-us/web/api/document/hasunpartitionedcookieaccess/index.md new file mode 100644 index 000000000000000..bd23ccdbac704bd --- /dev/null +++ b/files/en-us/web/api/document/hasunpartitionedcookieaccess/index.md @@ -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) diff --git a/files/en-us/web/api/document/index.md b/files/en-us/web/api/document/index.md index 63dadf4833643c9..fe6c4d059dcaf0e 100644 --- a/files/en-us/web/api/document/index.md +++ b/files/en-us/web/api/document/index.md @@ -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}} diff --git a/files/en-us/web/api/document/requeststorageaccess/index.md b/files/en-us/web/api/document/requeststorageaccess/index.md index 1c929c48f8981dc..954fc7e22674d15 100644 --- a/files/en-us/web/api/document/requeststorageaccess/index.md +++ b/files/en-us/web/api/document/requeststorageaccess/index.md @@ -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) diff --git a/files/en-us/web/api/document/requeststorageaccessfor/index.md b/files/en-us/web/api/document/requeststorageaccessfor/index.md index ab6e71671db4d4f..f181d66dda38173 100644 --- a/files/en-us/web/api/document/requeststorageaccessfor/index.md +++ b/files/en-us/web/api/document/requeststorageaccessfor/index.md @@ -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) diff --git a/files/en-us/web/api/storage_access_api/index.md b/files/en-us/web/api/storage_access_api/index.md index 4e3f4d9bd8747a1..3962014c14d0d5a 100644 --- a/files/en-us/web/api/storage_access_api/index.md +++ b/files/en-us/web/api/storage_access_api/index.md @@ -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")}} @@ -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}} diff --git a/files/jsondata/GroupData.json b/files/jsondata/GroupData.json index 01d210592046c51..2c74f2a0b0d56b8 100644 --- a/files/jsondata/GroupData.json +++ b/files/jsondata/GroupData.json @@ -1439,6 +1439,7 @@ "interfaces": [], "methods": [ "Document.hasStorageAccess()", + "Document.hasUnpartitionedCookieAccess()", "Document.requestStorageAccess()", "Document.requestStorageAccessFor()" ],