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 // Fill up a given SourceBuffer by appending data repeatedly via doAppendDataFunc until
13 // an exception is thrown. The thrown exception is passed to onCaughtExceptionCallback.
14 function fillUpSourceBuffer(test
, sourceBuffer
, doAppendDataFunc
, onCaughtExceptionCallback
) {
15 // We are appending data repeatedly in sequence mode, there should be no gaps.
16 assert_false(sourceBuffer
.buffered
.length
> 1, "unexpected gap in buffered ranges.");
20 onCaughtExceptionCallback(ex
);
22 test
.expectEvent(sourceBuffer
, 'updateend', 'append ended.');
23 test
.waitForExpectedEvents(function() { fillUpSourceBuffer(test
, sourceBuffer
, doAppendDataFunc
, onCaughtExceptionCallback
); });
26 mediasource_test(function(test
, mediaElement
, mediaSource
)
28 MediaSourceUtil
.fetchManifestAndData(test
, 'webm/test-a-5min-44100Hz-1ch-manifest.json', function(type
, mediaData
)
30 var sourceBuffer
= mediaSource
.addSourceBuffer(MediaSourceUtil
.AUDIO_ONLY_TYPE
);
31 sourceBuffer
.mode
= 'sequence';
33 fillUpSourceBuffer(test
, sourceBuffer
,
34 function () { // doAppendDataFunc
35 sourceBuffer
.appendBuffer(mediaData
);
37 function (ex
) { // onCaughtExceptionCallback
38 assert_equals(ex
.name
, 'QuotaExceededError');
42 }, 'Appending data repeatedly should fill up the buffer and throw a QuotaExceededError when buffer is full.');