<!DOCTYPE html>
<html>
<head>
<script src="../../resources/basic-gestures.js"></script>
<script src="../../resources/ui-helper.js"></script>
<script>
    if (window.testRunner) {
        testRunner.dumpAsText();
        testRunner.waitUntilDone();
    }

    async function runTest()
    {
        if (!testRunner.runUIScript)
            return;
    
        var output = '';

        await UIHelper.activateElementAndWaitForInputSession(document.getElementById('editable'));
        await UIHelper.enterText("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nTest");

        var firstPageOffset = window.pageYOffset;
        if (window.pageYOffset > 0)
            output += 'PASS: page has scrolled when caret is behind software keyboard.';
        else
            output += 'FAIL: page has failed to scroll when caret is behind software keyboard.';
        output += '<br>';

        await UIHelper.enterText("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nTest");
        if (window.pageYOffset > 0 && window.pageYOffset > firstPageOffset)
            output += 'PASS: page has continuted to scroll when caret is beyond the edge of the screen.';
        else
            output += 'FAIL: page has failed to scroll when caret is beyond the edge of the screen.';
        output += '<br>';

        document.getElementById('editable').innerHTML = output;
        testRunner.notifyDone();
    }

    window.addEventListener('load', runTest, false);
</script>
<style>
    #editable {
        height: 1000px;
        width: 300px;
        background-color: silver;
        font-family: monospace;
        font-size: 18px;
    }
</style>
</head>
<body>
This test presses return until the cursor would be behind the keyboard,
forcing the content to be scrolled to stay in view with a software keyboard on screen.
<div id="editable" contenteditable>
</body>
</html>