<html>
<head>
<style>
body { margin: 10; padding: 0 }
</style>
</head>
<body contenteditable>
123456
<script type="text/javascript">
	var console_messages = document.createElement("ol");
	
	function log(message)
	{
		var item = document.createElement("li");
		item.appendChild(document.createTextNode(message));
		console_messages.appendChild(item);
	}

    function logRect(comment, start, length)
    {
        log(comment + ": (" + start + "," + length + "), ("
            + textInputController.firstRectForCharacterRange(start, length) + ")");
    }

	if (window.testRunner) {
		try {
			testRunner.dumpAsText();

			window.getSelection().setPosition(document.body, 0);

			logRect("caret at the beginning", 0, 0);
			logRect("caret after the first character", 1, 0);
			logRect("caret at the end of line", 6, 0);
			logRect("caret at the end of line", 6, 100);
			logRect("first character", 0, 1);
			logRect("last character", 5, 1);
			logRect("last character", 5, 2);
			logRect("last character", 5, 100);
			logRect("first line", 0, 6);
			logRect("first line", 0, 7);
			logRect("first line", 0, 4294967295);
			logRect("first line without the first character", 1, 4294967295);
			logRect("out of bounds, clamped to the end", 7, 0);
			logRect("out of bounds, clamped to the end", 1000, 0);
			logRect("out of bounds, clamped to the end", 7, 1);
			logRect("out of bounds, clamped to the end", 7, 4294967295);
		} catch (ex) {
			log("Exception: " + ex.description);
		}

		var console = document.createElement("p");
		console.appendChild(console_messages);
		document.body.appendChild(console);
	} else {
		document.write("(cannot run interactively)");
	}
</script>
</body>
</html>
