Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / console / console-format-collections.html
blob07696e8d01ce101edc7bcc68de500b7146d6a1ac
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>
7 function logToConsole()
9 var formElement = document.getElementById("f");
10 var selectElement = document.getElementById("sel");
11 var spanElement = document.getElementById("span");
13 // NodeList
14 var nodelist = document.getElementsByTagName("select");
15 console.log(nodelist);
17 // HTMLCollection
18 var htmlcollection = document.head.children;
19 console.log(htmlcollection);
21 // HTMLOptionsCollection
22 var options = selectElement.options;
23 console.log(options);
25 // HTMLAllCollection
26 var all = document.all;
27 console.log(all);
29 // HTMLFormControlsCollection (currently shows HTMLCollection)
30 var formControls = formElement.elements;
31 console.log(formControls);
33 // RadioNodeList
34 var radioNodeList = formElement.x;
35 console.log(radioNodeList);
37 // Cross-referencing arrays.
38 var arrayX = [1];
39 var arrayY = [2, arrayX];
40 arrayX.push(arrayY);
41 console.log(arrayX);
43 var nonArray = new NonArrayWithLength();
44 console.log(nonArray);
46 // Arguments
47 function generateArguments(foo, bar)
49 return arguments;
51 console.log(generateArguments(1, "2"));
53 // DOMTokenList
54 var div = document.getElementsByTagName("div")[0];
55 console.log(div.classList);
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));
69 function onload()
71 logToConsole();
72 runTest();
75 function NonArrayWithLength()
77 this.keys = [];
80 NonArrayWithLength.prototype.__defineGetter__("length", function()
82 console.log("FAIL: 'length' should not be called");
83 return this.keys.length;
84 });
86 function ArrayLike(length)
88 this.length = length;
90 ArrayLike.prototype.splice = function() {};
92 function test()
94 InspectorTest.evaluateInPage("logToConsole()", callback);
96 function callback()
98 InspectorTest.dumpConsoleMessages();
99 InspectorTest.completeTest();
102 </script>
103 </head>
105 <body onload="onload()">
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>
120 </body>
121 </html>