blob: 4f094ad0167d827fea306ca225ac02cbc952a527 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<title>mock-media-source</title>
<script src="mock-media-source.js"></script>
<script src="../video-test.js"></script>
<script>
var source;
var sourceBuffer;
var initSegment;
if (window.internals)
internals.initializeMockMediaSource();
function runTest() {
findMediaElement();
source = new MediaSource();
waitForEventOn(source, 'sourceopen', sourceOpen);
run('video.src = URL.createObjectURL(source)');
}
function sourceOpen() {
run('sourceBuffer = source.addSourceBuffer("video/mock; codecs=mock")');
waitForEventOn(sourceBuffer, 'updateend', loadSamples, false, true);
initSegment = makeAInit(8, [makeATrack(1, 'mock', TRACK_KIND.VIDEO)]);
run('sourceBuffer.appendBuffer(initSegment)');
}
function loadSamples() {
samples = concatenateSamples([
makeASample(0, 0, 1, 1, 1, SAMPLE_FLAG.SYNC),
makeASample(2, 1, 1, 1, 1, SAMPLE_FLAG.NONE),
makeASample(1, 2, 1, 1, 1, SAMPLE_FLAG.SYNC),
]);
waitForEventOn(sourceBuffer, 'updateend', remove, false, true);
run('sourceBuffer.appendBuffer(samples)');
}
function remove() {
waitForEventOn(sourceBuffer, 'updateend', checkRemoved, false, true);
run('sourceBuffer.remove(1.9, 2)');
}
function checkRemoved() {
testExpected('sourceBuffer.buffered.length', 2);
testExpected('sourceBuffer.buffered.start(0)', 0);
testExpected('sourceBuffer.buffered.end(0)', 1);
endTest();
}
</script>
</head>
<body onload="runTest()">
<div>This tests the SourceBuffer.remove() API. The test removes samples where the decode and presentation orders differ. Should not crash.</div>
<video></video>
</body>
</html>