blob: 25eb941dbd61fbda07173eb74ab34e77a43aa76e [file] [log] [blame]
François Daoustade80c42016-06-30 07:43:591<!DOCTYPE html>
Matt Wolenetzb255ded2016-08-30 19:39:412<!-- Copyright © 2016 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). -->
François Daoustade80c42016-06-30 07:43:593<meta charset="utf-8">
Matt Wolenetz362ea982016-09-09 00:36:204<meta name="timeout" content="long">
François Daoustade80c42016-06-30 07:43:595<script src="/resources/testharness.js"></script>
6<script src="/resources/testharnessreport.js"></script>
7<script src="mediasource-util.js"></script>
8<script>
Matt Wolenetzda02eb32016-09-09 00:39:599 var subType = MediaSourceUtil.getSubType(MediaSourceUtil.AUDIO_ONLY_TYPE);
Matt Wolenetz362ea982016-09-09 00:36:2010 var manifestFilenameAudio = subType + "/test-a-128k-44100Hz-1ch-manifest.json";
11
François Daoustade80c42016-06-30 07:43:5912 // 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.");
17 try {
18 doAppendDataFunc();
19 } catch(ex) {
20 onCaughtExceptionCallback(ex);
21 }
22 test.expectEvent(sourceBuffer, 'updateend', 'append ended.');
23 test.waitForExpectedEvents(function() { fillUpSourceBuffer(test, sourceBuffer, doAppendDataFunc, onCaughtExceptionCallback); });
24 }
25
Matt Wolenetz362ea982016-09-09 00:36:2026 mediasource_test(function(test, mediaElement, mediaSource)
François Daoustade80c42016-06-30 07:43:5927 {
Matt Wolenetz362ea982016-09-09 00:36:2028 mediaElement.addEventListener("error", test.unreached_func("Unexpected event 'error'"));
29 MediaSourceUtil.fetchManifestAndData(test, manifestFilenameAudio, function(typeAudio, dataAudio)
30 {
31 var sourceBuffer = mediaSource.addSourceBuffer(typeAudio);
32 sourceBuffer.mode = 'sequence';
33 fillUpSourceBuffer(test, sourceBuffer,
34 function () { // doAppendDataFunc
35 sourceBuffer.appendBuffer(dataAudio);
36 },
37 function (ex) { // onCaughtExceptionCallback
38 assert_equals(ex.name, 'QuotaExceededError');
39 test.done();
40 });
41 });
François Daoustade80c42016-06-30 07:43:5942 }, 'Appending data repeatedly should fill up the buffer and throw a QuotaExceededError when buffer is full.');
Matt Wolenetzb255ded2016-08-30 19:39:4143</script>