Skip to content

Commit d87a810

Browse files
joyeecheungrichardlau
authored andcommitted
deps: V8: cherry-pick 3dd9576ce336
Original commit message: [inspector] Support Symbols in EntryPreview The Symbols-as-WeakMap-keys proposal allows non-Symbol.for Symbol values in weak collections, which means it can show in EntryPreviews. Also apparently Symbols in regular Maps and Sets were also unsupported. Bug: v8:13350, v8:12947 Change-Id: Ib10476fa2f3c7f59af67933f0bf61640be1bbd97 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3930037 Reviewed-by: Benedikt Meurer <[email protected]> Reviewed-by: Simon Zünd <[email protected]> Commit-Queue: Shu-yu Guo <[email protected]> Cr-Commit-Position: refs/heads/main@{#83518} Refs: v8/v8@3dd9576 PR-URL: #51004 Reviewed-By: Chengzhong Wu <[email protected]>
1 parent 6d50966 commit d87a810

File tree

4 files changed

+105
-2
lines changed

4 files changed

+105
-2
lines changed

common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# Reset this number to 0 on major V8 upgrades.
3838
# Increment by one for each non-official patch applied to deps/v8.
39-
'v8_embedder_string': '-node.32',
39+
'v8_embedder_string': '-node.33',
4040

4141
##### V8 defaults for Node.js #####
4242

deps/v8/src/inspector/value-mirror.cc

+12
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,18 @@ class SymbolMirror final : public ValueMirror {
656656
.build();
657657
}
658658

659+
void buildEntryPreview(
660+
v8::Local<v8::Context> context, int* nameLimit, int* indexLimit,
661+
std::unique_ptr<ObjectPreview>* preview) const override {
662+
*preview =
663+
ObjectPreview::create()
664+
.setType(RemoteObject::TypeEnum::Symbol)
665+
.setDescription(descriptionForSymbol(context, m_symbol))
666+
.setOverflow(false)
667+
.setProperties(std::make_unique<protocol::Array<PropertyPreview>>())
668+
.build();
669+
}
670+
659671
v8::Local<v8::Value> v8Value() const override { return m_symbol; }
660672

661673
protocol::Response buildWebDriverValue(

deps/v8/test/inspector/debugger/object-preview-internal-properties-expected.txt

+82
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,88 @@ expression: new WeakSet([{}])
159159
]
160160

161161

162+
Running test: symbolsAsKeysInEntries
163+
expression: new Map([[Symbol('key1'), 1]])
164+
{
165+
name : size
166+
type : number
167+
value : 1
168+
}
169+
[[Entries]]:
170+
[
171+
[0] : {
172+
key : {
173+
description : Symbol(key1)
174+
overflow : false
175+
properties : [
176+
]
177+
type : symbol
178+
}
179+
value : {
180+
description : 1
181+
overflow : false
182+
properties : [
183+
]
184+
type : number
185+
}
186+
}
187+
]
188+
189+
expression: new Set([Symbol('key2')])
190+
{
191+
name : size
192+
type : number
193+
value : 1
194+
}
195+
[[Entries]]:
196+
[
197+
[0] : {
198+
value : {
199+
description : Symbol(key2)
200+
overflow : false
201+
properties : [
202+
]
203+
type : symbol
204+
}
205+
}
206+
]
207+
208+
expression: new WeakMap([[Symbol('key3'), 2]])
209+
[[Entries]]:
210+
[
211+
[0] : {
212+
key : {
213+
description : Symbol(key3)
214+
overflow : false
215+
properties : [
216+
]
217+
type : symbol
218+
}
219+
value : {
220+
description : 2
221+
overflow : false
222+
properties : [
223+
]
224+
type : number
225+
}
226+
}
227+
]
228+
229+
expression: new WeakSet([Symbol('key4')])
230+
[[Entries]]:
231+
[
232+
[0] : {
233+
value : {
234+
description : Symbol(key4)
235+
overflow : false
236+
properties : [
237+
]
238+
type : symbol
239+
}
240+
}
241+
]
242+
243+
162244
Running test: iteratorObject
163245
expression: (new Map([[1,2]])).entries()
164246
[[Entries]]:

deps/v8/test/inspector/debugger/object-preview-internal-properties.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44
//
5-
// Flags: --harmony-class-fields
5+
// Flags: --harmony-symbol-as-weakmap-key
66

77
let {session, contextGroup, Protocol} = InspectorTest.start("Check internal properties reported in object preview.");
88

@@ -45,6 +45,15 @@ InspectorTest.runTestSuite([
4545
.then(next);
4646
},
4747

48+
function symbolsAsKeysInEntries(next)
49+
{
50+
checkExpression("new Map([[Symbol('key1'), 1]])")
51+
.then(() => checkExpression("new Set([Symbol('key2')])"))
52+
.then(() => checkExpression("new WeakMap([[Symbol('key3'), 2]])"))
53+
.then(() => checkExpression("new WeakSet([Symbol('key4')])"))
54+
.then(next);
55+
},
56+
4857
function iteratorObject(next)
4958
{
5059
checkExpression("(new Map([[1,2]])).entries()")

0 commit comments

Comments
 (0)