88a09cf231909c79fc14088673ae23c3a0c37638
[WebKit-https.git] / LayoutTests / inspector / console / console-format-collections.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 function onload()
8 {
9     var formElement = document.getElementById("f");
10     var selectElement = document.getElementById("sel");
11     var spanElement = document.getElementById("span");
12
13     // NodeList
14     var nodelist = document.getElementsByTagName("select");
15     console.log(nodelist);
16
17     // HTMLCollection
18     var htmlcollection = document.head.children;
19     console.log(htmlcollection);
20
21     // HTMLOptionsCollection
22     var options = selectElement.options;
23     console.log(options);
24
25     // HTMLAllCollection
26     var all = document.all;
27     console.log(all);
28
29     // HTMLFormControlsCollection (currently shows HTMLCollection)
30     var formControls = formElement.elements;
31     console.log(formControls);
32
33     // RadioNodeList (currently shows NodeList)
34     var radioNodeList = formElement.x;
35     console.log(radioNodeList);
36
37     // Cross-referencing arrays.
38     var arrayX = [1];
39     var arrayY = [2, arrayX];
40     arrayX.push(arrayY);
41     console.log(arrayX);
42
43     var nonArray = new NonArrayWithLength();
44     console.log(nonArray);
45
46     runTest();
47 }
48
49 function NonArrayWithLength()
50 {
51     this.keys=[];
52 }
53
54 NonArrayWithLength.prototype.__defineGetter__("length", function()
55 {
56     console.log(".length should not be called");
57     return this.keys.length;
58 });
59
60 function test()
61 {
62     InspectorTest.dumpConsoleMessages();
63     InspectorTest.completeTest();
64 }
65 </script>
66 </head>
67
68 <body onload="onload()">
69 <p>
70 Tests that console nicely formats HTML Collections and NodeLists.
71 </p>
72 <div style="display:none">
73     <form id="f">
74         <select id="sel" name="sel">
75             <option value="1">one</option>
76             <option value="2">two</option>
77         </select>
78         <input type="radio" name="x" value="x1" /> x1
79         <input type="radio" name="x" value="x2" /> x2
80     </form>
81 </div>
82
83 </body>
84 </html>