Bug 1943761 - Add class alignment to the mozsearch analysis file. r=asuth
[gecko.git] / dom / media / webvtt / test / mochitest / test_webvtt_empty_displaystate.html
blob209731692121a25db517a97bc381c189dfcf32e7
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <meta charset='utf-8'>
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"/>
8 </head>
9 <body>
10 <div id="content">
11 </div>
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.");
21 SimpleTest.finish();
24 function checkCueDisplayState(cue, expectedState) {
25 var cueChrome = SpecialPowers.wrap(cue);
26 if (expectedState) {
27 ok(cueChrome.displayState, "Cue's displayState shouldn't be empty.");
28 } else {
29 ok(!cueChrome.displayState, "Cue's displayState should be empty.");
33 function runTest() {
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 () {
41 video.onended = null;
42 checkCueEvents();
45 video.onpause = function () {
46 video.onpause = null;
47 checkCueEvents();
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 ---");
70 track.addCue(cue);
71 video.ontimeupdate = function () {
72 info("--- video.currentTime is " + video.currentTime);
74 cue.onenter = function () {
75 cue.onenter = null;
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 */);
81 } else {
82 info("This is a missing cue, video.currentTime is "+ video.currentTime);
85 cue.onexit = function () {
86 cue.onexit = null;
87 isReceivedOnExitEvent = true;
88 checkCueDisplayState(cue, false /* no display-state */);
89 video.pause();
94 onload = runTest;
95 </script>
96 </body>
97 </html>