5 <title>WebVTT : cue's displaystate should be empty when its active flag is unset
</title>
6 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
7 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
12 <script class=
"testbody" type=
"text/javascript">
13 SimpleTest.waitForExplicitFinish();
15 var isReceivedOnEnterEvent = false;
16 var isReceivedOnExitEvent = false;
18 function checkCueEvents() {
19 ok(isReceivedOnEnterEvent,
"Already received cue's onEnter event.");
20 ok(isReceivedOnExitEvent,
"Already received cue's onExit event.");
24 function checkCueDisplayState(cue, expectedState) {
25 var cueChrome = SpecialPowers.wrap(cue);
27 ok(cueChrome.displayState,
"Cue's displayState shouldn't be empty.");
29 ok(!cueChrome.displayState,
"Cue's displayState should be empty.");
34 info(
"--- create video ---");
35 var video = document.createElement(
"video");
36 video.src =
"seek.webm";
37 video.autoplay = true;
38 document.getElementById(
"content").appendChild(video);
40 video.onended = function () {
45 video.onpause = function () {
50 video.onloadedmetadata = function () {
51 ok(video.duration
> 2,
"video.duration should larger than 2");
54 info(
"--- create the type of track ---");
55 isnot(window.TextTrack, undefined,
"TextTrack should be defined.");
57 var track = video.addTextTrack(
"subtitles",
"A",
"en");
58 track.mode =
"showing";
59 ok(track instanceof TextTrack,
"Track should be an instanceof TextTrack.");
61 info(
"--- check the type of cue ---");
62 isnot(window.TextTrackCue, undefined,
"TextTrackCue should be defined.");
63 isnot(window.VTTCue, undefined,
"VTTCue should be defined.");
65 var cue = new VTTCue(
1,
2,
"Test cue");
66 ok(cue instanceof TextTrackCue,
"Cue should be an instanceof TextTrackCue.");
67 ok(cue instanceof VTTCue,
"Cue should be an instanceof VTTCue.");
69 info(
"--- add cue ---");
71 video.ontimeupdate = function () {
72 info(
"--- video.currentTime is " + video.currentTime);
74 cue.onenter = function () {
76 isReceivedOnEnterEvent = true;
77 var cueChrome = SpecialPowers.wrap(cue);
78 info(
"cueChrome.getActive " + cueChrome.getActive);
79 if (cueChrome.getActive) {
80 checkCueDisplayState(cue, true /* has display-state */);
82 info(
"This is a missing cue, video.currentTime is "+ video.currentTime);
85 cue.onexit = function () {
87 isReceivedOnExitEvent = true;
88 checkCueDisplayState(cue, false /* no display-state */);