| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <title>Tests that removing an active cue does not crash the browser.</title> |
| 3 <head> | 3 <script src="../media-file.js"></script> |
| 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | 4 <script src="../../resources/testharness.js"></script> |
| 5 <script src="../../resources/testharnessreport.js"></script> |
| 6 <video></video> |
| 7 <script> |
| 8 async_test(function(t) { |
| 9 var video = document.querySelector("video"); |
| 10 video.src = findMediaFile("video", "../content/test"); |
| 5 | 11 |
| 6 <script src=../media-file.js></script> | 12 // Add a text track to the video element. |
| 7 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 | 13 video.addTextTrack("captions", "regular captions track", "en"); |
| 8 (Please avoid writing new tests using video-test.js) --> | |
| 9 <script src=../video-test.js></script> | |
| 10 <script> | |
| 11 function removeActiveCue() | |
| 12 { | |
| 13 testExpected("video.textTracks[0].activeCues.length", 1); | |
| 14 | 14 |
| 15 consoleWrite(""); | 15 // Add a cue to the track with enter event listener. |
| 16 consoleWrite("** Remove the cue while it is active **"); | 16 var cue = new VTTCue(0, 4, "Random"); |
| 17 video.textTracks[0].removeCue(video.textTracks[0].activeCues[0]); | 17 cue.onenter = t.step_func_done(removeActiveCue); |
| 18 | 18 |
| 19 consoleWrite(""); | 19 var track = video.textTracks[0]; |
| 20 consoleWrite("No crash. PASS."); | 20 track.addCue(cue); |
| 21 consoleWrite(""); | |
| 22 | 21 |
| 23 endTest(); | 22 function removeActiveCue() { |
| 24 } | 23 assert_equals(track.activeCues.length, 1); |
| 25 | 24 |
| 26 function startTest() | 25 // Remove the cue while it is active. |
| 27 { | 26 track.removeCue(track.activeCues[0]); |
| 28 findMediaElement(); | |
| 29 video.src = findMediaFile('video', '../content/test'); | |
| 30 | 27 |
| 31 consoleWrite("** Add a text track to the video element **"); | 28 // No crash. PASS. |
| 32 video.addTextTrack("captions", "regular captions track", "en"); | 29 } |
| 33 | 30 |
| 34 consoleWrite("** Add a cue to the track with enter event listener. *
*"); | 31 // Play the video and remove cue when it becomes active. |
| 35 var cue = new VTTCue(0.00, 4.00, "Random"); | 32 video.play(); |
| 36 cue.addEventListener("enter", removeActiveCue); | 33 track.mode = "showing"; |
| 37 video.textTracks[0].addCue(cue); | 34 }); |
| 38 | 35 </script> |
| 39 consoleWrite(""); | |
| 40 consoleWrite("** Play the video and remove cue when it becomes activ
e. **"); | |
| 41 run("video.play()"); | |
| 42 | |
| 43 video.textTracks[0].mode = "showing"; | |
| 44 } | |
| 45 </script> | |
| 46 </head> | |
| 47 | |
| 48 <body onload="startTest()"> | |
| 49 <p>Tests that removing an active cue does not crash the browser.</p> | |
| 50 <video controls /> | |
| 51 </body> | |
| 52 </html> | |
| OLD | NEW |