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 url = createMediaSourceURL(); |
15 { | 12 // Running garbage collector. |
16 var mediaSource = new MediaSource(); | 13 gc(); |
17 var onSourceOpen = function (e) | |
18 { | |
19 sourceOpened = true; | |
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 | 14 |
28 function start() | 15 // Setting video.src to object URL. |
29 { | 16 video.src = url; |
30 var video = document.getElementById('vid'); | |
31 var onStalled = function (e) | |
32 { | |
33 if (sourceOpened) | |
34 return; | |
35 | 17 |
36 failTest('stalled event fired before sourceopen'); | 18 function createMediaSourceURL() { |
37 }; | 19 var mediaSource = new MediaSource(); |
38 video.addEventListener('stalled', onStalled); | 20 // Setting sourceopen event listener. |
39 | 21 mediaSource.onsourceopen = t.step_func_done(); |
40 var url = createMediaSourceURL(); | 22 return URL.createObjectURL(mediaSource); |
41 consoleWrite("Running garbage collector."); | 23 } |
42 gc(); | 24 }); |
43 | 25 </script> |
44 consoleWrite("Setting video.src to object URL."); | |
45 video.src = url; | |
46 } | |
47 start(); | |
48 </script> | |
49 </body> | |
50 </html> | |
OLD | NEW |