@@ -4519,9 +4519,9 @@ A <dfn>network intercept</dfn> is a mechanism to allow remote ends to intercept
4519
4519
and modify network requests and responses.
4520
4520
4521
4521
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.
4525
4525
4526
4526
A [=BiDi session=] has a <dfn>blocked request map</dfn> , used to track the
4527
4527
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
4530
4530
4531
4531
<div algorithm>
4532
4532
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 |:
4534
4534
4535
4535
1. Let |session intercepts| be |session|'s [=intercept map=] .
4536
4536
@@ -4553,6 +4553,12 @@ To <dfn>get the network intercepts</dfn> given |session|, |event|, and |request|
4553
4553
4554
4554
1. For each |intercept id| → |intercept| of |session intercepts|:
4555
4555
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
+
4556
4562
1. If |intercept|'s <code> phases</code> [=set/contains=] |phase|:
4557
4563
4558
4564
1. Let |url patterns| be |intercept|'s <code> url patterns</code> .
@@ -4753,8 +4759,6 @@ request in addition to the context.
4753
4759
<div algorithm>
4754
4760
To <dfn>process a network event</dfn> given |session|, |event|, and |request|:
4755
4761
4756
- 1. Let |intercepts| be the result of [=get the network intercepts=] with
4757
- |session|, |event|, and |request|.
4758
4762
4759
4763
1. Let |request data| be the result of [=get the request data=] with |request|.
4760
4764
@@ -4763,13 +4767,20 @@ To <dfn>process a network event</dfn> given |session|, |event|, and |request|:
4763
4767
4764
4768
1. Let |context id| be null.
4765
4769
4770
+ 1. Let |top-level context id| be null.
4771
+
4766
4772
1. If |request|'s [=request/window=] is an [=environment settings object=] :
4767
4773
4768
4774
1. Let |environment settings| be |request|'s [=request/window=]
4769
4775
4770
4776
1. If there is a [=/browsing context=] whose [=active window=] is |environment
4771
4777
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|.
4773
4784
4774
4785
1. Let |redirect count| be |request|'s [=redirect count=] .
4775
4786
@@ -5842,6 +5853,7 @@ The <dfn export for=commands>network.addIntercept</dfn> command adds a
5842
5853
5843
5854
network.AddInterceptParameters = {
5844
5855
phases: [+network.InterceptPhase] ,
5856
+ ? contexts: [+browsingContext.BrowsingContext] ,
5845
5857
? urlPatterns: [*network.UrlPattern] ,
5846
5858
}
5847
5859
@@ -5867,6 +5879,25 @@ The [=remote end steps=] given |session| and |command parameters| are:
5867
5879
1. Let |url patterns| be the <code> urlPatterns</code> field of |command
5868
5880
parameters| if present, or an empty [=/list=] otherwise.
5869
5881
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
+
5870
5901
1. Let |intercept map| be |session|'s [=intercept map=] .
5871
5902
5872
5903
1. Let |parsed patterns| be an empty [=/list=] .
@@ -5879,7 +5910,9 @@ The [=remote end steps=] given |session| and |command parameters| are:
5879
5910
1. [=list/Append=] |parsed| to |parsed patterns|.
5880
5911
5881
5912
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|.
5883
5916
5884
5917
1. Return a new [=/map=] matching the
5885
5918
<code> network.AddInterceptResult</code> production with the
0 commit comments