<!DOCTYPE html>

<p>Press tab twice. The second input should be focused.</p>

<input onfocus="notify('a')">
<iframe style="display:none"></iframe>
<input id="i2" onfocus="notify('b')">

<pre id=out>FAIL</pre>

<script>

function fail()
{
    document.getElementById('out').textContent = 'FAIL';
}

function pass()
{
  document.getElementById('out').textContent = 'PASS';
}

function notify(msg)
{
    if (msg != expected[i++])
        fail();
}

window.frames[0].document.body.onfocus = fail;

var expected = ['a', 'b'];
var i = 0;

if (window.testRunner)
    testRunner.dumpAsText();

if (window.eventSender) {
    document.body.focus();
    eventSender.keyDown('\t');
    eventSender.keyDown('\t');

    // Ensure we got 2 focus events.
    if (i == 2 && document.activeElement.id == 'i2')
        pass();
}

</script>
