tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_texttrack_moz.html (1967B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>Test for Bug 881976 - TextTrackList</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="metadata">
     11 <script type="text/javascript">
     12 /**
     13 * This test is used to ensure the text track list we got from video is as same
     14 * as the one in the text track.
     15 */
     16 var video = document.getElementById("v");
     17 
     18 async function runTest() {
     19  addTrackViaAddTrackAPI();
     20  await addTrackViaTrackElement();
     21  SimpleTest.finish();
     22 }
     23 
     24 SimpleTest.waitForExplicitFinish();
     25 onload = runTest;
     26 
     27 /**
     28 * The following are test helper functions.
     29 */
     30 function addTrackViaAddTrackAPI() {
     31  // Check if adding a text track manually sets the TextTrackList correctly.
     32  video.addTextTrack("subtitles", "", "");
     33  // TextTrack.textTrackList is an extension available only to privileged code,
     34  // so we need to access it through the SpecialPowers object.
     35  is(SpecialPowers.unwrap(SpecialPowers.wrap(video.textTracks[0]).textTrackList),
     36     video.textTracks,
     37     "The Track's TextTrackList should be the Video's TextTrackList.");
     38 }
     39 
     40 async function addTrackViaTrackElement() {
     41  // Check if loading a Track via a TrackElement sets the TextTrackList correctly.
     42  let trackElement = document.createElement("track");
     43  trackElement.src = "basic.vtt";
     44  trackElement.kind = "subtitles";
     45  trackElement.default = true;
     46  video.appendChild(trackElement);
     47 
     48  info(`wait until the track finishes loading`);
     49  await once(trackElement, "load");
     50 
     51  is(trackElement.readyState, HTMLTrackElement.LOADED,
     52     "Track::ReadyState should be set to LOADED.");
     53  is(SpecialPowers.unwrap(SpecialPowers.wrap(trackElement.track).textTrackList),
     54     video.textTracks,
     55     "TrackElement's Track's TextTrackList should be the Video's TextTrackList.");
     56 }
     57 
     58 </script>
     59 </body>
     60 </html>