access-key-label.html (840B)
1 <!DOCTYPE html> 2 <meta charset="UTF-8"> 3 <title>accessKeyLabel attribute</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <body> 7 <script> 8 function createButtonWithAccessKey(accessKey) { 9 const button = document.createElement('button'); 10 button.setAttribute('accesskey', accessKey); 11 return button; 12 } 13 14 // The modifiers are not the same across all browser vendors. 15 // Therefore, the test uses non empty. 16 test(() => { 17 const element = createButtonWithAccessKey('b'); 18 assert_not_equals(element.accessKeyLabel, ''); 19 }, 'Returns non empty string when accesskey is valid'); 20 21 test(() => { 22 const element = createButtonWithAccessKey('s 0'); 23 assert_equals(element.accessKeyLabel, ''); 24 }, 'Returns empty string when accesskey is invalid'); 25 </script> 26 </body> 27 </html>