OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <title>Tests that added cue object wrappers live across garbage collections.</ti
tle> |
3 <head> | 3 <script src="../../resources/testharness.js"></script> |
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | 4 <script src="../../resources/testharnessreport.js"></script> |
| 5 <script src="../media-file.js"></script> |
| 6 <video></video> |
| 7 <script> |
| 8 async_test(function(t) { |
| 9 var cueIndex = 0; |
| 10 var cueLimit = 10; |
| 11 var video = document.querySelector("video"); |
| 12 video.src = findMediaFile("video", "../content/test"); |
5 | 13 |
6 <script src=../media-file.js></script> | 14 video.textTracks.custom = "trackList"; |
7 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 15 assert_true(video.textTracks.hasOwnProperty("custom")); |
8 (Please avoid writing new tests using video-test.js) --> | |
9 <script src=../video-test.js></script> | |
10 <script> | |
11 var cue; | |
12 var track; | |
13 var j = 0; | |
14 var cueLimit = 10; | |
15 | 16 |
16 function checkNativeProperty() | 17 // Add a text track to the video element. |
17 { | 18 var track = video.addTextTrack("captions", "regular captions track", "en"); |
18 cue = this; | 19 track.custom = "track"; |
19 testExpected("cue.hasOwnProperty('custom')", true); | 20 assert_true(track.hasOwnProperty("custom")); |
20 if (++j >= cueLimit) | |
21 endTest(); | |
22 } | |
23 | 21 |
24 function startTest() | 22 // Add cues with own native property to the track with enter event listener. |
25 { | 23 for (var i = 0; i < cueLimit; i++) { |
26 findMediaElement(); | 24 var cue = new VTTCue(i / 4, i / 2 + 1, "Label" + i); |
27 video.src = findMediaFile('video', '../content/test'); | 25 cue.custom = "cue"; |
28 | 26 |
29 video.textTracks.custom = "trackList"; | 27 cue.onenter = t.step_func(function(event) { |
30 testExpected("video.textTracks.hasOwnProperty('custom')", true); | 28 var currentCue = event.target; |
| 29 assert_true(currentCue.hasOwnProperty("custom")); |
| 30 if (++cueIndex == cueLimit) |
| 31 t.done(); |
| 32 }); |
31 | 33 |
32 consoleWrite("** Add a text track to the video element **"); | 34 track.addCue(cue); |
| 35 } |
33 | 36 |
34 track = video.addTextTrack("captions", "regular captions track", "en
"); | 37 for (var i = 0; i < cueLimit; i++) { |
35 track.custom = "track"; | 38 var cue = track.cues[i]; |
36 testExpected("track.hasOwnProperty('custom')", true); | 39 assert_true(cue.hasOwnProperty("custom")); |
| 40 } |
37 | 41 |
38 consoleWrite("** Add cues with own native property to the track with
enter event listener. **"); | 42 // Trigger a garbage collection. |
39 for (var i = 0; i < cueLimit; i++) { | 43 track = null; |
40 var c = new VTTCue(i / 4, i / 2 + 1, "Label" + i); | 44 gc(); |
41 c.custom = "cue"; | |
42 c.addEventListener("enter", checkNativeProperty); | |
43 track.addCue(c); | |
44 c = null; | |
45 } | |
46 for (var i = 0; i < 10; i++) { | |
47 cue = track.cues[i]; | |
48 testExpected("cue.hasOwnProperty('custom')", true); | |
49 } | |
50 | 45 |
51 consoleWrite(""); | 46 assert_true(video.textTracks.hasOwnProperty("custom")); |
52 consoleWrite("** Trigger a garbage collection. **"); | |
53 track = null; | |
54 cue = null; | |
55 gc(); | |
56 | 47 |
57 testExpected("video.textTracks.hasOwnProperty('custom')", true); | 48 track = video.textTracks[0]; |
| 49 assert_true(track.hasOwnProperty("custom")); |
58 | 50 |
59 track = video.textTracks[0]; | 51 // Play the video and test cue wrappers. |
60 testExpected("track.hasOwnProperty('custom')", true); | 52 video.play(); |
61 | 53 track.mode = "showing"; |
62 consoleWrite(""); | 54 }); |
63 consoleWrite("** Play the video and test cue wrappers. **"); | 55 </script> |
64 run("video.play()"); | |
65 track.mode = "showing"; | |
66 } | |
67 </script> | |
68 </head> | |
69 | |
70 <body onload="startTest()"> | |
71 <p>Tests that added cue object wrappers live across garbage collections.
</p> | |
72 <video controls /> | |
73 </body> | |
74 </html> | |
OLD | NEW |