Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-addsourcebuffer.html |
| diff --git a/third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-addsourcebuffer.html b/third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-addsourcebuffer.html |
| index 2fe975473577e630e711e79848d6ac0d7b5f6045..088fa5f2ca957a5de07297c6174d4989949b268a 100644 |
| --- a/third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-addsourcebuffer.html |
| +++ b/third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-addsourcebuffer.html |
| @@ -39,7 +39,7 @@ |
| "addSourceBuffer() threw an exception when passed null."); |
| test.done(); |
| }, "Test addSourceBuffer() with null"); |
| - |
| + |
| mediasource_test(function(test, mediaElement, mediaSource) |
| { |
| assert_throws("NotSupportedError", |
| @@ -90,7 +90,7 @@ |
| assert_equals(mediaSource.activeSourceBuffers.length, 0, "SourceBuffer is not in mediaSource.activeSourceBuffers"); |
| test.done(); |
| }, "Test addSourceBuffer() video only"); |
| - |
| + |
| mediasource_test(function(test, mediaElement, mediaSource) |
| { |
| var mimetype = MediaSourceUtil.AUDIO_ONLY_TYPE; |
| @@ -134,24 +134,46 @@ |
| test.done(); |
| }, "Test addSourceBuffer() with AAC and H.264 in separate SourceBuffers"); |
| - mediasource_test(function(test, mediaElement, mediaSource) |
| + mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData) |
| { |
| - var reachedLimit = false; |
| - |
| - // The 20 here is an arbitrary upper limit to make sure the test terminates. This test |
| - // assumes that implementations won't support more than 20 SourceBuffers simultaneously. |
| - for (var i = 0; i < 20; ++i) { |
| - try { |
| - mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_VIDEO_TYPE); |
| - } catch(e) { |
| - assert_equals(e.name, "QuotaExceededError"); |
| - reachedLimit = true; |
| - break; |
| - } |
| - } |
| - assert_true(reachedLimit, "Reached SourceBuffer limit."); |
| - test.done(); |
| - }, "Test addSourceBuffer() QuotaExceededError."); |
| + test.expectEvent(sourceBuffer, "updateend"); |
| + sourceBuffer.appendBuffer(mediaData); |
| + test.waitForExpectedEvents(function() |
| + { |
| + assert_throws({name: "QuotaExceededError"}, |
| + function() { mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_VIDEO_TYPE); }, |
| + "addSourceBuffer must throw an exception if the MediaSource has already got some data"); |
|
wolenetz
2016/09/15 01:00:08
nit: s/has already.../has already received init se
servolk
2016/09/15 02:13:07
Done.
|
| + test.done(); |
| + }); |
| + }, "Test addSourceBuffer() throws QuotaExceededError after data has been appended."); |
| + |
| + mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData) |
| + { |
| + var initSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.init); |
| + // Append incomplete init segment to the first SourceBuffer. |
| + sourceBuffer.appendBuffer(initSegment.slice(0, initSegment.length - 1)); |
| + test.expectEvent(sourceBuffer, "updateend"); |
| + test.waitForExpectedEvents(function() |
| + { |
| + // We have not added a full init segment for the first SourceBuffer yet, so MediaSource init is not yet |
| + // finished and we should be able to add/remove one more SourceBuffer. |
| + var sourceBuffer2 = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_VIDEO_TYPE); |
| + mediaSource.removeSourceBuffer(sourceBuffer2); |
| + |
| + // Now append the rest of the init segment, this should complete the initialization of the MediaSource. |
| + test.expectEvent(sourceBuffer, "updateend"); |
| + test.expectEvent(mediaElement, "loadedmetadata", "mediaElement metadata."); |
| + sourceBuffer.appendBuffer(initSegment.slice(initSegment.length - 1)); |
| + test.waitForExpectedEvents(function() |
|
wolenetz
2016/09/15 01:00:08
nit: This wait doesn't need to nest inside the pre
servolk
2016/09/15 02:13:07
Done.
|
| + { |
| + // MediaSource is fully initialized now, so adding new SourceBuffers is no longer possible. |
|
wolenetz
2016/09/15 01:00:08
nit: assert_equals(mediaElement.readyState, HTMLMe
servolk
2016/09/15 02:13:07
Done.
|
| + assert_throws({name: "QuotaExceededError"}, |
| + function() { mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_VIDEO_TYPE); }, |
| + "addSourceBuffer must throw an exception if the MediaSource has already got some data"); |
|
wolenetz
2016/09/15 01:00:08
nit ditto of previous test.
servolk
2016/09/15 02:13:07
Done.
|
| + test.done(); |
| + }); |
| + }); |
| + }, "Test addSourceBuffer() succeeds while incomplete init segment is appended, fails after MediaSource init done."); |
| </script> |
| </body> |
| </html> |