accesskey.js (795B)
1 setup({explicit_done: true, explicit_timeout: true}); 2 3 const NOTRUN = 3; 4 let status = NOTRUN; 5 function notrun() { 6 return status === NOTRUN; 7 } 8 add_completion_callback(tests => { 9 status = tests[0].status; 10 }); 11 12 function pass() { 13 // Wait a couple of frames in case fail() is also called. 14 requestAnimationFrame(() => { 15 requestAnimationFrame(() => { 16 if (notrun()) { 17 test(() => {}); 18 done(); 19 } 20 }); 21 }); 22 } 23 24 function fail(msg) { 25 if (notrun()) { 26 test(() => { assert_unreached(msg); }); 27 done(); 28 } 29 } 30 31 document.addEventListener('DOMContentLoaded', () => { 32 const accessKeyElement = document.querySelector('[accesskey]'); 33 if (accessKeyElement.accessKeyLabel) { 34 document.querySelector('kbd').textContent = accessKeyElement.accessKeyLabel; 35 } 36 });