Commit 4e0fed2e authored by servolk@chromium.org's avatar servolk@chromium.org

LayoutTests for the new MSE GC behavior.

These unit tests verify that QuotaExceededErr is thrown when appending
data to an MSE SourceBuffer that is full. This new behavior was
ntroduced by the recent CLs:
https://codereview.chromium.org/1008463002/
https://codereview.chromium.org/1013923002/

BUG=421694

Review URL: https://codereview.chromium.org/1304953002

git-svn-id: svn://svn.chromium.org/blink/trunk@201032 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent aec9c699
<!DOCTYPE html>
<html>
<head>
<script src="/w3c/resources/testharness.js"></script>
<script src="/w3c/resources/testharnessreport.js"></script>
<script src="mediasource-util.js"></script>
<link rel='stylesheet' href='/w3c/resources/testharness.css'>
</head>
<body>
<div id="log"></div>
<script>
// Fill up a given SourceBuffer by appending data repeatedly via doAppendDataFunc until
// an exception is thrown. The thrown exception is passed to onCaughtExceptionCallback.
function fillUpSourceBuffer(test, sourceBuffer, doAppendDataFunc, onCaughtExceptionCallback) {
// We are appending data repeatedly in sequence mode, there should be no gaps.
assert_false(sourceBuffer.buffered.length > 1, "unexpected gap in buffered ranges.");
try {
doAppendDataFunc();
} catch(ex) {
onCaughtExceptionCallback(ex);
}
test.expectEvent(sourceBuffer, 'updateend', 'append ended.');
test.waitForExpectedEvents(function() { fillUpSourceBuffer(test, sourceBuffer, doAppendDataFunc, onCaughtExceptionCallback); });
}
mediasource_test(function(test, mediaElement, mediaSource)
{
MediaSourceUtil.fetchManifestAndData(test, 'webm/test-a-5min-44100Hz-1ch-manifest.json', function(type, mediaData)
{
var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_ONLY_TYPE);
sourceBuffer.mode = 'sequence';
fillUpSourceBuffer(test, sourceBuffer,
function () { // doAppendDataFunc
sourceBuffer.appendBuffer(mediaData);
},
function (ex) { // onCaughtExceptionCallback
assert_equals(ex.name, 'QuotaExceededError');
test.done();
});
});
}, 'Appending data repeatedly should fill up the buffer and throw a QuotaExceededError when buffer is full.');
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<script src="/w3c/resources/testharness.js"></script>
<script src="/w3c/resources/testharnessreport.js"></script>
<script src="mediasource-util.js"></script>
<link rel='stylesheet' href='/w3c/resources/testharness.css'>
</head>
<body>
<div id="log"></div>
<script>
function createMediaXHR(test, onFinished) {
var mediaURL = "/media/resources/media-source/webm/test-a-5min-44100Hz-1ch.webm";
var xhr = new XMLHttpRequest();
xhr.open('GET', mediaURL, true);
xhr.responseType = 'legacystream';
test.failOnEvent(xhr, 'error');
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
onFinished();
}
};
return xhr;
}
mediasource_test(function(test, mediaElement, mediaSource)
{
var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_ONLY_TYPE);
sourceBuffer.mode = 'sequence';
function onUpdateEnd() {
var xhr = createMediaXHR(test, function()
{
// We are appending data repeatedly in sequence mode, there should be no gaps.
assert_false(sourceBuffer.buffered.length > 1, "unexpected gap in buffered ranges.");
try {
sourceBuffer.appendStream(xhr.response, 551 * 1024);
} catch(ex) {
assert_equals(ex.name, 'QuotaExceededError');
test.done();
}
test.expectEvent(sourceBuffer, "updateend", "Append ended.");
test.waitForExpectedEvents(onUpdateEnd);
});
xhr.send();
}
// Start appending data
onUpdateEnd();
}, 'Calling appendStream repeatedly (with size parameter) should fill up the buffer and throw a QuotaExceededError when buffer is full.');
mediasource_test(function(test, mediaElement, mediaSource)
{
var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_ONLY_TYPE);
sourceBuffer.mode = 'sequence';
sourceBuffer.addEventListener('error', function() {
// Ok, we got error message as expected. This error notifies us that the async
// appendStream has failed due to buffer being full.
test.done();
});
function onUpdateEnd() {
var xhr = createMediaXHR(test, function()
{
// We are appending data repeatedly in sequence mode, there should be no gaps.
assert_false(sourceBuffer.buffered.length > 1, "unexpected gap in buffered ranges.");
sourceBuffer.appendStream(xhr.response);
test.expectEvent(sourceBuffer, "updateend", "Append ended.");
test.waitForExpectedEvents(onUpdateEnd);
});
xhr.send();
}
// Start appending data
onUpdateEnd();
}, 'Calling appendStream repeatedly (without size parameter) should fill up the buffer and send an error event when buffer is full.');
</script>
</body>
</html>
{
"url": "webm/test-a-5min-44100Hz-1ch.webm",
"type": "audio/webm;codecs=\"vorbis\""
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment