test_texttrackregion.html (1762B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title>Test for Bug 917945 - VTTRegion</title> 5 <script src="/tests/SimpleTest/SimpleTest.js"></script> 6 <script type="text/javascript" src="manifest.js"></script> 7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 8 </head> 9 <body> 10 <video id="v" src="seek.webm" preload="auto"> 11 <track src="region.vtt" kind="subtitles" id="default" default> 12 </video> 13 <script type="text/javascript"> 14 /** 15 * This test is used to ensure that we can parse VTT region attributes correctly 16 * from vtt file. 17 */ 18 var trackElement = document.getElementById("default"); 19 20 async function runTest() { 21 await waitUntiTrackLoaded(); 22 checkRegionAttributes(); 23 SimpleTest.finish(); 24 } 25 26 SimpleTest.waitForExplicitFinish(); 27 28 runTest(); 29 30 /** 31 * The following are test helper functions. 32 */ 33 async function waitUntiTrackLoaded() { 34 if (trackElement.readyState != 2) { 35 info(`wait until the track finishes loading`); 36 await once(trackElement, "load"); 37 } 38 is(trackElement.readyState, 2, "Track::ReadyState should be set to LOADED."); 39 } 40 41 function checkRegionAttributes() { 42 let cues = trackElement.track.cues; 43 is(cues.length, 1, "Cue list length should be 1."); 44 45 let region = cues[0].region; 46 isnot(region, null, "Region should not be null."); 47 is(region.width, 62, "Region width should be 50."); 48 is(region.lines, 5, "Region lines should be 5."); 49 is(region.regionAnchorX, 4, "Region regionAnchorX should be 4."); 50 is(region.regionAnchorY, 78, "Region regionAnchorY should be 78."); 51 is(region.viewportAnchorX, 10, "Region viewportAnchorX should be 10."); 52 is(region.viewportAnchorY, 90, "Region viewportAnchorY should be 90."); 53 is(region.scroll, "up", "Region scroll should be 'up'"); 54 } 55 56 </script> 57 </body> 58 </html>