4 <script src=
"../../../resources/js-test.js"></script>
10 window
.jsTestIsAsync
= true;
12 description("This tests the constructor for the TrackEvent DOM class.");
16 // Make sure the track actually loaded.
17 shouldBe("trackElement.track.readyState", "TextTrack.LOADED", true);
19 debug("<br>*** No initializer passed ***");
20 shouldBe("new TrackEvent('TrackEvent').bubbles", "false");
21 shouldBe("new TrackEvent('TrackEvent').cancelable", "false");
22 shouldBeNull("new TrackEvent('TrackEvent').track");
24 debug("<br>*** Bubbles and cancelable true, track is missing ***");
25 shouldBe("new TrackEvent('TrackEvent', { bubbles: true, cancelable: true }).bubbles", "true");
26 shouldBe("new TrackEvent('TrackEvent', { bubbles: true, cancelable: true }).cancelable", "true");
27 shouldBeNull("new TrackEvent('TrackEvent', { bubbles: true, cancelable: true }).track");
29 debug("<br>*** Bubbles and cancelable true, invalid track ***");
30 shouldThrow("new TrackEvent('TrackEvent', { bubbles: true, cancelable: true, track: HTMLTrackElement }).bubbles");
31 shouldThrow("new TrackEvent('TrackEvent', { bubbles: true, cancelable: true, track: HTMLTrackElement }).cancelable");
32 shouldThrow("new TrackEvent('TrackEvent', { bubbles: true, cancelable: true, track: HTMLTrackElement }).track");
34 debug("<br>*** Initialize 'track' with a invalid values ***");
35 shouldThrow("new TrackEvent('TrackEvent', { track: 10 }).track");
36 shouldThrow("new TrackEvent('TrackEvent', { track: \'string\' }).track");
38 shouldThrow("new TrackEvent('TrackEvent', { track: emptyObject }).track");
39 shouldThrow("new TrackEvent('TrackEvent', { track: document }).track");
41 debug("<br>*** Bubbles and cancelable true, valid track ***");
42 shouldBe("new TrackEvent('TrackEvent', { bubbles: true, cancelable: true, track: trackElement.track }).bubbles", "true");
43 shouldBe("new TrackEvent('TrackEvent', { bubbles: true, cancelable: true, track: trackElement.track }).cancelable", "true");
44 shouldBe("new TrackEvent('TrackEvent', { track: trackElement.track }).track", "trackElement.track");
46 debug("<br>*** Initialize 'track' with valid track object ***");
47 shouldBe("new TrackEvent('TrackEvent', { track: trackElement.track }).track", "trackElement.track");
53 video
= document
.createElement('video');
54 document
.body
.appendChild(video
);
56 trackElement
= document
.createElement('track');
57 video
.appendChild(trackElement
);
58 trackElement
.track
.mode
= "hidden";
59 trackElement
.addEventListener('load', test
);
60 trackElement
.src
='data:text/vtt,WEBVTT FILE \r\r1\r00:00:00.000 --> 00:00:30.500\ronly one caption';