@@ -1867,6 +1867,7 @@ NodeProperties = {
1867
1867
?attributes: {*text => text},
1868
1868
?children: [*NodeRemoteValue] ,
1869
1869
?localName: text,
1870
+ ?mode: "open" / "closed",
1870
1871
?namespaceURI: text,
1871
1872
?nodeValue: text,
1872
1873
?shadowRoot: NodeRemoteValue / null,
@@ -1895,7 +1896,7 @@ Issue: handle String / Number / etc. wrapper objects specially?
1895
1896
1896
1897
<div algorithm>
1897
1898
1898
- To <dfn>serialize as a remote value</dfn> given a |value|, a |max depth |,
1899
+ To <dfn>serialize as a remote value</dfn> given |value|, |serialization options |,
1899
1900
an |ownership type|, a |serialization internal map|, a |realm| and a |session|:
1900
1901
1901
1902
1. Let |remote value| be a result of [=serialize primitive protocol value=]
@@ -1923,7 +1924,8 @@ an |ownership type|, a |serialization internal map|, a |realm| and a |session|:
1923
1924
<dt> [=IsArray=] (|value|)
1924
1925
<dd> Let |remote value| be [=serialize an Array-like=] with |session|,
1925
1926
<code> ArrayRemoteValue</code> , |handle id|, |known object|, |value|,
1926
- |max depth|, |ownership type|, |serialization internal map|, and |realm|.
1927
+ |serialization options|, |ownership type|, |serialization internal map|,
1928
+ |realm|, and |session|.
1927
1929
1928
1930
<dt> [=IsRegExp=] (|value|)
1929
1931
<dd>
@@ -1964,11 +1966,12 @@ an |ownership type|, a |serialization internal map|, a |realm| and a |session|:
1964
1966
1965
1967
1. Let |serialized| be null.
1966
1968
1967
- 1. If |known object| is <code> false</code> , and |max depth| is not 0, run
1968
- the following steps:
1969
+ 1. If |known object| is <code> false</code> , and |serialization
1970
+ options|["<code>maxObjectDepth</code>"] is not 0, run the following
1971
+ steps:
1969
1972
1970
1973
1. Let |serialized| be the result of [=serialize as a mapping=] with
1971
- [=CreateMapIterator=] (|value|, key+value), |max depth |,
1974
+ [=CreateMapIterator=] (|value|, key+value), |serialization options |,
1972
1975
|ownership type|, |serialization internal map|, |realm|, and |session|.
1973
1976
1974
1977
1. If |serialized| is not null, set field <code> value</code> of |remote value| to
@@ -1986,12 +1989,14 @@ an |ownership type|, a |serialization internal map|, a |realm| and a |session|:
1986
1989
1987
1990
1. Let |serialized| be null.
1988
1991
1989
- 1. If |known object| is <code> false</code> , and |max depth| is not 0, run
1990
- the following steps:
1992
+ 1. If |known object| is <code> false</code> , and |serialization
1993
+ options|["<code>maxObjectDepth</code>"] is not 0, run the following
1994
+ steps:
1991
1995
1992
1996
1. Let |serialized| be the result of [=serialize as a list=] with
1993
- [=CreateSetIterator=] (|value|, value), |max depth|, |ownership type|,
1994
- |serialization internal map|, |realm|, and |session|.
1997
+ [=CreateSetIterator=] (|value|, value), |serialization options|,
1998
+ |ownership type|, |serialization internal map|, |realm|, and
1999
+ |session|.
1995
2000
1996
2001
1. If |serialized| is not null, set field <code> value</code> of |remote value| to
1997
2002
|serialized|.
@@ -2029,13 +2034,14 @@ an |ownership type|, a |serialization internal map|, a |realm| and a |session|:
2029
2034
<dt> |value| is a [=platform object=] that implements {{NodeList}}
2030
2035
<dd> Let |remote value| be [=serialize an Array-like=] with
2031
2036
<code> NodeListRemoteValue</code> ,|handle id|, |known object|, |value|,
2032
- |max depth|, |ownership type|, |serialization internal map|, and |realm|.
2037
+ |serialization options|, |ownership type|, |serialization internal map|,
2038
+ |realm|, and |session|.
2033
2039
2034
2040
<dt> |value| is a [=platform object=] that implements {{HTMLCollection}}
2035
2041
<dd> Let |remote value| be [=serialize an Array-like=] with
2036
2042
<code> HTMLCollectionRemoteValue</code> , |handle id|, |known object|, |value|,
2037
- |max depth |, |ownership type|, |known object|, |serialization internal map|,
2038
- and |realm |.
2043
+ |serialization options |, |ownership type|, |known object|, |serialization internal map|,
2044
+ |realm|, and |session |.
2039
2045
2040
2046
<dt> |value| is a [=platform object=] that implements {{Node}}
2041
2047
<dd>
@@ -2074,14 +2080,27 @@ an |ownership type|, a |serialization internal map|, a |realm| and a |session|:
2074
2080
2075
2081
1. Set |serialized|["<code>childNodeCount</code>"] to |child node count|.
2076
2082
2077
- 1. If |max depth| is equal to 0 let |children| be null.
2078
- Otherwise, let |children| be an empty [=/list=] and, for each node
2079
- |child| in the [=children=] of |value|:
2083
+ 1. If |serialization options|["<code>maxDomDepth</code>"] is equal to
2084
+ 0, or if |value| implements {{ShadowRoot}} and |serialization
2085
+ options|["<code>includeShadowTree</code>"] is "<code> none</code> ",
2086
+ or if |serialization options|["<code>includeShadowTree</code>"] is
2087
+ "<code> open</code> " and |value|'s <a spec=dom for=ShadowRoot>mode</a> is
2088
+ "<code> closed</code> ", let |children| be null.
2080
2089
2081
- 1. Let |child depth| be |max depth| - 1 if |max depth| is not null, or null otherwise.
2090
+ Otherwise, let |children| be an empty
2091
+ [=/list=] and, for each node |child| in the [=children=] of
2092
+ |value|:
2093
+
2094
+ 1. Let |child serialization options| be a [=map/clone=] of
2095
+ |serialization options|.
2096
+
2097
+ 1. If |child serialization options|["<code>maxDomDepth</code>"] is
2098
+ not null, set |child serialization
2099
+ options|["<code>maxDomDepth</code>"] to |child serialization
2100
+ options|["<code>maxDomDepth</code>"] - 1.
2082
2101
2083
2102
1. Let |serialized| be the result of [=serialize as a remote value=]
2084
- with |child|, |child depth |, |ownership type|,
2103
+ with |child|, |child serialization options |, |ownership type|,
2085
2104
|serialization internal map|, |realm|, and |session|.
2086
2105
2087
2106
1. Append |serialized| to |children|.
@@ -2107,16 +2126,16 @@ an |ownership type|, a |serialization internal map|, a |realm| and a |session|:
2107
2126
1. If |shadow root| is null, let |serialized shadow| be null.
2108
2127
Otherwise run the following substeps:
2109
2128
2110
- 1. Let |child depth| be |max depth| - 1 if |max depth| is not
2111
- null, or null otherwise.
2112
-
2113
2129
1. Let |serialized shadow| be the result of
2114
- [=serialize as a remote value=] with |shadow root|, |child depth|,
2115
- false , |ownership type|, |serialization internal map|,
2130
+ [=serialize as a remote value=] with |shadow root|,
2131
+ |serialization options| , |ownership type|, |serialization internal map|,
2116
2132
|realm|, and |session|.
2117
2133
2118
2134
1. Set |serialized|["<code>shadowRoot</code>"] to |serialized shadow|.
2119
2135
2136
+ 1. If |value| implements {{ShadowRoot}} , set |serialized|["<code>mode</code>"]
2137
+ to |value|'s <a spec=dom for=ShadowRoot>mode</a> .
2138
+
2120
2139
1. If |serialized| is not null, set field <code> value</code> of |remote value| to
2121
2140
|serialized|.
2122
2141
@@ -2148,11 +2167,12 @@ an |ownership type|, a |serialization internal map|, a |realm| and a |session|:
2148
2167
2149
2168
1. Let |serialized| be null.
2150
2169
2151
- 1. If |known object| is <code> false</code> , and |max depth| is not 0, run
2152
- the following steps:
2170
+ 1. If |known object| is <code> false</code> , and |serialization
2171
+ options|["<code>maxObjectDepth</code>"] is not 0, run the following
2172
+ steps:
2153
2173
2154
2174
1. Let |serialized| be the result of [=serialize as a mapping=] with
2155
- [=EnumerableOwnPropertyNames=] (|value|, key+value), |max depth |,
2175
+ [=EnumerableOwnPropertyNames=] (|value|, key+value), |serialization options |,
2156
2176
|ownership type|, |serialization internal map|,
2157
2177
|realm|, and |session|.
2158
2178
@@ -2179,7 +2199,8 @@ remove optional flag from the field.
2179
2199
2180
2200
<div algorithm>
2181
2201
To <dfn>serialize an Array-like</dfn> given |production|, |handle id|, |known object|,
2182
- |value|, |max depth|, |ownership type|, |serialization internal map|, |realm|, and |session|:
2202
+ |value|, |serialization options|, |ownership type|, |serialization internal map|, |realm|,
2203
+ and |session|:
2183
2204
2184
2205
1. Let |remote value| be a [=/map=] matching |production|, with the
2185
2206
<code> handle</code> property set to |handle id| if it's not null, or omitted
@@ -2188,10 +2209,11 @@ To <dfn>serialize an Array-like</dfn> given |production|, |handle id|, |known ob
2188
2209
1. [=Set internal ids if needed=] with |serialization internal map|,
2189
2210
|remote value| and |value|.
2190
2211
2191
- 1. If |known object| is <code> false</code> , and |max depth| is not 0:
2212
+ 1. If |known object| is <code> false</code> , and |serialization
2213
+ options|["<code>maxObjectDepth</code>"] | is not 0:
2192
2214
2193
2215
1. Let |serialized| be the result of [=serialize as a list=] with
2194
- [=CreateArrayIterator=] (|value|, value), |max depth |, |ownership type|,
2216
+ [=CreateArrayIterator=] (|value|, value), |serialization options |, |ownership type|,
2195
2217
|serialization internal map|, |realm|, and |session|.
2196
2218
2197
2219
1. If |serialized| is not null, set field <code> value</code> of |remote value| to
@@ -2202,31 +2224,43 @@ To <dfn>serialize an Array-like</dfn> given |production|, |handle id|, |known ob
2202
2224
</div>
2203
2225
2204
2226
<div algorithm>
2205
- To <dfn>serialize as a list</dfn> given |iterable|, |max depth |, |ownership type|,
2227
+ To <dfn>serialize as a list</dfn> given |iterable|, |serialization options |, |ownership type|,
2206
2228
|serialization internal map|, |realm|, and |session|:
2207
2229
2208
- 1. Let |serialized| be a new list.
2230
+ 1. Assert: |serialization options|["<code>maxObjectDepth</code>"] is greater
2231
+ than 0.
2232
+
2233
+ 1. Let |serialized| be a new list.
2209
2234
2210
- 1. For each |child value| in |iterable|:
2235
+ 1. For each |child value| in |iterable|:
2211
2236
2212
- 1. Let |child depth | be |max depth| - 1 if |max depth| is not null, or null
2213
- otherwise .
2237
+ 1. Let |child serialization options | be a [=map/clone=] of
2238
+ |serialization options| .
2214
2239
2215
- 1. Let |serialized child| be the result of [=serialize as a remote value=]
2216
- with |child value|, |child depth|, |ownership type|,
2217
- |serialization internal map|, |realm|, and |session|.
2240
+ 1. If |child serialization options|["<code>maxObjectDepth</code>"] is
2241
+ not null, set |child serialization
2242
+ options|["<code>maxObjectDepth</code>"] to |child serialization
2243
+ options|["<code>maxObjectDepth</code>"] - 1.
2218
2244
2219
- 1. Append |serialized child| to |serialized|.
2245
+ 1. Let |serialized child| be the result of [=serialize as a remote value=]
2246
+ with |child value|, |child serialization options|, |ownership type|,
2247
+ |serialization internal map|, |realm|, and |session|.
2248
+
2249
+ 1. Append |serialized child| to |serialized|.
2250
+
2251
+ 1. Return |serialized|
2220
2252
2221
- 1. Return |serialized|
2222
2253
</div>
2223
2254
2224
2255
Issue: this assumes for-in works on iterators
2225
2256
2226
2257
<div algorithm>
2227
- To <dfn>serialize as a mapping</dfn> given |iterable|, |max depth |,
2258
+ To <dfn>serialize as a mapping</dfn> given |iterable|, |serialization options |,
2228
2259
|ownership type|, |serialization internal map|, |realm|, and |session|:
2229
2260
2261
+ 1. Assert: |serialization options|["<code>maxObjectDepth</code>"] is greater
2262
+ than 0.
2263
+
2230
2264
1. Let |serialized| be a new list.
2231
2265
2232
2266
1. For |item| in |iterable|:
@@ -2239,16 +2273,21 @@ To <dfn>serialize as a mapping</dfn> given |iterable|, |max depth|,
2239
2273
2240
2274
1. Let |key| be |property|[0] and let |value| be |property|[1]
2241
2275
2242
- 1. Let |child depth| be |max depth| - 1 if |max depth| is not null, or null
2243
- otherwise.
2276
+ 1. Let |child serialization options| be a [=map/clone=] of
2277
+ |serialization options|.
2278
+
2279
+ 1. If |child serialization options|["<code>maxObjectDepth</code>"] is
2280
+ not null, set |child serialization
2281
+ options|["<code>maxObjectDepth</code>"] to |child serialization
2282
+ options|["<code>maxObjectDepth</code>"] - 1.
2244
2283
2245
2284
1. If [=Type=] (|key|) is String, let |serialized key| be |child key|,
2246
2285
otherwise let |serialized key| be the result of [=serialize as a remote value=]
2247
- with |child key|, |child depth |, |ownership type|,
2286
+ with |child key|, |child serialization options |, |ownership type|,
2248
2287
|serialization internal map|, |realm|, and |session|.
2249
2288
2250
2289
1. Let |serialized value| be the result of [=serialize as a remote value=]
2251
- with |value|, |child depth |, |ownership type|,
2290
+ with |value|, |child serialization options |, |ownership type|,
2252
2291
|serialization internal map|, |realm|, and |session|.
2253
2292
2254
2293
1. Let |serialized child| be («|serialized key|, |serialized value|»).
@@ -4237,8 +4276,12 @@ To <dfn>get exception details</dfn> given a |realm|, a [=completion record=]
4237
4276
TODO: Tighten up the requirements here; people will probably try to parse
4238
4277
this data with regex or something equally bad.
4239
4278
4279
+ 1. Let |serialization options| be a [=/map=] matching the
4280
+ <code> script.SerializationOptions</code> production with the fields set to
4281
+ their default values.
4282
+
4240
4283
1. Let |exception| be the result of [=serialize as a remote value=] with
4241
- |record|.\[[Value]] , <code> 1 </code> as max depth , |ownership type|,
4284
+ |record|.\[[Value]] , |serialization options| , |ownership type|,
4242
4285
a new [=/map=] as serialization internal map, |realm| and |session|.
4243
4286
4244
4287
1. Let |stack trace| be the [=stack trace for an exception=] given |record|.
@@ -4636,6 +4679,21 @@ script.ResultOwnership = "root" / "none"
4636
4679
The <code> script.ResultOwnership</code> specifies how the serialized value
4637
4680
ownership will be treated.
4638
4681
4682
+ #### The script.SerializationOptions type #### {#type-script-SerializationOptions}
4683
+
4684
+ [=Remote end definition=]
4685
+
4686
+ <pre class="cddl remote-cddl">
4687
+ script.SerializationOptions = {
4688
+ ?maxDomDepth: (js-uint / null) .default 0,
4689
+ ?maxObjectDepth: (js-uint / null) .default null,
4690
+ ?includeShadowTree: ("none" / "open" / "all") .default "none",
4691
+ }
4692
+ </pre>
4693
+
4694
+ The <code> script.SerializationOptions</code> allows specifying how ECMAScript
4695
+ objects will be serialized.
4696
+
4639
4697
#### The script.Source type #### {#type-script-Source}
4640
4698
4641
4699
[=Local end definition=]
@@ -4860,12 +4918,13 @@ Note: In case of an arrow function in <code>functionDeclaration</code>, the
4860
4918
}
4861
4919
4862
4920
script.CallFunctionParameters = {
4863
- functionDeclaration: text;
4864
- awaitPromise: bool;
4865
- target: script.Target;
4866
- ?arguments: [*script.ArgumentValue] ;
4867
- ?this: script.ArgumentValue;
4868
- ?resultOwnership: script.ResultOwnership;
4921
+ functionDeclaration: text,
4922
+ awaitPromise: bool,
4923
+ target: script.Target,
4924
+ ?arguments: [*script.ArgumentValue] ,
4925
+ ?resultOwnership: script.ResultOwnership,
4926
+ ?serializationOptions: script.SerializationOptions
4927
+ ?this: script.ArgumentValue,
4869
4928
}
4870
4929
4871
4930
script.ArgumentValue = (
@@ -4958,6 +5017,11 @@ The [=remote end steps=] with |session| and |command parameters| are:
4958
5017
1. Let |await promise| be the value of the <code> awaitPromise</code> field of
4959
5018
|command parameters|.
4960
5019
5020
+ 1. Let |serialization options| be the value of the
5021
+ <code> serializationOptions</code> field of |command parameters|, if present,
5022
+ or otherwise a [=/map=] matching the <code> script.SerializationOptions</code>
5023
+ production with the fields set to their default values.
5024
+
4961
5025
1. Let |result ownership| be the value of the <code> resultOwnership</code> field of
4962
5026
|command parameters|, if present, or <code> none</code> otherwise.
4963
5027
@@ -5004,7 +5068,7 @@ The [=remote end steps=] with |session| and |command parameters| are:
5004
5068
1. Assert: |evaluation status|.\[[Type]] is <code> normal</code> .
5005
5069
5006
5070
1. Let |result| be the result of [=serialize as a remote value=] with
5007
- |evaluation status|.\[[Value]] , <code> 1 </code> as |max depth |, |result ownership|,
5071
+ |evaluation status|.\[[Value]] , |serialization options |, |result ownership|,
5008
5072
a new [=/map=] as serialization internal map, |realm| and |session|.
5009
5073
5010
5074
1. Return a new [=/map=] matching the <code> script.EvaluateResultSuccess</code>
@@ -5034,10 +5098,11 @@ the promise is returned.
5034
5098
}
5035
5099
5036
5100
script.EvaluateParameters = {
5037
- expression: text;
5038
- target: script.Target;
5039
- awaitPromise: bool;
5040
- ?resultOwnership: script.ResultOwnership;
5101
+ expression: text,
5102
+ target: script.Target,
5103
+ awaitPromise: bool,
5104
+ ?resultOwnership: script.ResultOwnership,
5105
+ ?serializationOptions: script.SerializationOptions,
5041
5106
}
5042
5107
</pre>
5043
5108
</dd>
@@ -5069,6 +5134,11 @@ The [=remote end steps=] with |session| and |command parameters| are:
5069
5134
1. Let |await promise| be the value of the <code> awaitPromise</code> field of
5070
5135
|command parameters|.
5071
5136
5137
+ 1. Let |serialization options| be the value of the
5138
+ <code> serializationOptions</code> field of |command parameters|, if present,
5139
+ or otherwise a [=/map=] matching the <code> script.SerializationOptions</code>
5140
+ production with the fields set to their default values.
5141
+
5072
5142
1. Let |result ownership| be the value of the <code> resultOwnership</code> field of
5073
5143
|command parameters|, if present, or <code> none</code> otherwise.
5074
5144
@@ -5102,7 +5172,7 @@ The [=remote end steps=] with |session| and |command parameters| are:
5102
5172
1. Assert: |evaluation status|.\[[Type]] is <code> normal</code> .
5103
5173
5104
5174
1. Let |result| be the result of [=serialize as a remote value=] with
5105
- |evaluation status|.\[[Value]] , <code> 1 </code> as |max depth |, |result ownership|,
5175
+ |evaluation status|.\[[Value]] , |serialization options |, |result ownership|,
5106
5176
a new [=/map=] as serialization internal map, |realm| and |session|.
5107
5177
5108
5178
1. Return a new [=/map=] matching the <code> script.EvaluateResultSuccess</code>
@@ -5575,10 +5645,14 @@ Define the following [=console steps=] with |method|, |args|, and
5575
5645
5576
5646
1. Let |serialized args| be a new list.
5577
5647
5648
+ 1. Let |serialization options| be a [=/map=] matching the
5649
+ <code> script.SerializationOptions</code> production with the fields set to
5650
+ their default values.
5651
+
5578
5652
1. For each |arg| of |args|:
5579
5653
5580
5654
1. Let |serialized arg| be the result of [=serialize as a remote value=] with
5581
- |arg| as value, <code> 1 </code> as max depth , <code> none</code> as
5655
+ |arg| as value, |serialization options| , <code> none</code> as
5582
5656
ownership type, a new [=/map=] as serialization internal map, |realm| and
5583
5657
|session|.
5584
5658
0 commit comments