<!DOCTYPE html>
<head>
<title>This tests that simple and normal line layout produce the same getClientRects result.</title>
<style>
.rangeBox {
    position:absolute;
    outline: 5px solid green;
}

.box {
    width: 400px;
    line-height: 40px;
}

.outer {
    outline: 2px solid green;
}

#test8 {
    -webkit-transform: translate(50px, 100px) rotate(50deg);
}
</style>
</head>
<body>
<div class="box" id="test1">1 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
<div class="box" id="test2">2 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
<div class="box" id="test3">3 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
<div class="box" id="test4">4 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do <div class="outer">eiusmod tempor</div> incididunt ut labore etdolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
<div class="box" id="test5">5 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do <div class="outer">eiusmod tempor</div> incididunt ut labore etdolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
<div class="box" id="test6">6 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
<div class="box" id="test7">7 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
<div class="box" id="test8">8 <div>Lorem ipsum dolor sit amet,</div> consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
<div class="box" id="test9">9 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
<div class="box" id="test10">10 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
<script>
    function visualizeClientRects(range) {
    	var rects = range.getClientRects();
        for (var i = 0; i < rects.length; ++i) {
        	var rect = rects[i];
        	rangeBox = document.createElement('div');
        	rangeBox.className = "rangeBox";
        	var style = "";
        	style += "left: "   + rect.left + "px;";
        	style += "top: "    + rect.top + "px;";
        	style += "width: "  + (rect.right - rect.left) + "px;";
        	style += "height: " + (rect.bottom - rect.top) + "px;";
        	rangeBox.setAttribute("style", style);
        	document.documentElement.appendChild(rangeBox);
        }
    }

    var range = document.createRange();
    range.selectNode(document.getElementById('test1'));
    visualizeClientRects(range);

    range = document.createRange();
    range.setStart(document.getElementById('test2').firstChild, 10);
    range.selectNodeContents(document.getElementById('test2'));
    visualizeClientRects(range);

    range = document.createRange();
    range.setStart(document.getElementById('test3').firstChild, 11);
    range.setEnd(document.getElementById('test3').lastChild, 201);
    visualizeClientRects(range);

    range = document.createRange();
    range.selectNode(document.getElementById('test4'));
    visualizeClientRects(range);

    range = document.createRange();
    range.selectNodeContents(document.getElementById('test5'));
    visualizeClientRects(range);

    range = document.createRange();
    range.setStart(document.getElementById('test6').firstChild, 11);
    range.setEnd(document.getElementById('test6').lastChild, 0);
    visualizeClientRects(range);

    range = document.createRange();
    range.setStart(document.getElementById('test7'), 0);
    visualizeClientRects(range);

    range = document.createRange();
    range.setStart(document.getElementById('test8').firstChild, 0);
    visualizeClientRects(range);

    range = document.createRange();
    range.setStartBefore(document.getElementById('test9'));
    range.setEndAfter(document.getElementById('test9').firstChild);
    visualizeClientRects(range);

    range = document.createRange();
    range.setStartBefore(document.getElementById('test10'));
    range.setEndBefore(document.getElementById('test10').firstChild);
    visualizeClientRects(range);
</script>
</body>
</html>
