From 04e3492c8402d330b31d4887765a6c09ecfd1e59 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Fri, 10 Nov 2023 14:28:38 +0000 Subject: [PATCH 01/49] fix apiref --- .../en-us/web/api/cookiestoremanager/getsubscriptions/index.md | 2 +- files/en-us/web/api/cookiestoremanager/index.md | 2 +- files/en-us/web/api/cookiestoremanager/subscribe/index.md | 2 +- files/en-us/web/api/cookiestoremanager/unsubscribe/index.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/files/en-us/web/api/cookiestoremanager/getsubscriptions/index.md b/files/en-us/web/api/cookiestoremanager/getsubscriptions/index.md index 26de04fa8835332..15f61e43993a83f 100644 --- a/files/en-us/web/api/cookiestoremanager/getsubscriptions/index.md +++ b/files/en-us/web/api/cookiestoremanager/getsubscriptions/index.md @@ -8,7 +8,7 @@ status: browser-compat: api.CookieStoreManager.getSubscriptions --- -{{securecontext_header}}{{APIRef("Cookie Store")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} The **`getSubscriptions()`** method of the {{domxref("CookieStoreManager")}} interface returns a list of all the cookie change subscriptions for this {{domxref("ServiceWorkerRegistration")}}. diff --git a/files/en-us/web/api/cookiestoremanager/index.md b/files/en-us/web/api/cookiestoremanager/index.md index 23894f7ed4e60f2..c80c8b5a95bed12 100644 --- a/files/en-us/web/api/cookiestoremanager/index.md +++ b/files/en-us/web/api/cookiestoremanager/index.md @@ -7,7 +7,7 @@ status: browser-compat: api.CookieStoreManager --- -{{securecontext_header}}{{APIRef("Cookie Store")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} The **`CookieStoreManager`** interface of the ['Cookie Store API'](/en-US/docs/Web/API/Cookie_Store_API) allows service workers to subscribe to cookie change events. Call {{domxref("CookieStoreManager.subscribe()","subscribe()")}} on a particular service worker registration to receive change events. diff --git a/files/en-us/web/api/cookiestoremanager/subscribe/index.md b/files/en-us/web/api/cookiestoremanager/subscribe/index.md index c1f3b8acd694038..1297cc6641302ca 100644 --- a/files/en-us/web/api/cookiestoremanager/subscribe/index.md +++ b/files/en-us/web/api/cookiestoremanager/subscribe/index.md @@ -8,7 +8,7 @@ status: browser-compat: api.CookieStoreManager.subscribe --- -{{securecontext_header}}{{APIRef("Cookie Store")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} The **`subscribe()`** method of the {{domxref("CookieStoreManager")}} interface subscribes a {{domxref("ServiceWorkerRegistration")}} to cookie change events. diff --git a/files/en-us/web/api/cookiestoremanager/unsubscribe/index.md b/files/en-us/web/api/cookiestoremanager/unsubscribe/index.md index 5ce849ba2dc1dcd..549cdf7ab1d2d3e 100644 --- a/files/en-us/web/api/cookiestoremanager/unsubscribe/index.md +++ b/files/en-us/web/api/cookiestoremanager/unsubscribe/index.md @@ -8,7 +8,7 @@ status: browser-compat: api.CookieStoreManager.unsubscribe --- -{{securecontext_header}}{{APIRef("Cookie Store")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} The **`unsubscribe()`** method of the {{domxref("CookieStoreManager")}} interface stops the {{domxref("ServiceWorkerRegistration")}} from receiving previously subscribed events. From f9e06eb7eed684ce91902c340dc2ca01f13a4170 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Fri, 10 Nov 2023 14:37:10 +0000 Subject: [PATCH 02/49] style update of CookieStoreManager --- .../api/cookiestoremanager/getsubscriptions/index.md | 4 ++-- files/en-us/web/api/cookiestoremanager/index.md | 12 ++++++------ .../web/api/cookiestoremanager/subscribe/index.md | 2 +- .../web/api/cookiestoremanager/unsubscribe/index.md | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/files/en-us/web/api/cookiestoremanager/getsubscriptions/index.md b/files/en-us/web/api/cookiestoremanager/getsubscriptions/index.md index 15f61e43993a83f..f5f88859272f462 100644 --- a/files/en-us/web/api/cookiestoremanager/getsubscriptions/index.md +++ b/files/en-us/web/api/cookiestoremanager/getsubscriptions/index.md @@ -24,7 +24,7 @@ None. ### Return value -A {{jsxref("promise")}} that resolves with a list of objects, each containing: +A {{jsxref("Promise")}} that resolves with a list of objects, each containing: - `name` - : A string with the name of a cookie. @@ -33,7 +33,7 @@ A {{jsxref("promise")}} that resolves with a list of objects, each containing: ## Examples -If the {{domxref("ServiceWorkerRegistration")}} represented by `registration` has subscribed to any cookie change events `subscriptions` will resolve to a list of objects containing the name and URL of those cookies. +If the {{domxref("ServiceWorkerRegistration")}} represented by `registration` has subscribed to any cookie change events, `subscriptions` will resolve to a list of objects containing the name and URL of those cookies. ```js const subscriptions = await registration.cookies.getSubscriptions(); diff --git a/files/en-us/web/api/cookiestoremanager/index.md b/files/en-us/web/api/cookiestoremanager/index.md index c80c8b5a95bed12..a276399b330f9df 100644 --- a/files/en-us/web/api/cookiestoremanager/index.md +++ b/files/en-us/web/api/cookiestoremanager/index.md @@ -9,7 +9,7 @@ browser-compat: api.CookieStoreManager {{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} -The **`CookieStoreManager`** interface of the ['Cookie Store API'](/en-US/docs/Web/API/Cookie_Store_API) allows service workers to subscribe to cookie change events. Call {{domxref("CookieStoreManager.subscribe()","subscribe()")}} on a particular service worker registration to receive change events. +The **`CookieStoreManager`** interface of the [Cookie Store API](/en-US/docs/Web/API/Cookie_Store_API) allows service workers to subscribe to cookie change events. Call {{domxref("CookieStoreManager.subscribe()","subscribe()")}} on a particular service worker registration to receive change events. A `CookieStoreManager` has an associated {{domxref("ServiceWorkerRegistration")}}. Each service worker registration has a cookie change subscription list, which is a list of cookie change subscriptions each containing a name and URL. The methods in this interface allow the service worker to add and remove subscriptions from this list, and to get a list of all subscriptions. @@ -18,22 +18,22 @@ To get a `CookieStoreManager`, call {{domxref("ServiceWorkerRegistration.cookies ## Instance methods - {{domxref("CookieStoreManager.getSubscriptions()")}} {{Experimental_Inline}} - - : Returns a {{jsxref("promise")}} which resolves to a list of the cookie change subscriptions for this service worker registration. + - : Returns a {{jsxref("Promise")}} which resolves to a list of the cookie change subscriptions for this service worker registration. - {{domxref("CookieStoreManager.subscribe()")}} {{Experimental_Inline}} - - : Subscribes to changes to cookies. It returns a {{jsxref("promise")}} which resolves when the subscription is successful. + - : Subscribes to changes to cookies. It returns a {{jsxref("Promise")}} which resolves when the subscription is successful. - {{domxref("CookieStoreManager.unsubscribe()")}} {{Experimental_Inline}} - - : Unsubscribes the registered service worker from changes to cookies. It returns a {{jsxref("promise")}} which resolves when the operation is successful. + - : Unsubscribes the registered service worker from changes to cookies. It returns a {{jsxref("Promise")}} which resolves when the operation is successful. ## Examples In this example the {{domxref("ServiceWorkerRegistration")}} represented by `registration` is subscribing to change events on the cookie named `"cookie1"` with a scope of `"/path1"`. ```js -const subscriptions = [{ name: "cookie1", url: `/path1` }]; +const subscriptions = [{ name: "cookie1", url: "/path1" }]; await registration.cookies.subscribe(subscriptions); ``` -If the {{domxref("ServiceWorkerRegistration")}} has subscribed to any cookies then {{domxref("CookieStoreManager.getSubscriptions()","getSubscriptions()")}} will return a list of cookies represented by objects in the same format as used for the original subscription. +If the {{domxref("ServiceWorkerRegistration")}} has subscribed to any cookies, then {{domxref("CookieStoreManager.getSubscriptions()","getSubscriptions()")}} will return a list of cookies represented by objects in the same format as used for the original subscription. ```js const subscriptions = await registration.cookies.getSubscriptions(); diff --git a/files/en-us/web/api/cookiestoremanager/subscribe/index.md b/files/en-us/web/api/cookiestoremanager/subscribe/index.md index 1297cc6641302ca..d743de202af2acc 100644 --- a/files/en-us/web/api/cookiestoremanager/subscribe/index.md +++ b/files/en-us/web/api/cookiestoremanager/subscribe/index.md @@ -43,7 +43,7 @@ A {{jsxref("Promise")}} that resolves with {{jsxref("undefined")}} when the subs In this example the {{domxref("ServiceWorkerRegistration")}} represented by `registration` is subscribing to change events on the cookie named `"cookie1"` with a scope of `"/path1"`. ```js -const subscriptions = [{ name: "cookie1", url: `/path1` }]; +const subscriptions = [{ name: "cookie1", url: "/path1" }]; await registration.cookies.subscribe(subscriptions); ``` diff --git a/files/en-us/web/api/cookiestoremanager/unsubscribe/index.md b/files/en-us/web/api/cookiestoremanager/unsubscribe/index.md index 549cdf7ab1d2d3e..33a8a0599ebd1f1 100644 --- a/files/en-us/web/api/cookiestoremanager/unsubscribe/index.md +++ b/files/en-us/web/api/cookiestoremanager/unsubscribe/index.md @@ -43,7 +43,7 @@ A {{jsxref("Promise")}} that resolves with {{jsxref("undefined")}} when the serv In this example the {{domxref("ServiceWorkerRegistration")}} represented by `registration` is unsubscribing from change events on the cookie named `"cookie1"` with a scope of `"/path1"`. ```js -const subscriptions = [{ name: "cookie1", url: `/path1` }]; +const subscriptions = [{ name: "cookie1", url: "/path1" }]; await registration.cookies.unsubscribe(subscriptions); ``` From e07e9fd31cf92b118ae77f1c82103cb6d3096167 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Fri, 10 Nov 2023 14:45:15 +0000 Subject: [PATCH 03/49] style update to ExtendableCookieChangeEvent --- files/en-us/web/api/extendablecookiechangeevent/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/files/en-us/web/api/extendablecookiechangeevent/index.md b/files/en-us/web/api/extendablecookiechangeevent/index.md index b5dfe9cfb5256f7..18449ab739977eb 100644 --- a/files/en-us/web/api/extendablecookiechangeevent/index.md +++ b/files/en-us/web/api/extendablecookiechangeevent/index.md @@ -7,7 +7,7 @@ browser-compat: api.ExtendableCookieChangeEvent {{securecontext_header}}{{APIRef("Cookie Store API")}} -The **`ExtendableCookieChangeEvent`** interface of the['Cookie Store API'](/en-US/docs/Web/API/Cookie_Store_API) is the event type passed to {{domxref("ServiceWorkerRegistration.oncookiechange()")}} when any cookie changes occur. A cookie change event consists of a cookie and a type (either "changed" or "deleted".) +The **`ExtendableCookieChangeEvent`** interface of the [Cookie Store API](/en-US/docs/Web/API/Cookie_Store_API) is the event type passed to {{domxref("ServiceWorkerRegistration.oncookiechange()")}} when any cookie changes occur. A cookie change event consists of a cookie and a type (either "changed" or "deleted".) Cookie changes that cause the `ExtendableCookieChangeEvent` to be dispatched are: @@ -35,7 +35,7 @@ _This interface also inherits properties from {{domxref("ExtendableEvent")}}._ ## Examples -In the below example we use {{domxref("CookieStoreManager.getSubscriptions()")}} to get a list of existing subscriptions. (In service workers, a subscription is required in order to listen for events.) We unsubscribe from existing subscriptions using {{domxref("CookieStoreManager.unsubscribe()")}}, then subscribe to the cookie with a name of 'COOKIE_NAME' using {{domxref("CookieStoreManager.subscribe()")}}. If that cookie is changed, the event listener logs the event to the console. This will be an `ExtendableCookieChangeEvent` object, with the {{domxref("ExtendableCookieChangeEvent.changed","changed")}} or {{domxref("ExtendableCookieChangeEvent.deleted","deleted")}} property containing the modified cookie. +In the below example, we use {{domxref("CookieStoreManager.getSubscriptions()")}} to get a list of existing subscriptions. (In service workers, a subscription is required in order to listen for events.) We unsubscribe from existing subscriptions using {{domxref("CookieStoreManager.unsubscribe()")}}, then subscribe to the cookie with a name of 'COOKIE_NAME' using {{domxref("CookieStoreManager.subscribe()")}}. If that cookie is changed, the event listener logs the event to the console. This will be an `ExtendableCookieChangeEvent` object, with the {{domxref("ExtendableCookieChangeEvent.changed","changed")}} or {{domxref("ExtendableCookieChangeEvent.deleted","deleted")}} property containing the modified cookie. ```js self.addEventListener("activate", (event) => { From b9e048e0d19a9e6cb75efb2a07cd1cf4ebbf3131 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Fri, 10 Nov 2023 14:46:04 +0000 Subject: [PATCH 04/49] add a description --- files/en-us/web/api/extendablecookiechangeevent/index.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/files/en-us/web/api/extendablecookiechangeevent/index.md b/files/en-us/web/api/extendablecookiechangeevent/index.md index 18449ab739977eb..40c158ed768ddc1 100644 --- a/files/en-us/web/api/extendablecookiechangeevent/index.md +++ b/files/en-us/web/api/extendablecookiechangeevent/index.md @@ -33,6 +33,10 @@ _This interface also inherits properties from {{domxref("ExtendableEvent")}}._ - {{domxref("ExtendableCookieChangeEvent.deleted")}} {{ReadOnlyInline}} - : Returns an array containing the deleted cookies. +## Instance methods + +_This interface also inherits methods from {{domxref("ExtendableEvent")}}._ + ## Examples In the below example, we use {{domxref("CookieStoreManager.getSubscriptions()")}} to get a list of existing subscriptions. (In service workers, a subscription is required in order to listen for events.) We unsubscribe from existing subscriptions using {{domxref("CookieStoreManager.unsubscribe()")}}, then subscribe to the cookie with a name of 'COOKIE_NAME' using {{domxref("CookieStoreManager.subscribe()")}}. If that cookie is changed, the event listener logs the event to the console. This will be an `ExtendableCookieChangeEvent` object, with the {{domxref("ExtendableCookieChangeEvent.changed","changed")}} or {{domxref("ExtendableCookieChangeEvent.deleted","deleted")}} property containing the modified cookie. From e8fb09b30334505d7f80f2189d59dd4490191a0e Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Fri, 10 Nov 2023 14:48:17 +0000 Subject: [PATCH 05/49] fix macros to ExtendableCookieChangeEvent --- .../extendablecookiechangeevent/index.md | 2 +- files/en-us/web/api/extendablecookiechangeevent/index.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/files/en-us/web/api/extendablecookiechangeevent/extendablecookiechangeevent/index.md b/files/en-us/web/api/extendablecookiechangeevent/extendablecookiechangeevent/index.md index 5dee11fce44c2e3..556da49b3e76ed2 100644 --- a/files/en-us/web/api/extendablecookiechangeevent/extendablecookiechangeevent/index.md +++ b/files/en-us/web/api/extendablecookiechangeevent/extendablecookiechangeevent/index.md @@ -9,7 +9,7 @@ browser-compat: api.ExtendableCookieChangeEvent.ExtendableCookieChangeEvent {{securecontext_header}}{{APIRef("Cookie Store API")}} The **`ExtendableCookieChangeEvent()`** constructor creates a new {{domxref("ExtendableCookieChangeEvent")}} object -which is the event type passed to {{domxref("ServiceWorkerRegistration/cookiechange_event", "ServiceWorkerRegistration.oncookiechange()")}}. +which is the event type passed to {{domxref("ServiceWorkerGlobalScope/cookiechange_event", "ServiceWorkerGlobalScope.cookiechange")}}. This constructor is called by the browser when a change event occurs. > **Note:** This event constructor is generally not needed for production websites. It's primary use is for tests that require an instance of this event. diff --git a/files/en-us/web/api/extendablecookiechangeevent/index.md b/files/en-us/web/api/extendablecookiechangeevent/index.md index 40c158ed768ddc1..85ac8772da75d03 100644 --- a/files/en-us/web/api/extendablecookiechangeevent/index.md +++ b/files/en-us/web/api/extendablecookiechangeevent/index.md @@ -7,7 +7,7 @@ browser-compat: api.ExtendableCookieChangeEvent {{securecontext_header}}{{APIRef("Cookie Store API")}} -The **`ExtendableCookieChangeEvent`** interface of the [Cookie Store API](/en-US/docs/Web/API/Cookie_Store_API) is the event type passed to {{domxref("ServiceWorkerRegistration.oncookiechange()")}} when any cookie changes occur. A cookie change event consists of a cookie and a type (either "changed" or "deleted".) +The **`ExtendableCookieChangeEvent`** interface of the [Cookie Store API](/en-US/docs/Web/API/Cookie_Store_API) is the event type passed to {{domxref("ServiceWorkerGlobalScope/cookiechange_event", "ServiceWorkerGlobalScope.cookiechange")}} when any cookie changes occur. A cookie change event consists of a cookie and a type (either "changed" or "deleted".) Cookie changes that cause the `ExtendableCookieChangeEvent` to be dispatched are: From a077a0d662b3426892f4b5f843bca885d0c6144f Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Fri, 10 Nov 2023 14:50:28 +0000 Subject: [PATCH 06/49] fix description --- .../en-us/web/api/extendablecookiechangeevent/changed/index.md | 3 +++ .../en-us/web/api/extendablecookiechangeevent/deleted/index.md | 3 +++ 2 files changed, 6 insertions(+) diff --git a/files/en-us/web/api/extendablecookiechangeevent/changed/index.md b/files/en-us/web/api/extendablecookiechangeevent/changed/index.md index 33a5bd5dee64eca..f7c24bc949ad199 100644 --- a/files/en-us/web/api/extendablecookiechangeevent/changed/index.md +++ b/files/en-us/web/api/extendablecookiechangeevent/changed/index.md @@ -37,6 +37,9 @@ An array of objects containing the changed cookie(s). Each object contains the f - `"none"` - : Cookies will be sent in all contexts. +- `partitioned` + - : A boolean indicating whether the cookie is a partitioned cookie (`true`) or not (`false`). See [Cookies Having Independent Partitioned State (CHIPS)](/en-US/docs/Web/Privacy/Partitioned_cookies) for more information. + ## Examples In this example when the cookie is set, the event listener logs the `changed` property to the console. The first item in that array contains an object representing the cookie that has just been set. diff --git a/files/en-us/web/api/extendablecookiechangeevent/deleted/index.md b/files/en-us/web/api/extendablecookiechangeevent/deleted/index.md index fa3d8595dfcc570..7c7d57767f01b5b 100644 --- a/files/en-us/web/api/extendablecookiechangeevent/deleted/index.md +++ b/files/en-us/web/api/extendablecookiechangeevent/deleted/index.md @@ -37,6 +37,9 @@ An array of objects containing the deleted cookie(s). Each object contains the f - `"none"` - : Cookies will be sent in all contexts. +- `partitioned` + - : A boolean indicating whether the cookie is a partitioned cookie (`true`) or not (`false`). See [Cookies Having Independent Partitioned State (CHIPS)](/en-US/docs/Web/Privacy/Partitioned_cookies) for more information. + ## Examples In this example when the cookie is deleted the event listener logs the first item in the `deleted` property to the console. It contains an object representing the cookie that has just been deleted. From 222c3d5416ba7c677c4d0672eb2f3b871ccdbfe2 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Fri, 10 Nov 2023 14:57:49 +0000 Subject: [PATCH 07/49] add CookieStore change event type --- files/en-us/web/api/cookiestore/change_event/index.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/files/en-us/web/api/cookiestore/change_event/index.md b/files/en-us/web/api/cookiestore/change_event/index.md index 9ffb29511d1b491..63267c57190a648 100644 --- a/files/en-us/web/api/cookiestore/change_event/index.md +++ b/files/en-us/web/api/cookiestore/change_event/index.md @@ -22,6 +22,12 @@ cookieStore.addEventListener("change", (event) => { }) cookieStore.onchange = (event) => { } ``` +## Event type + +A {{domxref("CookieChangeEvent")}}. Inherits from {{domxref("Event")}}. + +{{InheritanceDiagram("CookieChangeEvent")}} + ## Examples To be informed when a cookie has changed, you can add a handler to the `cookieStore` instance using {{domxref("EventTarget.addEventListener", "addEventListener()")}}, like this: From 6ccf7b6e78dd2a9230a1bed241a9f4ab8378c183 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Fri, 10 Nov 2023 15:00:51 +0000 Subject: [PATCH 08/49] fix the incoorect event name in Cookie Store API --- files/en-us/web/api/cookie_store_api/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/en-us/web/api/cookie_store_api/index.md b/files/en-us/web/api/cookie_store_api/index.md index 0c1a9eb897f85ac..935867fc5239e5e 100644 --- a/files/en-us/web/api/cookie_store_api/index.md +++ b/files/en-us/web/api/cookie_store_api/index.md @@ -28,7 +28,7 @@ The _Cookie Store API_ provides an updated method of managing cookies. It is {{G - {{domxref("CookieChangeEvent")}} - : A `CookieChangeEvent` named `change` is dispatched against `CookieStore` objects in {{domxref("Window")}} contexts when any script-visible cookies changes occur. - {{domxref("ExtendableCookieChangeEvent")}} - - : An `ExtendableCookieChangeEvent` named `change` is dispatched against {{domxref("ServiceWorkerGlobalScope")}} events when any script-visible cookie changes occur that match the service worker's cookie change subscription list. + - : An `ExtendableCookieChangeEvent` named `cookiechange` is dispatched against {{domxref("ServiceWorkerGlobalScope")}} events when any script-visible cookie changes occur that match the service worker's cookie change subscription list. ## Specifications From a9821684bea1f271e4cc50b14174dc0aa8e170ec Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Fri, 10 Nov 2023 15:03:42 +0000 Subject: [PATCH 09/49] style update to Cookie Store API --- files/en-us/web/api/cookie_store_api/index.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/files/en-us/web/api/cookie_store_api/index.md b/files/en-us/web/api/cookie_store_api/index.md index 935867fc5239e5e..d0e100d2223ab6c 100644 --- a/files/en-us/web/api/cookie_store_api/index.md +++ b/files/en-us/web/api/cookie_store_api/index.md @@ -13,9 +13,9 @@ The _**Cookie Store API**_ provides an asynchronous API for managing cookies, wh ## Concepts and Usage -The existing method of getting and setting cookies involves working with {{domxref("document.cookie")}} as a string of key/value pairs. In addition to this being cumbersome and error prone, it also has a host of issues in the context of modern web development. +The existing method of getting and setting cookies involves working with {{domxref("document.cookie")}} as a string of key-value pairs. In addition to this being cumbersome and error prone, it also has a host of issues in the context of modern web development. -The `document.cookie` interface is {{Glossary("synchronous")}}, single-threaded, and blocking. When writing a cookie you must wait for the browser to update the string of all cookies. In addition, the reliance on {{domxref("document")}} means that cookies cannot be accessed by service workers which cannot access the `document` object. +The `document.cookie` interface is {{Glossary("synchronous")}}, single-threaded, and blocking. When writing a cookie you must wait for the browser to update the string of all cookies. In addition, the reliance on {{domxref("document")}} means that cookies cannot be accessed by service workers which cannot access the {{domxref("document")}} object. The _Cookie Store API_ provides an updated method of managing cookies. It is {{Glossary("asynchronous")}} and promise-based, therefore does not block the event loop. It does not rely on {{domxref("document")}} and so is available to service workers. The methods for getting and setting cookies also provide more feedback by way of error messages. This means that web developers do not have to set then immediately read back a cookie to check that setting was successful. @@ -26,9 +26,9 @@ The _Cookie Store API_ provides an updated method of managing cookies. It is {{G - {{domxref("CookieStoreManager")}} - : The `CookieStoreManager` interface provides a service worker registration to enable service workers to subscribe to cookie change events. - {{domxref("CookieChangeEvent")}} - - : A `CookieChangeEvent` named `change` is dispatched against `CookieStore` objects in {{domxref("Window")}} contexts when any script-visible cookies changes occur. + - : A `CookieChangeEvent` named `change` is dispatched against `CookieStore` object in {{domxref("Window")}} contexts when any script-visible cookies changes occur. - {{domxref("ExtendableCookieChangeEvent")}} - - : An `ExtendableCookieChangeEvent` named `cookiechange` is dispatched against {{domxref("ServiceWorkerGlobalScope")}} events when any script-visible cookie changes occur that match the service worker's cookie change subscription list. + - : An `ExtendableCookieChangeEvent` named `cookiechange` is dispatched against {{domxref("ServiceWorkerGlobalScope")}} contexts when any script-visible cookie changes occur that match the service worker's cookie change subscription list. ## Specifications From 05009868d96cc0bb1d10128581c1ab3c183f24cf Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Fri, 10 Nov 2023 15:19:40 +0000 Subject: [PATCH 10/49] style update to CookieChangeEvent --- files/en-us/web/api/cookiechangeevent/changed/index.md | 2 +- .../web/api/cookiechangeevent/cookiechangeevent/index.md | 5 ++--- files/en-us/web/api/cookiechangeevent/deleted/index.md | 2 +- files/en-us/web/api/cookiechangeevent/index.md | 5 +++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/files/en-us/web/api/cookiechangeevent/changed/index.md b/files/en-us/web/api/cookiechangeevent/changed/index.md index 202125d5725cf3d..b86483ce96d08ed 100644 --- a/files/en-us/web/api/cookiechangeevent/changed/index.md +++ b/files/en-us/web/api/cookiechangeevent/changed/index.md @@ -41,7 +41,7 @@ An array of objects containing the changed cookie(s). Each object contains the f ## Examples -In this example when the cookie is set, the event listener logs the `changed` property to the console. The first item in that array contains an object representing the cookie that has just been set. +In this example, when the cookie is set, the event listener logs the `changed` property to the console. The first item in that array contains an object representing the cookie that has just been set. ```js cookieStore.addEventListener("change", (event) => { diff --git a/files/en-us/web/api/cookiechangeevent/cookiechangeevent/index.md b/files/en-us/web/api/cookiechangeevent/cookiechangeevent/index.md index eeb08e89884436b..825b188c334262f 100644 --- a/files/en-us/web/api/cookiechangeevent/cookiechangeevent/index.md +++ b/files/en-us/web/api/cookiechangeevent/cookiechangeevent/index.md @@ -11,7 +11,7 @@ browser-compat: api.CookieChangeEvent.CookieChangeEvent {{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} The **`CookieChangeEvent()`** constructor creates a new {{domxref("CookieChangeEvent")}} object -which is the event type passed to {{domxref("CookieStore/change_event", "CookieStore.onchange()")}}. +which is the event type passed to {{domxref("CookieStore/change_event", "CookieStore.change")}}. This constructor is called by the browser when a change event occurs. > **Note:** This event constructor is generally not needed for production websites. It's primary use is for tests that require an instance of this event. @@ -26,8 +26,7 @@ new CookieChangeEvent(type, options) ### Parameters - `type` - - : A string with the name of the event. - It is case-sensitive and browsers always set it to `cookiechange`. + - : A string with the name of the event. It is case-sensitive and browsers always set it to `cookiechange`. - `options` {{Optional_Inline}} - : An object that, _in addition of the properties defined in {{domxref("Event/Event", "Event()")}}_, can have the following properties: - `changed` diff --git a/files/en-us/web/api/cookiechangeevent/deleted/index.md b/files/en-us/web/api/cookiechangeevent/deleted/index.md index b129e5d2a90cd5b..b8968c5da92d70f 100644 --- a/files/en-us/web/api/cookiechangeevent/deleted/index.md +++ b/files/en-us/web/api/cookiechangeevent/deleted/index.md @@ -41,7 +41,7 @@ An array of objects containing the deleted cookie(s). Each object contains the f ## Examples -In this example when the cookie is deleted the event listener logs the first item in the `CookieChangeEvent.deleted` property to the console. It contains an object representing the cookie that has just been deleted. +In this example, when the cookie is deleted the event listener logs the first item in the `CookieChangeEvent.deleted` property to the console. It contains an object representing the cookie that has just been deleted. ```js cookieStore.addEventListener("change", (event) => { diff --git a/files/en-us/web/api/cookiechangeevent/index.md b/files/en-us/web/api/cookiechangeevent/index.md index 6f0130249ef9b99..cd1b4551188b963 100644 --- a/files/en-us/web/api/cookiechangeevent/index.md +++ b/files/en-us/web/api/cookiechangeevent/index.md @@ -9,12 +9,12 @@ browser-compat: api.CookieChangeEvent {{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} -The **`CookieChangeEvent`** interface of the ['Cookie Store API'](/en-US/docs/Web/API/Cookie_Store_API) is the event type of the {{domxref("CookieStore.change_event", "change")}} event fired at a {{domxref("CookieStore")}} when any cookie changes occur. A cookie change consists of a cookie and a type (either "changed" or "deleted"). +The **`CookieChangeEvent`** interface of the [Cookie Store API](/en-US/docs/Web/API/Cookie_Store_API) is the event type of the {{domxref("CookieStore.change_event", "change")}} event fired at a {{domxref("CookieStore")}} when any cookie changes occur. A cookie change consists of a cookie and a type (either "changed" or "deleted"). Cookie changes that will cause the `CookieChangeEvent` to be dispatched are: - A cookie is newly created and not immediately removed. In this case `type` is "changed". -- A cookie is newly created and immediately removed. In this case `type` is "deleted" +- A cookie is newly created and immediately removed. In this case `type` is "deleted". - A cookie is removed. In this case `type` is "deleted". > **Note:** A cookie that is replaced due to the insertion of another cookie with the same name, domain, and path, is ignored and does not trigger a change event. @@ -45,6 +45,7 @@ cookieStore.addEventListener("change", (event) => { }); const one_day = 24 * 60 * 60 * 1000; + cookieStore.set({ name: "cookie1", value: "cookie1-value", From 17f764b7429f74e0e18ceeb720f0699741736c42 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Fri, 10 Nov 2023 15:20:09 +0000 Subject: [PATCH 11/49] fix the event name --- .../en-us/web/api/cookiechangeevent/cookiechangeevent/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/en-us/web/api/cookiechangeevent/cookiechangeevent/index.md b/files/en-us/web/api/cookiechangeevent/cookiechangeevent/index.md index 825b188c334262f..41ab50c4bc13802 100644 --- a/files/en-us/web/api/cookiechangeevent/cookiechangeevent/index.md +++ b/files/en-us/web/api/cookiechangeevent/cookiechangeevent/index.md @@ -26,7 +26,7 @@ new CookieChangeEvent(type, options) ### Parameters - `type` - - : A string with the name of the event. It is case-sensitive and browsers always set it to `cookiechange`. + - : A string with the name of the event. It is case-sensitive and browsers always set it to `change`. - `options` {{Optional_Inline}} - : An object that, _in addition of the properties defined in {{domxref("Event/Event", "Event()")}}_, can have the following properties: - `changed` From 27bf6db6fbd8ba3526934bb844af6a85510ebef3 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Fri, 10 Nov 2023 15:21:08 +0000 Subject: [PATCH 12/49] add additional methods description --- files/en-us/web/api/cookiechangeevent/index.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/files/en-us/web/api/cookiechangeevent/index.md b/files/en-us/web/api/cookiechangeevent/index.md index cd1b4551188b963..4595d6ca2d3f594 100644 --- a/files/en-us/web/api/cookiechangeevent/index.md +++ b/files/en-us/web/api/cookiechangeevent/index.md @@ -35,6 +35,10 @@ _This interface also inherits properties from {{domxref("Event")}}._ - {{domxref("CookieChangeEvent.deleted")}} {{ReadOnlyInline}} {{Experimental_Inline}} - : Returns an array containing one or more deleted cookies. +## Instance methods + +_This interface also inherits methods from {{domxref("ExtendableEvent")}}._ + ## Examples In this example when the cookie is set, the event listener logs the event to the console. This is a `CookieChangeEvent` object with the {{domxref("CookieChangeEvent.changed","changed")}} property containing an object representing the cookie that has just been set. From 998482c3719777c59ed23ce4b166c4f8c483160c Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Fri, 10 Nov 2023 15:22:19 +0000 Subject: [PATCH 13/49] update to CookieChangeEvent for partitioned --- files/en-us/web/api/cookiechangeevent/changed/index.md | 3 +++ files/en-us/web/api/cookiechangeevent/deleted/index.md | 3 +++ 2 files changed, 6 insertions(+) diff --git a/files/en-us/web/api/cookiechangeevent/changed/index.md b/files/en-us/web/api/cookiechangeevent/changed/index.md index b86483ce96d08ed..ed19dd1cbd93b5a 100644 --- a/files/en-us/web/api/cookiechangeevent/changed/index.md +++ b/files/en-us/web/api/cookiechangeevent/changed/index.md @@ -39,6 +39,9 @@ An array of objects containing the changed cookie(s). Each object contains the f - `"none"` - : Cookies will be sent in all contexts. +- `partitioned` + - : A boolean indicating whether the cookie is a partitioned cookie (`true`) or not (`false`). See [Cookies Having Independent Partitioned State (CHIPS)](/en-US/docs/Web/Privacy/Partitioned_cookies) for more information. + ## Examples In this example, when the cookie is set, the event listener logs the `changed` property to the console. The first item in that array contains an object representing the cookie that has just been set. diff --git a/files/en-us/web/api/cookiechangeevent/deleted/index.md b/files/en-us/web/api/cookiechangeevent/deleted/index.md index b8968c5da92d70f..a6f2a30bb30263e 100644 --- a/files/en-us/web/api/cookiechangeevent/deleted/index.md +++ b/files/en-us/web/api/cookiechangeevent/deleted/index.md @@ -39,6 +39,9 @@ An array of objects containing the deleted cookie(s). Each object contains the f - `"none"` - : Cookies will be sent in all contexts. +- `partitioned` + - : A boolean indicating whether the cookie is a partitioned cookie (`true`) or not (`false`). See [Cookies Having Independent Partitioned State (CHIPS)](/en-US/docs/Web/Privacy/Partitioned_cookies) for more information. + ## Examples In this example, when the cookie is deleted the event listener logs the first item in the `CookieChangeEvent.deleted` property to the console. It contains an object representing the cookie that has just been deleted. From 1012322a2430335e03eb36474616749603e3ffcb Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Fri, 10 Nov 2023 15:30:04 +0000 Subject: [PATCH 14/49] style update to CookieStore --- files/en-us/web/api/cookiestore/change_event/index.md | 2 +- files/en-us/web/api/cookiestore/delete/index.md | 2 +- files/en-us/web/api/cookiestore/get/index.md | 2 +- files/en-us/web/api/cookiestore/getall/index.md | 2 +- files/en-us/web/api/cookiestore/index.md | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/files/en-us/web/api/cookiestore/change_event/index.md b/files/en-us/web/api/cookiestore/change_event/index.md index 63267c57190a648..3c9b226a59f0110 100644 --- a/files/en-us/web/api/cookiestore/change_event/index.md +++ b/files/en-us/web/api/cookiestore/change_event/index.md @@ -30,7 +30,7 @@ A {{domxref("CookieChangeEvent")}}. Inherits from {{domxref("Event")}}. ## Examples -To be informed when a cookie has changed, you can add a handler to the `cookieStore` instance using {{domxref("EventTarget.addEventListener", "addEventListener()")}}, like this: +To be informed when a cookie has changed, you can add a handler to the `CookieStore` instance using {{domxref("EventTarget.addEventListener", "addEventListener()")}}, like this: ```js cookieStore.addEventListener("change", (event) => { diff --git a/files/en-us/web/api/cookiestore/delete/index.md b/files/en-us/web/api/cookiestore/delete/index.md index 5655ac11c98dfab..3de3ae0dccf7388 100644 --- a/files/en-us/web/api/cookiestore/delete/index.md +++ b/files/en-us/web/api/cookiestore/delete/index.md @@ -54,7 +54,7 @@ A {{jsxref("Promise")}} that resolves with {{jsxref("undefined")}} when deletion ## Examples -In this example a cookie is deleted by passing the name to the `delete()` method. +In this example, a cookie is deleted by passing the name to the `delete()` method. ```js let result = cookieStore.delete("cookie1"); diff --git a/files/en-us/web/api/cookiestore/get/index.md b/files/en-us/web/api/cookiestore/get/index.md index ddc1111c1810fc3..8654b6e42875a1c 100644 --- a/files/en-us/web/api/cookiestore/get/index.md +++ b/files/en-us/web/api/cookiestore/get/index.md @@ -88,7 +88,7 @@ A {{jsxref("Promise")}} that resolves with an object representing the first cook ## Examples -In this example we return a cookie named "cookie1". If the cookie is found the result of the Promise is an object containing the details of a single cookie. +In this example, we return a cookie named "cookie1". If the cookie is found the result of the Promise is an object containing the details of a single cookie. ```js let cookie = cookieStore.get("cookie1"); diff --git a/files/en-us/web/api/cookiestore/getall/index.md b/files/en-us/web/api/cookiestore/getall/index.md index 07d593c8a9567bb..912f41d28d6cf14 100644 --- a/files/en-us/web/api/cookiestore/getall/index.md +++ b/files/en-us/web/api/cookiestore/getall/index.md @@ -88,7 +88,7 @@ Each object contains the following properties: ## Examples -In this example we use `getAll()` with no parameters. This returns all of the cookies for this context as an array of objects. +In this example, we use `getAll()` with no parameters. This returns all of the cookies for this context as an array of objects. ```js let cookies = await cookieStore.getAll(); diff --git a/files/en-us/web/api/cookiestore/index.md b/files/en-us/web/api/cookiestore/index.md index b6b403d00750398..1fb8bb2cacb1222 100644 --- a/files/en-us/web/api/cookiestore/index.md +++ b/files/en-us/web/api/cookiestore/index.md @@ -9,7 +9,7 @@ browser-compat: api.CookieStore {{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} -The **`CookieStore`** interface of the ['Cookie Store API'](/en-US/docs/Web/API/Cookie_Store_API) provides methods for getting and setting cookies asynchronously from either a page or a service worker. +The **`CookieStore`** interface of the [Cookie Store API](/en-US/docs/Web/API/Cookie_Store_API) provides methods for getting and setting cookies asynchronously from either a page or a service worker. The `CookieStore` is accessed via attributes in the global scope in a {{domxref("Window")}} or {{domxref("ServiceWorkerGlobalScope")}} context. Therefore there is no constructor. From a241b12ba64ed2c7a9243da4c746ef585ed91c94 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Fri, 10 Nov 2023 15:31:17 +0000 Subject: [PATCH 15/49] fix examples in CookieStore --- files/en-us/web/api/cookiestore/get/index.md | 2 +- files/en-us/web/api/cookiestore/getall/index.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/files/en-us/web/api/cookiestore/get/index.md b/files/en-us/web/api/cookiestore/get/index.md index 8654b6e42875a1c..99933d27763fac6 100644 --- a/files/en-us/web/api/cookiestore/get/index.md +++ b/files/en-us/web/api/cookiestore/get/index.md @@ -91,7 +91,7 @@ A {{jsxref("Promise")}} that resolves with an object representing the first cook In this example, we return a cookie named "cookie1". If the cookie is found the result of the Promise is an object containing the details of a single cookie. ```js -let cookie = cookieStore.get("cookie1"); +let cookie = await cookieStore.get("cookie1"); if (cookie) { console.log(cookie); } else { diff --git a/files/en-us/web/api/cookiestore/getall/index.md b/files/en-us/web/api/cookiestore/getall/index.md index 912f41d28d6cf14..02a94df5031d856 100644 --- a/files/en-us/web/api/cookiestore/getall/index.md +++ b/files/en-us/web/api/cookiestore/getall/index.md @@ -92,7 +92,7 @@ In this example, we use `getAll()` with no parameters. This returns all of the c ```js let cookies = await cookieStore.getAll(); -if (cookies) { +if (cookies.length > 0) { console.log(cookies); } else { console.log("Cookie not found"); From 0f44c6f59459fb5ee772b47b91345c2090faa6da Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Fri, 10 Nov 2023 15:35:35 +0000 Subject: [PATCH 16/49] mark methods parameters in CookieStore as optional --- files/en-us/web/api/cookiestore/delete/index.md | 4 ++-- files/en-us/web/api/cookiestore/get/index.md | 4 ++-- files/en-us/web/api/cookiestore/set/index.md | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/files/en-us/web/api/cookiestore/delete/index.md b/files/en-us/web/api/cookiestore/delete/index.md index 3de3ae0dccf7388..6f86f53fe8e8865 100644 --- a/files/en-us/web/api/cookiestore/delete/index.md +++ b/files/en-us/web/api/cookiestore/delete/index.md @@ -23,12 +23,12 @@ delete(options) This method requires one of the following: -- `name` +- `name` {{optional_inline}} - : A string with the name of a cookie. Or -- `options` +- `options` {{optional_inline}} - : An object containing: diff --git a/files/en-us/web/api/cookiestore/get/index.md b/files/en-us/web/api/cookiestore/get/index.md index 99933d27763fac6..b0f2e8b29cacc1a 100644 --- a/files/en-us/web/api/cookiestore/get/index.md +++ b/files/en-us/web/api/cookiestore/get/index.md @@ -23,12 +23,12 @@ get(options) This method requires one of the following: -- `name` +- `name` {{optional_inline}} - : A string with the name of a cookie. Or -- `options` +- `options` {{optional_inline}} - : An object containing: diff --git a/files/en-us/web/api/cookiestore/set/index.md b/files/en-us/web/api/cookiestore/set/index.md index c2a2f7fe5706285..e40459c516f040c 100644 --- a/files/en-us/web/api/cookiestore/set/index.md +++ b/files/en-us/web/api/cookiestore/set/index.md @@ -23,14 +23,14 @@ set(options) This method requires one of the following: -- `name` +- `name` {{optional_inline}} - : A string with the name of the cookie. -- `value` +- `value` {{optional_inline}} - : A string with the value of the cookie. Or -- `options` +- `options` {{optional_inline}} - : An object containing: From 20f5144a5ab3e7828fee6f9198e8d31981fb7f4c Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Fri, 10 Nov 2023 15:52:56 +0000 Subject: [PATCH 17/49] update exception section to CookieStore --- files/en-us/web/api/cookiestore/delete/index.md | 2 ++ files/en-us/web/api/cookiestore/get/index.md | 8 +++++++- files/en-us/web/api/cookiestore/getall/index.md | 7 ++++++- files/en-us/web/api/cookiestore/set/index.md | 4 ++-- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/files/en-us/web/api/cookiestore/delete/index.md b/files/en-us/web/api/cookiestore/delete/index.md index 6f86f53fe8e8865..71ed5916e4385cc 100644 --- a/files/en-us/web/api/cookiestore/delete/index.md +++ b/files/en-us/web/api/cookiestore/delete/index.md @@ -49,6 +49,8 @@ A {{jsxref("Promise")}} that resolves with {{jsxref("undefined")}} when deletion ### Exceptions +- `SecurityError` {{domxref("DOMException")}} + - : Thrown if the origin does not {{glossary("Serialization", "serialize")}} to a URL. - {{jsxref("TypeError")}} - : Thrown if deleting the cookie represented by the given `name` or `options` fails. diff --git a/files/en-us/web/api/cookiestore/get/index.md b/files/en-us/web/api/cookiestore/get/index.md index b0f2e8b29cacc1a..50f5f3f5e57b242 100644 --- a/files/en-us/web/api/cookiestore/get/index.md +++ b/files/en-us/web/api/cookiestore/get/index.md @@ -83,8 +83,14 @@ A {{jsxref("Promise")}} that resolves with an object representing the first cook ### Exceptions +- `SecurityError` {{domxref("DOMException")}} + - : Thrown if the origin does not {{glossary("Serialization", "serialize")}} to a URL. - {{jsxref("TypeError")}} - - : Thrown if getting the cookie represented by the given `name` or `options` fails. + - : Thrown if: + - The passing `options` is an empty object. + - The `url` in `options` is present and is not equal with the creation URL if in Window context. + - The `url` in `options` is present and its origin is same as the origin of the creation URL. + - Getting the cookie or cookies represented by the given `name` or `options` fails. ## Examples diff --git a/files/en-us/web/api/cookiestore/getall/index.md b/files/en-us/web/api/cookiestore/getall/index.md index 02a94df5031d856..e22be4c75aa4f5d 100644 --- a/files/en-us/web/api/cookiestore/getall/index.md +++ b/files/en-us/web/api/cookiestore/getall/index.md @@ -83,8 +83,13 @@ Each object contains the following properties: ### Exceptions +- `SecurityError` {{domxref("DOMException")}} + - : Thrown if the origin does not {{glossary("Serialization", "serialize")}} to a URL. - {{jsxref("TypeError")}} - - : Thrown if getting the cookie or cookies represented by the given `name` or `options` fails. + - : Thrown if: + - The `url` in `options` is present and is not equal with the creation URL if in Window context. + - The `url` in `options` is present and its origin is same as the origin of the creation URL. + - Getting the cookie or cookies represented by the given `name` or `options` fails. ## Examples diff --git a/files/en-us/web/api/cookiestore/set/index.md b/files/en-us/web/api/cookiestore/set/index.md index e40459c516f040c..1da5b6ee6b1baf3 100644 --- a/files/en-us/web/api/cookiestore/set/index.md +++ b/files/en-us/web/api/cookiestore/set/index.md @@ -64,10 +64,10 @@ A {{jsxref("Promise")}} that resolves with {{jsxref("undefined")}} when setting ### Exceptions -- {{jsxref("TypeError")}} - - : Thrown if setting the cookie with the given values fails. - `SecurityError` {{domxref("DOMException")}} - : Thrown if the origin does not {{glossary("Serialization", "serialize")}} to a URL. +- {{jsxref("TypeError")}} + - : Thrown if setting the cookie with the given `name` and `value` or `options` fails. ## Examples From d56edc19cd5b54d407c3751a396a11767e603814 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Fri, 10 Nov 2023 15:55:37 +0000 Subject: [PATCH 18/49] update event description --- files/en-us/web/api/cookiechangeevent/index.md | 2 +- files/en-us/web/api/extendablecookiechangeevent/index.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/files/en-us/web/api/cookiechangeevent/index.md b/files/en-us/web/api/cookiechangeevent/index.md index 4595d6ca2d3f594..ff4d7940ab28ed5 100644 --- a/files/en-us/web/api/cookiechangeevent/index.md +++ b/files/en-us/web/api/cookiechangeevent/index.md @@ -9,7 +9,7 @@ browser-compat: api.CookieChangeEvent {{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} -The **`CookieChangeEvent`** interface of the [Cookie Store API](/en-US/docs/Web/API/Cookie_Store_API) is the event type of the {{domxref("CookieStore.change_event", "change")}} event fired at a {{domxref("CookieStore")}} when any cookie changes occur. A cookie change consists of a cookie and a type (either "changed" or "deleted"). +The **`CookieChangeEvent`** interface of the [Cookie Store API](/en-US/docs/Web/API/Cookie_Store_API) is the event type passed to {{domxref("CookieStore.change_event", "change")}} event when any cookie changes occur. A cookie change consists of a cookie and a type (either "changed" or "deleted"). Cookie changes that will cause the `CookieChangeEvent` to be dispatched are: diff --git a/files/en-us/web/api/extendablecookiechangeevent/index.md b/files/en-us/web/api/extendablecookiechangeevent/index.md index 85ac8772da75d03..2aa19be92e02213 100644 --- a/files/en-us/web/api/extendablecookiechangeevent/index.md +++ b/files/en-us/web/api/extendablecookiechangeevent/index.md @@ -7,7 +7,7 @@ browser-compat: api.ExtendableCookieChangeEvent {{securecontext_header}}{{APIRef("Cookie Store API")}} -The **`ExtendableCookieChangeEvent`** interface of the [Cookie Store API](/en-US/docs/Web/API/Cookie_Store_API) is the event type passed to {{domxref("ServiceWorkerGlobalScope/cookiechange_event", "ServiceWorkerGlobalScope.cookiechange")}} when any cookie changes occur. A cookie change event consists of a cookie and a type (either "changed" or "deleted".) +The **`ExtendableCookieChangeEvent`** interface of the [Cookie Store API](/en-US/docs/Web/API/Cookie_Store_API) is the event type passed to {{domxref("ServiceWorkerGlobalScope/cookiechange_event", "cookiechange")}} event when any cookie changes occur. A cookie change event consists of a cookie and a type (either "changed" or "deleted".) Cookie changes that cause the `ExtendableCookieChangeEvent` to be dispatched are: From fbc7f7d069f3089c28c986dd5a26ca0008eaa31a Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sat, 11 Nov 2023 14:46:57 +0000 Subject: [PATCH 19/49] style fix --- files/en-us/web/api/cookiechangeevent/deleted/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/en-us/web/api/cookiechangeevent/deleted/index.md b/files/en-us/web/api/cookiechangeevent/deleted/index.md index a6f2a30bb30263e..db52d76393cf414 100644 --- a/files/en-us/web/api/cookiechangeevent/deleted/index.md +++ b/files/en-us/web/api/cookiechangeevent/deleted/index.md @@ -44,7 +44,7 @@ An array of objects containing the deleted cookie(s). Each object contains the f ## Examples -In this example, when the cookie is deleted the event listener logs the first item in the `CookieChangeEvent.deleted` property to the console. It contains an object representing the cookie that has just been deleted. +In this example, when the cookie is deleted, the event listener logs the first item in the `CookieChangeEvent.deleted` property to the console. It contains an object representing the cookie that has just been deleted. ```js cookieStore.addEventListener("change", (event) => { From d3331e030287463d856a26cf152aa04aadf2b812 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sat, 11 Nov 2023 15:19:27 +0000 Subject: [PATCH 20/49] add Window.cookieStore --- .../en-us/web/api/window/cookieStore/index.md | 30 +++++++++++++++++++ files/en-us/web/api/window/index.md | 2 ++ 2 files changed, 32 insertions(+) create mode 100644 files/en-us/web/api/window/cookieStore/index.md diff --git a/files/en-us/web/api/window/cookieStore/index.md b/files/en-us/web/api/window/cookieStore/index.md new file mode 100644 index 000000000000000..b6d302cc54ecaa2 --- /dev/null +++ b/files/en-us/web/api/window/cookieStore/index.md @@ -0,0 +1,30 @@ +--- +title: "Window: cookieStore property" +short-title: cookieStore +slug: Web/API/Window/cookieStore +page-type: web-api-instance-property +status: + - experimental +browser-compat: api.Window.cookieStore +--- + +{{APIRef}}{{seecompattable}} + +The **`cookieStore`** read-only property of the +{{domxref("Window")}} interface returns a reference to the {{domxref("CookieStore")}} object for the current document context. + +## Value + +A {{domxref("CookieStore")}} object instance. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- {{domxref("Cookie Store API")}} diff --git a/files/en-us/web/api/window/index.md b/files/en-us/web/api/window/index.md index 3f738aea70c2421..aa84b962536ba6a 100644 --- a/files/en-us/web/api/window/index.md +++ b/files/en-us/web/api/window/index.md @@ -33,6 +33,8 @@ Note that properties which are objects (e.g., for overriding the prototype of bu - : This property indicates whether the current window is closed or not. - {{domxref("Window.console")}} {{ReadOnlyInline}} - : Returns a reference to the console object which provides access to the browser's debugging console. +- {{domxref("Window.cookieStore")}} {{ReadOnlyInline}} {{Experimental_Inline}} + - : Returns a reference to the {{domxref("CookieStore")}} object for the current document context. - {{domxref("Window.credentialless")}} {{ReadOnlyInline}} {{Experimental_Inline}} {{Non-standard_Inline}} - : Returns a boolean that indicates whether the current document was loaded inside a credentialless {{htmlelement("iframe")}}. See [IFrame credentialless](/en-US/docs/Web/Security/IFrame_credentialless) for more details. - {{domxref("crossOriginIsolated", "Window.crossOriginIsolated")}} {{ReadOnlyInline}} From a78ce46ac5a71c6308d350c3b693df2a39796b83 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sat, 11 Nov 2023 15:20:47 +0000 Subject: [PATCH 21/49] rename --- files/en-us/web/api/window/{cookieStore => cookiestore}/index.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename files/en-us/web/api/window/{cookieStore => cookiestore}/index.md (100%) diff --git a/files/en-us/web/api/window/cookieStore/index.md b/files/en-us/web/api/window/cookiestore/index.md similarity index 100% rename from files/en-us/web/api/window/cookieStore/index.md rename to files/en-us/web/api/window/cookiestore/index.md From e98e4e9d9af964538e9fb178ff875cb91bf6c5bb Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sat, 11 Nov 2023 15:22:44 +0000 Subject: [PATCH 22/49] add ServiceWorkerGlobalScope.cookieStore --- .../cookiestore/index.md | 29 +++++++++++++++++++ .../web/api/serviceworkerglobalscope/index.md | 2 ++ .../en-us/web/api/window/cookiestore/index.md | 3 +- 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 files/en-us/web/api/serviceworkerglobalscope/cookiestore/index.md diff --git a/files/en-us/web/api/serviceworkerglobalscope/cookiestore/index.md b/files/en-us/web/api/serviceworkerglobalscope/cookiestore/index.md new file mode 100644 index 000000000000000..f56031c4bb3a3f0 --- /dev/null +++ b/files/en-us/web/api/serviceworkerglobalscope/cookiestore/index.md @@ -0,0 +1,29 @@ +--- +title: "ServiceWorkerGlobalScope: cookieStore property" +short-title: cookieStore +slug: Web/API/ServiceWorkerGlobalScope/cookieStore +page-type: web-api-instance-property +status: + - experimental +browser-compat: api.ServiceWorkerGlobalScope.cookieStore +--- + +{{APIRef}}{{seecompattable}} + +The **`cookieStore`** read-only property of the {{domxref("ServiceWorkerGlobalScope")}} interface returns a reference to the {{domxref("CookieStore")}} object for the current document context. + +## Value + +A {{domxref("CookieStore")}} object instance. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- {{domxref("Cookie Store API")}} diff --git a/files/en-us/web/api/serviceworkerglobalscope/index.md b/files/en-us/web/api/serviceworkerglobalscope/index.md index 7fe6a444de88fec..98dbe443cfcef2a 100644 --- a/files/en-us/web/api/serviceworkerglobalscope/index.md +++ b/files/en-us/web/api/serviceworkerglobalscope/index.md @@ -25,6 +25,8 @@ _This interface inherits properties from the {{domxref("WorkerGlobalScope")}} in - {{domxref("ServiceWorkerGlobalScope.clients")}} {{ReadOnlyInline}} - : Contains the {{domxref("Clients")}} object associated with the service worker. +- {{domxref("ServiceWorkerGlobalScope.cookieStore")}} {{ReadOnlyInline}} {{Experimental_Inline}} + - : Returns a reference to the {{domxref("CookieStore")}} object for the current document context. - {{domxref("ServiceWorkerGlobalScope.registration")}} {{ReadOnlyInline}} - : Contains the {{domxref("ServiceWorkerRegistration")}} object that represents the service worker's registration. diff --git a/files/en-us/web/api/window/cookiestore/index.md b/files/en-us/web/api/window/cookiestore/index.md index b6d302cc54ecaa2..7b6e408da575b8d 100644 --- a/files/en-us/web/api/window/cookiestore/index.md +++ b/files/en-us/web/api/window/cookiestore/index.md @@ -10,8 +10,7 @@ browser-compat: api.Window.cookieStore {{APIRef}}{{seecompattable}} -The **`cookieStore`** read-only property of the -{{domxref("Window")}} interface returns a reference to the {{domxref("CookieStore")}} object for the current document context. +The **`cookieStore`** read-only property of the {{domxref("Window")}} interface returns a reference to the {{domxref("CookieStore")}} object for the current document context. ## Value From 02584fe48b6ec7a4b7dcc4a1ea49efc815b95fab Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sat, 11 Nov 2023 15:26:11 +0000 Subject: [PATCH 23/49] update description --- .../en-us/web/api/serviceworkerglobalscope/cookiestore/index.md | 2 +- files/en-us/web/api/window/cookiestore/index.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/files/en-us/web/api/serviceworkerglobalscope/cookiestore/index.md b/files/en-us/web/api/serviceworkerglobalscope/cookiestore/index.md index f56031c4bb3a3f0..d3cabcff2fc5a66 100644 --- a/files/en-us/web/api/serviceworkerglobalscope/cookiestore/index.md +++ b/files/en-us/web/api/serviceworkerglobalscope/cookiestore/index.md @@ -10,7 +10,7 @@ browser-compat: api.ServiceWorkerGlobalScope.cookieStore {{APIRef}}{{seecompattable}} -The **`cookieStore`** read-only property of the {{domxref("ServiceWorkerGlobalScope")}} interface returns a reference to the {{domxref("CookieStore")}} object for the current document context. +The **`cookieStore`** read-only property of the {{domxref("ServiceWorkerGlobalScope")}} interface returns a reference to the {{domxref("CookieStore")}} object for the current document context, which is part of the {{domxref("Cookie Store API")}}. ## Value diff --git a/files/en-us/web/api/window/cookiestore/index.md b/files/en-us/web/api/window/cookiestore/index.md index 7b6e408da575b8d..cd549fb24fe77e8 100644 --- a/files/en-us/web/api/window/cookiestore/index.md +++ b/files/en-us/web/api/window/cookiestore/index.md @@ -10,7 +10,7 @@ browser-compat: api.Window.cookieStore {{APIRef}}{{seecompattable}} -The **`cookieStore`** read-only property of the {{domxref("Window")}} interface returns a reference to the {{domxref("CookieStore")}} object for the current document context. +The **`cookieStore`** read-only property of the {{domxref("Window")}} interface returns a reference to the {{domxref("CookieStore")}} object for the current document context, which is part of the {{domxref("Cookie Store API")}}. ## Value From 654bf175d5f493bbc5dcc365f3836ec05a3e0cc6 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sat, 11 Nov 2023 15:36:14 +0000 Subject: [PATCH 24/49] add ServiceWorkerGlobalScope.cookiechange_event --- .../cookiechange_event/index.md | 41 +++++++++++++++++++ .../web/api/serviceworkerglobalscope/index.md | 2 + 2 files changed, 43 insertions(+) create mode 100644 files/en-us/web/api/serviceworkerglobalscope/cookiechange_event/index.md diff --git a/files/en-us/web/api/serviceworkerglobalscope/cookiechange_event/index.md b/files/en-us/web/api/serviceworkerglobalscope/cookiechange_event/index.md new file mode 100644 index 000000000000000..bdd2eee8a66a96e --- /dev/null +++ b/files/en-us/web/api/serviceworkerglobalscope/cookiechange_event/index.md @@ -0,0 +1,41 @@ +--- +title: "ServiceWorkerGlobalScope: cookiechange event" +short-title: cookiechange +slug: Web/API/ServiceWorkerGlobalScope/cookiechange_event +page-type: web-api-event +browser-compat: api.ServiceWorkerGlobalScope.cookiechange_event +--- + +{{APIRef("Service Workers API")}} + +The **`cookiechange`** event of the {{domxref("ServiceWorkerGlobalScope")}} interface is fired when any cookie changes have occurred which match the Service Worker's cookie change subscription list added via {{domxref("CookieStoreManager.subscribe()")}}. + +This event is not cancelable and does not bubble. + +## Syntax + +Use the event name in methods like {{domxref("EventTarget.addEventListener", "addEventListener()")}}, or set an event handler property. + +```js +addEventListener("cookiechange", (event) => {}); + +oncookiechange = (event) => {}; +``` + +## Event type + +An {{domxref("ExtendableCookieChangeEvent")}}. Inherits from {{domxref("ExtendableEvent")}}. + +{{InheritanceDiagram("ExtendableCookieChangeEvent")}} + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- {{domxref("Cookie Store API")}} diff --git a/files/en-us/web/api/serviceworkerglobalscope/index.md b/files/en-us/web/api/serviceworkerglobalscope/index.md index 98dbe443cfcef2a..5cd2fa92c9218a6 100644 --- a/files/en-us/web/api/serviceworkerglobalscope/index.md +++ b/files/en-us/web/api/serviceworkerglobalscope/index.md @@ -97,6 +97,8 @@ _This interface inherits methods from the {{domxref("WorkerGlobalScope")}} inter - : Fired on a payment app's service worker to check whether it is ready to handle a payment. Specifically, it is fired when the merchant website calls {{domxref("PaymentRequest.PaymentRequest", "new PaymentRequest()")}}. - {{domxref("ServiceWorkerGlobalScope/contentdelete_event", "contentdelete")}} {{Experimental_Inline}} - : Occurs when an item is removed from the {{domxref("ContentIndex", "Content Index")}}. +- {{domxref("ServiceWorkerGlobalScope/cookiechange_event", "cookiechange")}} + - : Fired when any cookie changes have occurred which match the Service Worker's cookie change subscription list added via {{domxref("CookieStoreManager.subscribe()")}}. - {{domxref("ServiceWorkerGlobalScope/fetch_event", "fetch")}} - : Occurs when a {{domxref("fetch()")}} is called. - {{domxref("ServiceWorkerGlobalScope/install_event", "install")}} From 5e6b46c9eb5293e09488ba3fb7c8370fbcaedbaf Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sat, 11 Nov 2023 15:40:21 +0000 Subject: [PATCH 25/49] small fix --- .../api/serviceworkerglobalscope/cookiechange_event/index.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/files/en-us/web/api/serviceworkerglobalscope/cookiechange_event/index.md b/files/en-us/web/api/serviceworkerglobalscope/cookiechange_event/index.md index bdd2eee8a66a96e..2d1d10d0c960785 100644 --- a/files/en-us/web/api/serviceworkerglobalscope/cookiechange_event/index.md +++ b/files/en-us/web/api/serviceworkerglobalscope/cookiechange_event/index.md @@ -3,10 +3,12 @@ title: "ServiceWorkerGlobalScope: cookiechange event" short-title: cookiechange slug: Web/API/ServiceWorkerGlobalScope/cookiechange_event page-type: web-api-event +status: + - experimental browser-compat: api.ServiceWorkerGlobalScope.cookiechange_event --- -{{APIRef("Service Workers API")}} +{{APIRef("Cookie Store API")}}{{SeeCompatTable}} The **`cookiechange`** event of the {{domxref("ServiceWorkerGlobalScope")}} interface is fired when any cookie changes have occurred which match the Service Worker's cookie change subscription list added via {{domxref("CookieStoreManager.subscribe()")}}. From 102b45a64808820e3df44972446aa4030f70838b Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sat, 11 Nov 2023 15:42:28 +0000 Subject: [PATCH 26/49] small fix --- .../en-us/web/api/serviceworkerglobalscope/cookiestore/index.md | 2 +- files/en-us/web/api/window/cookiestore/index.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/files/en-us/web/api/serviceworkerglobalscope/cookiestore/index.md b/files/en-us/web/api/serviceworkerglobalscope/cookiestore/index.md index d3cabcff2fc5a66..a37d8e75c1fc832 100644 --- a/files/en-us/web/api/serviceworkerglobalscope/cookiestore/index.md +++ b/files/en-us/web/api/serviceworkerglobalscope/cookiestore/index.md @@ -8,7 +8,7 @@ status: browser-compat: api.ServiceWorkerGlobalScope.cookieStore --- -{{APIRef}}{{seecompattable}} +{{APIRef("Cookie Store API")}}{{SeeCompatTable}} The **`cookieStore`** read-only property of the {{domxref("ServiceWorkerGlobalScope")}} interface returns a reference to the {{domxref("CookieStore")}} object for the current document context, which is part of the {{domxref("Cookie Store API")}}. diff --git a/files/en-us/web/api/window/cookiestore/index.md b/files/en-us/web/api/window/cookiestore/index.md index cd549fb24fe77e8..ce2c73b74e5f830 100644 --- a/files/en-us/web/api/window/cookiestore/index.md +++ b/files/en-us/web/api/window/cookiestore/index.md @@ -8,7 +8,7 @@ status: browser-compat: api.Window.cookieStore --- -{{APIRef}}{{seecompattable}} +{{APIRef("Cookie Store API")}}{{SeeCompatTable}} The **`cookieStore`** read-only property of the {{domxref("Window")}} interface returns a reference to the {{domxref("CookieStore")}} object for the current document context, which is part of the {{domxref("Cookie Store API")}}. From 90f99554fb674c44158b8ddd10b3b46d206af3a3 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sat, 11 Nov 2023 15:45:04 +0000 Subject: [PATCH 27/49] add ServiceWorkerRegistration.cookies --- .../cookies/index.md | 29 +++++++++++++++++++ .../api/serviceworkerregistration/index.md | 2 ++ 2 files changed, 31 insertions(+) create mode 100644 files/en-us/web/api/serviceworkerregistration/cookies/index.md diff --git a/files/en-us/web/api/serviceworkerregistration/cookies/index.md b/files/en-us/web/api/serviceworkerregistration/cookies/index.md new file mode 100644 index 000000000000000..ba88f30c1db8347 --- /dev/null +++ b/files/en-us/web/api/serviceworkerregistration/cookies/index.md @@ -0,0 +1,29 @@ +--- +title: "ServiceWorkerRegistration: cookies property" +short-title: cookies +slug: Web/API/ServiceWorkerRegistration/cookies +page-type: web-api-instance-property +status: + - experimental +browser-compat: api.ServiceWorkerRegistration.cookies +--- + +{{APIRef("Cookie Store API")}}{{SeeCompatTable}} + +The **`cookies`** read-only property of the {{domxref("ServiceWorkerRegistration")}} interface returns a reference to the {{domxref('CookieStoreManager')}} interface, which allows subscribe and unsubscribe to cookie change events. + +## Value + +A {{domxref('CookieStoreManager')}} object. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- {{domxref("Cookie Store API")}} diff --git a/files/en-us/web/api/serviceworkerregistration/index.md b/files/en-us/web/api/serviceworkerregistration/index.md index 9eb51d9482f24a6..0dd4a4e88b91c5e 100644 --- a/files/en-us/web/api/serviceworkerregistration/index.md +++ b/files/en-us/web/api/serviceworkerregistration/index.md @@ -23,6 +23,8 @@ _Also implements properties from its parent interface,_ {{domxref("EventTarget") - : Returns a service worker whose state is `activating` or `activated`. This is initially set to `null`. An active worker will control a {{domxref("Client")}} if the client's URL falls within the scope of the registration (the `scope` option set when {{domxref("ServiceWorkerContainer.register")}} is first called.) - {{domxref("ServiceWorkerRegistration.backgroundFetch")}} {{ReadOnlyInline}} {{Experimental_Inline}} - : Returns a reference to a {{domxref("BackgroundFetchManager")}} object, which manages background fetch operations. +- {{domxref("ServiceWorkerRegistration.cookies")}} {{ReadOnlyInline}} {{Experimental_Inline}} + - : Returns a reference to the {{domxref('CookieStoreManager')}} interface, which allows subscribe and unsubscribe to cookie change events. - {{domxref("ServiceWorkerRegistration.index")}} {{ReadOnlyInline}} {{Experimental_Inline}} - : Returns a reference to the {{domxref("ContentIndex")}} interface, for managing indexed content for offline viewing. - {{domxref("ServiceWorkerRegistration.installing")}} {{ReadOnlyInline}} From 681f75e31435f0cdd6372c3b7cc93ebaa8034a40 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sat, 11 Nov 2023 15:48:32 +0000 Subject: [PATCH 28/49] update groupdata --- files/jsondata/GroupData.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/files/jsondata/GroupData.json b/files/jsondata/GroupData.json index 75e19dd3402e5e2..d42dd1e7cfb2ae4 100644 --- a/files/jsondata/GroupData.json +++ b/files/jsondata/GroupData.json @@ -195,8 +195,12 @@ "ExtendableCookieChangeEvent" ], "methods": [], - "properties": [], - "events": [] + "properties": [ + "Window.cookieStore", + "ServiceWorkerGlobalScope.cookieStore", + "ServiceWorkerRegistration.cookies" + ], + "events": ["ServiceWorkerGlobalScope: cookiechange"] }, "Credential Management API": { "overview": ["Credential Management API"], From 7680942e8d6018be2f9f58a79443ec0c58a85d63 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sat, 11 Nov 2023 15:57:45 +0000 Subject: [PATCH 29/49] small text update --- .../api/serviceworkerglobalscope/cookiechange_event/index.md | 2 +- .../web/api/serviceworkerglobalscope/cookiestore/index.md | 2 +- files/en-us/web/api/serviceworkerglobalscope/index.md | 4 ++-- .../en-us/web/api/serviceworkerregistration/cookies/index.md | 2 +- files/en-us/web/api/window/cookiestore/index.md | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/files/en-us/web/api/serviceworkerglobalscope/cookiechange_event/index.md b/files/en-us/web/api/serviceworkerglobalscope/cookiechange_event/index.md index 2d1d10d0c960785..85d7caa1039ebf8 100644 --- a/files/en-us/web/api/serviceworkerglobalscope/cookiechange_event/index.md +++ b/files/en-us/web/api/serviceworkerglobalscope/cookiechange_event/index.md @@ -10,7 +10,7 @@ browser-compat: api.ServiceWorkerGlobalScope.cookiechange_event {{APIRef("Cookie Store API")}}{{SeeCompatTable}} -The **`cookiechange`** event of the {{domxref("ServiceWorkerGlobalScope")}} interface is fired when any cookie changes have occurred which match the Service Worker's cookie change subscription list added via {{domxref("CookieStoreManager.subscribe()")}}. +The **`cookiechange`** event of the {{domxref("ServiceWorkerGlobalScope")}} interface is fired when any cookie changes have occurred which match the Service Worker's cookie change subscription list added via {{domxref("CookieStoreManager.subscribe()")}}. This is part of the {{domxref("Cookie Store API")}}. This event is not cancelable and does not bubble. diff --git a/files/en-us/web/api/serviceworkerglobalscope/cookiestore/index.md b/files/en-us/web/api/serviceworkerglobalscope/cookiestore/index.md index a37d8e75c1fc832..4fa01392295345b 100644 --- a/files/en-us/web/api/serviceworkerglobalscope/cookiestore/index.md +++ b/files/en-us/web/api/serviceworkerglobalscope/cookiestore/index.md @@ -10,7 +10,7 @@ browser-compat: api.ServiceWorkerGlobalScope.cookieStore {{APIRef("Cookie Store API")}}{{SeeCompatTable}} -The **`cookieStore`** read-only property of the {{domxref("ServiceWorkerGlobalScope")}} interface returns a reference to the {{domxref("CookieStore")}} object for the current document context, which is part of the {{domxref("Cookie Store API")}}. +The **`cookieStore`** read-only property of the {{domxref("ServiceWorkerGlobalScope")}} interface associated with the service worker. This is part of the {{domxref("Cookie Store API")}}. ## Value diff --git a/files/en-us/web/api/serviceworkerglobalscope/index.md b/files/en-us/web/api/serviceworkerglobalscope/index.md index 5cd2fa92c9218a6..aae04c311835ea8 100644 --- a/files/en-us/web/api/serviceworkerglobalscope/index.md +++ b/files/en-us/web/api/serviceworkerglobalscope/index.md @@ -26,7 +26,7 @@ _This interface inherits properties from the {{domxref("WorkerGlobalScope")}} in - {{domxref("ServiceWorkerGlobalScope.clients")}} {{ReadOnlyInline}} - : Contains the {{domxref("Clients")}} object associated with the service worker. - {{domxref("ServiceWorkerGlobalScope.cookieStore")}} {{ReadOnlyInline}} {{Experimental_Inline}} - - : Returns a reference to the {{domxref("CookieStore")}} object for the current document context. + - : Returns a reference to the {{domxref("CookieStore")}} object associated with the service worker. - {{domxref("ServiceWorkerGlobalScope.registration")}} {{ReadOnlyInline}} - : Contains the {{domxref("ServiceWorkerRegistration")}} object that represents the service worker's registration. @@ -97,7 +97,7 @@ _This interface inherits methods from the {{domxref("WorkerGlobalScope")}} inter - : Fired on a payment app's service worker to check whether it is ready to handle a payment. Specifically, it is fired when the merchant website calls {{domxref("PaymentRequest.PaymentRequest", "new PaymentRequest()")}}. - {{domxref("ServiceWorkerGlobalScope/contentdelete_event", "contentdelete")}} {{Experimental_Inline}} - : Occurs when an item is removed from the {{domxref("ContentIndex", "Content Index")}}. -- {{domxref("ServiceWorkerGlobalScope/cookiechange_event", "cookiechange")}} +- {{domxref("ServiceWorkerGlobalScope/cookiechange_event", "cookiechange")}} {{Experimental_Inline}} - : Fired when any cookie changes have occurred which match the Service Worker's cookie change subscription list added via {{domxref("CookieStoreManager.subscribe()")}}. - {{domxref("ServiceWorkerGlobalScope/fetch_event", "fetch")}} - : Occurs when a {{domxref("fetch()")}} is called. diff --git a/files/en-us/web/api/serviceworkerregistration/cookies/index.md b/files/en-us/web/api/serviceworkerregistration/cookies/index.md index ba88f30c1db8347..7d1192f167a3aa0 100644 --- a/files/en-us/web/api/serviceworkerregistration/cookies/index.md +++ b/files/en-us/web/api/serviceworkerregistration/cookies/index.md @@ -10,7 +10,7 @@ browser-compat: api.ServiceWorkerRegistration.cookies {{APIRef("Cookie Store API")}}{{SeeCompatTable}} -The **`cookies`** read-only property of the {{domxref("ServiceWorkerRegistration")}} interface returns a reference to the {{domxref('CookieStoreManager')}} interface, which allows subscribe and unsubscribe to cookie change events. +The **`cookies`** read-only property of the {{domxref("ServiceWorkerRegistration")}} interface returns a reference to the {{domxref('CookieStoreManager')}} interface, which allows subscribe and unsubscribe to cookie change events. This is part of the {{domxref("Cookie Store API")}}. ## Value diff --git a/files/en-us/web/api/window/cookiestore/index.md b/files/en-us/web/api/window/cookiestore/index.md index ce2c73b74e5f830..e80bec641410875 100644 --- a/files/en-us/web/api/window/cookiestore/index.md +++ b/files/en-us/web/api/window/cookiestore/index.md @@ -10,7 +10,7 @@ browser-compat: api.Window.cookieStore {{APIRef("Cookie Store API")}}{{SeeCompatTable}} -The **`cookieStore`** read-only property of the {{domxref("Window")}} interface returns a reference to the {{domxref("CookieStore")}} object for the current document context, which is part of the {{domxref("Cookie Store API")}}. +The **`cookieStore`** read-only property of the {{domxref("Window")}} interface returns a reference to the {{domxref("CookieStore")}} object for the current document context. This is part of the {{domxref("Cookie Store API")}}. ## Value From 42a1065261aed0cc680edf6b10b99bb74801685d Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sat, 11 Nov 2023 16:25:48 +0000 Subject: [PATCH 30/49] small fix --- files/en-us/web/api/cookie_store_api/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/en-us/web/api/cookie_store_api/index.md b/files/en-us/web/api/cookie_store_api/index.md index d0e100d2223ab6c..d829da03c3fc57e 100644 --- a/files/en-us/web/api/cookie_store_api/index.md +++ b/files/en-us/web/api/cookie_store_api/index.md @@ -9,7 +9,7 @@ browser-compat: api.CookieStore {{securecontext_header}}{{DefaultAPISidebar("Cookie Store API")}}{{SeeCompatTable}} -The _**Cookie Store API**_ provides an asynchronous API for managing cookies, while also exposing cookies to [Service Worker API](/en-US/docs/Web/API/Service_Worker_API), +The _**Cookie Store API**_ provides an asynchronous API for managing cookies, while also exposing cookies to [Service Worker API](/en-US/docs/Web/API/Service_Worker_API). ## Concepts and Usage From 271156f7d27a5f85c8e880e183fa366618b33d42 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sat, 11 Nov 2023 16:27:01 +0000 Subject: [PATCH 31/49] add {{securecontext_header}} to Window.cookieStore --- files/en-us/web/api/window/cookiestore/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/en-us/web/api/window/cookiestore/index.md b/files/en-us/web/api/window/cookiestore/index.md index e80bec641410875..f811be1536ba287 100644 --- a/files/en-us/web/api/window/cookiestore/index.md +++ b/files/en-us/web/api/window/cookiestore/index.md @@ -8,7 +8,7 @@ status: browser-compat: api.Window.cookieStore --- -{{APIRef("Cookie Store API")}}{{SeeCompatTable}} +{{APIRef("Cookie Store API")}}{{SeeCompatTable}}{{securecontext_header}} The **`cookieStore`** read-only property of the {{domxref("Window")}} interface returns a reference to the {{domxref("CookieStore")}} object for the current document context. This is part of the {{domxref("Cookie Store API")}}. From 291dfe202517540f87c02f1d36ca597c3f360ff2 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sat, 11 Nov 2023 16:27:23 +0000 Subject: [PATCH 32/49] add {{AvailableInWorkers}} --- files/en-us/web/api/cookiestore/delete/index.md | 2 +- files/en-us/web/api/cookiestore/get/index.md | 2 +- files/en-us/web/api/cookiestore/getall/index.md | 2 +- files/en-us/web/api/cookiestore/index.md | 2 +- files/en-us/web/api/cookiestore/set/index.md | 2 +- .../en-us/web/api/cookiestoremanager/getsubscriptions/index.md | 2 +- files/en-us/web/api/cookiestoremanager/index.md | 2 +- files/en-us/web/api/cookiestoremanager/subscribe/index.md | 2 +- files/en-us/web/api/cookiestoremanager/unsubscribe/index.md | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/files/en-us/web/api/cookiestore/delete/index.md b/files/en-us/web/api/cookiestore/delete/index.md index 71ed5916e4385cc..63f701aa330bd35 100644 --- a/files/en-us/web/api/cookiestore/delete/index.md +++ b/files/en-us/web/api/cookiestore/delete/index.md @@ -8,7 +8,7 @@ status: browser-compat: api.CookieStore.delete --- -{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}}{{AvailableInWorkers}} The **`delete()`** method of the {{domxref("CookieStore")}} interface deletes a cookie with the given name or options object. The `delete()` method expires the cookie by changing the date to one in the past. diff --git a/files/en-us/web/api/cookiestore/get/index.md b/files/en-us/web/api/cookiestore/get/index.md index 50f5f3f5e57b242..83a246db809d220 100644 --- a/files/en-us/web/api/cookiestore/get/index.md +++ b/files/en-us/web/api/cookiestore/get/index.md @@ -8,7 +8,7 @@ status: browser-compat: api.CookieStore.get --- -{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}}{{AvailableInWorkers}} The **`get()`** method of the {{domxref("CookieStore")}} interface returns a single cookie with the given name or options object. The method will return the first matching cookie for the passed parameters. diff --git a/files/en-us/web/api/cookiestore/getall/index.md b/files/en-us/web/api/cookiestore/getall/index.md index e22be4c75aa4f5d..6252040a492818b 100644 --- a/files/en-us/web/api/cookiestore/getall/index.md +++ b/files/en-us/web/api/cookiestore/getall/index.md @@ -8,7 +8,7 @@ status: browser-compat: api.CookieStore.getAll --- -{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}}{{AvailableInWorkers}} The **`getAll()`** method of the {{domxref("CookieStore")}} interface returns a list of cookies that match the name or options passed to it. Passing no parameters will return all cookies for the current context. diff --git a/files/en-us/web/api/cookiestore/index.md b/files/en-us/web/api/cookiestore/index.md index 1fb8bb2cacb1222..8b1035a0801e597 100644 --- a/files/en-us/web/api/cookiestore/index.md +++ b/files/en-us/web/api/cookiestore/index.md @@ -7,7 +7,7 @@ status: browser-compat: api.CookieStore --- -{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}}{{AvailableInWorkers}} The **`CookieStore`** interface of the [Cookie Store API](/en-US/docs/Web/API/Cookie_Store_API) provides methods for getting and setting cookies asynchronously from either a page or a service worker. diff --git a/files/en-us/web/api/cookiestore/set/index.md b/files/en-us/web/api/cookiestore/set/index.md index 1da5b6ee6b1baf3..f9d42fb02eb6d75 100644 --- a/files/en-us/web/api/cookiestore/set/index.md +++ b/files/en-us/web/api/cookiestore/set/index.md @@ -8,7 +8,7 @@ status: browser-compat: api.CookieStore.set --- -{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}}{{AvailableInWorkers}} The **`set()`** method of the {{domxref("CookieStore")}} interface sets a cookie with the given name and value or options object. diff --git a/files/en-us/web/api/cookiestoremanager/getsubscriptions/index.md b/files/en-us/web/api/cookiestoremanager/getsubscriptions/index.md index f5f88859272f462..f9d3ec104074691 100644 --- a/files/en-us/web/api/cookiestoremanager/getsubscriptions/index.md +++ b/files/en-us/web/api/cookiestoremanager/getsubscriptions/index.md @@ -8,7 +8,7 @@ status: browser-compat: api.CookieStoreManager.getSubscriptions --- -{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}}{{AvailableInWorkers}} The **`getSubscriptions()`** method of the {{domxref("CookieStoreManager")}} interface returns a list of all the cookie change subscriptions for this {{domxref("ServiceWorkerRegistration")}}. diff --git a/files/en-us/web/api/cookiestoremanager/index.md b/files/en-us/web/api/cookiestoremanager/index.md index a276399b330f9df..1270d5e9a11a714 100644 --- a/files/en-us/web/api/cookiestoremanager/index.md +++ b/files/en-us/web/api/cookiestoremanager/index.md @@ -7,7 +7,7 @@ status: browser-compat: api.CookieStoreManager --- -{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}}{{AvailableInWorkers}} The **`CookieStoreManager`** interface of the [Cookie Store API](/en-US/docs/Web/API/Cookie_Store_API) allows service workers to subscribe to cookie change events. Call {{domxref("CookieStoreManager.subscribe()","subscribe()")}} on a particular service worker registration to receive change events. diff --git a/files/en-us/web/api/cookiestoremanager/subscribe/index.md b/files/en-us/web/api/cookiestoremanager/subscribe/index.md index d743de202af2acc..f8d3ff9a6cda452 100644 --- a/files/en-us/web/api/cookiestoremanager/subscribe/index.md +++ b/files/en-us/web/api/cookiestoremanager/subscribe/index.md @@ -8,7 +8,7 @@ status: browser-compat: api.CookieStoreManager.subscribe --- -{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}}{{AvailableInWorkers}} The **`subscribe()`** method of the {{domxref("CookieStoreManager")}} interface subscribes a {{domxref("ServiceWorkerRegistration")}} to cookie change events. diff --git a/files/en-us/web/api/cookiestoremanager/unsubscribe/index.md b/files/en-us/web/api/cookiestoremanager/unsubscribe/index.md index 33a8a0599ebd1f1..262ccae0bf15cd3 100644 --- a/files/en-us/web/api/cookiestoremanager/unsubscribe/index.md +++ b/files/en-us/web/api/cookiestoremanager/unsubscribe/index.md @@ -8,7 +8,7 @@ status: browser-compat: api.CookieStoreManager.unsubscribe --- -{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}}{{AvailableInWorkers}} The **`unsubscribe()`** method of the {{domxref("CookieStoreManager")}} interface stops the {{domxref("ServiceWorkerRegistration")}} from receiving previously subscribed events. From e672ed2dc5d4a8057143e9cf6c74b796a8c1a877 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sat, 11 Nov 2023 16:33:53 +0000 Subject: [PATCH 33/49] update api summary --- files/en-us/web/api/cookie_store_api/index.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/files/en-us/web/api/cookie_store_api/index.md b/files/en-us/web/api/cookie_store_api/index.md index d829da03c3fc57e..fb35129f353cee4 100644 --- a/files/en-us/web/api/cookie_store_api/index.md +++ b/files/en-us/web/api/cookie_store_api/index.md @@ -30,6 +30,17 @@ The _Cookie Store API_ provides an updated method of managing cookies. It is {{G - {{domxref("ExtendableCookieChangeEvent")}} - : An `ExtendableCookieChangeEvent` named `cookiechange` is dispatched against {{domxref("ServiceWorkerGlobalScope")}} contexts when any script-visible cookie changes occur that match the service worker's cookie change subscription list. +## Extensions to other interfaces + +- {{domxref("ServiceWorkerGlobalScope.cookieStore")}} {{ReadOnlyInline}} {{Experimental_Inline}} + - : Returns a reference to the {{domxref("CookieStore")}} object associated with the service worker. +- {{domxref("ServiceWorkerGlobalScope/cookiechange_event", "cookiechange")}} {{Experimental_Inline}} + - : Fired when any cookie changes have occurred which match the Service Worker's cookie change subscription list added via {{domxref("CookieStoreManager.subscribe()")}}. +- {{domxref("ServiceWorkerRegistration.cookies")}} {{ReadOnlyInline}} {{Experimental_Inline}} + - : Returns a reference to the {{domxref('CookieStoreManager')}} interface, which allows subscribe and unsubscribe to cookie change events. +- {{domxref("Window.cookieStore")}} {{ReadOnlyInline}} {{Experimental_Inline}} + - : Returns a reference to the {{domxref("CookieStore")}} object for the current document context. + ## Specifications {{Specifications}} From 60374c8c1718b2d59a30a0ea4013c820a5f9227e Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sat, 11 Nov 2023 16:40:58 +0000 Subject: [PATCH 34/49] small update --- .../en-us/web/api/cookiechangeevent/cookiechangeevent/index.md | 2 +- .../extendablecookiechangeevent/index.md | 2 +- files/en-us/web/api/extendablecookiechangeevent/index.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/files/en-us/web/api/cookiechangeevent/cookiechangeevent/index.md b/files/en-us/web/api/cookiechangeevent/cookiechangeevent/index.md index 41ab50c4bc13802..98e6ba78ef9e1e9 100644 --- a/files/en-us/web/api/cookiechangeevent/cookiechangeevent/index.md +++ b/files/en-us/web/api/cookiechangeevent/cookiechangeevent/index.md @@ -11,7 +11,7 @@ browser-compat: api.CookieChangeEvent.CookieChangeEvent {{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} The **`CookieChangeEvent()`** constructor creates a new {{domxref("CookieChangeEvent")}} object -which is the event type passed to {{domxref("CookieStore/change_event", "CookieStore.change")}}. +which is the event type passed to {{domxref("CookieStore.change_event", "change")}}. This constructor is called by the browser when a change event occurs. > **Note:** This event constructor is generally not needed for production websites. It's primary use is for tests that require an instance of this event. diff --git a/files/en-us/web/api/extendablecookiechangeevent/extendablecookiechangeevent/index.md b/files/en-us/web/api/extendablecookiechangeevent/extendablecookiechangeevent/index.md index 556da49b3e76ed2..eb79de2a5476436 100644 --- a/files/en-us/web/api/extendablecookiechangeevent/extendablecookiechangeevent/index.md +++ b/files/en-us/web/api/extendablecookiechangeevent/extendablecookiechangeevent/index.md @@ -9,7 +9,7 @@ browser-compat: api.ExtendableCookieChangeEvent.ExtendableCookieChangeEvent {{securecontext_header}}{{APIRef("Cookie Store API")}} The **`ExtendableCookieChangeEvent()`** constructor creates a new {{domxref("ExtendableCookieChangeEvent")}} object -which is the event type passed to {{domxref("ServiceWorkerGlobalScope/cookiechange_event", "ServiceWorkerGlobalScope.cookiechange")}}. +which is the event type passed to {{domxref("ServiceWorkerGlobalScope.cookiechange_event", "cookiechange")}}. This constructor is called by the browser when a change event occurs. > **Note:** This event constructor is generally not needed for production websites. It's primary use is for tests that require an instance of this event. diff --git a/files/en-us/web/api/extendablecookiechangeevent/index.md b/files/en-us/web/api/extendablecookiechangeevent/index.md index 2aa19be92e02213..f2b6440f40ba05a 100644 --- a/files/en-us/web/api/extendablecookiechangeevent/index.md +++ b/files/en-us/web/api/extendablecookiechangeevent/index.md @@ -7,7 +7,7 @@ browser-compat: api.ExtendableCookieChangeEvent {{securecontext_header}}{{APIRef("Cookie Store API")}} -The **`ExtendableCookieChangeEvent`** interface of the [Cookie Store API](/en-US/docs/Web/API/Cookie_Store_API) is the event type passed to {{domxref("ServiceWorkerGlobalScope/cookiechange_event", "cookiechange")}} event when any cookie changes occur. A cookie change event consists of a cookie and a type (either "changed" or "deleted".) +The **`ExtendableCookieChangeEvent`** interface of the [Cookie Store API](/en-US/docs/Web/API/Cookie_Store_API) is the event type passed to {{domxref("ServiceWorkerGlobalScope.cookiechange_event", "cookiechange")}} event when any cookie changes occur. A cookie change event consists of a cookie and a type (either "changed" or "deleted".) Cookie changes that cause the `ExtendableCookieChangeEvent` to be dispatched are: From 591302ed267ba351d55271b34dd050d59d60e2bf Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sat, 11 Nov 2023 16:49:21 +0000 Subject: [PATCH 35/49] fix a word --- files/en-us/web/api/cookiestoremanager/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/en-us/web/api/cookiestoremanager/index.md b/files/en-us/web/api/cookiestoremanager/index.md index 1270d5e9a11a714..87ac59fcda1046b 100644 --- a/files/en-us/web/api/cookiestoremanager/index.md +++ b/files/en-us/web/api/cookiestoremanager/index.md @@ -13,7 +13,7 @@ The **`CookieStoreManager`** interface of the [Cookie Store API](/en-US/docs/Web A `CookieStoreManager` has an associated {{domxref("ServiceWorkerRegistration")}}. Each service worker registration has a cookie change subscription list, which is a list of cookie change subscriptions each containing a name and URL. The methods in this interface allow the service worker to add and remove subscriptions from this list, and to get a list of all subscriptions. -To get a `CookieStoreManager`, call {{domxref("ServiceWorkerRegistration.cookies")}}. +To get a `CookieStoreManager`, use {{domxref("ServiceWorkerRegistration.cookies")}}. ## Instance methods From b1b30e71a2dd592cdf1c78cb92dcc65d18301bf9 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sat, 11 Nov 2023 17:02:12 +0000 Subject: [PATCH 36/49] add description for default value --- files/en-us/web/api/cookiestore/delete/index.md | 8 ++++---- files/en-us/web/api/cookiestore/set/index.md | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/files/en-us/web/api/cookiestore/delete/index.md b/files/en-us/web/api/cookiestore/delete/index.md index 63f701aa330bd35..e2e6eac29f3b781 100644 --- a/files/en-us/web/api/cookiestore/delete/index.md +++ b/files/en-us/web/api/cookiestore/delete/index.md @@ -34,12 +34,12 @@ Or - `name` - : A string with the name of a cookie. + - `domain` {{Optional_Inline}} + - : A string with the URL of a cookie. Defaults to `null`. + - `path` {{Optional_Inline}} + - : A string containing a path. Defaults to `/`. - `partitioned` {{Optional_Inline}} - : A boolean value that defaults to `false`. Setting it to `true` specifies that the cookie to delete will be a partitioned cookie. See [Cookies Having Independent Partitioned State (CHIPS)](/en-US/docs/Web/Privacy/Partitioned_cookies) for more information. - - `path` {{Optional_Inline}} - - : A string containing a path. - - `url` {{Optional_Inline}} - - : A string with the URL of a cookie. > **Note:** The `url` option enables the modification of a cookie scoped under a particular URL. Service workers can obtain cookies that would be sent to any URL under their scope. From a document you may only obtain the cookies at the current URL, so the only valid URL in a document context is the document's URL. diff --git a/files/en-us/web/api/cookiestore/set/index.md b/files/en-us/web/api/cookiestore/set/index.md index f9d42fb02eb6d75..5a7223274825e8e 100644 --- a/files/en-us/web/api/cookiestore/set/index.md +++ b/files/en-us/web/api/cookiestore/set/index.md @@ -35,21 +35,21 @@ Or - : An object containing: - `domain` {{Optional_Inline}} - - : A string containing the domain of the cookie. + - : A string containing the domain of the cookie. Defaults to `null`. - `expires` {{Optional_Inline}} - - : A timestamp, given as [Unix time](/en-US/docs/Glossary/Unix_time) in milliseconds, containing the expiration date of the cookie. + - : A timestamp, given as [Unix time](/en-US/docs/Glossary/Unix_time) in milliseconds, containing the expiration date of the cookie. Defaults to `null`. - `name` - : A string with the name of a cookie. - `partitioned` {{Optional_Inline}} - - : A boolean value that defaults to `false`. If set to `true`, the set cookie will be a partitioned cookie. See [Cookies Having Independent Partitioned State (CHIPS)](/en-US/docs/Web/Privacy/Partitioned_cookies) for more information. + - : A boolean value that defaults to `false`. If set to `true`, the set cookie will be a partitioned cookie. See [Cookies Having Independent Partitioned State (CHIPS)](/en-US/docs/Web/Privacy/Partitioned_cookies) for more information. Defaults to `false`. - `path` {{Optional_Inline}} - - : A string containing the path of the cookie. + - : A string containing the path of the cookie. Defaults to `/`. - `sameSite` {{Optional_Inline}} - : One of the following [`SameSite`](/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value) values: - `"strict"` - - : Cookies will only be sent in a first-party context and not be sent along with requests initiated by third party websites. + - : Cookies will only be sent in a first-party context and not be sent along with requests initiated by third party websites. This is the default value if not specificed. - `"lax"` - : Cookies are not sent on normal cross-site subrequests (for example to load images or frames into a third party site), but are sent when a user is navigating to the origin site (i.e. when following a link). - `"none"` From c945e47622af7bd3eb1caeeb5ec9a934eb0e13db Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sun, 26 Nov 2023 03:20:23 +0800 Subject: [PATCH 37/49] Apply suggestions from code review --- files/en-us/web/api/cookie_store_api/index.md | 10 +++++----- .../api/cookiechangeevent/cookiechangeevent/index.md | 2 +- files/en-us/web/api/cookiechangeevent/index.md | 4 ++-- files/en-us/web/api/cookiestore/delete/index.md | 2 +- files/en-us/web/api/cookiestore/getall/index.md | 4 ++-- files/en-us/web/api/cookiestore/set/index.md | 2 +- .../en-us/web/api/extendablecookiechangeevent/index.md | 2 +- .../api/serviceworkerglobalscope/cookiestore/index.md | 2 +- .../web/api/serviceworkerregistration/cookies/index.md | 2 +- files/jsondata/GroupData.json | 2 +- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/files/en-us/web/api/cookie_store_api/index.md b/files/en-us/web/api/cookie_store_api/index.md index fb35129f353cee4..0773e8e5135ca55 100644 --- a/files/en-us/web/api/cookie_store_api/index.md +++ b/files/en-us/web/api/cookie_store_api/index.md @@ -13,7 +13,7 @@ The _**Cookie Store API**_ provides an asynchronous API for managing cookies, wh ## Concepts and Usage -The existing method of getting and setting cookies involves working with {{domxref("document.cookie")}} as a string of key-value pairs. In addition to this being cumbersome and error prone, it also has a host of issues in the context of modern web development. +The existing method of getting and setting cookies involves working with {{domxref("document.cookie")}} as a string of key/value pairs. In addition to this being cumbersome and error prone, it also has a host of issues in the context of modern web development. The `document.cookie` interface is {{Glossary("synchronous")}}, single-threaded, and blocking. When writing a cookie you must wait for the browser to update the string of all cookies. In addition, the reliance on {{domxref("document")}} means that cookies cannot be accessed by service workers which cannot access the {{domxref("document")}} object. @@ -23,11 +23,11 @@ The _Cookie Store API_ provides an updated method of managing cookies. It is {{G - {{domxref("CookieStore")}} - : The `CookieStore` interface enables getting and setting cookies. -- {{domxref("CookieStoreManager")}} +- {{domxref("CookieStoreManager")}} {{Experimental_Inline}} - : The `CookieStoreManager` interface provides a service worker registration to enable service workers to subscribe to cookie change events. -- {{domxref("CookieChangeEvent")}} +- {{domxref("CookieChangeEvent")}} {{Experimental_Inline}} - : A `CookieChangeEvent` named `change` is dispatched against `CookieStore` object in {{domxref("Window")}} contexts when any script-visible cookies changes occur. -- {{domxref("ExtendableCookieChangeEvent")}} +- {{domxref("ExtendableCookieChangeEvent")}} {{Experimental_Inline}} - : An `ExtendableCookieChangeEvent` named `cookiechange` is dispatched against {{domxref("ServiceWorkerGlobalScope")}} contexts when any script-visible cookie changes occur that match the service worker's cookie change subscription list. ## Extensions to other interfaces @@ -37,7 +37,7 @@ The _Cookie Store API_ provides an updated method of managing cookies. It is {{G - {{domxref("ServiceWorkerGlobalScope/cookiechange_event", "cookiechange")}} {{Experimental_Inline}} - : Fired when any cookie changes have occurred which match the Service Worker's cookie change subscription list added via {{domxref("CookieStoreManager.subscribe()")}}. - {{domxref("ServiceWorkerRegistration.cookies")}} {{ReadOnlyInline}} {{Experimental_Inline}} - - : Returns a reference to the {{domxref('CookieStoreManager')}} interface, which allows subscribe and unsubscribe to cookie change events. + - : Returns a reference to the {{domxref("CookieStoreManager")}} interface, which allows subscribe and unsubscribe to cookie change events. - {{domxref("Window.cookieStore")}} {{ReadOnlyInline}} {{Experimental_Inline}} - : Returns a reference to the {{domxref("CookieStore")}} object for the current document context. diff --git a/files/en-us/web/api/cookiechangeevent/cookiechangeevent/index.md b/files/en-us/web/api/cookiechangeevent/cookiechangeevent/index.md index 98e6ba78ef9e1e9..704b34da3fc3b9c 100644 --- a/files/en-us/web/api/cookiechangeevent/cookiechangeevent/index.md +++ b/files/en-us/web/api/cookiechangeevent/cookiechangeevent/index.md @@ -11,7 +11,7 @@ browser-compat: api.CookieChangeEvent.CookieChangeEvent {{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} The **`CookieChangeEvent()`** constructor creates a new {{domxref("CookieChangeEvent")}} object -which is the event type passed to {{domxref("CookieStore.change_event", "change")}}. +which is the event type passed to {{domxref("CookieStore.change_event", "change")}} event. This constructor is called by the browser when a change event occurs. > **Note:** This event constructor is generally not needed for production websites. It's primary use is for tests that require an instance of this event. diff --git a/files/en-us/web/api/cookiechangeevent/index.md b/files/en-us/web/api/cookiechangeevent/index.md index ff4d7940ab28ed5..f9d70a4fa62ae7c 100644 --- a/files/en-us/web/api/cookiechangeevent/index.md +++ b/files/en-us/web/api/cookiechangeevent/index.md @@ -9,7 +9,7 @@ browser-compat: api.CookieChangeEvent {{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} -The **`CookieChangeEvent`** interface of the [Cookie Store API](/en-US/docs/Web/API/Cookie_Store_API) is the event type passed to {{domxref("CookieStore.change_event", "change")}} event when any cookie changes occur. A cookie change consists of a cookie and a type (either "changed" or "deleted"). +The **`CookieChangeEvent`** interface of the [Cookie Store API](/en-US/docs/Web/API/Cookie_Store_API) is the event type passed to {{domxref("CookieStore.change_event", "change")}} event fired at the {{domxref("CookieStore")}} when any cookie changes occur. A cookie change consists of a cookie and a type (either "changed" or "deleted"). Cookie changes that will cause the `CookieChangeEvent` to be dispatched are: @@ -37,7 +37,7 @@ _This interface also inherits properties from {{domxref("Event")}}._ ## Instance methods -_This interface also inherits methods from {{domxref("ExtendableEvent")}}._ +_This interface also inherits methods from {{domxref("Event")}}._ ## Examples diff --git a/files/en-us/web/api/cookiestore/delete/index.md b/files/en-us/web/api/cookiestore/delete/index.md index e2e6eac29f3b781..416c88eefbc58df 100644 --- a/files/en-us/web/api/cookiestore/delete/index.md +++ b/files/en-us/web/api/cookiestore/delete/index.md @@ -50,7 +50,7 @@ A {{jsxref("Promise")}} that resolves with {{jsxref("undefined")}} when deletion ### Exceptions - `SecurityError` {{domxref("DOMException")}} - - : Thrown if the origin does not {{glossary("Serialization", "serialize")}} to a URL. + - : Thrown if the origin can not {{glossary("Serialization", "serialize")}} to a URL. - {{jsxref("TypeError")}} - : Thrown if deleting the cookie represented by the given `name` or `options` fails. diff --git a/files/en-us/web/api/cookiestore/getall/index.md b/files/en-us/web/api/cookiestore/getall/index.md index 6252040a492818b..2eb7f9eadb91486 100644 --- a/files/en-us/web/api/cookiestore/getall/index.md +++ b/files/en-us/web/api/cookiestore/getall/index.md @@ -87,8 +87,8 @@ Each object contains the following properties: - : Thrown if the origin does not {{glossary("Serialization", "serialize")}} to a URL. - {{jsxref("TypeError")}} - : Thrown if: - - The `url` in `options` is present and is not equal with the creation URL if in Window context. - - The `url` in `options` is present and its origin is same as the origin of the creation URL. + - The `url` member of `options` parameter is present and is not equal with the creation URL if in Window context. + - The `url` member of `options` parameter is present and its origin is same as the origin of the creation URL. - Getting the cookie or cookies represented by the given `name` or `options` fails. ## Examples diff --git a/files/en-us/web/api/cookiestore/set/index.md b/files/en-us/web/api/cookiestore/set/index.md index 5a7223274825e8e..727301230949603 100644 --- a/files/en-us/web/api/cookiestore/set/index.md +++ b/files/en-us/web/api/cookiestore/set/index.md @@ -65,7 +65,7 @@ A {{jsxref("Promise")}} that resolves with {{jsxref("undefined")}} when setting ### Exceptions - `SecurityError` {{domxref("DOMException")}} - - : Thrown if the origin does not {{glossary("Serialization", "serialize")}} to a URL. + - : Thrown if the origin can not {{glossary("Serialization", "serialize")}} to a URL. - {{jsxref("TypeError")}} - : Thrown if setting the cookie with the given `name` and `value` or `options` fails. diff --git a/files/en-us/web/api/extendablecookiechangeevent/index.md b/files/en-us/web/api/extendablecookiechangeevent/index.md index f2b6440f40ba05a..347125be2751e5e 100644 --- a/files/en-us/web/api/extendablecookiechangeevent/index.md +++ b/files/en-us/web/api/extendablecookiechangeevent/index.md @@ -7,7 +7,7 @@ browser-compat: api.ExtendableCookieChangeEvent {{securecontext_header}}{{APIRef("Cookie Store API")}} -The **`ExtendableCookieChangeEvent`** interface of the [Cookie Store API](/en-US/docs/Web/API/Cookie_Store_API) is the event type passed to {{domxref("ServiceWorkerGlobalScope.cookiechange_event", "cookiechange")}} event when any cookie changes occur. A cookie change event consists of a cookie and a type (either "changed" or "deleted".) +The **`ExtendableCookieChangeEvent`** interface of the [Cookie Store API](/en-US/docs/Web/API/Cookie_Store_API) is the event type passed to {{domxref("ServiceWorkerGlobalScope.cookiechange_event", "cookiechange")}} event fired at the {{domxref("ServiceWorkerGlobalScope")}} when any cookie changes occur. A cookie change event consists of a cookie and a type (either "changed" or "deleted".) Cookie changes that cause the `ExtendableCookieChangeEvent` to be dispatched are: diff --git a/files/en-us/web/api/serviceworkerglobalscope/cookiestore/index.md b/files/en-us/web/api/serviceworkerglobalscope/cookiestore/index.md index 4fa01392295345b..ee23ba84761f262 100644 --- a/files/en-us/web/api/serviceworkerglobalscope/cookiestore/index.md +++ b/files/en-us/web/api/serviceworkerglobalscope/cookiestore/index.md @@ -10,7 +10,7 @@ browser-compat: api.ServiceWorkerGlobalScope.cookieStore {{APIRef("Cookie Store API")}}{{SeeCompatTable}} -The **`cookieStore`** read-only property of the {{domxref("ServiceWorkerGlobalScope")}} interface associated with the service worker. This is part of the {{domxref("Cookie Store API")}}. +The **`cookieStore`** read-only property of the {{domxref("ServiceWorkerGlobalScope")}} interface returns a reference to the {{domxref("CookieStore")}} object associated with the service worker. This is part of the {{domxref("Cookie Store API", "", "", "nocode")}}. ## Value diff --git a/files/en-us/web/api/serviceworkerregistration/cookies/index.md b/files/en-us/web/api/serviceworkerregistration/cookies/index.md index 7d1192f167a3aa0..84a02efa1ccf5d3 100644 --- a/files/en-us/web/api/serviceworkerregistration/cookies/index.md +++ b/files/en-us/web/api/serviceworkerregistration/cookies/index.md @@ -14,7 +14,7 @@ The **`cookies`** read-only property of the {{domxref("ServiceWorkerRegistration ## Value -A {{domxref('CookieStoreManager')}} object. +A {{domxref("CookieStoreManager")}} object. ## Specifications diff --git a/files/jsondata/GroupData.json b/files/jsondata/GroupData.json index d42dd1e7cfb2ae4..b686f8132a8f39c 100644 --- a/files/jsondata/GroupData.json +++ b/files/jsondata/GroupData.json @@ -200,7 +200,7 @@ "ServiceWorkerGlobalScope.cookieStore", "ServiceWorkerRegistration.cookies" ], - "events": ["ServiceWorkerGlobalScope: cookiechange"] + "events": ["ServiceWorkerGlobalScope: cookiechange event"] }, "Credential Management API": { "overview": ["Credential Management API"], From 9d02907be79c8c233f35bfb9c8325a2f66ceaf4a Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sat, 25 Nov 2023 19:28:04 +0000 Subject: [PATCH 38/49] append unadded {{Experimental_Inline}} --- files/en-us/web/api/cookie_store_api/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/en-us/web/api/cookie_store_api/index.md b/files/en-us/web/api/cookie_store_api/index.md index 0773e8e5135ca55..6a6917dedd51238 100644 --- a/files/en-us/web/api/cookie_store_api/index.md +++ b/files/en-us/web/api/cookie_store_api/index.md @@ -21,7 +21,7 @@ The _Cookie Store API_ provides an updated method of managing cookies. It is {{G ## Interfaces -- {{domxref("CookieStore")}} +- {{domxref("CookieStore")}} {{Experimental_Inline}} - : The `CookieStore` interface enables getting and setting cookies. - {{domxref("CookieStoreManager")}} {{Experimental_Inline}} - : The `CookieStoreManager` interface provides a service worker registration to enable service workers to subscribe to cookie change events. From 2757828a2f05d22a86aa0582155e4a694f66855e Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sat, 25 Nov 2023 19:28:52 +0000 Subject: [PATCH 39/49] add {{Optional_Inline}} for event constructor --- .../web/api/cookiechangeevent/cookiechangeevent/index.md | 4 ++-- .../extendablecookiechangeevent/index.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/files/en-us/web/api/cookiechangeevent/cookiechangeevent/index.md b/files/en-us/web/api/cookiechangeevent/cookiechangeevent/index.md index 704b34da3fc3b9c..02f3f286898c250 100644 --- a/files/en-us/web/api/cookiechangeevent/cookiechangeevent/index.md +++ b/files/en-us/web/api/cookiechangeevent/cookiechangeevent/index.md @@ -29,9 +29,9 @@ new CookieChangeEvent(type, options) - : A string with the name of the event. It is case-sensitive and browsers always set it to `change`. - `options` {{Optional_Inline}} - : An object that, _in addition of the properties defined in {{domxref("Event/Event", "Event()")}}_, can have the following properties: - - `changed` + - `changed` {{Optional_Inline}} - : An array containing the changed cookies. - - `deleted` + - `deleted` {{Optional_Inline}} - : An array containing the deleted cookies. ### Return value diff --git a/files/en-us/web/api/extendablecookiechangeevent/extendablecookiechangeevent/index.md b/files/en-us/web/api/extendablecookiechangeevent/extendablecookiechangeevent/index.md index eb79de2a5476436..f77c4e4c5a31d55 100644 --- a/files/en-us/web/api/extendablecookiechangeevent/extendablecookiechangeevent/index.md +++ b/files/en-us/web/api/extendablecookiechangeevent/extendablecookiechangeevent/index.md @@ -28,9 +28,9 @@ new ExtendableCookieChangeEvent(type, options) It is case-sensitive and browsers always set it to `cookiechange`. - `options` {{optional_inline}} - : An object that, _in addition of the properties defined in {{domxref("ExtendableEvent/ExtendableEvent", "ExtendableEvent()")}}_, can have the following properties: - - `changed` + - `changed` {{optional_inline}} - : An array containing a changed cookie. - - `deleted` + - `deleted` {{optional_inline}} - : An array containing a deleted cookie. ### Return value From 09318d21f4496466929e89d07f2348bdccb5f268 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sat, 25 Nov 2023 19:31:27 +0000 Subject: [PATCH 40/49] add {{AvailableInWorkers}} --- .../en-us/web/api/extendablecookiechangeevent/changed/index.md | 2 +- .../en-us/web/api/extendablecookiechangeevent/deleted/index.md | 2 +- .../extendablecookiechangeevent/index.md | 2 +- files/en-us/web/api/extendablecookiechangeevent/index.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/files/en-us/web/api/extendablecookiechangeevent/changed/index.md b/files/en-us/web/api/extendablecookiechangeevent/changed/index.md index f7c24bc949ad199..fb1bc189c874266 100644 --- a/files/en-us/web/api/extendablecookiechangeevent/changed/index.md +++ b/files/en-us/web/api/extendablecookiechangeevent/changed/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-property browser-compat: api.ExtendableCookieChangeEvent.changed --- -{{securecontext_header}}{{APIRef("Cookie Store API")}} +{{securecontext_header}}{{APIRef("Cookie Store API")}}{{AvailableInWorkers}} The **`changed`** read-only property of the {{domxref("ExtendableCookieChangeEvent")}} interface returns any cookies that have been changed by the given `ExtendableCookieChangeEvent` instance. diff --git a/files/en-us/web/api/extendablecookiechangeevent/deleted/index.md b/files/en-us/web/api/extendablecookiechangeevent/deleted/index.md index 7c7d57767f01b5b..8c399667b3a2cd9 100644 --- a/files/en-us/web/api/extendablecookiechangeevent/deleted/index.md +++ b/files/en-us/web/api/extendablecookiechangeevent/deleted/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-property browser-compat: api.ExtendableCookieChangeEvent.deleted --- -{{securecontext_header}}{{APIRef("Cookie Store API")}} +{{securecontext_header}}{{APIRef("Cookie Store API")}}{{AvailableInWorkers}} The **`deleted`** read-only property of the {{domxref("ExtendableCookieChangeEvent")}} interface returns any cookies that have been deleted by the given `ExtendableCookieChangeEvent` instance. diff --git a/files/en-us/web/api/extendablecookiechangeevent/extendablecookiechangeevent/index.md b/files/en-us/web/api/extendablecookiechangeevent/extendablecookiechangeevent/index.md index f77c4e4c5a31d55..8e037dc696900d1 100644 --- a/files/en-us/web/api/extendablecookiechangeevent/extendablecookiechangeevent/index.md +++ b/files/en-us/web/api/extendablecookiechangeevent/extendablecookiechangeevent/index.md @@ -6,7 +6,7 @@ page-type: web-api-constructor browser-compat: api.ExtendableCookieChangeEvent.ExtendableCookieChangeEvent --- -{{securecontext_header}}{{APIRef("Cookie Store API")}} +{{securecontext_header}}{{APIRef("Cookie Store API")}}{{AvailableInWorkers}} The **`ExtendableCookieChangeEvent()`** constructor creates a new {{domxref("ExtendableCookieChangeEvent")}} object which is the event type passed to {{domxref("ServiceWorkerGlobalScope.cookiechange_event", "cookiechange")}}. diff --git a/files/en-us/web/api/extendablecookiechangeevent/index.md b/files/en-us/web/api/extendablecookiechangeevent/index.md index 347125be2751e5e..0566fee93ccb4ef 100644 --- a/files/en-us/web/api/extendablecookiechangeevent/index.md +++ b/files/en-us/web/api/extendablecookiechangeevent/index.md @@ -5,7 +5,7 @@ page-type: web-api-interface browser-compat: api.ExtendableCookieChangeEvent --- -{{securecontext_header}}{{APIRef("Cookie Store API")}} +{{securecontext_header}}{{APIRef("Cookie Store API")}}{{AvailableInWorkers}} The **`ExtendableCookieChangeEvent`** interface of the [Cookie Store API](/en-US/docs/Web/API/Cookie_Store_API) is the event type passed to {{domxref("ServiceWorkerGlobalScope.cookiechange_event", "cookiechange")}} event fired at the {{domxref("ServiceWorkerGlobalScope")}} when any cookie changes occur. A cookie change event consists of a cookie and a type (either "changed" or "deleted".) From 2e23a5015b62f49c9516d94e2670c844c2211c49 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sat, 25 Nov 2023 19:32:27 +0000 Subject: [PATCH 41/49] specific spec-urls front matter key --- files/en-us/web/api/cookie_store_api/index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/files/en-us/web/api/cookie_store_api/index.md b/files/en-us/web/api/cookie_store_api/index.md index 6a6917dedd51238..41a2a7e408ddd3d 100644 --- a/files/en-us/web/api/cookie_store_api/index.md +++ b/files/en-us/web/api/cookie_store_api/index.md @@ -5,6 +5,7 @@ page-type: web-api-overview status: - experimental browser-compat: api.CookieStore +spec-urls: https://wicg.github.io/cookie-store/ --- {{securecontext_header}}{{DefaultAPISidebar("Cookie Store API")}}{{SeeCompatTable}} From eab69d6244e2cedf6b1070e54613542e70dff0d2 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sat, 25 Nov 2023 19:37:30 +0000 Subject: [PATCH 42/49] update browser-compat front matter key --- files/en-us/web/api/cookie_store_api/index.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/files/en-us/web/api/cookie_store_api/index.md b/files/en-us/web/api/cookie_store_api/index.md index 41a2a7e408ddd3d..5d1667084bd0f87 100644 --- a/files/en-us/web/api/cookie_store_api/index.md +++ b/files/en-us/web/api/cookie_store_api/index.md @@ -4,7 +4,11 @@ slug: Web/API/Cookie_Store_API page-type: web-api-overview status: - experimental -browser-compat: api.CookieStore +browser-compat: + - api.CookieChangeEvent + - api.CookieStore + - api.CookieStoreManager + - api.ExtendableCookieChangeEvent spec-urls: https://wicg.github.io/cookie-store/ --- From 2b7dba2281bba27848e97e80bf8e049aab3c2db4 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sat, 25 Nov 2023 19:49:26 +0000 Subject: [PATCH 43/49] {{domxref("Cookie Store API", "", "", "nocode")}} --- files/en-us/web/api/cookiechangeevent/index.md | 2 +- files/en-us/web/api/cookiestore/index.md | 2 +- files/en-us/web/api/cookiestoremanager/index.md | 2 +- files/en-us/web/api/extendablecookiechangeevent/index.md | 2 +- .../serviceworkerglobalscope/cookiechange_event/index.md | 4 ++-- .../web/api/serviceworkerglobalscope/cookiestore/index.md | 2 +- .../web/api/serviceworkerregistration/cookies/index.md | 4 ++-- files/en-us/web/api/window/cookiestore/index.md | 6 +++--- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/files/en-us/web/api/cookiechangeevent/index.md b/files/en-us/web/api/cookiechangeevent/index.md index f9d70a4fa62ae7c..59101c8c1c790f4 100644 --- a/files/en-us/web/api/cookiechangeevent/index.md +++ b/files/en-us/web/api/cookiechangeevent/index.md @@ -9,7 +9,7 @@ browser-compat: api.CookieChangeEvent {{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} -The **`CookieChangeEvent`** interface of the [Cookie Store API](/en-US/docs/Web/API/Cookie_Store_API) is the event type passed to {{domxref("CookieStore.change_event", "change")}} event fired at the {{domxref("CookieStore")}} when any cookie changes occur. A cookie change consists of a cookie and a type (either "changed" or "deleted"). +The **`CookieChangeEvent`** interface of the {{domxref("Cookie Store API", "", "", "nocode")}} is the event type passed to {{domxref("CookieStore.change_event", "change")}} event fired at the {{domxref("CookieStore")}} when any cookie changes occur. A cookie change consists of a cookie and a type (either "changed" or "deleted"). Cookie changes that will cause the `CookieChangeEvent` to be dispatched are: diff --git a/files/en-us/web/api/cookiestore/index.md b/files/en-us/web/api/cookiestore/index.md index 8b1035a0801e597..24eeb7e6c606793 100644 --- a/files/en-us/web/api/cookiestore/index.md +++ b/files/en-us/web/api/cookiestore/index.md @@ -9,7 +9,7 @@ browser-compat: api.CookieStore {{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}}{{AvailableInWorkers}} -The **`CookieStore`** interface of the [Cookie Store API](/en-US/docs/Web/API/Cookie_Store_API) provides methods for getting and setting cookies asynchronously from either a page or a service worker. +The **`CookieStore`** interface of the {{domxref("Cookie Store API", "", "", "nocode")}} provides methods for getting and setting cookies asynchronously from either a page or a service worker. The `CookieStore` is accessed via attributes in the global scope in a {{domxref("Window")}} or {{domxref("ServiceWorkerGlobalScope")}} context. Therefore there is no constructor. diff --git a/files/en-us/web/api/cookiestoremanager/index.md b/files/en-us/web/api/cookiestoremanager/index.md index 87ac59fcda1046b..9ee12fc8e3c2ba9 100644 --- a/files/en-us/web/api/cookiestoremanager/index.md +++ b/files/en-us/web/api/cookiestoremanager/index.md @@ -9,7 +9,7 @@ browser-compat: api.CookieStoreManager {{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}}{{AvailableInWorkers}} -The **`CookieStoreManager`** interface of the [Cookie Store API](/en-US/docs/Web/API/Cookie_Store_API) allows service workers to subscribe to cookie change events. Call {{domxref("CookieStoreManager.subscribe()","subscribe()")}} on a particular service worker registration to receive change events. +The **`CookieStoreManager`** interface of the {{domxref("Cookie Store API", "", "", "nocode")}} allows service workers to subscribe to cookie change events. Call {{domxref("CookieStoreManager.subscribe()","subscribe()")}} on a particular service worker registration to receive change events. A `CookieStoreManager` has an associated {{domxref("ServiceWorkerRegistration")}}. Each service worker registration has a cookie change subscription list, which is a list of cookie change subscriptions each containing a name and URL. The methods in this interface allow the service worker to add and remove subscriptions from this list, and to get a list of all subscriptions. diff --git a/files/en-us/web/api/extendablecookiechangeevent/index.md b/files/en-us/web/api/extendablecookiechangeevent/index.md index 0566fee93ccb4ef..4ac9e6e236090b2 100644 --- a/files/en-us/web/api/extendablecookiechangeevent/index.md +++ b/files/en-us/web/api/extendablecookiechangeevent/index.md @@ -7,7 +7,7 @@ browser-compat: api.ExtendableCookieChangeEvent {{securecontext_header}}{{APIRef("Cookie Store API")}}{{AvailableInWorkers}} -The **`ExtendableCookieChangeEvent`** interface of the [Cookie Store API](/en-US/docs/Web/API/Cookie_Store_API) is the event type passed to {{domxref("ServiceWorkerGlobalScope.cookiechange_event", "cookiechange")}} event fired at the {{domxref("ServiceWorkerGlobalScope")}} when any cookie changes occur. A cookie change event consists of a cookie and a type (either "changed" or "deleted".) +The **`ExtendableCookieChangeEvent`** interface of the {{domxref("Cookie Store API", "", "", "nocode")}} is the event type passed to {{domxref("ServiceWorkerGlobalScope.cookiechange_event", "cookiechange")}} event fired at the {{domxref("ServiceWorkerGlobalScope")}} when any cookie changes occur. A cookie change event consists of a cookie and a type (either "changed" or "deleted".) Cookie changes that cause the `ExtendableCookieChangeEvent` to be dispatched are: diff --git a/files/en-us/web/api/serviceworkerglobalscope/cookiechange_event/index.md b/files/en-us/web/api/serviceworkerglobalscope/cookiechange_event/index.md index 85d7caa1039ebf8..d3c277405f2fff7 100644 --- a/files/en-us/web/api/serviceworkerglobalscope/cookiechange_event/index.md +++ b/files/en-us/web/api/serviceworkerglobalscope/cookiechange_event/index.md @@ -10,7 +10,7 @@ browser-compat: api.ServiceWorkerGlobalScope.cookiechange_event {{APIRef("Cookie Store API")}}{{SeeCompatTable}} -The **`cookiechange`** event of the {{domxref("ServiceWorkerGlobalScope")}} interface is fired when any cookie changes have occurred which match the Service Worker's cookie change subscription list added via {{domxref("CookieStoreManager.subscribe()")}}. This is part of the {{domxref("Cookie Store API")}}. +The **`cookiechange`** event of the {{domxref("ServiceWorkerGlobalScope")}} interface is fired when any cookie changes have occurred which match the Service Worker's cookie change subscription list added via {{domxref("CookieStoreManager.subscribe()")}}. This is part of the {{domxref("Cookie Store API", "", "", "nocode")}}. This event is not cancelable and does not bubble. @@ -40,4 +40,4 @@ An {{domxref("ExtendableCookieChangeEvent")}}. Inherits from {{domxref("Extendab ## See also -- {{domxref("Cookie Store API")}} +- {{domxref("Cookie Store API", "", "", "nocode")}} diff --git a/files/en-us/web/api/serviceworkerglobalscope/cookiestore/index.md b/files/en-us/web/api/serviceworkerglobalscope/cookiestore/index.md index ee23ba84761f262..fccca6d9506fcda 100644 --- a/files/en-us/web/api/serviceworkerglobalscope/cookiestore/index.md +++ b/files/en-us/web/api/serviceworkerglobalscope/cookiestore/index.md @@ -26,4 +26,4 @@ A {{domxref("CookieStore")}} object instance. ## See also -- {{domxref("Cookie Store API")}} +- {{domxref("Cookie Store API", "", "", "nocode")}} diff --git a/files/en-us/web/api/serviceworkerregistration/cookies/index.md b/files/en-us/web/api/serviceworkerregistration/cookies/index.md index 84a02efa1ccf5d3..7c6950a49189c33 100644 --- a/files/en-us/web/api/serviceworkerregistration/cookies/index.md +++ b/files/en-us/web/api/serviceworkerregistration/cookies/index.md @@ -10,7 +10,7 @@ browser-compat: api.ServiceWorkerRegistration.cookies {{APIRef("Cookie Store API")}}{{SeeCompatTable}} -The **`cookies`** read-only property of the {{domxref("ServiceWorkerRegistration")}} interface returns a reference to the {{domxref('CookieStoreManager')}} interface, which allows subscribe and unsubscribe to cookie change events. This is part of the {{domxref("Cookie Store API")}}. +The **`cookies`** read-only property of the {{domxref("ServiceWorkerRegistration")}} interface returns a reference to the {{domxref('CookieStoreManager')}} interface, which allows subscribe and unsubscribe to cookie change events. This is part of the {{domxref("Cookie Store API", "", "", "nocode")}}. ## Value @@ -26,4 +26,4 @@ A {{domxref("CookieStoreManager")}} object. ## See also -- {{domxref("Cookie Store API")}} +- {{domxref("Cookie Store API", "", "", "nocode")}} diff --git a/files/en-us/web/api/window/cookiestore/index.md b/files/en-us/web/api/window/cookiestore/index.md index f811be1536ba287..60de7b0294fd0da 100644 --- a/files/en-us/web/api/window/cookiestore/index.md +++ b/files/en-us/web/api/window/cookiestore/index.md @@ -8,9 +8,9 @@ status: browser-compat: api.Window.cookieStore --- -{{APIRef("Cookie Store API")}}{{SeeCompatTable}}{{securecontext_header}} +{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} -The **`cookieStore`** read-only property of the {{domxref("Window")}} interface returns a reference to the {{domxref("CookieStore")}} object for the current document context. This is part of the {{domxref("Cookie Store API")}}. +The **`cookieStore`** read-only property of the {{domxref("Window")}} interface returns a reference to the {{domxref("CookieStore")}} object for the current document context. This is part of the {{domxref("Cookie Store API", "", "", "nocode")}}. ## Value @@ -26,4 +26,4 @@ A {{domxref("CookieStore")}} object instance. ## See also -- {{domxref("Cookie Store API")}} +- {{domxref("Cookie Store API", "", "", "nocode")}} From af4d67d3c9f76c7230fff447100447a7309719b2 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sun, 26 Nov 2023 08:02:44 +0800 Subject: [PATCH 44/49] Update files/en-us/web/api/cookie_store_api/index.md --- files/en-us/web/api/cookie_store_api/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/files/en-us/web/api/cookie_store_api/index.md b/files/en-us/web/api/cookie_store_api/index.md index 5d1667084bd0f87..3c822d29cd1ba2d 100644 --- a/files/en-us/web/api/cookie_store_api/index.md +++ b/files/en-us/web/api/cookie_store_api/index.md @@ -31,9 +31,9 @@ The _Cookie Store API_ provides an updated method of managing cookies. It is {{G - {{domxref("CookieStoreManager")}} {{Experimental_Inline}} - : The `CookieStoreManager` interface provides a service worker registration to enable service workers to subscribe to cookie change events. - {{domxref("CookieChangeEvent")}} {{Experimental_Inline}} - - : A `CookieChangeEvent` named `change` is dispatched against `CookieStore` object in {{domxref("Window")}} contexts when any script-visible cookies changes occur. + - : A `CookieChangeEvent` named `change` is dispatched against `CookieStore` object in {{domxref("Window")}} context when any script-visible cookies changes occur. - {{domxref("ExtendableCookieChangeEvent")}} {{Experimental_Inline}} - - : An `ExtendableCookieChangeEvent` named `cookiechange` is dispatched against {{domxref("ServiceWorkerGlobalScope")}} contexts when any script-visible cookie changes occur that match the service worker's cookie change subscription list. + - : An `ExtendableCookieChangeEvent` named `cookiechange` is dispatched against {{domxref("ServiceWorkerGlobalScope")}} context when any script-visible cookie changes occur that match the service worker's cookie change subscription list. ## Extensions to other interfaces From d547c14885d31f4db9baedd0235d0c5c6b392a68 Mon Sep 17 00:00:00 2001 From: skyclouds2001 Date: Sun, 26 Nov 2023 11:15:46 +0800 Subject: [PATCH 45/49] some small update --- files/en-us/web/api/cookie_store_api/index.md | 6 +++--- files/en-us/web/api/cookiechangeevent/changed/index.md | 7 ++++--- .../api/cookiechangeevent/cookiechangeevent/index.md | 2 +- files/en-us/web/api/cookiechangeevent/deleted/index.md | 4 ++-- files/en-us/web/api/cookiechangeevent/index.md | 4 ++-- files/en-us/web/api/cookiestore/change_event/index.md | 4 ++-- files/en-us/web/api/cookiestore/delete/index.md | 3 ++- files/en-us/web/api/cookiestore/get/index.md | 5 +++-- files/en-us/web/api/cookiestore/getall/index.md | 5 +++-- files/en-us/web/api/cookiestore/index.md | 3 ++- files/en-us/web/api/cookiestore/set/index.md | 5 +++-- .../api/cookiestoremanager/getsubscriptions/index.md | 2 +- files/en-us/web/api/cookiestoremanager/index.md | 5 +++-- .../web/api/cookiestoremanager/subscribe/index.md | 10 ++++++---- .../web/api/cookiestoremanager/unsubscribe/index.md | 3 ++- .../api/extendablecookiechangeevent/changed/index.md | 3 ++- .../en-us/web/api/extendablecookiechangeevent/index.md | 1 + 17 files changed, 42 insertions(+), 30 deletions(-) diff --git a/files/en-us/web/api/cookie_store_api/index.md b/files/en-us/web/api/cookie_store_api/index.md index 3c822d29cd1ba2d..40a4fd16f314de9 100644 --- a/files/en-us/web/api/cookie_store_api/index.md +++ b/files/en-us/web/api/cookie_store_api/index.md @@ -14,7 +14,7 @@ spec-urls: https://wicg.github.io/cookie-store/ {{securecontext_header}}{{DefaultAPISidebar("Cookie Store API")}}{{SeeCompatTable}} -The _**Cookie Store API**_ provides an asynchronous API for managing cookies, while also exposing cookies to [Service Worker API](/en-US/docs/Web/API/Service_Worker_API). +The _**Cookie Store API**_ provides an asynchronous API for managing cookies, while also exposing cookies to {{domxref("Service Worker API", "", "", "nocode")}}. ## Concepts and Usage @@ -26,12 +26,12 @@ The _Cookie Store API_ provides an updated method of managing cookies. It is {{G ## Interfaces +- {{domxref("CookieChangeEvent")}} {{Experimental_Inline}} + - : A `CookieChangeEvent` named `change` is dispatched against `CookieStore` object in {{domxref("Window")}} context when any script-visible cookies changes occur. - {{domxref("CookieStore")}} {{Experimental_Inline}} - : The `CookieStore` interface enables getting and setting cookies. - {{domxref("CookieStoreManager")}} {{Experimental_Inline}} - : The `CookieStoreManager` interface provides a service worker registration to enable service workers to subscribe to cookie change events. -- {{domxref("CookieChangeEvent")}} {{Experimental_Inline}} - - : A `CookieChangeEvent` named `change` is dispatched against `CookieStore` object in {{domxref("Window")}} context when any script-visible cookies changes occur. - {{domxref("ExtendableCookieChangeEvent")}} {{Experimental_Inline}} - : An `ExtendableCookieChangeEvent` named `cookiechange` is dispatched against {{domxref("ServiceWorkerGlobalScope")}} context when any script-visible cookie changes occur that match the service worker's cookie change subscription list. diff --git a/files/en-us/web/api/cookiechangeevent/changed/index.md b/files/en-us/web/api/cookiechangeevent/changed/index.md index ed19dd1cbd93b5a..1d2cc020b47cccd 100644 --- a/files/en-us/web/api/cookiechangeevent/changed/index.md +++ b/files/en-us/web/api/cookiechangeevent/changed/index.md @@ -25,7 +25,7 @@ An array of objects containing the changed cookie(s). Each object contains the f - `path` - : A string containing the path of the cookie. - `expires` - - : A timestamp, given as [Unix time](/en-US/docs/Glossary/Unix_time) in milliseconds, containing the expiration date of the cookie. + - : A timestamp, given as {{glossary("Unix time")}} in milliseconds, containing the expiration date of the cookie. - `secure` - : A {{jsxref("boolean")}} indicating whether the cookie is from a site with a secure context (HTTPS rather than HTTP). - `sameSite` @@ -47,12 +47,13 @@ An array of objects containing the changed cookie(s). Each object contains the f In this example, when the cookie is set, the event listener logs the `changed` property to the console. The first item in that array contains an object representing the cookie that has just been set. ```js -cookieStore.addEventListener("change", (event) => { +window.cookieStore.addEventListener("change", (event) => { console.log(event.changed[0]); }); const one_day = 24 * 60 * 60 * 1000; -cookieStore.set({ + +window.cookieStore.set({ name: "cookie1", value: "cookie1-value", expires: Date.now() + one_day, diff --git a/files/en-us/web/api/cookiechangeevent/cookiechangeevent/index.md b/files/en-us/web/api/cookiechangeevent/cookiechangeevent/index.md index 02f3f286898c250..d6df912446c039c 100644 --- a/files/en-us/web/api/cookiechangeevent/cookiechangeevent/index.md +++ b/files/en-us/web/api/cookiechangeevent/cookiechangeevent/index.md @@ -11,7 +11,7 @@ browser-compat: api.CookieChangeEvent.CookieChangeEvent {{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} The **`CookieChangeEvent()`** constructor creates a new {{domxref("CookieChangeEvent")}} object -which is the event type passed to {{domxref("CookieStore.change_event", "change")}} event. +which is the event type passed to {{domxref("CookieStore/change_event", "change")}} event. This constructor is called by the browser when a change event occurs. > **Note:** This event constructor is generally not needed for production websites. It's primary use is for tests that require an instance of this event. diff --git a/files/en-us/web/api/cookiechangeevent/deleted/index.md b/files/en-us/web/api/cookiechangeevent/deleted/index.md index db52d76393cf414..95158160dde3607 100644 --- a/files/en-us/web/api/cookiechangeevent/deleted/index.md +++ b/files/en-us/web/api/cookiechangeevent/deleted/index.md @@ -25,7 +25,7 @@ An array of objects containing the deleted cookie(s). Each object contains the f - `path` - : A string containing the path of the cookie. - `expires` - - : A timestamp, given as [Unix time](/en-US/docs/Glossary/Unix_time) in milliseconds, containing the expiration date of the cookie. + - : A timestamp, given as {{glossary("Unix time")}} in milliseconds, containing the expiration date of the cookie. - `secure` - : A {{jsxref("boolean")}} indicating whether the cookie is from a site with a secure context (HTTPS rather than HTTP). - `sameSite` @@ -47,7 +47,7 @@ An array of objects containing the deleted cookie(s). Each object contains the f In this example, when the cookie is deleted, the event listener logs the first item in the `CookieChangeEvent.deleted` property to the console. It contains an object representing the cookie that has just been deleted. ```js -cookieStore.addEventListener("change", (event) => { +window.cookieStore.addEventListener("change", (event) => { console.log(event.deleted[0]); }); ``` diff --git a/files/en-us/web/api/cookiechangeevent/index.md b/files/en-us/web/api/cookiechangeevent/index.md index 59101c8c1c790f4..86007c9f388f414 100644 --- a/files/en-us/web/api/cookiechangeevent/index.md +++ b/files/en-us/web/api/cookiechangeevent/index.md @@ -44,13 +44,13 @@ _This interface also inherits methods from {{domxref("Event")}}._ In this example when the cookie is set, the event listener logs the event to the console. This is a `CookieChangeEvent` object with the {{domxref("CookieChangeEvent.changed","changed")}} property containing an object representing the cookie that has just been set. ```js -cookieStore.addEventListener("change", (event) => { +window.cookieStore.addEventListener("change", (event) => { console.log(event); }); const one_day = 24 * 60 * 60 * 1000; -cookieStore.set({ +window.cookieStore.set({ name: "cookie1", value: "cookie1-value", expires: Date.now() + one_day, diff --git a/files/en-us/web/api/cookiestore/change_event/index.md b/files/en-us/web/api/cookiestore/change_event/index.md index 3c9b226a59f0110..ee55b8b430767f1 100644 --- a/files/en-us/web/api/cookiestore/change_event/index.md +++ b/files/en-us/web/api/cookiestore/change_event/index.md @@ -33,7 +33,7 @@ A {{domxref("CookieChangeEvent")}}. Inherits from {{domxref("Event")}}. To be informed when a cookie has changed, you can add a handler to the `CookieStore` instance using {{domxref("EventTarget.addEventListener", "addEventListener()")}}, like this: ```js -cookieStore.addEventListener("change", (event) => { +window.cookieStore.addEventListener("change", (event) => { console.log("1 change event"); }); ``` @@ -41,7 +41,7 @@ cookieStore.addEventListener("change", (event) => { Alternatively, you can use the `CookieStore.onchange` event handler property to establish a handler for the `change` event: ```js -cookieStore.onchange = (event) => { +window.cookieStore.onchange = (event) => { console.log("1 change event"); }; ``` diff --git a/files/en-us/web/api/cookiestore/delete/index.md b/files/en-us/web/api/cookiestore/delete/index.md index 416c88eefbc58df..4bdc985880c72ec 100644 --- a/files/en-us/web/api/cookiestore/delete/index.md +++ b/files/en-us/web/api/cookiestore/delete/index.md @@ -59,7 +59,8 @@ A {{jsxref("Promise")}} that resolves with {{jsxref("undefined")}} when deletion In this example, a cookie is deleted by passing the name to the `delete()` method. ```js -let result = cookieStore.delete("cookie1"); +let result = window.cookieStore.delete("cookie1"); + console.log(result); ``` diff --git a/files/en-us/web/api/cookiestore/get/index.md b/files/en-us/web/api/cookiestore/get/index.md index 83a246db809d220..e2e4997f727f27a 100644 --- a/files/en-us/web/api/cookiestore/get/index.md +++ b/files/en-us/web/api/cookiestore/get/index.md @@ -49,7 +49,7 @@ A {{jsxref("Promise")}} that resolves with an object representing the first cook - `expires` - - : A timestamp, given as [Unix time](/en-US/docs/Glossary/Unix_time) in milliseconds, containing the expiration date of the cookie. + - : A timestamp, given as {{glossary("Unix time")}} in milliseconds, containing the expiration date of the cookie. - `name` @@ -97,7 +97,8 @@ A {{jsxref("Promise")}} that resolves with an object representing the first cook In this example, we return a cookie named "cookie1". If the cookie is found the result of the Promise is an object containing the details of a single cookie. ```js -let cookie = await cookieStore.get("cookie1"); +let cookie = await window.cookieStore.get("cookie1"); + if (cookie) { console.log(cookie); } else { diff --git a/files/en-us/web/api/cookiestore/getall/index.md b/files/en-us/web/api/cookiestore/getall/index.md index 2eb7f9eadb91486..665412456174816 100644 --- a/files/en-us/web/api/cookiestore/getall/index.md +++ b/files/en-us/web/api/cookiestore/getall/index.md @@ -49,7 +49,7 @@ Each object contains the following properties: - `expires` - - : A timestamp, given as [Unix time](/en-US/docs/Glossary/Unix_time) in milliseconds, containing the expiration date of the cookie. + - : A timestamp, given as {{glossary("Unix time")}} in milliseconds, containing the expiration date of the cookie. - `name` @@ -96,7 +96,8 @@ Each object contains the following properties: In this example, we use `getAll()` with no parameters. This returns all of the cookies for this context as an array of objects. ```js -let cookies = await cookieStore.getAll(); +let cookies = await window.cookieStore.getAll(); + if (cookies.length > 0) { console.log(cookies); } else { diff --git a/files/en-us/web/api/cookiestore/index.md b/files/en-us/web/api/cookiestore/index.md index 24eeb7e6c606793..51108e4c78a7d2c 100644 --- a/files/en-us/web/api/cookiestore/index.md +++ b/files/en-us/web/api/cookiestore/index.md @@ -37,7 +37,8 @@ In this example we set a cookie and write to the console feedback as to whether ```js const day = 24 * 60 * 60 * 1000; -cookieStore + +window.cookieStore .set({ name: "cookie1", value: "cookie1-value", diff --git a/files/en-us/web/api/cookiestore/set/index.md b/files/en-us/web/api/cookiestore/set/index.md index 727301230949603..aec99b38d95580e 100644 --- a/files/en-us/web/api/cookiestore/set/index.md +++ b/files/en-us/web/api/cookiestore/set/index.md @@ -37,7 +37,7 @@ Or - `domain` {{Optional_Inline}} - : A string containing the domain of the cookie. Defaults to `null`. - `expires` {{Optional_Inline}} - - : A timestamp, given as [Unix time](/en-US/docs/Glossary/Unix_time) in milliseconds, containing the expiration date of the cookie. Defaults to `null`. + - : A timestamp, given as {{glossary("Unix time")}} in milliseconds, containing the expiration date of the cookie. Defaults to `null`. - `name` - : A string with the name of a cookie. - `partitioned` {{Optional_Inline}} @@ -75,7 +75,8 @@ The following example sets a cookie by passing an object with `name`, `value`, ` ```js const day = 24 * 60 * 60 * 1000; -cookieStore.set({ + +window.cookieStore.set({ name: "cookie1", value: "cookie1-value", expires: Date.now() + day, diff --git a/files/en-us/web/api/cookiestoremanager/getsubscriptions/index.md b/files/en-us/web/api/cookiestoremanager/getsubscriptions/index.md index f9d3ec104074691..44a053d0ade18ec 100644 --- a/files/en-us/web/api/cookiestoremanager/getsubscriptions/index.md +++ b/files/en-us/web/api/cookiestoremanager/getsubscriptions/index.md @@ -36,7 +36,7 @@ A {{jsxref("Promise")}} that resolves with a list of objects, each containing: If the {{domxref("ServiceWorkerRegistration")}} represented by `registration` has subscribed to any cookie change events, `subscriptions` will resolve to a list of objects containing the name and URL of those cookies. ```js -const subscriptions = await registration.cookies.getSubscriptions(); +const subscriptions = await self.registration.cookies.getSubscriptions(); ``` ## Specifications diff --git a/files/en-us/web/api/cookiestoremanager/index.md b/files/en-us/web/api/cookiestoremanager/index.md index 9ee12fc8e3c2ba9..3a8ed1d2b35820b 100644 --- a/files/en-us/web/api/cookiestoremanager/index.md +++ b/files/en-us/web/api/cookiestoremanager/index.md @@ -30,13 +30,14 @@ In this example the {{domxref("ServiceWorkerRegistration")}} represented by `reg ```js const subscriptions = [{ name: "cookie1", url: "/path1" }]; -await registration.cookies.subscribe(subscriptions); + +await self.registration.cookies.subscribe(subscriptions); ``` If the {{domxref("ServiceWorkerRegistration")}} has subscribed to any cookies, then {{domxref("CookieStoreManager.getSubscriptions()","getSubscriptions()")}} will return a list of cookies represented by objects in the same format as used for the original subscription. ```js -const subscriptions = await registration.cookies.getSubscriptions(); +const subscriptions = await self.registration.cookies.getSubscriptions(); ``` ## Specifications diff --git a/files/en-us/web/api/cookiestoremanager/subscribe/index.md b/files/en-us/web/api/cookiestoremanager/subscribe/index.md index f8d3ff9a6cda452..3fec1a2e0c07b58 100644 --- a/files/en-us/web/api/cookiestoremanager/subscribe/index.md +++ b/files/en-us/web/api/cookiestoremanager/subscribe/index.md @@ -44,15 +44,17 @@ In this example the {{domxref("ServiceWorkerRegistration")}} represented by `reg ```js const subscriptions = [{ name: "cookie1", url: "/path1" }]; -await registration.cookies.subscribe(subscriptions); + +await self.registration.cookies.subscribe(subscriptions); ``` The URL passed to the `subscribe()` method, may be narrower than the service worker registration scope. In the following example the subscription is for `/path/one/`, so it will receive change events for changes on the first cookie, but not the second. ```js -registration.cookies.subscribe([{ name: "cookie1", url: "/path/one/" }]); // subscription -cookieStore.set({ name: "cookie1", value: "cookie-value", path: "/path/one/" }); // receives a change event -cookieStore.set({ name: "cookie1", value: "cookie-value", path: "/path/two/" }); // does not receive a change event +self.registration.cookies.subscribe([{ name: "cookie1", url: "/path/one/" }]); // subscription + +self.cookieStore.set({ name: "cookie1", value: "cookie-value", path: "/path/one/" }); // receives a change event +self.cookieStore.set({ name: "cookie1", value: "cookie-value", path: "/path/two/" }); // does not receive a change event ``` ## Specifications diff --git a/files/en-us/web/api/cookiestoremanager/unsubscribe/index.md b/files/en-us/web/api/cookiestoremanager/unsubscribe/index.md index 262ccae0bf15cd3..42669d832755b93 100644 --- a/files/en-us/web/api/cookiestoremanager/unsubscribe/index.md +++ b/files/en-us/web/api/cookiestoremanager/unsubscribe/index.md @@ -44,7 +44,8 @@ In this example the {{domxref("ServiceWorkerRegistration")}} represented by `reg ```js const subscriptions = [{ name: "cookie1", url: "/path1" }]; -await registration.cookies.unsubscribe(subscriptions); + +await self.registration.cookies.unsubscribe(subscriptions); ``` ## Specifications diff --git a/files/en-us/web/api/extendablecookiechangeevent/changed/index.md b/files/en-us/web/api/extendablecookiechangeevent/changed/index.md index fb1bc189c874266..2e8c0a9a4883f95 100644 --- a/files/en-us/web/api/extendablecookiechangeevent/changed/index.md +++ b/files/en-us/web/api/extendablecookiechangeevent/changed/index.md @@ -50,7 +50,8 @@ self.addEventListener("cookiechange", (event) => { }); const one_day = 24 * 60 * 60 * 1000; -cookieStore.set({ + +self.cookieStore.set({ name: "cookie1", value: "cookie1-value", expires: Date.now() + one_day, diff --git a/files/en-us/web/api/extendablecookiechangeevent/index.md b/files/en-us/web/api/extendablecookiechangeevent/index.md index 4ac9e6e236090b2..9b1c52c6e847d41 100644 --- a/files/en-us/web/api/extendablecookiechangeevent/index.md +++ b/files/en-us/web/api/extendablecookiechangeevent/index.md @@ -45,6 +45,7 @@ In the below example, we use {{domxref("CookieStoreManager.getSubscriptions()")} self.addEventListener("activate", (event) => { event.waitUntil(async () => { const subscriptions = await self.registration.cookies.getSubscriptions(); + await self.registration.cookies.unsubscribe(subscriptions); await self.registration.cookies.subscribe([ From 17e436aa1dda2f81972bcc5c8214c591df8a404c Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sun, 26 Nov 2023 11:20:11 +0800 Subject: [PATCH 46/49] Update files/en-us/web/api/cookiestoremanager/subscribe/index.md Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .../web/api/cookiestoremanager/subscribe/index.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/files/en-us/web/api/cookiestoremanager/subscribe/index.md b/files/en-us/web/api/cookiestoremanager/subscribe/index.md index 3fec1a2e0c07b58..6bb0456cfde7289 100644 --- a/files/en-us/web/api/cookiestoremanager/subscribe/index.md +++ b/files/en-us/web/api/cookiestoremanager/subscribe/index.md @@ -53,8 +53,16 @@ The URL passed to the `subscribe()` method, may be narrower than the service wor ```js self.registration.cookies.subscribe([{ name: "cookie1", url: "/path/one/" }]); // subscription -self.cookieStore.set({ name: "cookie1", value: "cookie-value", path: "/path/one/" }); // receives a change event -self.cookieStore.set({ name: "cookie1", value: "cookie-value", path: "/path/two/" }); // does not receive a change event +self.cookieStore.set({ + name: "cookie1", + value: "cookie-value", + path: "/path/one/", +}); // receives a change event +self.cookieStore.set({ + name: "cookie1", + value: "cookie-value", + path: "/path/two/", +}); // does not receive a change event ``` ## Specifications From 38817cc87f1343f4b5175c5dce39558e1ad44441 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Tue, 28 Nov 2023 22:07:19 +0800 Subject: [PATCH 47/49] Update files/en-us/web/api/cookie_store_api/index.md --- files/en-us/web/api/cookie_store_api/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/en-us/web/api/cookie_store_api/index.md b/files/en-us/web/api/cookie_store_api/index.md index 40a4fd16f314de9..c9b025717185965 100644 --- a/files/en-us/web/api/cookie_store_api/index.md +++ b/files/en-us/web/api/cookie_store_api/index.md @@ -35,7 +35,7 @@ The _Cookie Store API_ provides an updated method of managing cookies. It is {{G - {{domxref("ExtendableCookieChangeEvent")}} {{Experimental_Inline}} - : An `ExtendableCookieChangeEvent` named `cookiechange` is dispatched against {{domxref("ServiceWorkerGlobalScope")}} context when any script-visible cookie changes occur that match the service worker's cookie change subscription list. -## Extensions to other interfaces +### Extensions to other interfaces - {{domxref("ServiceWorkerGlobalScope.cookieStore")}} {{ReadOnlyInline}} {{Experimental_Inline}} - : Returns a reference to the {{domxref("CookieStore")}} object associated with the service worker. From 30f1de68631e6f47b39867b76eecdfb942286113 Mon Sep 17 00:00:00 2001 From: skyclouds2001 Date: Thu, 30 Nov 2023 16:09:44 +0800 Subject: [PATCH 48/49] small update --- files/en-us/web/api/cookie_store_api/index.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/files/en-us/web/api/cookie_store_api/index.md b/files/en-us/web/api/cookie_store_api/index.md index c9b025717185965..f1452a7e6d35153 100644 --- a/files/en-us/web/api/cookie_store_api/index.md +++ b/files/en-us/web/api/cookie_store_api/index.md @@ -32,15 +32,15 @@ The _Cookie Store API_ provides an updated method of managing cookies. It is {{G - : The `CookieStore` interface enables getting and setting cookies. - {{domxref("CookieStoreManager")}} {{Experimental_Inline}} - : The `CookieStoreManager` interface provides a service worker registration to enable service workers to subscribe to cookie change events. -- {{domxref("ExtendableCookieChangeEvent")}} {{Experimental_Inline}} +- {{domxref("ExtendableCookieChangeEvent")}} - : An `ExtendableCookieChangeEvent` named `cookiechange` is dispatched against {{domxref("ServiceWorkerGlobalScope")}} context when any script-visible cookie changes occur that match the service worker's cookie change subscription list. ### Extensions to other interfaces +- {{domxref("ServiceWorkerGlobalScope/cookiechange_event", "cookiechange")}} event {{Experimental_Inline}} + - : Fired when any cookie changes have occurred which match the Service Worker's cookie change subscription list added via {{domxref("CookieStoreManager.subscribe()")}}. - {{domxref("ServiceWorkerGlobalScope.cookieStore")}} {{ReadOnlyInline}} {{Experimental_Inline}} - : Returns a reference to the {{domxref("CookieStore")}} object associated with the service worker. -- {{domxref("ServiceWorkerGlobalScope/cookiechange_event", "cookiechange")}} {{Experimental_Inline}} - - : Fired when any cookie changes have occurred which match the Service Worker's cookie change subscription list added via {{domxref("CookieStoreManager.subscribe()")}}. - {{domxref("ServiceWorkerRegistration.cookies")}} {{ReadOnlyInline}} {{Experimental_Inline}} - : Returns a reference to the {{domxref("CookieStoreManager")}} interface, which allows subscribe and unsubscribe to cookie change events. - {{domxref("Window.cookieStore")}} {{ReadOnlyInline}} {{Experimental_Inline}} From b68694962841ae26aebb2e6b1de21af91f2ed77c Mon Sep 17 00:00:00 2001 From: skyclouds2001 Date: Thu, 30 Nov 2023 16:25:27 +0800 Subject: [PATCH 49/49] small fix --- files/en-us/web/api/cookie_store_api/index.md | 2 +- files/en-us/web/api/cookiestoremanager/index.md | 2 +- .../extendablecookiechangeevent/index.md | 2 +- files/en-us/web/api/extendablecookiechangeevent/index.md | 2 +- files/en-us/web/api/serviceworkerglobalscope/index.md | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/files/en-us/web/api/cookie_store_api/index.md b/files/en-us/web/api/cookie_store_api/index.md index f1452a7e6d35153..2d4e479da4496e0 100644 --- a/files/en-us/web/api/cookie_store_api/index.md +++ b/files/en-us/web/api/cookie_store_api/index.md @@ -37,7 +37,7 @@ The _Cookie Store API_ provides an updated method of managing cookies. It is {{G ### Extensions to other interfaces -- {{domxref("ServiceWorkerGlobalScope/cookiechange_event", "cookiechange")}} event {{Experimental_Inline}} +- {{domxref("ServiceWorkerGlobalScope/cookiechange_event", "cookiechange")}} {{Experimental_Inline}} - : Fired when any cookie changes have occurred which match the Service Worker's cookie change subscription list added via {{domxref("CookieStoreManager.subscribe()")}}. - {{domxref("ServiceWorkerGlobalScope.cookieStore")}} {{ReadOnlyInline}} {{Experimental_Inline}} - : Returns a reference to the {{domxref("CookieStore")}} object associated with the service worker. diff --git a/files/en-us/web/api/cookiestoremanager/index.md b/files/en-us/web/api/cookiestoremanager/index.md index 3a8ed1d2b35820b..a403c8c0accd8c0 100644 --- a/files/en-us/web/api/cookiestoremanager/index.md +++ b/files/en-us/web/api/cookiestoremanager/index.md @@ -13,7 +13,7 @@ The **`CookieStoreManager`** interface of the {{domxref("Cookie Store API", "", A `CookieStoreManager` has an associated {{domxref("ServiceWorkerRegistration")}}. Each service worker registration has a cookie change subscription list, which is a list of cookie change subscriptions each containing a name and URL. The methods in this interface allow the service worker to add and remove subscriptions from this list, and to get a list of all subscriptions. -To get a `CookieStoreManager`, use {{domxref("ServiceWorkerRegistration.cookies")}}. +To get a `CookieStoreManager`, call {{domxref("ServiceWorkerRegistration.cookies")}}. ## Instance methods diff --git a/files/en-us/web/api/extendablecookiechangeevent/extendablecookiechangeevent/index.md b/files/en-us/web/api/extendablecookiechangeevent/extendablecookiechangeevent/index.md index 8e037dc696900d1..f56f36338e0e53b 100644 --- a/files/en-us/web/api/extendablecookiechangeevent/extendablecookiechangeevent/index.md +++ b/files/en-us/web/api/extendablecookiechangeevent/extendablecookiechangeevent/index.md @@ -9,7 +9,7 @@ browser-compat: api.ExtendableCookieChangeEvent.ExtendableCookieChangeEvent {{securecontext_header}}{{APIRef("Cookie Store API")}}{{AvailableInWorkers}} The **`ExtendableCookieChangeEvent()`** constructor creates a new {{domxref("ExtendableCookieChangeEvent")}} object -which is the event type passed to {{domxref("ServiceWorkerGlobalScope.cookiechange_event", "cookiechange")}}. +which is the event type passed to {{domxref("ServiceWorkerGlobalScope/cookiechange_event", "cookiechange")}}. This constructor is called by the browser when a change event occurs. > **Note:** This event constructor is generally not needed for production websites. It's primary use is for tests that require an instance of this event. diff --git a/files/en-us/web/api/extendablecookiechangeevent/index.md b/files/en-us/web/api/extendablecookiechangeevent/index.md index 9b1c52c6e847d41..15a7be00adf84b4 100644 --- a/files/en-us/web/api/extendablecookiechangeevent/index.md +++ b/files/en-us/web/api/extendablecookiechangeevent/index.md @@ -7,7 +7,7 @@ browser-compat: api.ExtendableCookieChangeEvent {{securecontext_header}}{{APIRef("Cookie Store API")}}{{AvailableInWorkers}} -The **`ExtendableCookieChangeEvent`** interface of the {{domxref("Cookie Store API", "", "", "nocode")}} is the event type passed to {{domxref("ServiceWorkerGlobalScope.cookiechange_event", "cookiechange")}} event fired at the {{domxref("ServiceWorkerGlobalScope")}} when any cookie changes occur. A cookie change event consists of a cookie and a type (either "changed" or "deleted".) +The **`ExtendableCookieChangeEvent`** interface of the {{domxref("Cookie Store API", "", "", "nocode")}} is the event type passed to {{domxref("ServiceWorkerGlobalScope.cookiechange_event", "cookiechange")}} event fired at the {{domxref("ServiceWorkerGlobalScope")}} when any cookie changes occur. A cookie change event consists of a cookie and a type (either "changed" or "deleted"). Cookie changes that cause the `ExtendableCookieChangeEvent` to be dispatched are: diff --git a/files/en-us/web/api/serviceworkerglobalscope/index.md b/files/en-us/web/api/serviceworkerglobalscope/index.md index aae04c311835ea8..1a8691764727d3e 100644 --- a/files/en-us/web/api/serviceworkerglobalscope/index.md +++ b/files/en-us/web/api/serviceworkerglobalscope/index.md @@ -98,7 +98,7 @@ _This interface inherits methods from the {{domxref("WorkerGlobalScope")}} inter - {{domxref("ServiceWorkerGlobalScope/contentdelete_event", "contentdelete")}} {{Experimental_Inline}} - : Occurs when an item is removed from the {{domxref("ContentIndex", "Content Index")}}. - {{domxref("ServiceWorkerGlobalScope/cookiechange_event", "cookiechange")}} {{Experimental_Inline}} - - : Fired when any cookie changes have occurred which match the Service Worker's cookie change subscription list added via {{domxref("CookieStoreManager.subscribe()")}}. + - : Fired when any cookie changes have occurred which match the Service Worker's cookie change subscription list. - {{domxref("ServiceWorkerGlobalScope/fetch_event", "fetch")}} - : Occurs when a {{domxref("fetch()")}} is called. - {{domxref("ServiceWorkerGlobalScope/install_event", "install")}}