Chromium Code Reviews| Index: LayoutTests/http/tests/media/media-source/mediasource-appendwindow.html |
| diff --git a/LayoutTests/http/tests/media/media-source/mediasource-appendwindow.html b/LayoutTests/http/tests/media/media-source/mediasource-appendwindow.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1323440e7b518520b213c895bd5a7cb30e661995 |
| --- /dev/null |
| +++ b/LayoutTests/http/tests/media/media-source/mediasource-appendwindow.html |
| @@ -0,0 +1,131 @@ |
| +<!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> |
| + var mediaType = 'video/webm;codecs="vp8,vorbis"'; |
| + |
| + mediasource_loaddata_test = function(callback, description) |
| + { |
| + mediasource_test(function(test, mediaElement, mediaSource) |
| + { |
| + var mediaURL = '/media/resources/media-source/webm/test.webm'; |
| + var sourceBuffer = mediaSource.addSourceBuffer(mediaType); |
| + MediaSourceUtil.loadBinaryData(test, mediaURL, function(mediaData) |
| + { |
| + callback(test, mediaElement, mediaSource, sourceBuffer, mediaData); |
| + |
| + }); |
| + }, description); |
| + }; |
| + |
| + mediasource_test(function(test, mediaElement, mediaSource) |
| + { |
| + var sourceBuffer = mediaSource.addSourceBuffer(mediaType); |
| + assert_true(sourceBuffer != null, "New SourceBuffer returned"); |
| + |
| + sourceBuffer.appendWindowStart = 100.0; |
| + sourceBuffer.appendWindowEnd = 500.0; |
| + assert_equals(sourceBuffer.appendWindowStart, 100.0, "appendWindowStart is correctly set'"); |
| + assert_equals(sourceBuffer.appendWindowEnd, 500.0, "appendWindowEnd is correctly set'"); |
| + |
| + sourceBuffer.appendWindowStart = 200.0; |
| + sourceBuffer.appendWindowEnd = 400.0; |
| + assert_equals(sourceBuffer.appendWindowStart, 200.0, "appendWindowStart is correctly reset'"); |
| + assert_equals(sourceBuffer.appendWindowEnd, 400.0, "appendWindowEnd is correctly reset'"); |
| + test.done(); |
| + }, "Test correctly reset appendWindowStart and appendWindowEnd values"); |
| + |
| + mediasource_test(function(test, mediaElement, mediaSource) |
| + { |
| + var sourceBuffer = mediaSource.addSourceBuffer(mediaType); |
| + assert_true(sourceBuffer != null, "New SourceBuffer returned"); |
| + sourceBuffer.appendWindowEnd = 500.0; |
| + |
| + assert_throws("TypeMismatchError", |
| + function() { sourceBuffer.appendWindowStart = Number.NEGATIVE_INFINITY; }, |
| + "set appendWindowStart throws an exception for Number.NEGATIVE_INFINITY."); |
| + |
| + assert_throws("TypeMismatchError", |
| + function() { sourceBuffer.appendWindowStart = Number.POSITIVE_INFINITY; }, |
| + "set appendWindowStart throws an exception for Number.POSITIVE_INFINITY."); |
| + |
| + assert_throws("TypeMismatchError", |
| + function() { sourceBuffer.appendWindowStart = Number.NaN; }, |
| + "set appendWindowStart throws an exception for Number.NaN."); |
| + |
| + assert_throws("InvalidAccessError", |
| + function() { sourceBuffer.appendWindowStart = 600.0; }, |
| + "set appendWindowStart throws an exception when greater than appendWindowEnd."); |
| + |
| + assert_throws("InvalidAccessError", |
| + function() { sourceBuffer.appendWindowStart = -100.0; }, |
| + "set appendWindowStart throws an exception when less than 0."); |
| + |
| + assert_throws("InvalidAccessError", |
| + function() { sourceBuffer.appendWindowEnd = Number.NaN; }, |
| + "set appendWindowEnd throws an exception if NaN."); |
| + test.done(); |
| + }, "Test set wrong values to appendWindowStart and appendWindowEnd."); |
| + |
| + mediasource_loaddata_test(function(test, mediaElement, mediaSource, sourceBuffer, mediaData) |
| + { |
| + sourceBuffer.appendBuffer(mediaData); |
|
acolwell GONE FROM CHROMIUM
2013/08/07 16:15:56
nit: Do you actually need the appendBuffer() here?
|
| + |
| + mediaSource.removeSourceBuffer(sourceBuffer); |
| + assert_throws("InvalidStateError", |
| + function() { sourceBuffer.appendWindowStart = 100.0; }, |
| + "set appendWindowStart throws an exception when mediasource object is not associated with a buffer."); |
| + |
| + assert_throws("InvalidStateError", |
| + function() { sourceBuffer.appendWindowEnd = 500.0; }, |
| + "set appendWindowEnd throws an exception when mediasource object is not associated with a buffer."); |
| + test.done(); |
| + |
| + }, "Test appendwindow throw error when mediasource object is not associated with a sourebuffer."); |
| + |
| + mediasource_loaddata_test(function(test, mediaElement, mediaSource, sourceBuffer, mediaData) |
| + { |
| + sourceBuffer.appendBuffer(mediaData); |
|
acolwell GONE FROM CHROMIUM
2013/08/07 16:15:56
nit: You need a 'test.expectEvent(sourceBuffer, "u
|
| + assert_true(sourceBuffer.updating, "updating attribute is true"); |
| + |
| + assert_throws("InvalidStateError", |
| + function() { sourceBuffer.appendWindowStart = 100.0; }, |
| + "set appendWindowStart throws an exception when there is a pending append."); |
| + |
| + assert_throws("InvalidStateError", |
| + function() { sourceBuffer.appendWindowEnd = 500.0; }, |
| + "set appendWindowEnd throws an exception when there is a pending append."); |
| + |
| + test.waitForExpectedEvents(function() |
| + { |
| + assert_false(sourceBuffer.updating, "updating attribute is false"); |
| + test.done(); |
| + }); |
| + }, "Test set appendWindowStart and appendWindowEnd when source buffer updating."); |
| + |
| + mediasource_loaddata_test(function(test, mediaElement, mediaSource, sourceBuffer, mediaData) |
| + { |
| + sourceBuffer.appendBuffer(mediaData); |
|
acolwell GONE FROM CHROMIUM
2013/08/07 16:15:56
nit: You need a 'test.expectEvent(sourceBuffer, "u
|
| + assert_true(sourceBuffer.updating, "updating attribute is true"); |
| + |
| + sourceBuffer.abort(); |
| + assert_equals(sourceBuffer.appendWindowStart, 0, "appendWindowStart is 0 after an abort'"); |
| + assert_equals(sourceBuffer.appendWindowEnd, Number.POSITIVE_INFINITY, |
| + "appendWindowStart is POSITIVE_INFINITY after an abort"); |
| + test.waitForExpectedEvents(function() |
| + { |
| + assert_false(sourceBuffer.updating, "updating attribute is false"); |
| + test.done(); |
| + }); |
| + }, "Test appendWindowStart and appendWindowEnd value after a sourceBuffer.abort()."); |
| + |
| + </script> |
| + </body> |
| +</html> |