84feb53c704b7d49f91a096b61bf7b556508398c
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / console / console-object-preview-accessors.html
1 <html>
2 <head>
3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../http/tests/inspector/console-test.js"></script>
5 <script>
6
7 var arrayLikeWithAccessors = {
8     splice: function() {},
9     length: 10,
10     get 0() { foo.bar = 1; },
11     get 1() { throw new Error("arrayLikeWithAccessors"); },
12     set 3(_) {},
13     4: {foo: 1, bar: 2},
14     get 5() { return {afoo: 3, abar: 4}; },
15     6: [1, 2],
16     get 7() { return [3, 4]; },
17     8: "value8",
18     get 9() { return NaN; }
19 };
20
21 var objectWithAccessors = {
22     get 0() { baz.baz = 3; },
23     get 1() { throw new Error("objectWithAccessors"); },
24     set 3(_) {},
25     4: {foo: 1, bar: 2},
26     get 5() { return {afoo: 3, abar: 4}; },
27     6: [1, 2],
28     get 7() { return [3, 4]; },
29     8: function func8() {},
30     get 9() { return -Infinity; }
31 };
32
33 var tableObject = [arrayLikeWithAccessors, objectWithAccessors];
34
35 function test()
36 {
37     InspectorTest.evaluateInConsole("arrayLikeWithAccessors");
38     InspectorTest.evaluateInConsole("console.log(arrayLikeWithAccessors)");
39     InspectorTest.evaluateInConsole("objectWithAccessors");
40     InspectorTest.evaluateInConsole("console.log(objectWithAccessors)");
41     InspectorTest.evaluateInConsole("console.table(tableObject)");
42     InspectorTest.evaluateInConsole("console.dir(objectWithAccessors)");
43     InspectorTest.runAfterPendingDispatches(onMessagesLogged);
44
45     function onMessagesLogged()
46     {
47         InspectorTest.waitForRemoteObjectsConsoleMessages(onRemoteObjectsRendered);
48     }
49
50     function onRemoteObjectsRendered()
51     {
52         InspectorTest.expandConsoleMessages(onMessagesExpanded);
53     }
54
55     function onMessagesExpanded()
56     {
57         InspectorTest.addResult("Before expanding accessors:");
58         InspectorTest.dumpConsoleMessages(false, false);
59
60         var messages = WebInspector.ConsolePanel._view()._visibleViewMessages;
61         var buttons = [];
62         for (var i = 0; i < messages.length; ++i) {
63             var element = messages[i].toMessageElement();
64             var getters = element.getElementsByClassName("properties-calculate-value-button");
65             for (var j = 0; j < getters.length; ++j)
66                 buttons.push(getters[j]);
67         }
68         InspectorTest.addResult("\nAccessor property buttons count: " + buttons.length);
69         for (var i = 0; i < buttons.length; ++i)
70             buttons[i].click();
71         InspectorTest.runAfterPendingDispatches(step2);
72     }
73
74     function step2()
75     {
76         InspectorTest.addResult("\nAfter expanding accessors:");
77         InspectorTest.dumpConsoleMessages(false, false);
78         InspectorTest.completeTest();
79     }
80 }
81 </script>
82 </head>
83
84 <body onload="runTest()">
85 <p>
86 Tests that console produces instant previews for arrays and objects that have getters and setters.
87 </p>
88
89 </body>
90 </html>