Index: LayoutTests/http/tests/media/media-source/mediasource-errors.html |
diff --git a/LayoutTests/http/tests/media/media-source/mediasource-errors.html b/LayoutTests/http/tests/media/media-source/mediasource-errors.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6f61b0e558531cbecd0bd2f5a1655ee01067559f |
--- /dev/null |
+++ b/LayoutTests/http/tests/media/media-source/mediasource-errors.html |
@@ -0,0 +1,156 @@ |
+<!DOCTYPE html> |
+<html> |
+ <head> |
+ <script src="/w3c/resources/testharness.js"></script> |
+ <script src="/w3c/resources/testharnessreport.js"></script> |
+ <script src="mediasource-util.js"></script> |
+ <link rel='stylesheet' href='/w3c/resources/testharness.css'> |
+ </head> |
+ <body> |
+ <div id="log"></div> |
+ <script> |
+ function ErrorTest(testFunction, description) |
+ { |
+ mediasource_test(function(test, mediaElement, mediaSource) |
+ { |
+ var segmentInfo = MediaSourceUtil.SEGMENT_INFO; |
+ |
+ if (!segmentInfo) { |
+ assert_unreached("No segment info compatible with this MediaSource implementation."); |
+ return; |
+ } |
+ |
+ var sourceBuffer = mediaSource.addSourceBuffer(segmentInfo.type); |
+ MediaSourceUtil.loadBinaryData(test, segmentInfo.url, function(mediaData) |
+ { |
+ testFunction(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData); |
+ }); |
+ }, description); |
+ } |
+ |
+ ErrorTest(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData) |
+ { |
+ var mediaSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.media[0]); |
+ |
+ test.expectEvent(sourceBuffer, "updateend", "mediaSegment append ended."); |
+ test.expectEvent(mediaElement, "error", "mediaElement error."); |
+ test.expectEvent(mediaSource, "sourceclose", "mediaSource closed."); |
+ sourceBuffer.appendBuffer(mediaSegment); |
+ |
+ test.waitForExpectedEvents(function() |
+ { |
+ assert_true(mediaElement.error != null); |
+ assert_equals(mediaElement.error.code, MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED); |
+ |
+ assert_equals(mediaSource.sourceBuffers.length, 0); |
+ assert_equals(mediaSource.readyState, "closed"); |
+ test.done(); |
+ }); |
+ }, "Appending media segment before the first initialization segment."); |
+ |
+ ErrorTest(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData) |
+ { |
+ assert_equals(mediaElement.readyState, HTMLMediaElement.HAVE_NOTHING); |
+ |
+ test.expectEvent(mediaElement, "error", "mediaElement error."); |
+ test.expectEvent(mediaSource, "sourceended", "mediaSource ended."); |
+ test.expectEvent(mediaSource, "sourceclose", "mediaSource closed."); |
+ |
+ mediaSource.endOfStream("decode"); |
+ |
+ test.waitForExpectedEvents(function() |
+ { |
+ assert_true(mediaElement.error != null); |
+ assert_equals(mediaElement.error.code, MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED); |
+ |
+ assert_equals(mediaSource.sourceBuffers.length, 0); |
+ assert_equals(mediaSource.readyState, "closed"); |
+ test.done(); |
+ }); |
+ }, "Signaling 'decode' error via endOfStream() before initialization segment has been appended."); |
+ |
+ ErrorTest(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData) |
+ { |
+ assert_equals(mediaElement.readyState, HTMLMediaElement.HAVE_NOTHING); |
+ |
+ test.expectEvent(mediaElement, "error", "mediaElement error."); |
+ test.expectEvent(mediaSource, "sourceended", "mediaSource ended."); |
+ test.expectEvent(mediaSource, "sourceclose", "mediaSource closed."); |
+ |
+ mediaSource.endOfStream("network"); |
+ |
+ test.waitForExpectedEvents(function() |
+ { |
+ assert_true(mediaElement.error != null); |
+ assert_equals(mediaElement.error.code, MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED); |
+ |
+ assert_equals(mediaSource.sourceBuffers.length, 0); |
+ assert_equals(mediaSource.readyState, "closed"); |
+ test.done(); |
+ }); |
+ }, "Signaling 'network' error via endOfStream() before initialization segment has been appended."); |
+ |
+ ErrorTest(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData) |
+ { |
+ var initSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.init); |
+ assert_equals(mediaElement.readyState, HTMLMediaElement.HAVE_NOTHING); |
+ |
+ test.expectEvent(sourceBuffer, "updateend", "mediaSegment append ended."); |
+ test.expectEvent(mediaElement, "loadedmetadata", "mediaElement metadata."); |
+ sourceBuffer.appendBuffer(initSegment); |
+ |
+ test.waitForExpectedEvents(function() |
+ { |
+ assert_equals(mediaElement.readyState, HTMLMediaElement.HAVE_METADATA); |
+ |
+ test.expectEvent(mediaElement, "error", "mediaElement error."); |
+ test.expectEvent(mediaSource, "sourceended", "mediaSource ended."); |
+ test.expectEvent(mediaSource, "sourceclose", "mediaSource closed."); |
+ |
+ mediaSource.endOfStream("decode"); |
+ }); |
+ |
+ test.waitForExpectedEvents(function() |
+ { |
+ assert_true(mediaElement.error != null); |
+ assert_equals(mediaElement.error.code, MediaError.MEDIA_ERR_DECODE); |
+ |
+ assert_equals(mediaSource.sourceBuffers.length, 0); |
+ assert_equals(mediaSource.readyState, "closed"); |
+ test.done(); |
+ }); |
+ }, "Signaling 'decode' error via endOfStream() after initialization segment has been appended and the HTMLMediaElement has reached HAVE_METADATA."); |
+ |
+ ErrorTest(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData) |
+ { |
+ var initSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.init); |
+ assert_equals(mediaElement.readyState, HTMLMediaElement.HAVE_NOTHING); |
+ |
+ test.expectEvent(sourceBuffer, "updateend", "mediaSegment append ended."); |
+ test.expectEvent(mediaElement, "loadedmetadata", "mediaElement metadata."); |
+ sourceBuffer.appendBuffer(initSegment); |
+ |
+ test.waitForExpectedEvents(function() |
+ { |
+ assert_equals(mediaElement.readyState, HTMLMediaElement.HAVE_METADATA); |
+ |
+ test.expectEvent(mediaElement, "error", "mediaElement error."); |
+ test.expectEvent(mediaSource, "sourceended", "mediaSource ended."); |
+ test.expectEvent(mediaSource, "sourceclose", "mediaSource closed."); |
+ |
+ mediaSource.endOfStream("network"); |
+ }); |
+ |
+ test.waitForExpectedEvents(function() |
+ { |
+ assert_true(mediaElement.error != null); |
+ assert_equals(mediaElement.error.code, MediaError.MEDIA_ERR_NETWORK); |
+ |
+ assert_equals(mediaSource.sourceBuffers.length, 0); |
+ assert_equals(mediaSource.readyState, "closed"); |
+ test.done(); |
+ }); |
+ }, "Signaling 'network' error via endOfStream() after initialization segment has been appended and the HTMLMediaElement has reached HAVE_METADATA."); |
+ </script> |
+ </body> |
+</html> |