diff --git a/index.bs b/index.bs index d7357604..df21dfe1 100644 --- a/index.bs +++ b/index.bs @@ -713,11 +713,13 @@ all [=subscription/subscription ids=] that have been issued to the [=local end=] A subscription is a [=/struct=] consisting of a subscription id (a string), -event names (a [=/set=] of event names) -and top-level traversable ids (a [=/set=] of IDs of [=/top-level traversables=]). +event names (a [=/set=] of event names), +top-level traversable ids (a [=/set=] of IDs of [=/top-level traversables=]) +and user context ids (a [=/set=] of IDs of [=user contexts=]). A [=subscription=] |subscription| is global -if |subscription|'s [=subscription/top-level traversable ids=] is an empty set. +if |subscription|'s [=subscription/top-level traversable ids=] is an empty set +and |subscription|'s [=user context ids=] is an empty set.
@@ -750,10 +752,19 @@ Note: |navigables| is a set because a [=shared worker=] can be associated 1. If |subscription| is [=subscription/global=] return true. - 1. Let |subscription top-level traversables| be [=get navigables by ids=] with |subscription|'s [=subscription/top-level traversable ids=]. + 1. If [=subscription/user context ids=] is not empty: - 1. If the [=set/intersection=] of |top-level traversables| and - |subscription top-level traversables| is not [=list/empty=] return true. + 1. [=list/For each=] |navigable| in |top-level traversables|: + + 1. If |subscription|'s [=subscription/user context ids=] [=set/contains=] + |navigable|'s [=associated user context=]'s [=user context id=], return true. + + 1. Otherwise: + + 1. Let |subscription top-level traversables| be [=get navigables by ids=] with |subscription|'s [=subscription/top-level traversable ids=]. + + 1. If the [=set/intersection=] of |top-level traversables| and + |subscription top-level traversables| is not [=list/empty=] return true. 1. Return false. @@ -779,6 +790,14 @@ given |event name| and |session| is: 1. [=Break=]. + 1. Otherwise, if [=subscription/user context ids=] is not empty: + + 1. For each |traversable| in remote end's [=/top-level traversables=]: + + 1. [=set/Append=] |traversable| to |result| if + |subscription|'s [=subscription/user context ids=] [=set/contains=] + |traversable|'s [=associated user context=]'s [=user context id=]. + 1. Otherwise: 1. Let |top-level traversables| be [=get navigables by ids=] with |subscription|'s [=subscription/top-level traversable ids=]. @@ -1446,6 +1465,31 @@ time. However they are not required to remove such [=user contexts=]. [=User contexts=] that are not [=empty user contexts=] must not be removed from the [=set of user contexts=]. +When a [=user context=] is [=set/remove|removed=] from the +[=set of user contexts=], [=remove user context subscriptions=]. + +
+ +To remove user context subscriptions: + +1. For each |session| in [=active sessions=]: + + 1. Let |subscriptions to remove| be a [=/set=]. + + 1. For each |subscription| in |session|'s [=subscriptions=]: + + 1. If |subscription|'s [=subscription/user context ids=] [=set/contains=] |navigable|'s [=associated user context=]'s [=user context id=]; + + 1. [=set/Remove=] |navigable|'s [=associated user context=]'s [=user context id=] from |subscription|'s [=subscription/user context ids=]. + + 1. If |subscription|'s [=subscription/user context ids=] is empty: + + 1. [=set/Append=] |subscription| to |subscriptions to remove|. + + 1. [=list/Remove=] |subscriptions to remove| from |session|'s [=subscriptions=]. + +
+
To get user context given |user context id|: @@ -1685,6 +1729,7 @@ The session.Subscription type represents a unique subscription iden session.SubscriptionRequest = { events: [+text], ? contexts: [+browsingContext.BrowsingContext], + ? userContexts: [+browser.UserContext], } @@ -1926,12 +1971,17 @@ The [=remote end steps=] with |session| and |command parameters| are: let |event names| be the [=set/union=] of |event names| and the result of [=trying=] to [=obtain a set of event names=] with |name|. +1. Let |input user context ids| be [=set/create|create a set=] with |command parameters|[contexts]. + +1. Let |input context ids| be [=set/create|create a set=] with |command parameters|[contexts]. + +1. If |input user context ids| is not empty and |input context ids| is not empty, + return [=error=] with [=error code=] [=invalid argument=]. + 1. Let |subscription navigables| be a [=/set=]. 1. Let |top-level traversable context ids| be a [=/set=]. -1. Let |input context ids| be [=set/create|create a set=] with |command parameters|[contexts]. - 1. If |input context ids| is not empty: 1. Let |navigables| be [=get navigables by ids=] with |input context ids|. @@ -1946,12 +1996,26 @@ The [=remote end steps=] with |session| and |command parameters| are: 1. [=set/Append=] |navigable|'s [=navigable id=] to |top-level traversable context ids|. +1. Otherwise, if |input user context ids| is not empty: + + 1. [=list/For each=] |user context id| of |input user context ids|: + + 1. Let |user context| be [=get user context=] with |user context id|. + + 1. If |user context| is null, return [=error=] with [=error code=] [=invalid argument=]. + + 1. [=list/For each=] |top-level traversable| in the list of all [=/top-level traversables=] + whose [=associated user context=] is |user context|: + + 1. [=list/Append=] |top-level traversable| to |subscription navigables|. + 1. Otherwise, set |subscription navigables| to a [=/set=] of all [=navigable/top-level traversables=] in the [=remote end=]. 1. Let |subscription| be a [=subscription=] with [=subscription/subscription id=] set to the string representation of a [[!RFC9562|UUID]], - [=subscription/event names=] set to |event names|, and - [=subscription/top-level traversable ids=] set to |top-level traversable context ids|. + [=subscription/event names=] set to |event names|, + [=subscription/top-level traversable ids=] set to |top-level traversable context ids| and + [=subscription/user context ids=] set to |input user context ids|. 1. Let |subscribe step events| be a new [=/map=]. @@ -2098,6 +2162,8 @@ The [=remote end steps=] with |session| and |command parameters| are: 1. [=list/append=] |subscription| to |new subscriptions|. + 1. Otherwise, if |subscription|'s [=subscription/user context ids=] is not empty, [=continue=]. + 1. Otherwise: Note: unsubscribe by contexts is deprecated and will be removed in the future versions.