diff --git a/index.bs b/index.bs index 1a62c261..7f713338 100644 --- a/index.bs +++ b/index.bs @@ -706,35 +706,22 @@ occurred on the [=remote end=]. are run when multiple events are enabled at once, with lower integers indicating steps that run earlier. -A [=BiDi session=] has a global event set -which is a [=/set=] containing the event names for events that are enabled for all -navigables. This initially contains the [=event name=] for events that -are in the default event set. - -A [=BiDi session=] has a navigable event map, -which is a [=/map=] with [=/top-level traversable=] keys and values -that are a [=/set=] of [=event name=]s for events that are enabled in the given -navigable. - -
method
"
@@ -1482,113 +1503,6 @@ To cleanup remote end state.
session.UserPromptHandlerType
type represents the behavior
of the user prompt handler.
+#### The session.Subscription Type #### {#type-session-Subscription}
+
++session.Subscription = text ++ +The
session.Subscription
type represents a unique subscription identifier.
+
#### The session.SubscriptionRequest Type #### {#type-session-SubscriptionRequest}
@@ -1745,6 +1667,31 @@ session.SubscriptionRequest = { Thesession.SubscriptionRequest
type represents a request to subscribe to or unsubscribe from a specific set of events. +#### The session.UnsubscribeByIDRequest Type #### {#type-session-UnsubscribeByIDRequest} + ++session.UnsubscribeByIDRequest = { + subscriptions: [+session.Subscription], +} ++ +Thesession.UnsubscribeByIDRequest
type represents a request to +remove event subscriptions identified by subscription IDs. + +#### The session.UnsubscribeByAttributesRequest Type #### {#type-session-UnsubscribeByAttributesRequest} + +Note: contexts param is deprecated and will be removed in the future versions. + ++session.UnsubscribeByAttributesRequest = { + events: [+text], + ? contexts: [+browsingContext.BrowsingContext], +} ++ +Thesession.UnsubscribeByAttributesRequest
type represents a request to +unsubscribe using subscription attributes. + ### Commands ### {#module-session-commands} #### The session.status Command #### {#command-session-status} @@ -1938,31 +1885,61 @@ Issue: This needs to be generalized to work with realms too.
- EmptyResult
-
+ + session.SubscriptionRequestResult = { + subscription: session.Subscription, + } +
events
field of
- |command parameters|
+1. Let the |event names| be [=set/create=] a [=/set=] given |command parameters|["events
"].
+
+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=] a [=/set=] given |command parameters|[contexts
].
+
+1. If |input context ids| is not empty:
-1. Let the |list of navigables| be the value of the contexts
- field of |command parameters| if it is present or null if it isn't.
+ 1. Let |navigables| be [=get navigables by ids=] with |input context ids|.
-1. Let |enabled events| be the result of [=trying=] to [=update the event map=]
- with |session|, |list of event names| , |list of navigables| and
- enabled true.
+ 1. If [=list/size=] of |navigables| does not equal [=list/size=] of |input context ids|:
+
+ 1. Return [=error=] with [=error code=] [=invalid argument=].
+
+ 1. Set |subscription navigables| be [=get top-level traversables=] with |navigables|.
+
+ 1. For each |navigable| in |subscription navigables|:
+
+ 1. [=set/Append=] |navigable|'s [=navigable id=] to |top-level traversable context ids|.
+
+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|.
1. Let |subscribe step events| be a new [=/map=].
-1. For each |event name| → |navigables| in |enabled events|:
+1. For each |event name| in the |event names|:
- 1. If the [=event=] with [=event name=] |event name| defines [=remote end
- subscribe steps=], set |subscribe step events|[|event name|] to |navigables|.
+ 1. If the [=event=] with [=event name=] |event name| does not define [=remote end
+ subscribe steps=], continue;
+
+ 1. Let |existing navigables| be a [=set of top-level traversables for which an event is enabled=] with |session| and |event name|.
+
+ 1. Set |subscribe step events|[|event name|] to [=set/difference=] of
+ |subscription navigables| and |existing navigables|.
+
+1. Append |subscription| to |session|'s [=subscriptions=].
+
+1. Append |subscription|'s [=subscription/subscription id=] to |session|'s [=known subscription ids=].
1. [=map/Sort in ascending order=] |subscribe step events| using the following less
than algorithm given two entries with keys |event name one| and |event
@@ -1975,7 +1952,7 @@ The [=remote end steps=] with |session| and |command parameters| are:
1. Return true if |event one|'s [=subscribe priority=] is less than |event
two|'s subscribe priority, or false otherwise.
-1. If |list of navigables| is null, let |include global| be true, otherwise let
+1. If |subscription| is [=subscription/global=], let |include global| be true, otherwise let
|include global| be false.
1. For each |event name| → |navigables| in |subscribe step events|:
@@ -1994,13 +1971,16 @@ either globally or for a set of navigables.
Issue: This needs to be generalised to work with realms too.
+Note: contexts parameter in UnsubscribeByAttributesRequest is deprecated
+and will be removed in the future versions.
+
session.Unsubscribe = ( method: "session.unsubscribe", - params: session.SubscriptionRequest + params: session.UnsubscribeByAttributesRequest / session.UnsubscribeByIDRequest, )
events
field of
- |command parameters|.
+1. If |command parameters| matches the session.UnsubscribeByAttributesRequest
production:
+
+ 1. Let |event names| be [=set/create|create a set=] with |command parameters|["events
"].
+
+ 1. Let |top-level traversable context ids| be a [=/set=].
+
+ 1. Let |input context ids| be [=set/create=] a [=/set=] given |command parameters|[contexts
].
+
+ 1. If |input context ids| is not empty:
+
+ 1. Let |navigables| be [=get navigables by ids=] with |input context ids|.
+
+ 1. If [=list/size=] of |navigables| does not equal [=list/size=] of |input context ids|:
+
+ 1. Return [=error=] with [=error code=] [=invalid argument=].
+
+ 1. Set |top-level traversables| be [=get top-level traversables=] with |navigables|.
+
+ 1. For each |navigable| in |top-level traversables|:
+
+ 1. [=set/Append=] |navigable|'s [=navigable id=] to |top-level traversable context ids|.
-1. Let the |list of contexts| be the value of the contexts
- field of |command parameters| if it is present or null if it isn't.
+ 1. Let |new subscriptions| to be a [=/list=].
-1. [=Try=] to [=update the event map=] with |session|,
- |list of event names|, |list of contexts| and enabled false.
+ 1. For each |subscription| of |session|'s [=subscriptions=]:
+
+ 1. If [=set/intersection=] of |subscription|'s [=subscription/event names=] and |event names| is an empty [=/set=]:
+
+ 1. [=list/append=] |subscription| to |new subscriptions|.
+
+ 1. Continue.
+
+ 1. If |top-level traversable context ids| is an empty [=/set=]:
+
+ 1. [=list/Remove=] all items [=list/contains|contained=] in |event names| from |subscription|'s [=subscription/event names=].
+
+ 1. If |subscription|'s [=subscription/event names=] is not empty:
+
+ 1. [=list/append=] |subscription| to |new subscriptions|.
+
+ 1. Otherwise:
+
+ 1. If |subscription| is [=subscription/global=]:
+
+ 1. [=list/append=] |subscription| to |new subscriptions|.
+
+ 1. Otherwise:
+
+ Note: unsubscribe by contexts is deprecated and will be removed in the future versions.
+
+ 1. Let |event map| be an empty [=/map=].
+
+ 1. For each |event name| in |subscription|'s [=subscription/event names=]:
+
+ 1. Set |event map|[|event name|] to [=set/clone=] of |subscription|'s [=subscription/top-level traversable ids=].
+
+ 1. For each |event name| in |event names|:
+
+ 1. If |event map|[|event name|] does not exist,
+ continue.
+
+ 1. Set |event map|[|event name|] to the [=set/difference=]
+ between |event map|[|event name|] and |top-level traversable context ids|.
+
+ 1. If |event map|[|event name|] is an empty [=/set=],
+
+ 1. [=map/Remove=] |event map|[|event name|].
+
+ 1. For each |event name| → |remaining top-level traversable ids| in |event map|:
+
+ 1. Let |partial subscription| be a [=subscription=] with
+ [=subscription/subscription id=] set to |subscription|'s [=subscription/subscription id=],
+ [=subscription/event names=] set to a new [=/set=] containing |event name|,
+ [=subscription/top-level traversable ids=] set to |remaining top-level traversable ids|.
+
+ 1. [=list/append=] |partial subscription| to |new subscriptions|.
+
+ 1. Set |session|'s [=subscriptions=] to |new subscriptions|.
+
+1. Otherwise:
+
+ 1. Let |subscriptions| be [=set/create=] a [=/set=] with |command parameters|[subscriptions
].
+
+ 1. Let |unknown subscription ids| to [=set/difference=] between |subscriptions| and |session|'s [=known subscription ids=].
+
+ 1. If |unknown subscription ids| is not empty:
+
+ 1. Return [=error=] with [=error code=] [=invalid argument=].
+
+ 1. Let |subscriptions to remove| be an empty [=/set=].
+
+ 1. For each |subscription| in |session|'s [=subscriptions=]:
+
+ 1. If |subscriptions| [=set/contains=] |subscription|'s [=subscription/subscription id=]:
+
+ 1. [=set/Append=] |subscription| to |subscriptions to remove|.
+
+ 1. Set |session|'s [=known subscription ids=] to
+ [=set/difference=] between |session|'s [=known subscription ids=] and |subscriptions|.
+
+ 1. [=list/Remove=] each item in |subscriptions to remove| from |session|'s [=subscriptions=].
1. Return [=success=] with data null.
@@ -4677,6 +4750,20 @@ the WebDriver BiDi navigable destroyed steps given |navigable|
1. [=Emit an event=] with |session| and |body|.
+ 1. Let |subscriptions to remove| be a [=/set=].
+
+ 1. For each |subscription| in |session|'s [=subscriptions=]:
+
+ 1. If |subscription|'s [=subscription/top-level traversable ids=] [=set/contains=] |navigable|'s [=navigable id=];
+
+ 1. [=set/Remove=] |navigable|'s [=navigable id=] from |subscription|'s [=subscription/top-level traversable ids=].
+
+ 1. If |subscription|'s [=subscription/top-level traversable ids=] is empty:
+
+ 1. [=set/Append=] |subscription| to |subscriptions to remove|.
+
+ 1. [=list/Remove=] |subscriptions to remove| from |session|'s [=subscriptions=].
+
Issue: It's unclear if we ought to only fire this event for browsing
contexts that have active documents; navigation can also cause contexts to
become inaccessible but not yet get discarded because bfcache.