Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / 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 logToConsole()
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
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
53     // DOMTokenList
54     var div = document.getElementsByTagName("div")[0];
55     console.log(div.classList);
56
57     // Array-like's.
58     console.log(new ArrayLike(5));
59     console.log(new ArrayLike(0xFFFFFFFF));
60     // Array-like's with wrong length.
61     console.log(new ArrayLike(-5));
62     console.log(new ArrayLike(5.6));
63     console.log(new ArrayLike(NaN));
64     console.log(new ArrayLike(Infinity));
65     console.log(new ArrayLike(-0));
66     console.log(new ArrayLike(0xFFFFFFFF + 1));
67 }
68
69 function onload()
70 {
71     logToConsole();
72     runTest();
73 }
74
75 function NonArrayWithLength()
76 {
77     this.keys = [];
78 }
79
80 NonArrayWithLength.prototype.__defineGetter__("length", function()
81 {
82     console.log("FAIL: 'length' should not be called");
83     return this.keys.length;
84 });
85
86 function ArrayLike(length)
87 {
88     this.length = length;
89 }
90 ArrayLike.prototype.splice = function() {};
91
92 function test()
93 {
94     InspectorTest.evaluateInPage("logToConsole()", callback);
95
96     function callback()
97     {
98         InspectorTest.dumpConsoleMessages();
99         InspectorTest.completeTest();
100     }
101 }
102 </script>
103 </head>
104
105 <body onload="onload()">
106 <p>
107 Tests that console nicely formats HTML Collections, NodeLists and DOMTokenLists.
108 </p>
109 <div style="display:none" class="c1 c2 c3">
110     <form id="f">
111         <select id="sel" name="sel">
112             <option value="1">one</option>
113             <option value="2">two</option>
114         </select>
115         <input type="radio" name="x" value="x1" /> x1
116         <input type="radio" name="x" value="x2" /> x2
117     </form>
118 </div>
119
120 </body>
121 </html>