Skip to content

Commit 42abefe

Browse files
OrKoNjrandolf-2
andauthored
Support enabling an interception for a top-level browsing context (#653)
* Support enabling an interception for a top-level browsing context * Update index.bs Co-authored-by: jrandolf <[email protected]> --------- Co-authored-by: jrandolf <[email protected]>
1 parent 0a11647 commit 42abefe

File tree

1 file changed

+41
-8
lines changed

1 file changed

+41
-8
lines changed

index.bs

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4519,9 +4519,9 @@ A <dfn>network intercept</dfn> is a mechanism to allow remote ends to intercept
45194519
and modify network requests and responses.
45204520

45214521
A [=BiDi session=] has an <dfn>intercept map</dfn> which is a [=/map=] between
4522-
intercept id and a [=struct=] with fields <code>url patterns</code> and
4523-
<code>phases</code> that define the properties of active network intercepts. It
4524-
is initially empty.
4522+
intercept id and a [=struct=] with fields <code>url patterns</code>,
4523+
<code>phases</code>, and <code>browsingContexts</code> that define the properties
4524+
of active network intercepts. It is initially empty.
45254525

45264526
A [=BiDi session=] has a <dfn>blocked request map</dfn>, used to track the
45274527
requests which are actively being blocked. It is an [=/map=] between [=request id=]
@@ -4530,7 +4530,7 @@ and a [=struct=] with fields <code>request</code>, <code>phase</code>, and
45304530

45314531
<div algorithm>
45324532

4533-
To <dfn>get the network intercepts</dfn> given |session|, |event|, and |request|:
4533+
To <dfn>get the network intercepts</dfn> given |session|, |event|, |request|, and |context id|:
45344534

45354535
1. Let |session intercepts| be |session|'s [=intercept map=].
45364536

@@ -4553,6 +4553,12 @@ To <dfn>get the network intercepts</dfn> given |session|, |event|, and |request|
45534553

45544554
1. For each |intercept id| → |intercept| of |session intercepts|:
45554555

4556+
1. If |intercept|'s <code>contexts</code> is not null:
4557+
4558+
1. If |intercept|'s <code>contexts</code> does not [=set/contains|contain=] |context id|:
4559+
4560+
1. Continue.
4561+
45564562
1. If |intercept|'s <code>phases</code> [=set/contains=] |phase|:
45574563

45584564
1. Let |url patterns| be |intercept|'s <code>url patterns</code>.
@@ -4753,8 +4759,6 @@ request in addition to the context.
47534759
<div algorithm>
47544760
To <dfn>process a network event</dfn> given |session|, |event|, and |request|:
47554761

4756-
1. Let |intercepts| be the result of [=get the network intercepts=] with
4757-
|session|, |event|, and |request|.
47584762

47594763
1. Let |request data| be the result of [=get the request data=] with |request|.
47604764

@@ -4763,13 +4767,20 @@ To <dfn>process a network event</dfn> given |session|, |event|, and |request|:
47634767

47644768
1. Let |context id| be null.
47654769

4770+
1. Let |top-level context id| be null.
4771+
47664772
1. If |request|'s [=request/window=] is an [=environment settings object=]:
47674773

47684774
1. Let |environment settings| be |request|'s [=request/window=]
47694775

47704776
1. If there is a [=/browsing context=] whose [=active window=] is |environment
47714777
settings|' [=environment settings object/global object=], set |context id|
4772-
to the [=browsing context id=] for that context.
4778+
to the [=browsing context id=] for that context, and set |top-level context id|
4779+
to be [=top-level browsing context=]'s [=browsing context id=] for that
4780+
context.
4781+
4782+
1. Let |intercepts| be the result of [=get the network intercepts=] with
4783+
|session|, |event|, |request|, and |top-level context id|.
47734784

47744785
1. Let |redirect count| be |request|'s [=redirect count=].
47754786

@@ -5842,6 +5853,7 @@ The <dfn export for=commands>network.addIntercept</dfn> command adds a
58425853

58435854
network.AddInterceptParameters = {
58445855
phases: [+network.InterceptPhase],
5856+
? contexts: [+browsingContext.BrowsingContext],
58455857
? urlPatterns: [*network.UrlPattern],
58465858
}
58475859

@@ -5867,6 +5879,25 @@ The [=remote end steps=] given |session| and |command parameters| are:
58675879
1. Let |url patterns| be the <code>urlPatterns</code> field of |command
58685880
parameters| if present, or an empty [=/list=] otherwise.
58695881

5882+
1. Let |contexts| be null.
5883+
5884+
1. If the <code>contexts</code> field of |command parameters| is present:
5885+
5886+
1. Set |contexts| to an empty [=/set=].
5887+
5888+
1. For each |context id| of |command parameters|["<code>contexts</code>"]
5889+
5890+
1. Let |context| be the result of [=trying=] to [=get a browsing context=]
5891+
with |context id|.
5892+
5893+
1. If |context| is not a [=top-level browsing context=], return [=error=]
5894+
with [=error code=] [=invalid argument=].
5895+
5896+
1. Append |context| to |contexts|.
5897+
5898+
1. If |contexts| is an empty [=/set=], return [=error=] with [=error code=]
5899+
[=invalid argument=].
5900+
58705901
1. Let |intercept map| be |session|'s [=intercept map=].
58715902

58725903
1. Let |parsed patterns| be an empty [=/list=].
@@ -5879,7 +5910,9 @@ The [=remote end steps=] given |session| and |command parameters| are:
58795910
1. [=list/Append=] |parsed| to |parsed patterns|.
58805911

58815912
1. Set |intercept map|[|intercept|] to a struct with <code>url patterns</code>
5882-
|parsed patterns| and <code>phases</code> |command parameters|["<code>phases</code>"].
5913+
|parsed patterns|, <code>phases</code> |command
5914+
parameters|["<code>phases</code>"] and <code>browsingContexts</code>
5915+
|contexts|.
58835916

58845917
1. Return a new [=/map=] matching the
58855918
<code>network.AddInterceptResult</code> production with the

0 commit comments

Comments
 (0)