OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="/w3c/resources/testharness.js"></script> | 4 <script src="/w3c/resources/testharness.js"></script> |
5 <script src="/w3c/resources/testharnessreport.js"></script> | 5 <script src="/w3c/resources/testharnessreport.js"></script> |
6 <script src="mediasource-util.js"></script> | 6 <script src="mediasource-util.js"></script> |
7 <link rel='stylesheet' href='/w3c/resources/testharness.css'> | 7 <link rel='stylesheet' href='/w3c/resources/testharness.css'> |
8 </head> | 8 </head> |
9 <body> | 9 <body> |
10 <div id="log"></div> | 10 <div id="log"></div> |
11 <script> | 11 <script> |
12 function DurationBoundaryConditionTest(testDurationValue, expectedErro
r, description) | 12 function DurationBoundaryConditionTest(testDurationValue, expectTypeEr
ror, description) |
13 { | 13 { |
14 return mediasource_testafterdataloaded(function(test, mediaElement
, mediaSource, segmentInfo, sourceBuffer, mediaData) | 14 return mediasource_testafterdataloaded(function(test, mediaElement
, mediaSource, segmentInfo, sourceBuffer, mediaData) |
15 { | 15 { |
16 // Append initialization segment. | 16 // Append initialization segment. |
17 test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer'); | 17 test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer'); |
18 test.expectEvent(mediaElement, 'loadedmetadata', 'mediaElement
'); | 18 test.expectEvent(mediaElement, 'loadedmetadata', 'mediaElement
'); |
19 sourceBuffer.appendBuffer(MediaSourceUtil.extractSegmentData(m
ediaData, segmentInfo.init)); | 19 sourceBuffer.appendBuffer(MediaSourceUtil.extractSegmentData(m
ediaData, segmentInfo.init)); |
20 test.waitForExpectedEvents(function() | 20 test.waitForExpectedEvents(function() |
21 { | 21 { |
22 if (expectedError) { | 22 if (expectTypeError) { |
23 assert_throws(expectedError, | 23 assert_throws({name: "TypeError"}, |
24 function() { mediaSource.duration = testDurationVa
lue; }, | 24 function() { mediaSource.duration = testDurationVa
lue; }, |
25 "mediaSource.duration assignment throws an excepti
on for " + testDurationValue); | 25 "mediaSource.duration assignment throws an excepti
on for " + testDurationValue); |
26 test.done(); | 26 test.done(); |
27 return; | 27 return; |
28 } | 28 } |
29 | 29 |
30 mediaSource.duration = testDurationValue; | 30 mediaSource.duration = testDurationValue; |
31 | 31 |
32 assert_equals(mediaSource.duration, testDurationValue, "me
diaSource.duration"); | 32 assert_equals(mediaSource.duration, testDurationValue, "me
diaSource.duration"); |
33 assert_equals(mediaElement.duration, testDurationValue, "m
ediaElement.duration"); | 33 assert_equals(mediaElement.duration, testDurationValue, "m
ediaElement.duration"); |
34 | 34 |
35 test.expectEvent(mediaElement, 'durationchange', 'mediaEle
ment'); | 35 test.expectEvent(mediaElement, 'durationchange', 'mediaEle
ment'); |
36 test.waitForExpectedEvents(function() | 36 test.waitForExpectedEvents(function() |
37 { | 37 { |
38 assert_equals(mediaSource.duration, testDurationValue,
"mediaSource.duration"); | 38 assert_equals(mediaSource.duration, testDurationValue,
"mediaSource.duration"); |
39 assert_equals(mediaElement.duration, testDurationValue
, "mediaElement.duration"); | 39 assert_equals(mediaElement.duration, testDurationValue
, "mediaElement.duration"); |
40 test.done(); | 40 test.done(); |
41 }); | 41 }); |
42 }); | 42 }); |
43 | 43 |
44 }, description); | 44 }, description); |
45 } | 45 } |
46 | 46 |
47 DurationBoundaryConditionTest(Math.pow(2, 31) - 1, null, "Set duration
to 2^31 - 1"); | 47 DurationBoundaryConditionTest(Math.pow(2, 31) - 1, false, "Set duratio
n to 2^31 - 1"); |
48 DurationBoundaryConditionTest(1, null, "Set duration to 1"); | 48 DurationBoundaryConditionTest(1, false, "Set duration to 1"); |
49 DurationBoundaryConditionTest(Number.MAX_VALUE, null, "Set duration to
Number.MAX_VALUE"); | 49 DurationBoundaryConditionTest(Number.MAX_VALUE, false, "Set duration t
o Number.MAX_VALUE"); |
50 DurationBoundaryConditionTest(Number.MIN_VALUE, null, "Set duration to
Number.MIN_VALUE"); | 50 DurationBoundaryConditionTest(Number.MIN_VALUE, false, "Set duration t
o Number.MIN_VALUE"); |
51 DurationBoundaryConditionTest(Number.MAX_VALUE - 1, null, "Set duratio
n to Number.MAX_VALUE - 1"); | 51 DurationBoundaryConditionTest(Number.MAX_VALUE - 1, false, "Set durati
on to Number.MAX_VALUE - 1"); |
52 DurationBoundaryConditionTest(Number.MIN_VALUE - 1, "InvalidAccessErro
r", "Set duration to Number.MIN_VALUE - 1"); | 52 DurationBoundaryConditionTest(Number.MIN_VALUE - 1, true, "Set duratio
n to Number.MIN_VALUE - 1"); |
53 DurationBoundaryConditionTest(Number.POSITIVE_INFINITY, null, "Set dur
ation to Number.POSITIVE_INFINITY"); | 53 DurationBoundaryConditionTest(Number.POSITIVE_INFINITY, false, "Set du
ration to Number.POSITIVE_INFINITY"); |
54 DurationBoundaryConditionTest(Number.NEGATIVE_INFINITY, "InvalidAccess
Error", "Set duration to Number.NEGATIVE_INFINITY"); | 54 DurationBoundaryConditionTest(Number.NEGATIVE_INFINITY, true, "Set dur
ation to Number.NEGATIVE_INFINITY"); |
55 DurationBoundaryConditionTest(-1 * Number.MAX_VALUE, "InvalidAccessErr
or", "Set duration to lowest value."); | 55 DurationBoundaryConditionTest(-1 * Number.MAX_VALUE, true, "Set durati
on to lowest value."); |
56 DurationBoundaryConditionTest(-101.9, "InvalidAccessError", "Set durat
ion to a negative double."); | 56 DurationBoundaryConditionTest(-101.9, true, "Set duration to a negativ
e double."); |
57 DurationBoundaryConditionTest(101.9, null, "Set duration to a positive
double."); | 57 DurationBoundaryConditionTest(101.9, false, "Set duration to a positiv
e double."); |
58 DurationBoundaryConditionTest(0, null, "Set duration to zero"); | 58 DurationBoundaryConditionTest(0, false, "Set duration to zero"); |
59 DurationBoundaryConditionTest(NaN, "InvalidAccessError", "Set duration
to NaN"); | 59 DurationBoundaryConditionTest(NaN, true, "Set duration to NaN"); |
60 </script> | 60 </script> |
61 </body> | 61 </body> |
62 </html> | 62 </html> |
OLD | NEW |