blob: 6dfafcb98247c88b2110262b809bb54d4587d6f1 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src=../video-test.js></script>
<script type="text/javascript">
var mock;
var promise;
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 passingTestWithCapabilities(capabilities, success) {
shouldResolve(testWithCapabilities(capabilities)).then(success).then(next, next);
}
function failingTestWithCapabilities(capabilities, failure) {
shouldReject(testWithCapabilities(capabilities)).then(failure).then(next, next);
}
function testWithCapabilities(capabilities) {
window.capabilities = capabilities;
consoleWrite(`SET capabilities = '${ JSON.stringify(capabilities, null, 1) }'`);
run('promise = navigator.requestMediaKeySystemAccess("org.webkit.mock", capabilities)');
return promise;
}
tests = [
function() {
passingTestWithCapabilities([{
initDataTypes: ['mock'],
videoCapabilities: [{ contentType: 'video/mock; codecs="mock"' }]
}],
mediaKeySystemAccess => {
window.access = mediaKeySystemAccess;
testExpected('access.keySystem', 'org.webkit.mock');
testExpected('access.getConfiguration().initDataTypes.length', '1');
testExpected('access.getConfiguration().initDataTypes[0]', 'mock');
testExpected('access.getConfiguration().sessionTypes.length', '1');
testExpected('access.getConfiguration().sessionTypes[0]', 'temporary');
testExpected('access.getConfiguration().distinctiveIdentifier', 'not-allowed');
testExpected('access.getConfiguration().persistentState', 'not-allowed');
});
},
function() {
failingTestWithCapabilities([{
initDataTypes: ['mock'],
videoCapabilities: [{ contentType: 'unknown/mime; codecs="unknown"' }]
}],
exceptionCode => {
window.exceptionCode = exceptionCode;
testExpected('exceptionCode.name', 'NotSupportedError');
});
},
function() {
failingTestWithCapabilities([{
initDataTypes: ['unknownType'],
videoCapabilities: [{ contentType: 'video/mock; codecs="mock"' }]
}],
exceptionCode => {
window.exceptionCode = exceptionCode;
testExpected('exceptionCode.name', 'NotSupportedError');
});
},
function() {
run('mock.supportedRobustness = ["high"]');
passingTestWithCapabilities([{
initDataTypes: ['mock'],
videoCapabilities: [{ contentType: 'video/mock; codecs="mock"', robustness: "high" }],
}],
mediaKeySystemAccess => {
window.access = mediaKeySystemAccess;
testExpected('access.getConfiguration().videoCapabilities.length', '1');
testExpected('access.getConfiguration().videoCapabilities[0].robustness', 'high');
});
},
function() {
run('mock.supportedRobustness = ["high"]');
failingTestWithCapabilities([{
initDataTypes: ['mock'],
videoCapabilities: [{ contentType: 'video/mock; codecs="mock"', robustness: "low" }],
}],
exceptionCode => {
window.exceptionCode = exceptionCode;
testExpected('exceptionCode.name', 'NotSupportedError');
});
},
function() {
run('mock.distinctiveIdentifierRequirement = "not-allowed"');
passingTestWithCapabilities([{
initDataTypes: ['mock'],
videoCapabilities: [{ contentType: 'video/mock; codecs="mock"'}],
distinctiveIdentifier: 'optional'
}],
mediaKeySystemAccess => {
window.access = mediaKeySystemAccess;
testExpected('access.getConfiguration().distinctiveIdentifier', 'not-allowed');
});
},
function() {
run('mock.distinctiveIdentifiersRequirement = "required"');
passingTestWithCapabilities([{
initDataTypes: ['mock'],
videoCapabilities: [{ contentType: 'video/mock; codecs="mock"'}],
distinctiveIdentifier: 'optional'
}],
mediaKeySystemAccess => {
window.access = mediaKeySystemAccess;
testExpected('access.getConfiguration().distinctiveIdentifier', 'required');
});
},
function() {
run('mock.distinctiveIdentifiersRequirement = "not-allowed"');
failingTestWithCapabilities([{
initDataTypes: ['mock'],
videoCapabilities: [{ contentType: 'video/mock; codecs="mock"'}],
distinctiveIdentifier: 'required'
}],
exceptionCode => {
window.exceptionCode = exceptionCode;
testExpected('exceptionCode.name', 'NotSupportedError');
});
},
function() {
run('mock.distinctiveIdentifiersRequirement = "not-allowed"');
passingTestWithCapabilities([{
label: 'distinctive-identifiers-required',
initDataTypes: ['mock'],
videoCapabilities: [{ contentType: 'video/mock; codecs="mock"'}],
distinctiveIdentifier: 'required'
}, {
label: 'distinctive-identifiers-not-required',
initDataTypes: ['mock'],
videoCapabilities: [{ contentType: 'video/mock; codecs="mock"'}],
distinctiveIdentifier: 'optional'
}],
mediaKeySystemAccess => {
window.access = mediaKeySystemAccess;
testExpected('access.getConfiguration().label', 'distinctive-identifiers-not-required');
testExpected('access.getConfiguration().distinctiveIdentifier', 'not-allowed');
});
},
function() {
run('mock.persistentStateRequirement = "required"');
passingTestWithCapabilities([{
initDataTypes: ['mock'],
videoCapabilities: [{ contentType: 'video/mock; codecs="mock"'}],
persistentState: 'optional'
}],
mediaKeySystemAccess => {
window.access = mediaKeySystemAccess;
testExpected('access.getConfiguration().persistentState', 'required');
});
},
function() {
run('mock.persistentStateRequirement = "not-allowed"');
passingTestWithCapabilities([{
initDataTypes: ['mock'],
videoCapabilities: [{ contentType: 'video/mock; codecs="mock"'}],
persistentState: 'optional'
}],
mediaKeySystemAccess => {
window.access = mediaKeySystemAccess;
testExpected('access.getConfiguration().persistentState', 'not-allowed');
});
},
function() {
run('mock.persistentStateRequirement = "not-allowed"');
failingTestWithCapabilities([{
initDataTypes: ['mock'],
videoCapabilities: [{ contentType: 'video/mock; codecs="mock"'}],
persistentState: 'required'
}],
exceptionCode => {
window.exceptionCode = exceptionCode;
testExpected('exceptionCode.name', 'NotSupportedError');
});
},
function() {
run('mock.persistentStateRequirement = "not-allowed"');
passingTestWithCapabilities([{
label: 'persistent-state-required',
initDataTypes: ['mock'],
videoCapabilities: [{ contentType: 'video/mock; codecs="mock"'}],
persistentState: 'required'
}, {
label: 'persistent-state-not-required',
initDataTypes: ['mock'],
videoCapabilities: [{ contentType: 'video/mock; codecs="mock"'}],
persistentState: 'optional'
}],
mediaKeySystemAccess => {
window.access = mediaKeySystemAccess;
testExpected('access.getConfiguration().label', 'persistent-state-not-required');
testExpected('access.getConfiguration().persistentState', 'not-allowed');
});
},
function() {
run('mock.supportedEncryptionSchemes = ["cenc"]');
passingTestWithCapabilities([{
label: 'encryption-scheme-cenc',
initDataTypes: ['mock'],
videoCapabilities: [{ contentType: 'video/mock; codecs="mock"', encryptionScheme: 'cenc'}],
}],
mediaKeySystemAccess => {
window.access = mediaKeySystemAccess;
testExpected('access.getConfiguration().label', 'encryption-scheme-cenc');
testExpected('access.getConfiguration().videoCapabilities[0].encryptionScheme', 'cenc');
});
},
function() {
failingTestWithCapabilities([{
initDataTypes: ['mock'],
videoCapabilities: [{ contentType: 'video/mock; codecs="mock"', encryptionScheme: 'cbcs'}],
}],
exceptionCode => {
window.exceptionCode = exceptionCode;
testExpected('exceptionCode.name', 'NotSupportedError');
});
},
function() {
run('mock.supportedEncryptionSchemes = ["cenc", "cbcs"]');
passingTestWithCapabilities([{
label: 'encryption-scheme-cbcs',
initDataTypes: ['mock'],
videoCapabilities: [{ contentType: 'video/mock; codecs="mock"', encryptionScheme: 'cbcs'}],
}],
mediaKeySystemAccess => {
window.access = mediaKeySystemAccess;
testExpected('access.getConfiguration().label', 'encryption-scheme-cbcs');
testExpected('access.getConfiguration().videoCapabilities[0].encryptionScheme', 'cbcs');
});
},
];
</script>
</head>
<body onload="doTest()">
</body>
</html>