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'
>
12 function createMediaXHR(test
, onFinished
) {
13 var mediaURL
= "/media/resources/media-source/webm/test-a-5min-44100Hz-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) {
26 mediasource_test(function(test
, mediaElement
, mediaSource
)
28 var sourceBuffer
= mediaSource
.addSourceBuffer(MediaSourceUtil
.AUDIO_ONLY_TYPE
);
29 sourceBuffer
.mode
= 'sequence';
31 function onUpdateEnd() {
32 var xhr
= createMediaXHR(test
, function()
34 // We are appending data repeatedly in sequence mode, there should be no gaps.
35 assert_false(sourceBuffer
.buffered
.length
> 1, "unexpected gap in buffered ranges.");
37 sourceBuffer
.appendStream(xhr
.response
, 551 * 1024);
39 assert_equals(ex
.name
, 'QuotaExceededError');
42 test
.expectEvent(sourceBuffer
, "updateend", "Append ended.");
43 test
.waitForExpectedEvents(onUpdateEnd
);
47 // Start appending data
49 }, 'Calling appendStream repeatedly (with size parameter) should fill up the buffer and throw a QuotaExceededError when buffer is full.');
51 mediasource_test(function(test
, mediaElement
, mediaSource
)
53 var sourceBuffer
= mediaSource
.addSourceBuffer(MediaSourceUtil
.AUDIO_ONLY_TYPE
);
54 sourceBuffer
.mode
= 'sequence';
56 sourceBuffer
.addEventListener('error', function() {
57 // Ok, we got error message as expected. This error notifies us that the async
58 // appendStream has failed due to buffer being full.
62 function onUpdateEnd() {
63 var xhr
= createMediaXHR(test
, function()
65 // We are appending data repeatedly in sequence mode, there 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
);
73 // Start appending data
75 }, 'Calling appendStream repeatedly (without size parameter) should fill up the buffer and send an error event when buffer is full.');