Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(475)

Unified Diff: LayoutTests/http/tests/media/media-source/mediasource-errors.html

Issue 245893002: Improve unprefixed MediaSource test coverage. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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>

Powered by Google App Engine
This is Rietveld 408576698