3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../http/tests/inspector/console-test.js"></script>
7 var arrayLikeWithAccessors = {
10 get 0() { foo.bar = 1; },
11 get 1() { throw new Error("arrayLikeWithAccessors"); },
14 get 5() { return {afoo: 3, abar: 4}; },
16 get 7() { return [3, 4]; },
18 get 9() { return NaN; }
21 var objectWithAccessors = {
22 get 0() { baz.baz = 3; },
23 get 1() { throw new Error("objectWithAccessors"); },
26 get 5() { return {afoo: 3, abar: 4}; },
28 get 7() { return [3, 4]; },
29 8: function func8() {},
30 get 9() { return -Infinity; }
33 var tableObject = [arrayLikeWithAccessors, objectWithAccessors];
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);
45 function onMessagesLogged()
47 InspectorTest.waitForRemoteObjectsConsoleMessages(onRemoteObjectsRendered);
50 function onRemoteObjectsRendered()
52 InspectorTest.expandConsoleMessages(onMessagesExpanded);
55 function onMessagesExpanded()
57 InspectorTest.addResult("Before expanding accessors:");
58 InspectorTest.dumpConsoleMessages(false, false);
60 var messages = WebInspector.ConsolePanel._view()._visibleViewMessages;
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]);
68 InspectorTest.addResult("\nAccessor property buttons count: " + buttons.length);
69 for (var i = 0; i < buttons.length; ++i)
71 InspectorTest.runAfterPendingDispatches(step2);
76 InspectorTest.addResult("\nAfter expanding accessors:");
77 InspectorTest.dumpConsoleMessages(false, false);
78 InspectorTest.completeTest();
84 <body onload="runTest()">
86 Tests that console produces instant previews for arrays and objects that have getters and setters.