Index: LayoutTests/http/tests/media/media-source/mediasource-duration-boundaryconditions.html |
diff --git a/LayoutTests/http/tests/media/media-source/mediasource-duration-boundaryconditions.html b/LayoutTests/http/tests/media/media-source/mediasource-duration-boundaryconditions.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8dbec0bc07c2f33c0029fac425ca2f901113c8f9 |
--- /dev/null |
+++ b/LayoutTests/http/tests/media/media-source/mediasource-duration-boundaryconditions.html |
@@ -0,0 +1,62 @@ |
+<!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 DurationBoundaryConditionTest(testDurationValue, expectedError, description) |
+ { |
+ return mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData) |
+ { |
+ // Append initialization segment. |
+ test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer'); |
+ test.expectEvent(mediaElement, 'loadedmetadata', 'mediaElement'); |
+ sourceBuffer.appendBuffer(MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.init)); |
+ test.waitForExpectedEvents(function() |
+ { |
+ if (expectedError) { |
+ assert_throws(expectedError, |
+ function() { mediaSource.duration = testDurationValue; }, |
+ "mediaSource.duration assignment throws an exception for " + testDurationValue); |
+ test.done(); |
+ return; |
+ } |
+ |
+ mediaSource.duration = testDurationValue; |
+ |
+ assert_equals(mediaSource.duration, testDurationValue, "mediaSource.duration"); |
+ assert_equals(mediaElement.duration, testDurationValue, "mediaElement.duration"); |
+ |
+ test.expectEvent(mediaElement, 'durationchange', 'mediaElement'); |
+ test.waitForExpectedEvents(function() |
+ { |
+ assert_equals(mediaSource.duration, testDurationValue, "mediaSource.duration"); |
+ assert_equals(mediaElement.duration, testDurationValue, "mediaElement.duration"); |
+ test.done(); |
+ }); |
+ }); |
+ |
+ }, description); |
+ } |
+ |
+ DurationBoundaryConditionTest(Math.pow(2, 31) - 1, null, "Set duration to 2^31 - 1"); |
+ DurationBoundaryConditionTest(1, null, "Set duration to 1"); |
+ DurationBoundaryConditionTest(Number.MAX_VALUE, null, "Set duration to Number.MAX_VALUE"); |
+ DurationBoundaryConditionTest(Number.MIN_VALUE, null, "Set duration to Number.MIN_VALUE"); |
+ DurationBoundaryConditionTest(Number.MAX_VALUE - 1, null, "Set duration to Number.MAX_VALUE - 1"); |
+ DurationBoundaryConditionTest(Number.MIN_VALUE - 1, "InvalidAccessError", "Set duration to Number.MIN_VALUE - 1"); |
+ DurationBoundaryConditionTest(Number.POSITIVE_INFINITY, null, "Set duration to Number.POSITIVE_INFINITY"); |
+ DurationBoundaryConditionTest(Number.NEGATIVE_INFINITY, "InvalidAccessError", "Set duration to Number.NEGATIVE_INFINITY"); |
+ DurationBoundaryConditionTest(-1 * Number.MAX_VALUE, "InvalidAccessError", "Set duration to lowest value."); |
+ DurationBoundaryConditionTest(-101.9, "InvalidAccessError", "Set duration to a negative double."); |
+ DurationBoundaryConditionTest(101.9, null, "Set duration to a positive double."); |
+ DurationBoundaryConditionTest(0, null, "Set duration to zero"); |
+ DurationBoundaryConditionTest(NaN, "InvalidAccessError", "Set duration to NaN"); |
+ </script> |
+ </body> |
+</html> |