test_media.html (3906B)
1 <!DOCTYPE html> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=483573 5 --> 6 <head> 7 <title>HTML5 audio/video tests</title> 8 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" /> 9 10 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 11 12 <script type="application/javascript" 13 src="../common.js"></script> 14 <script type="application/javascript" 15 src="../events.js"></script> 16 <script type="application/javascript" 17 src="../actions.js"></script> 18 <script type="application/javascript" 19 src="../role.js"></script> 20 <script type="application/javascript" 21 src="../states.js"></script> 22 23 <script type="application/javascript"> 24 SimpleTest.requestCompleteLog(); // To help diagnose bug 1845221 25 26 // gA11yEventDumpID = "eventDump"; 27 // gA11yEventDumpToConsole = true; // debug stuff 28 29 function focusChecker(aAcc) { 30 this.type = EVENT_FOCUS; 31 this.target = aAcc; 32 this.getID = function focusChecker_getID() { 33 return "focus handling"; 34 }; 35 this.check = function focusChecker_check() { 36 testStates(this.target, STATE_FOCUSED); 37 }; 38 } 39 40 function nameChecker(aAcc, aName) { 41 this.type = EVENT_NAME_CHANGE; 42 this.target = aAcc; 43 this.getID = function nameChecker_getID() { 44 return "name change handling"; 45 }; 46 this.check = function nameChecker_check(aEvent) { 47 is(aEvent.accessible.name, aName, 48 "Wrong name of " + prettyName(aEvent.accessible) + " on focus"); 49 }; 50 } 51 52 async function loadAudioSource() { 53 /** 54 * Setting the source dynamically and wait for it to load, 55 * so we can test the accessibility tree of the control in its ready and 56 * stable state. 57 * 58 * See bug 1484048 comment 25 for discussion on how it switches UI when 59 * loading a statically declared source. 60 */ 61 await new Promise(resolve => { 62 let el = document.getElementById("audio"); 63 el.addEventListener("canplaythrough", resolve, {once: true}); 64 el.src = "../bug461281.ogg"; 65 }); 66 67 doTest(); 68 } 69 70 function doTest() { 71 // //////////////////////////////////////////////////////////////////////// 72 // test actions of audio controls 73 74 todo(false, "Focus test are disabled until bug 494175 is fixed."); 75 76 var audioElm = getAccessible("audio"); 77 var playBtn = audioElm.firstChild; 78 // var scrubber = playBtn.nextSibling.nextSibling.nextSibling; 79 var muteBtn = audioElm.lastChild.previousSibling; 80 81 var actions = [ 82 { 83 ID: muteBtn, 84 actionName: "press", 85 eventTarget: "element", 86 eventSeq: [ 87 // new focusChecker(muteBtn), 88 new nameChecker(muteBtn, "Unmute"), 89 ], 90 }, 91 // { 92 // ID: scrubber, 93 // actionName: "activate", 94 // events: null, 95 // eventSeq: [ 96 // new focusChecker(scrubber) 97 // ] 98 // }, 99 { 100 ID: playBtn, 101 actionName: "press", 102 eventTarget: "element", 103 eventSeq: [ 104 // new focusChecker(playBtn), 105 new nameChecker(playBtn, "Pause"), 106 ], 107 }, 108 ]; 109 110 testActions(actions); // Will call SimpleTest.finish(); 111 } 112 113 SimpleTest.waitForExplicitFinish(); 114 addA11yLoadEvent(loadAudioSource); 115 </script> 116 </head> 117 <body> 118 119 <a target="_blank" rel="opener" 120 title="Expose HTML5 video and audio elements' embedded controls through accessibility APIs" 121 href="https://bugzilla.mozilla.org/show_bug.cgi?id=483573">Mozilla Bug 483573</a> 122 <p id="display"></p> 123 <div id="content" style="display: none"></div> 124 <pre id="test"> 125 </pre> 126 127 <audio id="audio" controls="true"></audio> 128 129 <div id="eventDump"></div> 130 </body> 131 </html>