blob: 3a0764918c825c5db589c237bfb171d30cdde1c9 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<title>media-source-restrictions</title>
<script src="mock-media-source.js"></script>
<script src="../video-test.js"></script>
<script>
var source;
var sourceBuffer;
var initSegment;
var samples;
if (window.internals)
internals.initializeMockMediaSource();
function runTest() {
findMediaElement();
run(`internals.setMediaElementRestrictions(video, 'RequireUserGestureForAudioRateChange')`);
source = new MediaSource();
testExpected('source.readyState', 'closed');
waitForEventOn(source, 'sourceopen', sourceOpen);
video.src = URL.createObjectURL(source);
}
function handlePause() {
endTest();
}
function sourceOpen() {
run('sourceBuffer = source.addSourceBuffer("video/mock; codecs=mock")');
waitForEventOn(sourceBuffer, 'updateend', loadSamples, false, true);
initSegment = makeAInit(8, [makeATrack(1, 'mock', TRACK_KIND.AUDIO)]);
run('sourceBuffer.appendBuffer(initSegment)');
waitForEvent('pause', handlePause);
video.play().catch(function(error) {
failTest();
});
}
function loadSamples() {
samples = concatenateSamples([
makeASample(0, 0, 1, 1, 1, SAMPLE_FLAG.SYNC),
makeASample(1, 1, 1, 1, 1, SAMPLE_FLAG.SYNC),
makeASample(2, 2, 1, 1, 1, SAMPLE_FLAG.SYNC),
makeASample(3, 3, 1, 1, 1, SAMPLE_FLAG.SYNC),
makeASample(4, 4, 1, 1, 1, SAMPLE_FLAG.SYNC),
makeASample(5, 5, 1, 1, 1, SAMPLE_FLAG.SYNC),
makeASample(6, 6, 1, 1, 1, SAMPLE_FLAG.SYNC),
makeASample(7, 7, 1, 1, 1, SAMPLE_FLAG.SYNC),
]);
waitForEventOn(sourceBuffer, 'updateend', updateEnd, false, true);
run('sourceBuffer.appendBuffer(samples)');
}
function updateEnd() {
waitForEventAndFail("onended");
}
</script>
</head>
<body onload="runTest()">
<video></video>
</body>
</html>