OLD | NEW |
---|---|
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <title>Tests that "sourceopen" event fires even if garbage collection happens be tween setting "video.src" and the "sourceopen" event.</title> |
3 <head> | 3 <script src="/w3c/resources/testharness.js"></script> |
4 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 4 <script src="/w3c/resources/testharnessreport.js"></script> |
5 (Please avoid writing new tests using video-test.js) --> | 5 <video></video> |
6 <script src="/media-resources/video-test.js"></script> | 6 <script> |
7 </head> | 7 async_test(function(t) { |
8 <body> | 8 var video = document.querySelector('video'); |
9 <video autoplay controls="controls" id='vid'></video> | 9 video.onstalled = t.unreached_func(); |
10 <p>Tests that sourceopen event fires even if garbage collection happens between setting video.src & the sourceopen event.</p> | |
11 <script type="text/javascript"> | |
12 var sourceOpened = false; | |
13 | 10 |
14 function createMediaSourceURL() | 11 var mediaSource = new MediaSource(); |
fs
2016/07/28 17:18:03
It may be reasonable to keep this helper, to avoid
Srirama
2016/07/29 10:21:28
Done.
| |
15 { | 12 // Setting sourceopen event listener. |
16 var mediaSource = new MediaSource(); | 13 mediaSource.onsourceopen = t.step_func_done(); |
17 var onSourceOpen = function (e) | 14 var url = URL.createObjectURL(mediaSource); |
18 { | 15 // Running garbage collector. |
19 sourceOpened = true; | 16 gc(); |
20 consoleWrite("onSourceOpen called."); | |
21 endTest(); | |
22 }; | |
23 consoleWrite("Setting sourceopen event listener."); | |
24 mediaSource.addEventListener('sourceopen', onSourceOpen); | |
25 return window.URL.createObjectURL(mediaSource); | |
26 } | |
27 | 17 |
28 function start() | 18 // Setting video.src to object URL. |
29 { | 19 video.src = url; |
30 var video = document.getElementById('vid'); | 20 }); |
31 var onStalled = function (e) | 21 </script> |
32 { | |
33 if (sourceOpened) | |
34 return; | |
35 | |
36 failTest('stalled event fired before sourceopen'); | |
37 }; | |
38 video.addEventListener('stalled', onStalled); | |
39 | |
40 var url = createMediaSourceURL(); | |
41 consoleWrite("Running garbage collector."); | |
42 gc(); | |
43 | |
44 consoleWrite("Setting video.src to object URL."); | |
45 video.src = url; | |
46 } | |
47 start(); | |
48 </script> | |
49 </body> | |
50 </html> | |
OLD | NEW |