DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (409f3966645a)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
<!DOCTYPE HTML>
<html>
<head>
  <meta charset='utf-8'>
  <title>WebVTT : cue's displaystate should be empty when its active flag is unset</title>
  <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<div id="content">
</div>
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();

var isReceivedOnEnterEvent = false;
var isReceivedOnExitEvent = false;

function checkCueEvents() {
  ok(isReceivedOnEnterEvent, "Already received cue's onEnter event.");
  ok(isReceivedOnExitEvent, "Already received cue's onExit event.");
  SimpleTest.finish();
}

function checkCueDisplayState(cue, expectedState) {
  var cueChrome = SpecialPowers.wrap(cue);
  if (expectedState) {
    ok(cueChrome.displayState, "Cue's displayState shouldn't be empty.");
  } else {
    ok(!cueChrome.displayState, "Cue's displayState should be empty.");
  }
}

function runTest() {
  info("--- create video ---");
  var video = document.createElement("video");
  video.src = "seek.webm";
  video.autoplay = true;
  document.getElementById("content").appendChild(video);

  video.onended = function () {
    video.onended = null;
    checkCueEvents();
  };

  video.onpause = function () {
    video.onpause = null;
    checkCueEvents();
  }

  video.onloadedmetadata = function () {
    ok(video.duration > 2, "video.duration should larger than 2");
  }

  info("--- create the type of track ---");
  isnot(window.TextTrack, undefined, "TextTrack should be defined.");

  var track = video.addTextTrack("subtitles", "A", "en");
  track.mode = "showing";
  ok(track instanceof TextTrack, "Track should be an instanceof TextTrack.");

  info("--- check the type of cue ---");
  isnot(window.TextTrackCue, undefined, "TextTrackCue should be defined.");
  isnot(window.VTTCue, undefined, "VTTCue should be defined.");

  var cue = new VTTCue(1, 2, "Test cue");
  ok(cue instanceof TextTrackCue, "Cue should be an instanceof TextTrackCue.");
  ok(cue instanceof VTTCue, "Cue should be an instanceof VTTCue.");

  info("--- add cue ---");
  track.addCue(cue);
  video.ontimeupdate = function () {
    info("--- video.currentTime is " + video.currentTime);
  };
  cue.onenter = function () {
    cue.onenter = null;
    isReceivedOnEnterEvent = true;
    var cueChrome = SpecialPowers.wrap(cue);
    info("cueChrome.getActive " + cueChrome.getActive);
    if (cueChrome.getActive) {
      checkCueDisplayState(cue, true /* has display-state */);
    } else {
      info("This is a missing cue, video.currentTime is "+ video.currentTime);
    }

    cue.onexit = function () {
      cue.onexit = null;
      isReceivedOnExitEvent = true;
      checkCueDisplayState(cue, false /* no display-state */);
      video.pause();
    }
  }
}

onload = runTest;
</script>
</body>
</html>