<script src="resources/repaint.js" type="text/javascript"></script>
<script type="text/javascript">

function step1() {
    if (window.testRunner)
        window.testRunner.waitUntilDone();
    // Wait for the frame to load.
    window.setTimeout(step2, 100);
}

function step2() {
    var frame = frames[0];
    var doc = frame.document;
    var body = doc.body;
    var sel = frame.getSelection();
    frame.focus();
    sel.setPosition(body, 0);
    doc.execCommand("InsertText", false, "You should not see a caret in this text.");
    var text = body.firstChild;
    sel.setPosition(text, text.length);
    // Wait for the caret to paint.
    window.setTimeout(runRepaintTest, 100);
}

function repaintTest() {
    var frame = frames[0];
    var doc = frame.document;
    var body = doc.body;
    var text = body.firstChild;
    var sel = frame.getSelection();
    
    sel.setBaseAndExtent(text, 5, text, text.length);
    
    if (window.testRunner)
        window.testRunner.notifyDone();
}
</script>

<body onload="step1();">
<iframe src="resources/contenteditable-iframe-src.html"></iframe>
</body>
