OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../../resources/js-test.js"></script> | 4 <script src="../../../resources/js-test.js"></script> |
5 </head> | 5 </head> |
6 | 6 |
7 <body> | 7 <body> |
8 <script> | 8 <script> |
9 | 9 |
10 window.jsTestIsAsync = true; | 10 window.jsTestIsAsync = true; |
11 | 11 |
12 description("This tests the constructor for the TrackEvent DOM class."); | 12 description("This tests the constructor for the TrackEvent DOM class."); |
13 | 13 |
14 function test() | 14 function test() |
15 { | 15 { |
16 // Make sure the track actually loaded. | 16 // Make sure the track actually loaded. |
17 shouldBe("trackElement.track.readyState", "TextTrack.LOADED", true); | 17 shouldBe("trackElement.track.readyState", "TextTrack.LOADED", true); |
18 | 18 |
19 debug("<br>*** No initializer passed ***"); | 19 debug("<br>*** No initializer passed ***"); |
20 shouldBe("new TrackEvent('TrackEvent').bubbles", "false"); | 20 shouldBe("new TrackEvent('TrackEvent').bubbles", "false"); |
21 shouldBe("new TrackEvent('TrackEvent').cancelable", "false"); | 21 shouldBe("new TrackEvent('TrackEvent').cancelable", "false"); |
22 shouldBeNull("new TrackEvent('TrackEvent').track"); | 22 shouldBeNull("new TrackEvent('TrackEvent').track"); |
23 | 23 |
24 debug("<br>*** Bubbles and cancelable true, track is missing ***"); | 24 debug("<br>*** Bubbles and cancelable true, track is missing ***"); |
25 shouldBe("new TrackEvent('TrackEvent', { bubbles: true, cancelable:
true }).bubbles", "true"); | 25 shouldBe("new TrackEvent('TrackEvent', { bubbles: true, cancelable:
true }).bubbles", "true"); |
26 shouldBe("new TrackEvent('TrackEvent', { bubbles: true, cancelable:
true }).cancelable", "true"); | 26 shouldBe("new TrackEvent('TrackEvent', { bubbles: true, cancelable:
true }).cancelable", "true"); |
27 shouldBeNull("new TrackEvent('TrackEvent', { bubbles: true, cancelab
le: true }).track"); | 27 shouldBeNull("new TrackEvent('TrackEvent', { bubbles: true, cancelab
le: true }).track"); |
28 | 28 |
29 debug("<br>*** Bubbles and cancelable true, invalid track ***"); | 29 debug("<br>*** Bubbles and cancelable true, invalid track ***"); |
30 shouldBe("new TrackEvent('TrackEvent', { bubbles: true, cancelable:
true, track: HTMLTrackElement }).bubbles", "true"); | 30 shouldThrow("new TrackEvent('TrackEvent', { bubbles: true, cancelabl
e: true, track: HTMLTrackElement }).bubbles"); |
31 shouldBe("new TrackEvent('TrackEvent', { bubbles: true, cancelable:
true, track: HTMLTrackElement }).cancelable", "true"); | 31 shouldThrow("new TrackEvent('TrackEvent', { bubbles: true, cancelabl
e: true, track: HTMLTrackElement }).cancelable"); |
32 shouldBeNull("new TrackEvent('TrackEvent', { bubbles: true, cancelab
le: true, track: HTMLTrackElement }).track"); | 32 shouldThrow("new TrackEvent('TrackEvent', { bubbles: true, cancelabl
e: true, track: HTMLTrackElement }).track"); |
33 | 33 |
34 debug("<br>*** Initialize 'track' with a invalid values ***"); | 34 debug("<br>*** Initialize 'track' with a invalid values ***"); |
35 shouldBeNull("new TrackEvent('TrackEvent', { track: 10 }).track"); | 35 shouldThrow("new TrackEvent('TrackEvent', { track: 10 }).track"); |
36 shouldBeNull("new TrackEvent('TrackEvent', { track: \'string\' }).tr
ack"); | 36 shouldThrow("new TrackEvent('TrackEvent', { track: \'string\' }).tra
ck"); |
37 emptyObject = { }; | 37 emptyObject = { }; |
38 shouldBeNull("new TrackEvent('TrackEvent', { track: emptyObject }).t
rack"); | 38 shouldThrow("new TrackEvent('TrackEvent', { track: emptyObject }).tr
ack"); |
39 shouldBeNull("new TrackEvent('TrackEvent', { track: document }).trac
k"); | 39 shouldThrow("new TrackEvent('TrackEvent', { track: document }).track
"); |
40 | 40 |
41 debug("<br>*** Bubbles and cancelable true, valid track ***"); | 41 debug("<br>*** Bubbles and cancelable true, valid track ***"); |
42 shouldBe("new TrackEvent('TrackEvent', { bubbles: true, cancelable:
true, track: HTMLTrackElement }).bubbles", "true"); | 42 shouldBe("new TrackEvent('TrackEvent', { bubbles: true, cancelable:
true, track: trackElement.track }).bubbles", "true"); |
43 shouldBe("new TrackEvent('TrackEvent', { bubbles: true, cancelable:
true, track: HTMLTrackElement }).cancelable", "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"); | 44 shouldBe("new TrackEvent('TrackEvent', { track: trackElement.track }
).track", "trackElement.track"); |
45 | 45 |
46 debug("<br>*** Initialize 'track' with valid track object ***"); | 46 debug("<br>*** Initialize 'track' with valid track object ***"); |
47 shouldBe("new TrackEvent('TrackEvent', { track: trackElement.track }
).track", "trackElement.track"); | 47 shouldBe("new TrackEvent('TrackEvent', { track: trackElement.track }
).track", "trackElement.track"); |
48 | 48 |
49 debug(""); | 49 debug(""); |
50 finishJSTest(); | 50 finishJSTest(); |
51 } | 51 } |
52 | 52 |
53 video = document.createElement('video'); | 53 video = document.createElement('video'); |
54 document.body.appendChild(video); | 54 document.body.appendChild(video); |
55 | 55 |
56 trackElement = document.createElement('track'); | 56 trackElement = document.createElement('track'); |
57 video.appendChild(trackElement); | 57 video.appendChild(trackElement); |
58 trackElement.track.mode = "hidden"; | 58 trackElement.track.mode = "hidden"; |
59 trackElement.addEventListener('load', test); | 59 trackElement.addEventListener('load', test); |
60 trackElement.src='data:text/vtt,WEBVTT FILE \r\r1\r00:00:00.000 --> 00:0
0:30.500\ronly one caption'; | 60 trackElement.src='data:text/vtt,WEBVTT FILE \r\r1\r00:00:00.000 --> 00:0
0:30.500\ronly one caption'; |
61 | 61 |
62 </script> | 62 </script> |
63 | 63 |
64 </body> | 64 </body> |
65 </html> | 65 </html> |
OLD | NEW |