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