| 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 simpleTimestampOffsetTest(value, expected, description) | 12 function simpleTimestampOffsetTest(value, expected, description) |
| 13 { | 13 { |
| 14 mediasource_test(function(test, mediaElement, mediaSource) | 14 mediasource_test(function(test, mediaElement, mediaSource) |
| 15 { | 15 { |
| 16 var segmentInfo = MediaSourceUtil.SEGMENT_INFO; | 16 var segmentInfo = MediaSourceUtil.SEGMENT_INFO; |
| 17 var sourceBuffer = mediaSource.addSourceBuffer(segmentInfo.typ
e); | 17 var sourceBuffer = mediaSource.addSourceBuffer(segmentInfo.typ
e); |
| 18 | 18 |
| 19 if (expected == 'TypeMismatchError') { | 19 if (expected == 'TypeError') { |
| 20 assert_throws('TypeMismatchError', | 20 assert_throws({name: 'TypeError'}, |
| 21 function() { sourceBuffer.timestampOffset = value; }, | 21 function() { sourceBuffer.timestampOffset = value; }, |
| 22 'setting timestampOffset to ' + description + ' throws
an exception.'); | 22 'setting timestampOffset to ' + description + ' throws
an exception.'); |
| 23 } else { | 23 } else { |
| 24 sourceBuffer.timestampOffset = value; | 24 sourceBuffer.timestampOffset = value; |
| 25 assert_equals(sourceBuffer.timestampOffset, expected); | 25 assert_equals(sourceBuffer.timestampOffset, expected); |
| 26 } | 26 } |
| 27 | 27 |
| 28 test.done(); | 28 test.done(); |
| 29 }, 'Test setting SourceBuffer.timestampOffset to ' + description +
'.'); | 29 }, 'Test setting SourceBuffer.timestampOffset to ' + description +
'.'); |
| 30 } | 30 } |
| 31 | 31 |
| 32 simpleTimestampOffsetTest(10.5, 10.5, 'a positive number'); | 32 simpleTimestampOffsetTest(10.5, 10.5, 'a positive number'); |
| 33 simpleTimestampOffsetTest(-10.4, -10.4, 'a negative number'); | 33 simpleTimestampOffsetTest(-10.4, -10.4, 'a negative number'); |
| 34 simpleTimestampOffsetTest(0, 0, 'zero'); | 34 simpleTimestampOffsetTest(0, 0, 'zero'); |
| 35 simpleTimestampOffsetTest(Number.POSITIVE_INFINITY, 'TypeMismatchError
', 'positive infinity'); | 35 simpleTimestampOffsetTest(Number.POSITIVE_INFINITY, 'TypeError', 'posi
tive infinity'); |
| 36 simpleTimestampOffsetTest(Number.NEGATIVE_INFINITY, 'TypeMismatchError
', 'negative infinity'); | 36 simpleTimestampOffsetTest(Number.NEGATIVE_INFINITY, 'TypeError', 'nega
tive infinity'); |
| 37 simpleTimestampOffsetTest(Number.NaN, 'TypeMismatchError', 'NaN'); | 37 simpleTimestampOffsetTest(Number.NaN, 'TypeError', 'NaN'); |
| 38 simpleTimestampOffsetTest(undefined, 'TypeMismatchError', 'undefined')
; | 38 simpleTimestampOffsetTest(undefined, 'TypeError', 'undefined'); |
| 39 simpleTimestampOffsetTest(null, 0, 'null'); | 39 simpleTimestampOffsetTest(null, 0, 'null'); |
| 40 simpleTimestampOffsetTest(false, 0, 'false'); | 40 simpleTimestampOffsetTest(false, 0, 'false'); |
| 41 simpleTimestampOffsetTest(true, 1, 'true'); | 41 simpleTimestampOffsetTest(true, 1, 'true'); |
| 42 simpleTimestampOffsetTest('10.5', 10.5, 'a number string'); | 42 simpleTimestampOffsetTest('10.5', 10.5, 'a number string'); |
| 43 simpleTimestampOffsetTest('', 0, 'an empty string'); | 43 simpleTimestampOffsetTest('', 0, 'an empty string'); |
| 44 </script> | 44 </script> |
| 45 </body> | 45 </body> |
| 46 </html> | 46 </html> |
| OLD | NEW |