summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/access-key-for-all-elements.html
blob: ffaccd98dacb56e4a7006f772b2a6a63efb36794 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<script>
description('This test checks to see if accesskey attributes works on all elements.');

function pressKey(key)
{
    if (/\bMac OS X\b/.test(navigator.userAgent))
        modifiers = ["ctrlKey", "altKey"];
    else
        modifiers = ["altKey"];
    eventSender.keyDown(key, modifiers);
}

var tagNames = ["a","abbr","acronym","address","applet","area","article","aside","audio","b","base","basefont","bdo","bgsound","big","blockquote",
    "body","br","canvas","caption","center","cite","code","col","colgroup","command","datalist","dd","del","details","dfn","dir","div","dl","dt",
    "em","embed","fieldset","figcaption","figure","font","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html",
    "i","iframe","img","ins","kbd","keygen","label","layer","li","link","listing","main","map","mark","marquee","menu","meta","meter","nav",
    "nobr","noembed","noframes","nolayer","noscript","object","ol","output","p","param","plaintext","pre","progress","q","rp","rt","ruby","s",
    "samp","script","section","small","source","span","strike","strong","style","sub","summary","sup","table","tbody","td","tfoot","th","thead",
    "title","tr","track","tt","u","ul","var","video","wbr","xmp"];

for (var i = 0 ; i < tagNames.length; i++) {
    var testElement = document.createElement(tagNames[i]);
    document.body.appendChild(testElement);
    var clicked = false;
    testElement.onclick = function () { clicked = true; }
    var focused = false;
    testElement.onfocus = function () { focused = true; }
    debug('Check for ' + testElement.tagName + ' tag');    
    shouldBeDefined('testElement.accessKey');
    shouldBeTrue("testElement.accessKey ='k'; testElement.accessKey == 'k'");
    shouldBe("pressKey(testElement.accessKey);[clicked, focused]", "[true, false]");
    debug('');
}
</script>
<div id="console"></div>
</body>
</html>