Web Inspector: 'use strict' exceptions stop in inspector code
[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     // Arguments
47     function generateArguments(foo, bar)
48     {
49         return arguments;
50     }
51     console.log(generateArguments(1, "2"));
52     runTest();
53 }
54
55 function NonArrayWithLength()
56 {
57     this.keys=[];
58 }
59
60 NonArrayWithLength.prototype.__defineGetter__("length", function()
61 {
62     console.log(".length should not be called");
63     return this.keys.length;
64 });
65
66 function test()
67 {
68     InspectorTest.dumpConsoleMessages();
69     InspectorTest.completeTest();
70 }
71 </script>
72 </head>
73
74 <body onload="onload()">
75 <p>
76 Tests that console nicely formats HTML Collections and NodeLists.
77 </p>
78 <div style="display:none">
79     <form id="f">
80         <select id="sel" name="sel">
81             <option value="1">one</option>
82             <option value="2">two</option>
83         </select>
84         <input type="radio" name="x" value="x1" /> x1
85         <input type="radio" name="x" value="x2" /> x2
86     </form>
87 </div>
88
89 </body>
90 </html>