blob: 4796f18c201f1746d7df432742d975c75ee4ba75 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src=../video-test.js></script>
<script type="text/javascript">
var mock;
var promise;
var mediaKeySystemAccess;
var capabilities = {};
function doTest()
{
if (!window.internals) {
// failTest("Internals is required for this test.")
// return;
}
run('internals.initializeMockMediaSource()');
run('mock = internals.registerMockCDM()');
run('mock.supportedDataTypes = ["mock"]');
next();
}
function next() {
if (!tests.length) {
mock.unregister();
endTest()
return;
}
var nextTest = tests.shift();
consoleWrite('');
nextTest();
}
function gotMediaKeySystemAccess(result) {
mediaKeySystemAccess = result;
next();
}
tests = [
function() {
run('capabilities.initDataTypes = ["mock"]');
run(`capabilities.videoCapabilities = [{ contentType: 'video/mock; codecs="mock"' }] `);
run('promise = navigator.requestMediaKeySystemAccess("org.webkit.mock", [capabilities])');
shouldResolve(promise).then(gotMediaKeySystemAccess, failTest);
},
function() {
run('promise = mediaKeySystemAccess.createMediaKeys()');
shouldResolve(promise).then(next, next);
},
function() {
run('mock.canCreateInstances = false');
run('promise = mediaKeySystemAccess.createMediaKeys()');
shouldReject(promise).then(next, next);
},
function() {
run('mock.canCreateInstances = true');
run('capabilities.distinctiveIdentifier = "not-allowed"');
run('promise = navigator.requestMediaKeySystemAccess("org.webkit.mock", [capabilities])');
shouldResolve(promise).then(gotMediaKeySystemAccess, failTest);
},
function() {
run('promise = mediaKeySystemAccess.createMediaKeys()');
shouldResolve(promise).then(next, next);
},
function() {
run('mock.distinctiveIdentifiersRequirement = "required"');
run('promise = mediaKeySystemAccess.createMediaKeys()');
shouldReject(promise).then(next, next);
},
function() {
run('mock.distinctiveIdentifiersRequirement = "optional"');
run('capabilities.persistentState = "not-allowed"');
run('promise = navigator.requestMediaKeySystemAccess("org.webkit.mock", [capabilities])');
shouldResolve(promise).then(gotMediaKeySystemAccess, failTest);
},
function() {
run('promise = mediaKeySystemAccess.createMediaKeys()');
shouldResolve(promise).then(next, next);
},
function() {
run('mock.persistentStateRequirement = "required"');
run('promise = mediaKeySystemAccess.createMediaKeys()');
shouldReject(promise).then(next, next);
},
];
</script>
</head>
<body onload="doTest()">
</body>
</html>