Index: LayoutTests/http/tests/media/media-source/mediasource-closed-on-htmlmediaelement-destruction.html |
diff --git a/LayoutTests/http/tests/media/media-source/mediasource-closed-on-htmlmediaelement-destruction.html b/LayoutTests/http/tests/media/media-source/mediasource-closed-on-htmlmediaelement-destruction.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..15c027d546347040a9d44be1c468374ca5583be1 |
--- /dev/null |
+++ b/LayoutTests/http/tests/media/media-source/mediasource-closed-on-htmlmediaelement-destruction.html |
@@ -0,0 +1,54 @@ |
+<!DOCTYPE html> |
+<html> |
+ <head> |
+ <script src="/js-test-resources/js-test.js"></script> |
+ <script src="/media-resources/video-test.js"></script> |
+ <script src="/w3c/resources/testharness.js"></script> |
+ <script src="/w3c/resources/testharnessreport.js"></script> |
+ <script src="mediasource-util.js"></script> |
+ </head> |
+ <body> |
+ <div id="log"></div> |
+ <video id="vid"></video> |
+ <script> |
+ window.jsTestIsAsync = true; |
+ |
+ async_test(function(test) |
+ { |
+ var ms = new MediaSource(); |
+ |
+ function sourceOpened() |
+ { |
+ consoleWrite("sourceOpened called."); |
+ var vid = document.getElementById('vid'); |
+ var buffer = ms.addSourceBuffer('video/webm; codecs="vorbis,vp8"'); |
+ |
+ consoleWrite("Removing video element from DOM."); |
+ vid.parentNode.removeChild(vid); |
+ vid = null; |
+ |
+ consoleWrite("Running the garbage collector."); |
+ asyncGC(test.step_func(function() |
+ { |
+ assert_equals(ms.readyState, "closed", "MediaSource object is closed."); |
+ |
+ assert_throws( { name: "InvalidStateError"} , |
+ function() { buffer.timestampOffset = 42; }, |
+ "buffer.timestampOffset threw an exception as expected in the 'closed' state."); |
+ |
+ test.done(); |
+ })); |
+ } |
+ |
+ function sourceClosed() |
+ { |
+ consoleWrite("sourceClosed called."); |
+ } |
+ |
+ ms.addEventListener('sourceopen', test.step_func(sourceOpened)); |
+ ms.addEventListener('sourceclose', test.step_func(sourceClosed)); |
+ document.getElementById('vid').src = window.URL.createObjectURL(ms); |
+ }, "Tests that the MediaSource is closed when the HTMLMediaElement is destroyed."); |
+ </script> |
+ </body> |
+</html> |