Web Inspector: ES6: Show Symbol properties on Objects
[WebKit-https.git] / LayoutTests / inspector / model / remote-object-get-properties.html
1 <!doctype html>
2 <html>
3 <head>
4 <script type="text/javascript" src="../../http/tests/inspector/inspector-test.js"></script>
5 <script>
6 // ------------------------------
7 //   Setup Test Prototype Chain
8 // ------------------------------
9
10 function SuperBar() { this._bar = 10; }
11 SuperBar.prototype = {
12     __proto__: Object.prototype,
13     constructor: SuperBar,
14     BAR_CONSTANT: 99,
15     get getterProperty() { return 20; },
16     get bar() { return this._bar; },
17     set setterOnly(x) {},
18 };
19
20 function SuperFoo() { SuperBar.call(this); this._foo = 5; }
21 SuperFoo.prototype = {
22     __proto__: SuperBar.prototype,
23     constructor: SuperFoo,
24     get getterProperty() { return 10; },
25     get foo() { return this._foo; }
26 };
27
28 function ClassWithBadGetter() {}
29 ClassWithBadGetter.prototype = {
30     __proto__: Object.prototype,
31     constructor: ClassWithBadGetter,
32     get badGetter() { throw "throw in getter"; }
33 };
34
35
36 // --------------------
37 //   Objects to Debug
38 // --------------------
39
40 // window.loadEvent is set inside of <body onload="..."> below.
41 var simpleObject = {a:1, b:"string"};
42 var complexObject = new SuperFoo;
43 var badGetterObject = new ClassWithBadGetter;
44 var unboundFunction = function() { console.log(arguments); }
45 var boundFunction = unboundFunction.bind(document.body, 1, 2, 3);
46 var objectWithSymbolProperties = {prop:1, [Symbol()]:2, [Symbol('sym')]:3, [Symbol('sym')]:4, [Symbol()]: Symbol(), prop2: 5};
47
48
49 // --------
50 //   test
51 // --------
52
53 function test()
54 {
55     var currentStepIndex = 0;
56     var steps = [
57         {expression: "window.simpleObject"},
58         {expression: "window.loadEvent"},
59         {expression: "window.complexObject"},
60         {expression: "window.badGetterObject"},
61         {expression: "window.unboundFunction"},
62         {expression: "window.boundFunction"},
63         {expression: "window.objectWithSymbolProperties"},
64     ]
65
66     function runNextStep() {
67         if (currentStepIndex >= steps.length) {
68             InspectorTest.log("DONE");
69             InspectorTest.completeTest();
70             return;
71         }
72
73         var step = steps[currentStepIndex++];
74         InspectorTest.log("");
75         InspectorTest.log("-----------------------------------------------------");
76         InspectorTest.log("EXPRESSION: " + step.expression);
77
78         WebInspector.runtimeManager.evaluateInInspectedWindow(step.expression, "test", false, true, false, false, false, function(remoteObject, wasThrown) {
79             InspectorTest.assert(remoteObject instanceof WebInspector.RemoteObject);
80             InspectorTest.log("type: " + remoteObject.type);
81             if (remoteObject.subtype)
82                 InspectorTest.log("subtype: " + remoteObject.subtype);
83             InspectorTest.log("description: " + remoteObject.description);
84             remoteObject.getOwnPropertyDescriptors(function(properties) {
85                 InspectorTest.log("\nOWN PROPERTIES:");
86                 for (var property of properties) {
87                     InspectorTest.assert(property instanceof WebInspector.PropertyDescriptor);
88                     InspectorTest.log("    " + property.name);
89                 }
90             });
91
92             remoteObject.getDisplayablePropertyDescriptors(function(properties) {
93                 InspectorTest.log("\nDISPLAYABLE PROPERTIES:");
94                 for (var property of properties) {
95                     InspectorTest.assert(property instanceof WebInspector.PropertyDescriptor);
96                     InspectorTest.log("    " + property.name);
97                 }
98             });
99
100             remoteObject.getAllPropertyDescriptors(function(properties) {
101                 InspectorTest.log("\nALL PROPERTIES:");
102                 for (var property of properties) {
103                     InspectorTest.assert(property instanceof WebInspector.PropertyDescriptor);
104                     InspectorTest.log("    " + property.name);
105                 }
106
107                 InspectorTest.log("-----------------------------------------------------");
108                 runNextStep();
109             });
110         });
111     }
112
113     runNextStep();
114 }
115 </script>
116 </head>
117 <body onload="window.loadEvent = event; runTest()">
118 </body>
119 </html>