CookieStoreManager:getSubscriptions() 方法

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

安全上下文: 此项功能仅在一些支持的浏览器安全上下文(HTTPS)中可用。

备注: 此特性在 Service Worker 中可用。

CookieStoreManager 接口的 getSubscriptions() 方法返回该 ServiceWorkerRegistration 的所有 cookie 变更的订阅列表。

语法

js
getSubscriptions()

参数

无。

返回值

兑现为对象列表的 Promise,每个对象包含以下属性:

name

记录 cookie 名称的字符串。

url

记录了包含用于订阅 cookie 的作用域的 url 的字符串。

示例

如果注册(registration)所指示的 ServiceWorkerRegistration 订阅了任何 cookie 变更事件,subscriptions 将兑现为包含这些 cookie 的名称和 URL 的对象列表。

js
const subscriptions = await self.registration.cookies.getSubscriptions();

规范

Specification
Cookie Store API
# dom-cookiestoremanager-getsubscriptions

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
getSubscriptions

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support