
<html>
<head>
<meta charset="ISO-8859-8">
<style>
*[dir] { unicode-bidi: embed }
</style>
<body>
<p>Test rendering of ISO-8859-8.
<p>
<div class="test"></div>
<div class="test">  </div>
<div class="test"> abc </div>
<div class="test">abc  def</div>
<div class="test"> <span dir=ltr></span></div>
<div class="test"> <span dir=rtl></span></div>
<ul id="console" dir=ltr></ul>

<script src="../../../resources/js-test-pre.js"></script>
<script> 
    var succeed = true;

    function checkClientRect(test, index, offset, dir, char)
    {
        if (test.nodeType == 3) {
            for (var i = 0; i < test.textContent.length; ++i) {
                range.setStart(test, i);
                range.setEnd(test, i+1); 
                rects = range.getClientRects();
                if (dir == "ltr") {
                    if (rects[0].left < offset) {
                        testFailed("Test " + index + " LTR: character " + range.toString() + " should be rendered right of " + char);
                        succeed = false;
          
                    }
                } else {
                    if (rects[0].left > offset) {
                        testFailed("Test " + index + " RTL: character " + range.toString() + " should be rendered left of " + char);
                        succeed = false;
                    }
                }
                offset = rects[0].left;
                char = range.toString();
            }

        } else if (test.nodeType == 1) {
            for (var node = test.firstChild; node; node = node.nextSibling) {
                checkClientRect(node, index, offset, dir, char);
            }
        }
    }
            
    if (window.testRunner)
        testRunner.dumpAsText();
        
    var tests = document.getElementsByClassName('test');
    var range = document.createRange();
    for (var i = 0; i < tests.length; ++i) {
        checkClientRect(tests[i], i, -1, "ltr", " ");

        tests[i].style.direction = "rtl";
        checkClientRect(tests[i], i, 10000, "rtl", " ");
    
        tests[i].style.display = "none";
    }
    if (succeed == true) 
        testPassed("Test completed successfully");
</script> 
</body>
</html>
