Web Inspector: Expanding event objects in console shows undefined for most values...
[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
45
46 // --------
47 //   test
48 // --------
49
50 function test()
51 {
52     var currentStepIndex = 0;
53     var steps = [
54         {expression: "window.simpleObject"},
55         {expression: "window.loadEvent"},
56         {expression: "window.complexObject"},
57         {expression: "window.badGetterObject"},
58     ]
59
60     function runNextStep() {
61         if (currentStepIndex >= steps.length) {
62             InspectorTest.log("DONE");
63             InspectorTest.completeTest();
64             return;
65         }
66
67         var step = steps[currentStepIndex++];
68         InspectorTest.log("");
69         InspectorTest.log("-----------------------------------------------------");
70         InspectorTest.log("EXPRESSION: " + step.expression);
71
72         WebInspector.runtimeManager.evaluateInInspectedWindow(step.expression, "test", false, true, false, function(remoteObject, wasThrown) {
73             InspectorTest.assert(remoteObject instanceof WebInspector.RemoteObject);
74             InspectorTest.log("objectId: " + remoteObject.objectId);
75             InspectorTest.log("type: " + remoteObject.type);
76             if (remoteObject.subtype)
77                 InspectorTest.log("subtype: " + remoteObject.subtype);
78             InspectorTest.log("description: " + remoteObject.description);
79             remoteObject.getOwnProperties(function(properties) {
80                 InspectorTest.log("\nOWN PROPERTIES:");
81                 for (var property of properties) {
82                     InspectorTest.assert(property instanceof WebInspector.RemoteObjectProperty);
83                     InspectorTest.log("    " + property.name);
84                 }
85             });
86
87             remoteObject.getOwnAndGetterProperties(function(properties) {
88                 InspectorTest.log("\nOWN AND GETTER PROPERTIES:");
89                 for (var property of properties) {
90                     InspectorTest.assert(property instanceof WebInspector.RemoteObjectProperty);
91                     InspectorTest.log("    " + property.name);
92                 }
93             });
94
95             remoteObject.getAllProperties(function(properties) {
96                 InspectorTest.log("\nALL PROPERTIES:");
97                 for (var property of properties) {
98                     InspectorTest.assert(property instanceof WebInspector.RemoteObjectProperty);
99                     InspectorTest.log("    " + property.name);
100                 }
101
102                 InspectorTest.log("-----------------------------------------------------");
103                 runNextStep();
104             });
105         });
106     }
107
108     runNextStep();
109 }
110 </script>
111 </head>
112 <body onload="window.loadEvent = event; runTest()">
113 </body>
114 </html>