Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / media / media-source / mediasource-garbage-collection-before-sourceopen.html
blob95757b4d10a9ba822e94c3603a5f4954e0a0acb9
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="/media-resources/video-test.js"></script>
5 </head>
6 <body>
7 <video autoplay controls="controls" id='vid'></video>
8 <p>Tests that sourceopen event fires even if garbage collection happens between setting video.src &amp; the sourceopen event.</p>
9 <script type="text/javascript">
10 var sourceOpened = false;
12 function createMediaSourceURL()
14 var mediaSource = new MediaSource();
15 var onSourceOpen = function (e)
17 sourceOpened = true;
18 consoleWrite("onSourceOpen called.");
19 endTest();
21 consoleWrite("Setting sourceopen event listener.");
22 mediaSource.addEventListener('sourceopen', onSourceOpen);
23 return window.URL.createObjectURL(mediaSource);
26 function start()
28 var video = document.getElementById('vid');
29 var onStalled = function (e)
31 if (sourceOpened)
32 return;
34 failTest('stalled event fired before sourceopen');
36 video.addEventListener('stalled', onStalled);
38 var url = createMediaSourceURL();
39 consoleWrite("Running garbage collector.");
40 gc();
42 consoleWrite("Setting video.src to object URL.");
43 video.src = url;
45 start();
46 </script>
47 </body>
48 </html>