blob: 8f902382289cde901748b49f3c568bc228277ab6 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<title>media-source-error-crash</title>
<script src="media-source-loader.js"></script>
<script src="../video-test.js"></script>
<script>
var loader;
var source;
var sourceBuffer;
var sourceBuffer2;
function concatArrayBuffers(buffer1, buffer2) {
var view = new Uint8Array(buffer1.byteLength + buffer2.byteLength);
view.set(new Uint8Array(buffer1), 0);
view.set(new Uint8Array(buffer2), buffer1.byteLength);
return view.buffer;
}
function runTest() {
findMediaElement();
loader = new MediaSourceLoader('content/test-fragmented-manifest.json');
loader.onload = mediaDataLoaded;
loader.onerror = mediaDataLoadingFailed;
}
function mediaDataLoadingFailed() {
failTest('Media data loading failed');
}
function mediaDataLoaded() {
source = new MediaSource();
waitForEvent('sourceopen', sourceOpen, false, false, source);
run('video.src = URL.createObjectURL(source)');
}
function sourceOpen() {
run('source.duration = loader.duration()');
run('sourceBuffer = source.addSourceBuffer(loader.type())');
run('sourceBuffer2 = source.addSourceBuffer(loader.type())');
waitForEventAndEnd('error');
consoleWrite('Append an invalid media segment; should not crash.')
run('sourceBuffer.appendBuffer(concatArrayBuffers(loader.initSegment(), new ArrayBuffer(512)))');
}
</script>
</head>
<body onload="runTest()">
<video controls></video>
</body>
</html>