| 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 mediasource_test(function(test, mediaElement, mediaSource) | 12 mediasource_test(function(test, mediaElement, mediaSource) |
| 13 { | 13 { |
| 14 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUD
IO_VIDEO_TYPE); | 14 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUD
IO_VIDEO_TYPE); |
| 15 | 15 |
| 16 assert_throws("InvalidAccessError", function() | 16 assert_throws("InvalidAccessError", function() |
| 17 { | 17 { |
| 18 sourceBuffer.remove(-1, 2); | 18 sourceBuffer.remove(-1, 2); |
| 19 }, "remove"); | 19 }, "remove"); |
| 20 | 20 |
| 21 test.done(); | 21 test.done(); |
| 22 }, "Test remove with an negative start."); | 22 }, "Test remove with a negative start."); |
| 23 | 23 |
| 24 mediasource_test(function(test, mediaElement, mediaSource) | 24 mediasource_test(function(test, mediaElement, mediaSource) |
| 25 { | 25 { |
| 26 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUD
IO_VIDEO_TYPE); | 26 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUD
IO_VIDEO_TYPE); |
| 27 | 27 |
| 28 [ undefined, NaN, Infinity, -Infinity ].forEach(function(item) | 28 [ undefined, NaN, Infinity, -Infinity ].forEach(function(item) |
| 29 { | 29 { |
| 30 assert_throws(new TypeError(), function() | 30 assert_throws(new TypeError(), function() |
| 31 { | 31 { |
| 32 sourceBuffer.remove(item, 2); | 32 sourceBuffer.remove(item, 2); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 62 }, "remove"); | 62 }, "remove"); |
| 63 | 63 |
| 64 test.done(); | 64 test.done(); |
| 65 }, "Test remove with a start larger than the end."); | 65 }, "Test remove with a start larger than the end."); |
| 66 | 66 |
| 67 | 67 |
| 68 mediasource_test(function(test, mediaElement, mediaSource) | 68 mediasource_test(function(test, mediaElement, mediaSource) |
| 69 { | 69 { |
| 70 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUD
IO_VIDEO_TYPE); | 70 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUD
IO_VIDEO_TYPE); |
| 71 | 71 |
| 72 assert_throws("InvalidAccessError", function() |
| 73 { |
| 74 sourceBuffer.remove(0, Number.NEGATIVE_INFINITY); |
| 75 }, "remove"); |
| 76 |
| 77 test.done(); |
| 78 }, "Test remove with a NEGATIVE_INFINITY end."); |
| 79 |
| 80 mediasource_test(function(test, mediaElement, mediaSource) |
| 81 { |
| 82 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUD
IO_VIDEO_TYPE); |
| 83 |
| 84 assert_throws("InvalidAccessError", function() |
| 85 { |
| 86 sourceBuffer.remove(0, Number.NaN); |
| 87 }, "remove"); |
| 88 |
| 89 test.done(); |
| 90 }, "Test remove with a NaN end."); |
| 91 |
| 92 mediasource_test(function(test, mediaElement, mediaSource) |
| 93 { |
| 94 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUD
IO_VIDEO_TYPE); |
| 95 |
| 72 mediaSource.duration = 10; | 96 mediaSource.duration = 10; |
| 73 | 97 |
| 74 mediaSource.removeSourceBuffer(sourceBuffer); | 98 mediaSource.removeSourceBuffer(sourceBuffer); |
| 75 | 99 |
| 76 assert_throws("InvalidStateError", function() | 100 assert_throws("InvalidStateError", function() |
| 77 { | 101 { |
| 78 sourceBuffer.remove(1, 2); | 102 sourceBuffer.remove(1, 2); |
| 79 }, "remove"); | 103 }, "remove"); |
| 80 | 104 |
| 81 test.done(); | 105 test.done(); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 240 |
| 217 test.waitForExpectedEvents(function() | 241 test.waitForExpectedEvents(function() |
| 218 { | 242 { |
| 219 assertBufferedEquals(sourceBuffer, expected, "Buffered ranges
after remove()."); | 243 assertBufferedEquals(sourceBuffer, expected, "Buffered ranges
after remove()."); |
| 220 test.done(); | 244 test.done(); |
| 221 }); | 245 }); |
| 222 } | 246 } |
| 223 | 247 |
| 224 removeAppendedDataTests(function(test, sourceBuffer, bufferedRangeEnd,
subType) | 248 removeAppendedDataTests(function(test, sourceBuffer, bufferedRangeEnd,
subType) |
| 225 { | 249 { |
| 226 // Using MAX_VALUE rather than POSITIVE_INFINITY here due to lack | 250 removeAndCheckBufferedRanges(test, sourceBuffer, 0, Number.POSITIV
E_INFINITY, "{ }"); |
| 227 // of 'unrestricted' on end parameter. (See comment in SourceBuffe
r.idl) | |
| 228 removeAndCheckBufferedRanges(test, sourceBuffer, 0, Number.MAX_VAL
UE, "{ }"); | |
| 229 }, "Test removing all appended data."); | 251 }, "Test removing all appended data."); |
| 230 | 252 |
| 231 removeAppendedDataTests(function(test, sourceBuffer, bufferedRangeEnd,
subType) | 253 removeAppendedDataTests(function(test, sourceBuffer, bufferedRangeEnd,
subType) |
| 232 { | 254 { |
| 233 var expectations = { | 255 var expectations = { |
| 234 webm: ("{ [3.187, " + bufferedRangeEnd + ") }"), | 256 webm: ("{ [3.187, " + bufferedRangeEnd + ") }"), |
| 235 mp4: ("{ [3.021, " + bufferedRangeEnd + ") }"), | 257 mp4: ("{ [3.021, " + bufferedRangeEnd + ") }"), |
| 236 }; | 258 }; |
| 237 | 259 |
| 238 // Note: Range doesn't start exactly at the end of the remove rang
e because there isn't | 260 // Note: Range doesn't start exactly at the end of the remove rang
e because there isn't |
| (...skipping 21 matching lines...) Expand all Loading... |
| 260 mp4: "{ [0.000, 1.022) }", | 282 mp4: "{ [0.000, 1.022) }", |
| 261 }; | 283 }; |
| 262 | 284 |
| 263 // Using MAX_VALUE rather than POSITIVE_INFINITY here due to lack | 285 // Using MAX_VALUE rather than POSITIVE_INFINITY here due to lack |
| 264 // of 'unrestricted' on end parameter. (See comment in SourceBuffe
r.idl) | 286 // of 'unrestricted' on end parameter. (See comment in SourceBuffe
r.idl) |
| 265 removeAndCheckBufferedRanges(test, sourceBuffer, 1, Number.MAX_VAL
UE, expectations[subType]); | 287 removeAndCheckBufferedRanges(test, sourceBuffer, 1, Number.MAX_VAL
UE, expectations[subType]); |
| 266 }, "Test removing the end of appended data."); | 288 }, "Test removing the end of appended data."); |
| 267 </script> | 289 </script> |
| 268 </body> | 290 </body> |
| 269 </html> | 291 </html> |
| OLD | NEW |