OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <title>Ensure that a TextTrack won't be collected if it has a custom property.</
title> |
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> |
| 6 async_test(function(t) { |
| 7 var video = document.createElement('video'); |
| 8 var trackElement = document.createElement('track'); |
5 | 9 |
6 <script src=../media-file.js></script> | 10 trackElement.onload = t.step_func_done(function() { |
7 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 | 11 assert_equals(video.textTracks.length, 1); |
8 (Please avoid writing new tests using video-test.js) --> | 12 assert_equals(video.textTracks[0].kind, 'captions'); |
9 <script src=../video-test.js></script> | |
10 <script> | |
11 | 13 |
12 function forceGC() | 14 video.textTracks[0].myProperty = 'egg salad!?'; |
13 { | 15 assert_equals(video.textTracks[0].myProperty, 'egg salad!?'); |
14 if (window.GCController) | |
15 return GCController.collectAll(); | |
16 | 16 |
| 17 function gcCallback() { |
| 18 assert_equals(video.textTracks[0].cues.length, 4); |
| 19 assert_equals(video.textTracks[0].myProperty, 'egg salad!?'); |
| 20 t.done(); |
| 21 } |
| 22 |
| 23 function forceAsyncGC() { |
| 24 if (GCController) { |
| 25 GCController.collectAll(); |
| 26 } else { |
17 // Force garbage collection | 27 // Force garbage collection |
18 for (var ndx = 0; ndx < 99000; ndx++) | 28 for (var index = 0; index < 99000; index++) |
19 var str = new String("1234"); | 29 var str = new String('1234'); |
20 } | 30 } |
21 | 31 |
22 function trackLoaded() | 32 setTimeout(t.step_func(gcCallback), 0); |
23 { | 33 } |
24 findMediaElement(); | |
25 | 34 |
26 consoleWrite("** Validate."); | 35 forceAsyncGC(); |
27 testExpected("video.textTracks.length", 1); | 36 }); |
28 testExpected("video.textTracks[0].kind", "captions"); | |
29 | 37 |
30 consoleWrite("<br>** Add a custom property to the track."); | 38 trackElement.src = 'captions-webvtt/tc013-settings.vtt'; |
31 run("video.textTracks[0].myProperty = 'egg salad!?'"); | 39 trackElement.kind = 'captions'; |
32 testExpected("video.textTracks[0].myProperty", "egg salad!?"); | 40 trackElement.default = true; |
33 | 41 video.appendChild(trackElement); |
34 consoleWrite("<br>** Force garbage collection."); | 42 }); |
35 forceGC(); | 43 </script> |
36 testExpected("video.textTracks[0].cues.length", 4); | |
37 testExpected("video.textTracks[0].myProperty", "egg salad!?"); | |
38 | |
39 consoleWrite(""); | |
40 endTest(); | |
41 } | |
42 | |
43 </script> | |
44 </head> | |
45 <body> | |
46 <p>Ensure that a TextTrack won't be collected if it has a custom propert
y.</p> | |
47 <video> | |
48 <track src="captions-webvtt/tc013-settings.vtt" kind="captions" onlo
ad="trackLoaded()" default> | |
49 </video> | |
50 </body> | |
51 </html> | |
OLD | NEW |