(dv, result, seen = new WeakSet())
| 44 | // Build a nested tree of all private fields wherever they reside. Each level has KV tuples and their descendents: |
| 45 | // {cur: [[key1, value1], ...], children: {key1: {...next level}}} |
| 46 | function getProperties(dv, result, seen = new WeakSet()) { |
| 47 | if (!dv || seen.has(dv)) |
| 48 | return; |
| 49 | |
| 50 | if (typeof dv === 'object') |
| 51 | seen.add(dv); |
| 52 | |
| 53 | const privateKVs = dv.getOwnPrivateProperties?.().map(k => [k.description, dv.getProperty(k).return]) ?? []; |
| 54 | const nonPrivateKVs = dv.getOwnPropertyNames?.().concat(dv.getOwnPropertySymbols()).map(k => [k, dv.getProperty(k).return]) ?? []; |
| 55 | result.cur = privateKVs; |
| 56 | |
| 57 | result.children = {}; |
| 58 | // a private field can be under a non-private field |
| 59 | privateKVs.concat(nonPrivateKVs).forEach(([k, v]) => { |
| 60 | result.children[k] = {}; |
| 61 | getProperties(v, result.children[k], seen); |
| 62 | }); |
| 63 | // prettyPrint in the debuggee compartment needs access to the original private field value and not Debugger.Object |
| 64 | result.cur.forEach(kv => kv[1]?.unsafeDereference && (kv[1] = kv[1].unsafeDereference())); |
| 65 | } |
| 66 | |
| 67 | function debuggeeValueToString(dv, style = {pretty: options.pretty}) { |
| 68 | // Special sentinel values returned by Debugger.Environment.getVariable() |
no test coverage detected