| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | |
| 3 <head> | |
| 4 <script src="../../resources/js-test.js"></script> | |
| 5 </head> | |
| 6 <body> | 2 <body> |
| 3 <script src="../../resources/testharness.js"></script> |
| 4 <script src="../../resources/testharnessreport.js"></script> |
| 7 <script> | 5 <script> |
| 8 description('This test checks to see if accesskey attributes works on all elemen
ts.'); | 6 const modifiers = /\bMac OS X\b/.test(navigator.userAgent) ? ["ctrlKey", "altKey
"] : ["altKey"]; |
| 9 | 7 |
| 10 function pressKey(key) | 8 function pressKey(key) { |
| 11 { | 9 eventSender.keyDown(key, modifiers); |
| 12 if (/\bMac OS X\b/.test(navigator.userAgent)) | |
| 13 modifiers = ["ctrlKey", "altKey"]; | |
| 14 else | |
| 15 modifiers = ["altKey"]; | |
| 16 eventSender.keyDown(key, modifiers); | |
| 17 } | 10 } |
| 18 | 11 |
| 19 var tagNames = ["a","abbr","acronym","address","applet","area","article","aside"
,"audio","b","base","basefont","bdo","bgsound","big","blockquote", | 12 const tagNames = [ |
| 20 "body","br","canvas","caption","center","cite","code","col","colgroup","comm
and","datalist","dd","del","details","dfn","dir","div","dl","dt", | 13 "a", "abbr", "acronym", "address", "area", "article", "aside", "audio", |
| 21 "em","embed","fieldset","figcaption","figure","font","footer","form","frame"
,"frameset","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html", | 14 "b", "base", "basefont", "bdo", "bgsound", "big", "blockquote", "body", "br", |
| 22 "i","iframe","img","ins","kbd","keygen","label","layer","li","link","listing
","main","map","mark","marquee","menu","meta","meter","nav", | 15 "canvas", "caption", "center", "cite", "code", "col", "colgroup", "datalist", |
| 23 "nobr","noembed","noframes","nolayer","noscript","object","ol","output","p",
"param","plaintext","pre","progress","q","rp","rt","ruby","s", | 16 "dd", "del", "details", "dfn", "dir", "div", "dl", "dt", |
| 24 "samp","script","section","small","source","span","strike","strong","style",
"sub","summary","sup","table","tbody","td","tfoot","th","thead", | 17 "em", "embed", "fieldset", "figcaption", "figure", "font", "footer", "form", |
| 25 "title","tr","track","tt","u","ul","var","video","wbr","xmp"]; | 18 "frame", "frameset", |
| 19 "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup","hr","html", |
| 20 "i", "iframe", "img", "ins", "kbd", "label", "layer", "li", "link", "listing", |
| 21 "main", "map", "mark", "marquee", "menu", "meta", "meter", |
| 22 "nav", "nobr", "noembed", "noframes", "nolayer", "noscript", |
| 23 "object", "ol", "output", "p", "param", "plaintext", "pre", "progress", "q", |
| 24 "rp", "rt", "ruby", "s", "samp", "script", "section", "small", "source", |
| 25 "span", "strike", "strong", "style", "sub", "summary", "sup", |
| 26 "table", "tbody", "td", "tfoot", "th", "thead", "title", "tr", "track", "tt", |
| 27 "u", "ul", "var", "video", "wbr", "xmp"]; |
| 26 | 28 |
| 27 for (var i = 0 ; i < tagNames.length; i++) { | 29 tagNames.forEach((name) => { |
| 28 var testElement = document.createElement(tagNames[i]); | 30 test(() => { |
| 31 var testElement = document.createElement(name); |
| 29 document.body.appendChild(testElement); | 32 document.body.appendChild(testElement); |
| 30 var clicked = false; | 33 var clicked = false; |
| 31 testElement.onclick = function () { clicked = true; } | 34 testElement.onclick = () => { clicked = true; } |
| 32 var focused = false; | 35 var focused = false; |
| 33 testElement.onfocus = function () { focused = true; } | 36 testElement.onfocus = () => { focused = true; } |
| 34 debug('Check for ' + testElement.tagName + ' tag'); | 37 |
| 35 shouldBeDefined('testElement.accessKey'); | 38 assert_not_equals(testElement.accessKey, undefined); |
| 36 shouldBeTrue("testElement.accessKey ='k'; testElement.accessKey == 'k'"); | 39 |
| 37 shouldBe("pressKey(testElement.accessKey);[clicked, focused]", "[true, false
]"); | 40 testElement.accessKey = "k"; |
| 38 debug(''); | 41 assert_equals(testElement.accessKey, "k"); |
| 39 } | 42 |
| 43 pressKey(testElement.accessKey); |
| 44 assert_true(clicked, "Pressing access key should trigger click handler."); |
| 45 assert_false(focused, "Pressing access key should not focus on the element."
); |
| 46 |
| 47 document.body.removeChild(testElement); |
| 48 }, "Check for " + name + " tag"); |
| 49 }); |
| 40 </script> | 50 </script> |
| 41 <div id="console"></div> | |
| 42 </body> | 51 </body> |
| 43 </html> | |
| OLD | NEW |