<html>
<head>
<script>
function log(message)
{
    var item = document.createElement("li");
    item.appendChild(document.createTextNode(message));
    document.getElementById("console").appendChild(item);
}
function pressKey(key)
{
    if (navigator.userAgent.search(/\bMac OS X\b/) != -1)
        modifiers = ["ctrlKey", "altKey"];
    else
        modifiers = ["altKey"];
    eventSender.keyDown(key, modifiers);
}
function test()
{
    if (window.testRunner) {
        testRunner.dumpAsText();

        for (i = 1; i <= 9; i++)
            pressKey(i.toString());
        pressKey("a");
        pressKey("b");
        pressKey("c");
        pressKey("d");
        pressKey("e");
    }
}
</script>
</head>
<body onload="test()">
<p>This test checks to see if accesskey attributes works on the specified elements.</p>
<p>If this test passes you should see 1 - 9 and a, b and c clicked or focussed.</p>
<hr>
<p>
<button accesskey="1" onfocus="log('1 button focussed')" onclick="log('1 button clicked')"></button>
<input type="button" value="Click me!" accesskey="2" onfocus="log('2 input type button focussed')" onclick="log('2 input type button clicked')">
<input type="checkbox" accesskey="3" onfocus="log('3 input type checkbox focussed')" onclick="log('3 input type checkbox clicked')">
<input type="text" accesskey="4" onfocus="log('4 input type text focussed')" onclick="log('4 input type text clicked')">
<input type="submit" accesskey="5" onfocus="log('5 input type submit focussed')" onclick="log('5 input type submit clicked')">
<input type="reset" accesskey="6" onfocus="log('6 input type reset focussed')" onclick="log('6 input type reset clicked')">
<a href="#" accesskey="7" onfocus="log('7 link focussed')" onclick="log('7 link clicked')"></a>
<fieldset><legend accesskey="8"></legend><input type="text" onfocus="log('8 input type associated to legend focussed')" onclick="log('8 input type associated to legend clicked')"></fieldset>
<label accesskey="9" for="test1"><input type="text" id="test1" onfocus="log('9 input type associated to label around input focussed')" onclick="log('9 input type associated to label around input clicked')"></label>
<label accesskey="a" for="test2"></label><input type="text" id="test2" onfocus="log('a input type associated to label closed before input focussed')" onclick="log('a input type associated to label closed before input clicked')">
<map name="mymap">
    <area accesskey="b" shape="rect" coords="0,0,5,10" alt="" href="#" onfocus="log('b area 1 focussed')" onclick="log('b area 1 clicked')">
    <area accesskey="c" shape="rect" coords="6,0,10,10" alt="" href="#" onfocus="log('c area 2 focussed')" onclick="log('c area 2 clicked')">
</map>
<img usemap="#mymap" alt="pic" src="#" height="10" width="10">
<select accesskey="d" onfocus="log('d select focussed')" onclick="log('d select clicked')"></select>
<textarea accesskey="e" onfocus="log('e textarea focussed')" onclick="log('e textarea clicked')"></textarea>
</p>
<hr>
<ol id="console"></ol>
</body>
</html>
