| <html> |
| <head> |
| <script src="../../http/tests/inspector/inspector-test.js"></script> |
| <script src="../../http/tests/inspector/console-test.js"></script> |
| <script> |
| |
| function logToConsole() |
| { |
| var formElement = document.getElementById("f"); |
| var selectElement = document.getElementById("sel"); |
| var spanElement = document.getElementById("span"); |
| |
| // NodeList |
| var nodelist = document.getElementsByTagName("select"); |
| console.log(nodelist); |
| |
| // HTMLCollection |
| var htmlcollection = document.head.children; |
| console.log(htmlcollection); |
| |
| // HTMLOptionsCollection |
| var options = selectElement.options; |
| console.log(options); |
| |
| // HTMLAllCollection |
| var all = document.all; |
| console.log(all); |
| |
| // HTMLFormControlsCollection (currently shows HTMLCollection) |
| var formControls = formElement.elements; |
| console.log(formControls); |
| |
| // RadioNodeList (currently shows NodeList) |
| var radioNodeList = formElement.x; |
| console.log(radioNodeList); |
| |
| // Cross-referencing arrays. |
| var arrayX = [1]; |
| var arrayY = [2, arrayX]; |
| arrayX.push(arrayY); |
| console.log(arrayX); |
| |
| var nonArray = new NonArrayWithLength(); |
| console.log(nonArray); |
| |
| // Arguments |
| function generateArguments(foo, bar) |
| { |
| return arguments; |
| } |
| console.log(generateArguments(1, "2")); |
| } |
| |
| function onload() |
| { |
| logToConsole(); |
| runTest(); |
| } |
| |
| function NonArrayWithLength() |
| { |
| this.keys=[]; |
| } |
| |
| NonArrayWithLength.prototype.__defineGetter__("length", function() |
| { |
| console.log(".length should not be called"); |
| return this.keys.length; |
| }); |
| |
| function test() |
| { |
| InspectorTest.evaluateInPage("logToConsole()", callback); |
| |
| function callback() |
| { |
| InspectorTest.dumpConsoleMessages(); |
| InspectorTest.completeTest(); |
| } |
| } |
| </script> |
| </head> |
| |
| <body onload="onload()"> |
| <p> |
| Tests that console nicely formats HTML Collections and NodeLists. |
| </p> |
| <div style="display:none"> |
| <form id="f"> |
| <select id="sel" name="sel"> |
| <option value="1">one</option> |
| <option value="2">two</option> |
| </select> |
| <input type="radio" name="x" value="x1" /> x1 |
| <input type="radio" name="x" value="x2" /> x2 |
| </form> |
| </div> |
| |
| </body> |
| </html> |