blob: 824b04fbb1c5276538988817bedbd7c80c3c75d2 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<link rel="help" href="http://dev.w3.org/csswg/cssom-view/#dom-clientrectlist-item">
<script src="../../../resources/js-test.js"></script>
<style>
#testArea {
width: 300px;
}
#inner {
width: 200px;
height: 200px;
}
.testBox {
background-color: green;
}
</style>
</head>
<body>
<div id="testArea">
<p>14. Block in inline</p> <span id="testElement" class="testBox">Lorem<div id="inner"></div>ipsum</span>
</div>
<script>
description("Tests that the ClientRectList.item() argument is correctly validated.");
var clientRects = document.getElementById("testElement").getClientRects();
shouldBe("clientRects.length", "3");
shouldNotBe("clientRects.item(0)", "null");
shouldNotBe("clientRects.item(1)", "null");
shouldNotBe("clientRects.item(2)", "null");
shouldThrow("clientRects.item()", '"TypeError: Failed to execute \'item\' on \'DOMRectList\': 1 argument required, but only 0 present."');
shouldBe("clientRects.item(-4294967294)", "clientRects.item(2)"); // -4294967294 wraps to 2.
// According to the specification, we should throw an IndexSizeError exception when index is
// greater than the number of ClientRect objects associated with the object.
// However, we currently just return null like Firefox 22.
shouldBeNull("clientRects.item(3)");
shouldBeNull("clientRects.item(999)");
shouldBeNull("clientRects.item(-1)");
</script>
</body>
</html>