blob: 07696e8d01ce101edc7bcc68de500b7146d6a1ac [file] [log] [blame]
<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
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"));
// DOMTokenList
var div = document.getElementsByTagName("div")[0];
console.log(div.classList);
// Array-like's.
console.log(new ArrayLike(5));
console.log(new ArrayLike(0xFFFFFFFF));
// Array-like's with wrong length.
console.log(new ArrayLike(-5));
console.log(new ArrayLike(5.6));
console.log(new ArrayLike(NaN));
console.log(new ArrayLike(Infinity));
console.log(new ArrayLike(-0));
console.log(new ArrayLike(0xFFFFFFFF + 1));
}
function onload()
{
logToConsole();
runTest();
}
function NonArrayWithLength()
{
this.keys = [];
}
NonArrayWithLength.prototype.__defineGetter__("length", function()
{
console.log("FAIL: 'length' should not be called");
return this.keys.length;
});
function ArrayLike(length)
{
this.length = length;
}
ArrayLike.prototype.splice = function() {};
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, NodeLists and DOMTokenLists.
</p>
<div style="display:none" class="c1 c2 c3">
<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>