blob: 86f3591b0259529d0c06ac294c76b65c63694b88 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<title>media-source-stalled-holds-sleep-assertion</title>
<script src="media-source-loader.js"></script>
<script src="../video-test.js"></script>
<script>
var loader;
var source;
var sourceBuffer;
var currentTime;
var oldCurrentTime;
var initialCurrentTime = null;
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())');
waitForEventOn(sourceBuffer, 'update', sourceInitialized, false, true);
run('sourceBuffer.appendBuffer(loader.initSegment())');
}
function sourceInitialized() {
waitForEventOn(sourceBuffer, 'update', sourceUpdated, false, true);
run('sourceBuffer.appendBuffer(loader.mediaSegment(0))');
}
function checkStalled() {
oldCurrentTime = currentTime;
currentTime = video.currentTime;
if (initialCurrentTime == null)
initialCurrentTime = currentTime;
if (currentTime != initialCurrentTime && oldCurrentTime == currentTime)
stalled();
else
setTimeout(checkStalled, 300);
}
function sourceUpdated() {
run('video.play()');
checkStalled();
}
function stalled() {
testExpected('(currentTime != initialCurrentTime && oldCurrentTime == currentTime)', true);
testExpected('internals.elementIsBlockingDisplaySleep(video)', false);
endTest();
}
</script>
</head>
<body onload="runTest()">
<video controls></video>
</body>
</html>