OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <script src="/w3c/resources/testharness.js"></script> |
| 5 <script src="/w3c/resources/testharnessreport.js"></script> |
| 6 <script src="mediasource-util.js"></script> |
| 7 <link rel='stylesheet' href='/w3c/resources/testharness.css'> |
| 8 </head> |
| 9 <body> |
| 10 <div id="log"></div> |
| 11 <script> |
| 12 function simpleTimestampOffsetTest(value, expected, description) |
| 13 { |
| 14 mediasource_test(function(test, mediaElement, mediaSource) |
| 15 { |
| 16 var segmentInfo = MediaSourceUtil.SEGMENT_INFO; |
| 17 var sourceBuffer = mediaSource.addSourceBuffer(segmentInfo.typ
e); |
| 18 |
| 19 if (expected == 'TypeMismatchError') { |
| 20 assert_throws('TypeMismatchError', |
| 21 function() { sourceBuffer.timestampOffset = value; }, |
| 22 'setting timestampOffset to ' + description + ' throws
an exception.'); |
| 23 } else { |
| 24 sourceBuffer.timestampOffset = value; |
| 25 assert_equals(sourceBuffer.timestampOffset, expected); |
| 26 } |
| 27 |
| 28 test.done(); |
| 29 }, 'Test setting SourceBuffer.timestampOffset to ' + description +
'.'); |
| 30 } |
| 31 |
| 32 simpleTimestampOffsetTest(10.5, 10.5, 'a positive number'); |
| 33 simpleTimestampOffsetTest(-10.4, -10.4, 'a negative number'); |
| 34 simpleTimestampOffsetTest(0, 0, 'zero'); |
| 35 simpleTimestampOffsetTest(Number.POSITIVE_INFINITY, 'TypeMismatchError
', 'positive infinity'); |
| 36 simpleTimestampOffsetTest(Number.NEGATIVE_INFINITY, 'TypeMismatchError
', 'negative infinity'); |
| 37 simpleTimestampOffsetTest(Number.NaN, 'TypeMismatchError', 'NaN'); |
| 38 simpleTimestampOffsetTest(undefined, 'TypeMismatchError', 'undefined')
; |
| 39 simpleTimestampOffsetTest(null, 0, 'null'); |
| 40 simpleTimestampOffsetTest(false, 0, 'false'); |
| 41 simpleTimestampOffsetTest(true, 1, 'true'); |
| 42 simpleTimestampOffsetTest('10.5', 10.5, 'a number string'); |
| 43 simpleTimestampOffsetTest('', 0, 'an empty string'); |
| 44 </script> |
| 45 </body> |
| 46 </html> |
OLD | NEW |