| 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 createMediaXHR(test, onFinished) { | |
| 13 var mediaURL = "/media/resources/media-source/webm/test-a-5min-441
00Hz-1ch.webm"; | |
| 14 var xhr = new XMLHttpRequest(); | |
| 15 xhr.open('GET', mediaURL, true); | |
| 16 xhr.responseType = 'legacystream'; | |
| 17 test.failOnEvent(xhr, 'error'); | |
| 18 xhr.onreadystatechange = function() { | |
| 19 if (xhr.readyState == 4 && xhr.status == 200) { | |
| 20 onFinished(); | |
| 21 } | |
| 22 }; | |
| 23 return xhr; | |
| 24 } | |
| 25 | |
| 26 mediasource_test(function(test, mediaElement, mediaSource) | |
| 27 { | |
| 28 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUD
IO_ONLY_TYPE); | |
| 29 sourceBuffer.mode = 'sequence'; | |
| 30 | |
| 31 function onUpdateEnd() { | |
| 32 var xhr = createMediaXHR(test, function() | |
| 33 { | |
| 34 // We are appending data repeatedly in sequence mode, ther
e should be no gaps. | |
| 35 assert_false(sourceBuffer.buffered.length > 1, "unexpected
gap in buffered ranges."); | |
| 36 try { | |
| 37 sourceBuffer.appendStream(xhr.response, 551 * 1024); | |
| 38 } catch(ex) { | |
| 39 assert_equals(ex.name, 'QuotaExceededError'); | |
| 40 test.done(); | |
| 41 } | |
| 42 test.expectEvent(sourceBuffer, "updateend", "Append ended.
"); | |
| 43 test.waitForExpectedEvents(onUpdateEnd); | |
| 44 }); | |
| 45 xhr.send(); | |
| 46 } | |
| 47 // Start appending data | |
| 48 onUpdateEnd(); | |
| 49 }, 'Calling appendStream repeatedly (with size parameter) should fill
up the buffer and throw a QuotaExceededError when buffer is full.'); | |
| 50 | |
| 51 mediasource_test(function(test, mediaElement, mediaSource) | |
| 52 { | |
| 53 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUD
IO_ONLY_TYPE); | |
| 54 sourceBuffer.mode = 'sequence'; | |
| 55 | |
| 56 sourceBuffer.addEventListener('error', function() { | |
| 57 // Ok, we got error message as expected. This error notifies u
s that the async | |
| 58 // appendStream has failed due to buffer being full. | |
| 59 test.done(); | |
| 60 }); | |
| 61 | |
| 62 function onUpdateEnd() { | |
| 63 var xhr = createMediaXHR(test, function() | |
| 64 { | |
| 65 // We are appending data repeatedly in sequence mode, ther
e should be no gaps. | |
| 66 assert_false(sourceBuffer.buffered.length > 1, "unexpected
gap in buffered ranges."); | |
| 67 sourceBuffer.appendStream(xhr.response); | |
| 68 test.expectEvent(sourceBuffer, "updateend", "Append ended.
"); | |
| 69 test.waitForExpectedEvents(onUpdateEnd); | |
| 70 }); | |
| 71 xhr.send(); | |
| 72 } | |
| 73 // Start appending data | |
| 74 onUpdateEnd(); | |
| 75 }, 'Calling appendStream repeatedly (without size parameter) should fi
ll up the buffer and send an error event when buffer is full.'); | |
| 76 </script> | |
| 77 </body> | |
| 78 </html> | |
| OLD | NEW |