<p>
    Test for a bug where computing the text offset for a position at the
    beginning of a glyph cluster at the beginning of a Core Text run resulted
    in an attempt to read past the end of a vector. 
</p>
<p>
    The test passes if an assertion failure does not occur and the selection is
    before the first Thai character.
</p>
<p id="result">
    Test did not run.
</p>
<div id="target" style="font-size: 36px;">
    D
</div>
<script>
    if (window.testRunner) {
        testRunner.dumpAsText();

        var target = document.getElementById("target");
        var result = document.getElementById("result");
        var x = target.offsetLeft + 1;
        var y = target.offsetTop + target.offsetHeight / 2;

        eventSender.mouseMoveTo(x, y);
        eventSender.mouseDown();
        eventSender.mouseUp();

        var selection = getSelection();
        if (selection.baseNode === target.firstChild && selection.baseOffset === 5)
            result.innerText = "PASS";
        else
            result.innerText = "FAIL: Selection at " + selection.baseNode + "[" + selection.baseOffset + "]";
    }
</script>
