<!DOCTYPE html>
<html>
<body spellcheck="false">
<script src="../editing.js"></script>
<script src="../../resources/js-test-pre.js"></script>
<div id="misspelled" onmouseup="checkSpellingMarker()">tyop is misspelled.</div>
<script>
description("This tests whether WebKit does not spell check in 'designMode' "
    + "when spellcheck='false'. To test manually, click arround 'tyop'. "
    + "There should be no spelling marker for 'tyop' after the click.");

jsTestIsAsync = true;

if (window.internals) {
    internals.settings.setUnifiedTextCheckerEnabled(true);
    internals.settings.setAsynchronousSpellCheckingEnabled(true);
}

document.designMode = "on";

function checkSpellingMarker()
{
    // First, verify spelling with spellcheck attribute off.
    // Move selection to the next word to notify WebKit that "tyop" has been typed/changed
    // to give a chance to spellcheck.
    moveSelectionForwardByWordCommand();

    if (window.internals) {
        shouldBecomeEqual('internals.hasSpellingMarker(0, 4)', 'false', function() {
            evalAndLog('document.body.setAttribute("spellcheck", "true")');
            // Do any selection change to force spellchecking after attribute change.
            moveSelectionForwardByLineCommand();
            shouldBecomeDifferent('internals.hasSpellingMarker(0, 4)', 'false', finishJSTest);
        });
    }
}

if (window.eventSender) {
    var misspelledDiv = document.getElementById("misspelled");
    var x = misspelledDiv.offsetLeft;
    var y = misspelledDiv.offsetTop;
    eventSender.mouseMoveTo(x, y);
    eventSender.mouseDown();
    eventSender.mouseUp();
}
</script> 
<script src="../../resources/js-test-post.js"></script>
</body>
</html>
