@@ -713,11 +713,13 @@ all [=subscription/subscription ids=] that have been issued to the [=local end=]
713
713
714
714
A <dfn for=event>subscription</dfn> is a [=/struct=] consisting of a
715
715
<dfn for=subscription>subscription id</dfn> (a string),
716
- <dfn for=subscription>event names</dfn> (a [=/set=] of event names)
717
- and <dfn for=subscription>top-level traversable ids</dfn> (a [=/set=] of IDs of [=/top-level traversables=] ).
716
+ <dfn for=subscription>event names</dfn> (a [=/set=] of event names),
717
+ <dfn for=subscription>top-level traversable ids</dfn> (a [=/set=] of IDs of [=/top-level traversables=] )
718
+ and <dfn for=subscription>user context ids</dfn> (a [=/set=] of IDs of [=user contexts=] ).
718
719
719
720
A [=subscription=] |subscription| is <dfn for="subscription">global</dfn>
720
- if |subscription|'s [=subscription/top-level traversable ids=] is an empty set.
721
+ if |subscription|'s [=subscription/top-level traversable ids=] is an empty set
722
+ and |subscription|'s [=user context ids=] is an empty set.
721
723
722
724
<div algorithm>
723
725
@@ -750,10 +752,19 @@ Note: |navigables| is a set because a [=shared worker=] can be associated
750
752
751
753
1. If |subscription| is [=subscription/global=] return true.
752
754
753
- 1. Let |subscription top-level traversables| be [=get navigables by ids=] with |subscription|'s [=subscription/top-level traversable ids=] .
755
+ 1. If [=subscription/user context ids=] is not empty:
754
756
755
- 1. If the [=set/intersection=] of |top-level traversables| and
756
- |subscription top-level traversables| is not [=list/empty=] return true.
757
+ 1. [=list/For each=] |navigable| in |top-level traversables|:
758
+
759
+ 1. If |subscription|'s [=subscription/user context ids=] [=set/contains=]
760
+ |navigable|'s [=associated user context=]' s [=user context id=] , return true.
761
+
762
+ 1. Otherwise:
763
+
764
+ 1. Let |subscription top-level traversables| be [=get navigables by ids=] with |subscription|'s [=subscription/top-level traversable ids=] .
765
+
766
+ 1. If the [=set/intersection=] of |top-level traversables| and
767
+ |subscription top-level traversables| is not [=list/empty=] return true.
757
768
758
769
1. Return false.
759
770
@@ -779,6 +790,14 @@ given |event name| and |session| is:
779
790
780
791
1. [=Break=] .
781
792
793
+ 1. Otherwise, if [=subscription/user context ids=] is not empty:
794
+
795
+ 1. For each |traversable| in remote end's [=/top-level traversables=] :
796
+
797
+ 1. [=set/Append=] |traversable| to |result| if
798
+ |subscription|'s [=subscription/user context ids=] [=set/contains=]
799
+ |traversable|'s [=associated user context=]' s [=user context id=] .
800
+
782
801
1. Otherwise:
783
802
784
803
1. Let |top-level traversables| be [=get navigables by ids=] with |subscription|'s [=subscription/top-level traversable ids=] .
@@ -1436,6 +1455,31 @@ To <dfn export>get user context</dfn> given |user context id|:
1436
1455
1437
1456
</div>
1438
1457
1458
+ When a [=user context=] is [=set/remove|removed=] from the
1459
+ [=set of user contexts=] , [=remove user context subscriptions=] :
1460
+
1461
+ <div algorithm>
1462
+
1463
+ To <dfn export>remove user context subscriptions</dfn> :
1464
+
1465
+ 1. For each |session| in [=active sessions=] :
1466
+
1467
+ 1. Let |subscriptions to remove| be a [=/set=] .
1468
+
1469
+ 1. For each |subscription| in |session|'s [=subscriptions=] :
1470
+
1471
+ 1. If |subscription|'s [=subscription/user context ids=] [=set/contains=] |navigable|' s [=associated user context=] 's [=user context id=] ;
1472
+
1473
+ 1. [=set/Remove=] |navigable|'s [=associated user context=]' s [=user context id=] from |subscription|'s [=subscription/user context ids=] .
1474
+
1475
+ 1. If |subscription|'s [=subscription/user context ids=] is empty:
1476
+
1477
+ 1. [=set/Append=] |subscription| to |subscriptions to remove|.
1478
+
1479
+ 1. [=list/Remove=] |subscriptions to remove| from |session|'s [=subscriptions=] .
1480
+
1481
+ </div>
1482
+
1439
1483
# Modules # {#modules}
1440
1484
1441
1485
## The session Module ## {#module-session}
@@ -1661,6 +1705,7 @@ The <code>session.Subscription</code> type represents a unique subscription iden
1661
1705
session.SubscriptionRequest = {
1662
1706
events: [+text] ,
1663
1707
? contexts: [+browsingContext.BrowsingContext] ,
1708
+ ? userContexts: [+browser.UserContext] ,
1664
1709
}
1665
1710
</pre>
1666
1711
@@ -1896,14 +1941,20 @@ Issue: This needs to be generalized to work with realms too.
1896
1941
<div algorithm="remote end steps for session.subscribe">
1897
1942
The [=remote end steps=] with |session| and |command parameters| are:
1898
1943
1899
- 1. Let the |event names| be [=set/create=] a [=/set=] given |command parameters|["<code>events</code>"] .
1944
+ 1. Let the |event names| be [=set/create|create a set=] with |command parameters|["<code>events</code>"] .
1945
+
1946
+ 1. Let |input user context ids| be [=set/create|create a set=] with |command parameters|[<code>userContexts</code>] .
1947
+
1948
+ 1. Let |input context ids| be [=set/create|create a set=] with |command parameters|[<code>contexts</code>] .
1949
+
1950
+ 1. If |input context ids| is not empty and |input user context ids| is not empty:
1951
+
1952
+ 1. Return [=error=] with [=error code=] [=invalid argument=] .
1900
1953
1901
1954
1. Let |subscription navigables| be a [=/set=] .
1902
1955
1903
1956
1. Let |top-level traversable context ids| be a [=/set=] .
1904
1957
1905
- 1. Let |input context ids| be [=set/create=] a [=/set=] given |command parameters|[<code>contexts</code>] .
1906
-
1907
1958
1. If |input context ids| is not empty:
1908
1959
1909
1960
1. Let |navigables| be [=get navigables by ids=] with |input context ids|.
@@ -1918,12 +1969,26 @@ The [=remote end steps=] with |session| and |command parameters| are:
1918
1969
1919
1970
1. [=set/Append=] |navigable|'s [=navigable id=] to |top-level traversable context ids|.
1920
1971
1972
+ 1. Otherwise, if |input user context ids| is not empty:
1973
+
1974
+ 1. [=list/For each=] |user context id| of |input user context ids|:
1975
+
1976
+ 1. Let |user context| be [=get user context=] with |user context id|.
1977
+
1978
+ 1. If |user context| is null, return [=error=] with [=error code=] [=invalid argument=] .
1979
+
1980
+ 1. [=list/For each=] |top-level traversable| in the list of all [=/top-level traversables=]
1981
+ whose [=associated user context=] is |user context|:
1982
+
1983
+ 1. [=list/Append=] |top-level traversable| to |subscription navigables|.
1984
+
1921
1985
1. Otherwise, set |subscription navigables| to a [=/set=] of all [=navigable/top-level traversables=] in the [=remote end=] .
1922
1986
1923
1987
1. Let |subscription| be a [=subscription=] with
1924
1988
[=subscription/subscription id=] set to the string representation of a [[!RFC9562|UUID]] ,
1925
- [=subscription/event names=] set to |event names|, and
1926
- [=subscription/top-level traversable ids=] set to |top-level traversable context ids|.
1989
+ [=subscription/event names=] set to |event names|,
1990
+ [=subscription/top-level traversable ids=] set to |top-level traversable context ids| and
1991
+ [=subscription/user context ids=] set to |input user context ids|.
1927
1992
1928
1993
1. Let |subscribe step events| be a new [=/map=] .
1929
1994
@@ -2001,7 +2066,7 @@ The [=remote end steps=] with |session| and |command parameters| are:
2001
2066
2002
2067
1. Let |top-level traversable context ids| be a [=/set=] .
2003
2068
2004
- 1. Let |input context ids| be [=set/create=] a [=/ set=] given |command parameters|[<code>contexts</code>] .
2069
+ 1. Let |input context ids| be [=set/create|create a set=] with |command parameters|[<code>contexts</code>] .
2005
2070
2006
2071
1. If |input context ids| is not empty:
2007
2072
@@ -2041,6 +2106,8 @@ The [=remote end steps=] with |session| and |command parameters| are:
2041
2106
2042
2107
1. [=list/append=] |subscription| to |new subscriptions|.
2043
2108
2109
+ 1. Otherwise, if |subscription|'s [=subscription/user context ids=] is not empty, [=continue=] .
2110
+
2044
2111
1. Otherwise:
2045
2112
2046
2113
Note: unsubscribe by contexts is deprecated and will be removed in the future versions.
@@ -2076,7 +2143,7 @@ The [=remote end steps=] with |session| and |command parameters| are:
2076
2143
2077
2144
1. Otherwise:
2078
2145
2079
- 1. Let |subscriptions| be [=set/create=] a [=/ set=] with |command parameters|[<code>subscriptions</code>] .
2146
+ 1. Let |subscriptions| be [=set/create|create a set=] with |command parameters|[<code>subscriptions</code>] .
2080
2147
2081
2148
1. Let |unknown subscription ids| to [=set/difference=] between |subscriptions| and |session|'s [=known subscription ids=] .
2082
2149
0 commit comments