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> |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 assert_false(sourceBuffer.updating, "updating attribute is fal
se"); | 112 assert_false(sourceBuffer.updating, "updating attribute is fal
se"); |
113 test.done(); | 113 test.done(); |
114 }); | 114 }); |
115 }, "Test SourceBuffer.appendBuffer() triggering an 'ended' to 'open' t
ransition."); | 115 }, "Test SourceBuffer.appendBuffer() triggering an 'ended' to 'open' t
ransition."); |
116 | 116 |
117 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) | 117 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) |
118 { | 118 { |
119 test.failOnEvent(mediaElement, 'error'); | 119 test.failOnEvent(mediaElement, 'error'); |
120 | 120 |
121 test.expectEvent(sourceBuffer, "updatestart", "Append started."); | 121 test.expectEvent(sourceBuffer, "updatestart", "Append started."); |
| 122 test.expectEvent(sourceBuffer, "update", "Append success."); |
| 123 test.expectEvent(sourceBuffer, "updateend", "Append ended."); |
| 124 sourceBuffer.appendBuffer(mediaData); |
| 125 assert_true(sourceBuffer.updating, "updating attribute is true"); |
| 126 |
| 127 test.waitForExpectedEvents(function() |
| 128 { |
| 129 assert_false(sourceBuffer.updating, "updating attribute is fal
se"); |
| 130 |
| 131 test.expectEvent(mediaSource, "sourceended", "MediaSource sour
ceended event"); |
| 132 mediaSource.endOfStream(); |
| 133 assert_equals(mediaSource.readyState, "ended", "MediaSource re
adyState is 'ended'"); |
| 134 }); |
| 135 |
| 136 test.waitForExpectedEvents(function() |
| 137 { |
| 138 assert_equals(mediaSource.readyState, "ended", "MediaSource re
adyState is 'ended'"); |
| 139 |
| 140 test.expectEvent(mediaSource, "sourceopen", "MediaSource sourc
eopen event"); |
| 141 test.expectEvent(sourceBuffer, "updatestart", "Append started.
"); |
| 142 test.expectEvent(sourceBuffer, "update", "Append success."); |
| 143 test.expectEvent(sourceBuffer, "updateend", "Append ended."); |
| 144 sourceBuffer.appendBuffer(new Uint8Array(0)); |
| 145 |
| 146 assert_equals(mediaSource.readyState, "open", "MediaSource rea
dyState is 'open'"); |
| 147 assert_true(sourceBuffer.updating, "updating attribute is true
"); |
| 148 }); |
| 149 |
| 150 test.waitForExpectedEvents(function() |
| 151 { |
| 152 assert_equals(mediaSource.readyState, "open", "MediaSource rea
dyState is 'open'"); |
| 153 assert_false(sourceBuffer.updating, "updating attribute is fal
se"); |
| 154 test.done(); |
| 155 }); |
| 156 }, "Test zero byte SourceBuffer.appendBuffer() call triggering an 'end
ed' to 'open' transition."); |
| 157 |
| 158 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) |
| 159 { |
| 160 test.failOnEvent(mediaElement, 'error'); |
| 161 |
| 162 test.expectEvent(sourceBuffer, "updatestart", "Append started."); |
122 test.expectEvent(sourceBuffer, "abort", "Append aborted."); | 163 test.expectEvent(sourceBuffer, "abort", "Append aborted."); |
123 test.expectEvent(sourceBuffer, "updateend", "Append ended."); | 164 test.expectEvent(sourceBuffer, "updateend", "Append ended."); |
124 sourceBuffer.appendBuffer(mediaData); | 165 sourceBuffer.appendBuffer(mediaData); |
125 | 166 |
126 assert_true(sourceBuffer.updating, "updating attribute is true"); | 167 assert_true(sourceBuffer.updating, "updating attribute is true"); |
127 | 168 |
128 test.expectEvent(mediaSource.activeSourceBuffers, "removesourcebuf
fer", "activeSourceBuffers"); | 169 test.expectEvent(mediaSource.activeSourceBuffers, "removesourcebuf
fer", "activeSourceBuffers"); |
129 test.expectEvent(mediaSource.sourceBuffers, "removesourcebuffer",
"sourceBuffers"); | 170 test.expectEvent(mediaSource.sourceBuffers, "removesourcebuffer",
"sourceBuffers"); |
130 mediaSource.removeSourceBuffer(sourceBuffer); | 171 mediaSource.removeSourceBuffer(sourceBuffer); |
131 | 172 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 | 280 |
240 assert_true(sourceBuffer.updating, "updating attribute is true"); | 281 assert_true(sourceBuffer.updating, "updating attribute is true"); |
241 | 282 |
242 test.waitForExpectedEvents(function() | 283 test.waitForExpectedEvents(function() |
243 { | 284 { |
244 assert_false(sourceBuffer.updating, "updating attribute is fal
se"); | 285 assert_false(sourceBuffer.updating, "updating attribute is fal
se"); |
245 test.done(); | 286 test.done(); |
246 }); | 287 }); |
247 }, "Test appending an empty ArrayBuffer."); | 288 }, "Test appending an empty ArrayBuffer."); |
248 | 289 |
| 290 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) |
| 291 { |
| 292 var initSegment = MediaSourceUtil.extractSegmentData(mediaData, se
gmentInfo.init); |
| 293 var partialInitSegment = initSegment.subarray(0, initSegment.lengt
h / 2); |
| 294 var mediaSegment = MediaSourceUtil.extractSegmentData(mediaData, s
egmentInfo.media[0]); |
| 295 |
| 296 test.expectEvent(sourceBuffer, "updateend", "partialInitSegment ap
pend ended."); |
| 297 sourceBuffer.appendBuffer(partialInitSegment); |
| 298 |
| 299 test.waitForExpectedEvents(function() |
| 300 { |
| 301 // Call abort to reset the parser. |
| 302 sourceBuffer.abort(); |
| 303 |
| 304 // Append the full intiialization segment. |
| 305 test.expectEvent(sourceBuffer, "updateend", "initSegment appen
d ended."); |
| 306 sourceBuffer.appendBuffer(initSegment); |
| 307 }); |
| 308 |
| 309 test.waitForExpectedEvents(function() |
| 310 { |
| 311 test.expectEvent(sourceBuffer, "updateend", "mediaSegment appe
nd ended."); |
| 312 test.expectEvent(mediaElement, "loadeddata", "loadeddata fired
."); |
| 313 sourceBuffer.appendBuffer(mediaSegment); |
| 314 }); |
| 315 |
| 316 test.waitForExpectedEvents(function() |
| 317 { |
| 318 test.done(); |
| 319 }); |
| 320 }, "Test abort in the middle of an initialization segment."); |
| 321 |
| 322 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) |
| 323 { |
| 324 var initSegment = MediaSourceUtil.extractSegmentData(mediaData, se
gmentInfo.init); |
| 325 var mediaSegment = MediaSourceUtil.extractSegmentData(mediaData, s
egmentInfo.media[0]); |
| 326 var partialMediaSegment = mediaSegment.subarray(0, 3 * mediaSegmen
t.length / 4); |
| 327 var partialBufferedRanges = null; |
| 328 |
| 329 test.expectEvent(sourceBuffer, "updateend", "initSegment append en
ded."); |
| 330 sourceBuffer.appendBuffer(initSegment); |
| 331 |
| 332 test.waitForExpectedEvents(function() |
| 333 { |
| 334 test.expectEvent(sourceBuffer, "updateend", "partialMediaSegme
nt append ended."); |
| 335 sourceBuffer.appendBuffer(partialMediaSegment); |
| 336 }); |
| 337 |
| 338 test.waitForExpectedEvents(function() |
| 339 { |
| 340 // Call abort to reset the parser. |
| 341 sourceBuffer.abort(); |
| 342 |
| 343 // Keep a copy of the buffered ranges before we append the who
le media segment. |
| 344 partialBufferedRanges = sourceBuffer.buffered; |
| 345 assert_equals(partialBufferedRanges.length, 1, "partialBuffere
dRanges has 1 range"); |
| 346 |
| 347 // Append the full media segment. |
| 348 test.expectEvent(sourceBuffer, "updateend", "mediaSegment appe
nd ended."); |
| 349 sourceBuffer.appendBuffer(mediaSegment); |
| 350 }); |
| 351 |
| 352 test.waitForExpectedEvents(function() |
| 353 { |
| 354 test.expectEvent(sourceBuffer, "updateend", "Append ended."); |
| 355 |
| 356 assert_equals(sourceBuffer.buffered.length, 1, "sourceBuffer.b
uffered has 1 range"); |
| 357 assert_equals(sourceBuffer.buffered.length, partialBufferedRan
ges.length, "sourceBuffer.buffered and partialBufferedRanges are the same length
."); |
| 358 assert_equals(sourceBuffer.buffered.start(0), partialBufferedR
anges.start(0), "sourceBuffer.buffered and partialBufferedRanges start times mat
ch."); |
| 359 assert_greater_than(sourceBuffer.buffered.end(0), partialBuffe
redRanges.end(0), "sourceBuffer.buffered has a higher end time than partialBuffe
redRanges."); |
| 360 test.done(); |
| 361 }); |
| 362 }, "Test abort in the middle of a media segment."); |
| 363 |
| 364 mediasource_test(function(test, mediaElement, mediaSource) |
| 365 { |
| 366 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.VID
EO_ONLY_TYPE); |
| 367 |
| 368 test.expectEvent(sourceBuffer, "updatestart", "Append started."); |
| 369 test.expectEvent(sourceBuffer, "update", "Append success."); |
| 370 test.expectEvent(sourceBuffer, "updateend", "Append ended."); |
| 371 |
| 372 assert_throws( { name: "TypeError"} , |
| 373 function() { sourceBuffer.appendBuffer(null); }, |
| 374 "appendBuffer(null) throws an exception."); |
| 375 test.done(); |
| 376 }, "Test appending null."); |
| 377 |
| 378 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) |
| 379 { |
| 380 mediaSource.removeSourceBuffer(sourceBuffer); |
| 381 |
| 382 assert_throws( { name: "InvalidStateError"} , |
| 383 function() { sourceBuffer.appendBuffer(mediaData); }, |
| 384 "appendBuffer() throws an exception when called after removeSo
urceBuffer()."); |
| 385 test.done(); |
| 386 }, "Test appending after removeSourceBuffer()."); |
249 </script> | 387 </script> |
250 </body> | 388 </body> |
251 </html> | 389 </html> |
OLD | NEW |