summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Object-getOwnPrivateProperties.js
blob: 5be0d23fc733aaf700218c0beac54aa60954832d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// private fields

var g = newGlobal({ newCompartment: true });
var dbg = Debugger();
var gobj = dbg.addDebuggee(g);

g.eval(`
class MyClass {
    constructor() {
        this.publicProperty = 1;
        this.publicSymbol = Symbol("public");
        this[this.publicSymbol] = 2;
        this.#privateProperty1 = 3;
        this.#privateProperty2 = 4;
    }
    static #privateStatic1
    static #privateStatic2
    #privateProperty1
    #privateProperty2
    #privateMethod() {}
    publicMethod(){}
}
obj = new MyClass();
klass = MyClass`);

var privatePropertiesSymbolsDescriptions = gobj
  .getOwnPropertyDescriptor("obj")
  .value.getOwnPrivateProperties()
  .map(sym => sym.description);

assertEq(
  JSON.stringify(privatePropertiesSymbolsDescriptions),
  JSON.stringify([`#privateProperty1`, `#privateProperty2`])
);

var classPrivatePropertiesSymbolsDescriptions = gobj
  .getOwnPropertyDescriptor("klass")
  .value.getOwnPrivateProperties()
  .map(sym => sym.description);

assertEq(
  JSON.stringify(classPrivatePropertiesSymbolsDescriptions),
  JSON.stringify([`#privateStatic1`, `#privateStatic2`])
);