OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <html> | |
3 <head> | |
4 <script src="/js-test-resources/js-test.js"></script> | |
5 <script src="/media-resources/video-test.js"></script> | |
6 <script src="/w3c/resources/testharness.js"></script> | |
7 <script src="/w3c/resources/testharnessreport.js"></script> | |
8 <script src="mediasource-util.js"></script> | |
9 </head> | |
10 <body> | |
11 <div id="log"></div> | |
12 <video id="vid"></video> | |
13 <script> | |
14 window.jsTestIsAsync = true; | |
15 | |
16 async_test(function(test) | |
17 { | |
18 var ms = new MediaSource(); | |
19 | |
20 function sourceOpened() | |
21 { | |
22 consoleWrite("sourceOpened called."); | |
23 var vid = document.getElementById('vid'); | |
24 var buffer = ms.addSourceBuffer('video/webm; codecs="vorbis,vp
8"'); | |
25 | |
26 consoleWrite("Removing video element from DOM."); | |
27 vid.parentNode.removeChild(vid); | |
28 vid = null; | |
29 | |
30 consoleWrite("Running the garbage collector."); | |
31 asyncGC(test.step_func(function() | |
32 { | |
33 assert_equals(ms.readyState, "closed", "MediaSource object
is closed."); | |
34 | |
35 assert_throws( { name: "InvalidStateError"} , | |
36 function() { buffer.timestampOffset = 42; }, | |
37 "buffer.timestampOffset threw an exception as expected
in the 'closed' state."); | |
38 | |
39 test.done(); | |
40 })); | |
41 } | |
42 | |
43 function sourceClosed() | |
44 { | |
45 consoleWrite("sourceClosed called."); | |
46 } | |
47 | |
48 ms.addEventListener('sourceopen', test.step_func(sourceOpened)); | |
49 ms.addEventListener('sourceclose', test.step_func(sourceClosed)); | |
50 document.getElementById('vid').src = window.URL.createObjectURL(ms
); | |
51 }, "Tests that the MediaSource is closed when the HTMLMediaElement is
destroyed."); | |
52 </script> | |
53 </body> | |
54 </html> | |
OLD | NEW |