mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1189196 - Update EME mochitest to use new navigator.requestMediaKeySystemAccess. r=jwwang
This commit is contained in:
parent
9189284862
commit
b3e6f2108c
@ -369,14 +369,15 @@ function SetupEME(test, token, params)
|
||||
})
|
||||
}
|
||||
|
||||
var options = [
|
||||
{
|
||||
initDataType: ev.initDataType,
|
||||
videoType: streamType("video"),
|
||||
audioType: streamType("audio"),
|
||||
}
|
||||
];
|
||||
var p = navigator.requestMediaKeySystemAccess(KEYSYSTEM_TYPE, options);
|
||||
var options = { initDataTypes: [ev.initDataType] };
|
||||
if (streamType("video")) {
|
||||
options.videoCapabilities = [{contentType: streamType("video")}];
|
||||
}
|
||||
if (streamType("audio")) {
|
||||
options.audioCapabilities = [{contentType: streamType("audio")}];
|
||||
}
|
||||
|
||||
var p = navigator.requestMediaKeySystemAccess(KEYSYSTEM_TYPE, [options]);
|
||||
var r = bail(token + " Failed to request key system access.");
|
||||
chain(p, r)
|
||||
.then(function(keySystemAccess) {
|
||||
|
@ -15,9 +15,9 @@ var manager = new MediaTestManager;
|
||||
function DoSetMediaKeys(v, test)
|
||||
{
|
||||
var options = [{
|
||||
initDataType: "cenc",
|
||||
audioType: test.audioType,
|
||||
videoType: test.videoType,
|
||||
initDataTypes: ["cenc"],
|
||||
audioCapabilities: [{contentType: test.audioType}],
|
||||
videoCapabilities: [{contentType: test.videoType}],
|
||||
}];
|
||||
|
||||
return navigator.requestMediaKeySystemAccess("org.w3.clearkey", options)
|
||||
|
@ -86,7 +86,7 @@ function startTest(test, token)
|
||||
|
||||
// Once the session is closed, reload the MediaKeys and reload the session
|
||||
.then(function() {
|
||||
return navigator.requestMediaKeySystemAccess(KEYSYSTEM_TYPE);
|
||||
return navigator.requestMediaKeySystemAccess(KEYSYSTEM_TYPE, [{initDataTypes:["cenc"]}]);
|
||||
})
|
||||
|
||||
.then(function(requestedKeySystemAccess) {
|
||||
|
@ -13,6 +13,31 @@
|
||||
|
||||
const CLEARKEY_ID = 'org.w3.clearkey';
|
||||
const CLEARKEY_VERSION = '1';
|
||||
const SUPPORTED_LABEL = "pass label";
|
||||
|
||||
function ValidateConfig(name, expected, observed) {
|
||||
info("ValidateConfig " + name);
|
||||
info("expected cfg=" + JSON.stringify(expected));
|
||||
info("observed cfg=" + JSON.stringify(observed));
|
||||
|
||||
is(observed.label, expected.label, name + " label should match");
|
||||
if (expected.initDataTypes) {
|
||||
ok(expected.initDataTypes.every((element, index, array) => observed.initDataTypes.includes(element)), name + " initDataTypes should match.");
|
||||
}
|
||||
|
||||
if (expected.audioCapabilities) {
|
||||
ok(expected.audioCapabilities.length == 1, "Test function can only handle one capability.");
|
||||
ok(observed.audioCapabilities.length == 1, "Test function can only handle one capability.");
|
||||
is(observed.audioCapabilities[0].contentType, expected.audioCapabilities[0].contentType, name + " audioCapabilities should match.");
|
||||
}
|
||||
if (typeof expected.videoCapabilities !== 'undefined') {
|
||||
info("expected.videoCapabilities=" + expected.videoCapabilities);
|
||||
dump("expected.videoCapabilities=" + expected.videoCapabilities + "\n");
|
||||
ok(expected.videoCapabilities.length == 1, "Test function can only handle one capability.");
|
||||
ok(observed.videoCapabilities.length == 1, "Test function can only handle one capability.");
|
||||
is(observed.videoCapabilities[0].contentType, expected.videoCapabilities[0].contentType, name + " videoCapabilities should match.");
|
||||
}
|
||||
}
|
||||
|
||||
function Test(test) {
|
||||
var name = "'" + test.name + "'";
|
||||
@ -27,6 +52,7 @@ function Test(test) {
|
||||
function(keySystemAccess) {
|
||||
ok(test.shouldPass, name + " passed and was expected to " + (test.shouldPass ? "pass" : "fail"));
|
||||
is(keySystemAccess.keySystem, CLEARKEY_ID + "." + CLEARKEY_VERSION, "CDM version should be in MediaKeySystemAccess.keySystem");
|
||||
ValidateConfig(name, test.expectedConfig, keySystemAccess.getConfiguration());
|
||||
resolve();
|
||||
},
|
||||
function(ex) {
|
||||
@ -43,7 +69,12 @@ var tests = [
|
||||
{
|
||||
name: 'Empty keySystem string',
|
||||
keySystem: '',
|
||||
options: [ ],
|
||||
options: [
|
||||
{
|
||||
initDataTypes: ['cenc'],
|
||||
videoCapabilities: [{contentType: 'video/mp4'}],
|
||||
}
|
||||
],
|
||||
shouldPass: false,
|
||||
},
|
||||
{
|
||||
@ -55,23 +86,34 @@ var tests = [
|
||||
{
|
||||
name: 'Undefined options',
|
||||
keySystem: CLEARKEY_ID,
|
||||
shouldPass: true,
|
||||
shouldPass: false,
|
||||
},
|
||||
{
|
||||
name: 'Basic MP4 cenc',
|
||||
keySystem: CLEARKEY_ID,
|
||||
options: [
|
||||
{
|
||||
initDataType: 'cenc',
|
||||
videoType: 'video/mp4',
|
||||
label: SUPPORTED_LABEL,
|
||||
initDataTypes: ['cenc'],
|
||||
videoCapabilities: [{contentType: 'video/mp4'}],
|
||||
}
|
||||
],
|
||||
expectedConfig: {
|
||||
label: SUPPORTED_LABEL,
|
||||
initDataTypes: ['cenc'],
|
||||
videoCapabilities: [{contentType: 'video/mp4'}],
|
||||
},
|
||||
shouldPass: true,
|
||||
},
|
||||
{
|
||||
name: 'Invalid keysystem failure',
|
||||
keySystem: 'bogusKeySystem',
|
||||
options: [],
|
||||
options: [
|
||||
{
|
||||
initDataTypes: ['cenc'],
|
||||
videoCapabilities: [{contentType: 'video/mp4'}],
|
||||
}
|
||||
],
|
||||
shouldPass: false,
|
||||
},
|
||||
{
|
||||
@ -79,7 +121,32 @@ var tests = [
|
||||
keySystem: CLEARKEY_ID,
|
||||
options: [
|
||||
{
|
||||
initDataType: 'bogus',
|
||||
initDataTypes: ['bogus'],
|
||||
}
|
||||
],
|
||||
shouldPass: false,
|
||||
},
|
||||
{
|
||||
name: 'Valid initDataType after invalid',
|
||||
keySystem: CLEARKEY_ID,
|
||||
options: [
|
||||
{
|
||||
label: SUPPORTED_LABEL,
|
||||
initDataTypes: ['bogus', 'invalid', 'cenc'],
|
||||
}
|
||||
],
|
||||
expectedConfig: {
|
||||
label: SUPPORTED_LABEL,
|
||||
initDataTypes: ['cenc'],
|
||||
},
|
||||
shouldPass: true,
|
||||
},
|
||||
{
|
||||
name: 'Empty initDataTypes',
|
||||
keySystem: CLEARKEY_ID,
|
||||
options: [
|
||||
{
|
||||
initDataTypes: [],
|
||||
}
|
||||
],
|
||||
shouldPass: false,
|
||||
@ -89,72 +156,102 @@ var tests = [
|
||||
keySystem: CLEARKEY_ID,
|
||||
options: [
|
||||
{
|
||||
initDataType: 'cenc',
|
||||
videoType: 'video/bogus',
|
||||
initDataTypes: ['cenc'],
|
||||
videoCapabilities: [{contentType: 'video/bogus'}],
|
||||
}
|
||||
],
|
||||
shouldPass: false,
|
||||
},
|
||||
{
|
||||
name: 'Invalid statefulness',
|
||||
name: 'distinctiveIdentifier, persistentState, and robustness ignored',
|
||||
keySystem: CLEARKEY_ID,
|
||||
options: [
|
||||
{
|
||||
initDataType: 'cenc',
|
||||
videoType: 'video/mp4',
|
||||
stateful: 'bogus',
|
||||
label: SUPPORTED_LABEL,
|
||||
initDataTypes: ['cenc'],
|
||||
videoCapabilities: [{contentType: 'video/mp4', robustness: 'somewhat'}],
|
||||
distinctiveIdentifier: 'bogus',
|
||||
persistentState: 'bogus',
|
||||
}
|
||||
],
|
||||
expectedConfig: {
|
||||
label: SUPPORTED_LABEL,
|
||||
initDataTypes: ['cenc'],
|
||||
videoCapabilities: [{contentType: 'video/mp4'}],
|
||||
},
|
||||
shouldPass: true,
|
||||
},
|
||||
{
|
||||
name: 'Only unrecognised dict entries specified with unrecognised video type',
|
||||
keySystem: CLEARKEY_ID,
|
||||
options: [
|
||||
{
|
||||
videoCapabilities: [{robustness: 'very much so'}],
|
||||
distinctiveIdentifier: 'required',
|
||||
persistentState: 'required',
|
||||
}
|
||||
],
|
||||
shouldPass: false,
|
||||
},
|
||||
{
|
||||
name: 'Invalid uniqueidentifier',
|
||||
name: 'Only unrecognised dict entries specified should be ignored',
|
||||
keySystem: CLEARKEY_ID,
|
||||
options: [
|
||||
{
|
||||
initDataType: 'cenc',
|
||||
videoType: 'video/mp4',
|
||||
uniqueidentifier: 'bogus',
|
||||
label: SUPPORTED_LABEL,
|
||||
distinctiveIdentifier: 'required',
|
||||
persistentState: 'required',
|
||||
}
|
||||
],
|
||||
shouldPass: false,
|
||||
expectedConfig: {
|
||||
label: SUPPORTED_LABEL,
|
||||
},
|
||||
shouldPass: true,
|
||||
},
|
||||
{
|
||||
name: 'Audio capabilities not supported by CLEARKEY_ID',
|
||||
name: 'Empty config dict',
|
||||
keySystem: CLEARKEY_ID,
|
||||
options: [
|
||||
{
|
||||
initDataType: 'cenc',
|
||||
videoType: 'video/mp4',
|
||||
audioCapability: 'bogus',
|
||||
}
|
||||
],
|
||||
shouldPass: false,
|
||||
options: [{ label: SUPPORTED_LABEL }],
|
||||
expectedConfig: {
|
||||
label: SUPPORTED_LABEL
|
||||
},
|
||||
shouldPass: true,
|
||||
},
|
||||
{
|
||||
name: 'Video capabilities not supported by CLEARKEY_ID',
|
||||
name: 'Unexpected config entry should be ignored',
|
||||
keySystem: CLEARKEY_ID,
|
||||
options: [
|
||||
{
|
||||
initDataType: 'cenc',
|
||||
videoType: 'video/mp4',
|
||||
videoCapability: 'bogus',
|
||||
label: SUPPORTED_LABEL,
|
||||
initDataTypes: ['cenc'],
|
||||
unexpectedEntry: 'this should be ignored',
|
||||
}
|
||||
],
|
||||
shouldPass: false,
|
||||
expectedConfig: {
|
||||
label: SUPPORTED_LABEL,
|
||||
initDataTypes: ['cenc'],
|
||||
},
|
||||
shouldPass: true,
|
||||
},
|
||||
{
|
||||
name: 'Invalid option followed by valid',
|
||||
keySystem: CLEARKEY_ID,
|
||||
options: [
|
||||
{
|
||||
bogus: 'bogon',
|
||||
label: "this config should not be supported",
|
||||
initDataTypes: ['bogus'],
|
||||
},
|
||||
{
|
||||
initDataType: 'cenc',
|
||||
videoType: 'video/mp4',
|
||||
label: SUPPORTED_LABEL,
|
||||
initDataTypes: ['cenc'],
|
||||
videoCapabilities: [{contentType: 'video/mp4'}],
|
||||
}
|
||||
],
|
||||
expectedConfig: {
|
||||
label: SUPPORTED_LABEL,
|
||||
initDataTypes: ['cenc'],
|
||||
videoCapabilities: [{contentType: 'video/mp4'}],
|
||||
},
|
||||
shouldPass: true,
|
||||
},
|
||||
{
|
||||
@ -162,10 +259,16 @@ var tests = [
|
||||
keySystem: CLEARKEY_ID,
|
||||
options: [
|
||||
{
|
||||
initDataType: 'cenc',
|
||||
audioType: 'audio/mp4',
|
||||
label: SUPPORTED_LABEL,
|
||||
initDataTypes: ['cenc'],
|
||||
audioCapabilities: [{contentType: 'audio/mp4'}],
|
||||
}
|
||||
],
|
||||
expectedConfig: {
|
||||
label: SUPPORTED_LABEL,
|
||||
initDataTypes: ['cenc'],
|
||||
audioCapabilities: [{contentType: 'audio/mp4'}],
|
||||
},
|
||||
shouldPass: true,
|
||||
},
|
||||
{
|
||||
@ -173,10 +276,16 @@ var tests = [
|
||||
keySystem: CLEARKEY_ID,
|
||||
options: [
|
||||
{
|
||||
initDataType: 'cenc',
|
||||
audioType: 'audio/mp4; codecs="mp4a.40.2"',
|
||||
label: SUPPORTED_LABEL,
|
||||
initDataTypes: ['cenc'],
|
||||
audioCapabilities: [{contentType: 'audio/mp4; codecs="mp4a.40.2"'}],
|
||||
}
|
||||
],
|
||||
expectedConfig: {
|
||||
label: SUPPORTED_LABEL,
|
||||
initDataTypes: ['cenc'],
|
||||
audioCapabilities: [{contentType: 'audio/mp4; codecs="mp4a.40.2"'}],
|
||||
},
|
||||
shouldPass: true,
|
||||
},
|
||||
{
|
||||
@ -184,8 +293,8 @@ var tests = [
|
||||
keySystem: CLEARKEY_ID,
|
||||
options: [
|
||||
{
|
||||
initDataType: 'cenc',
|
||||
audioType: 'audio/mp4; codecs="bogus"',
|
||||
initDataTypes: ['cenc'],
|
||||
audioCapabilities: [{contentType: 'audio/mp4; codecs="bogus"'}],
|
||||
}
|
||||
],
|
||||
shouldPass: false,
|
||||
@ -195,19 +304,19 @@ var tests = [
|
||||
keySystem: CLEARKEY_ID,
|
||||
options: [
|
||||
{
|
||||
initDataType: 'cenc',
|
||||
audioType: 'audio/mp4; codecs="mp3"',
|
||||
initDataTypes: ['cenc'],
|
||||
audioCapabilities: [{contentType: 'audio/mp4; codecs="mp3"'}],
|
||||
}
|
||||
],
|
||||
shouldPass: false,
|
||||
},
|
||||
{
|
||||
name: 'MP4 video container type with an audio codec is unsupported',
|
||||
name: 'MP4 video container type with an mp3 codec is unsupported',
|
||||
keySystem: CLEARKEY_ID,
|
||||
options: [
|
||||
{
|
||||
initDataType: 'cenc',
|
||||
videoType: 'video/mp4; codecs="mp3"',
|
||||
initDataTypes: ['cenc'],
|
||||
videoCapabilities: [{contentType: 'video/mp4; codecs="mp3"'}],
|
||||
}
|
||||
],
|
||||
shouldPass: false,
|
||||
@ -217,8 +326,8 @@ var tests = [
|
||||
keySystem: CLEARKEY_ID,
|
||||
options: [
|
||||
{
|
||||
initDataType: 'cenc',
|
||||
audioType: 'audio/mp4; codecs="avc1.42E01E"',
|
||||
initDataTypes: ['cenc'],
|
||||
audioCapabilities: [{contentType: 'audio/mp4; codecs="avc1.42E01E"'}],
|
||||
}
|
||||
],
|
||||
shouldPass: false,
|
||||
@ -228,10 +337,16 @@ var tests = [
|
||||
keySystem: CLEARKEY_ID,
|
||||
options: [
|
||||
{
|
||||
initDataType: 'cenc',
|
||||
videoType: 'video/mp4; codecs="avc1.42E01E"',
|
||||
label: SUPPORTED_LABEL,
|
||||
initDataTypes: ['cenc'],
|
||||
videoCapabilities: [{contentType: 'video/mp4; codecs="avc1.42E01E"'}],
|
||||
}
|
||||
],
|
||||
expectedConfig: {
|
||||
label: SUPPORTED_LABEL,
|
||||
initDataTypes: ['cenc'],
|
||||
videoCapabilities: [{contentType: 'video/mp4; codecs="avc1.42E01E"'}],
|
||||
},
|
||||
shouldPass: true,
|
||||
},
|
||||
{
|
||||
@ -239,8 +354,8 @@ var tests = [
|
||||
keySystem: CLEARKEY_ID,
|
||||
options: [
|
||||
{
|
||||
initDataType: 'cenc',
|
||||
videoType: 'video/mp4; codecs="bogus"',
|
||||
initDataTypes: ['cenc'],
|
||||
videoCapabilities: [{contentType: 'video/mp4; codecs="bogus"'}],
|
||||
}
|
||||
],
|
||||
shouldPass: false,
|
||||
@ -250,8 +365,8 @@ var tests = [
|
||||
keySystem: CLEARKEY_ID,
|
||||
options: [
|
||||
{
|
||||
initDataType: 'cenc',
|
||||
videoType: 'video/mp4; codecs="avc1.42E01E,mp4a.40.2"',
|
||||
initDataTypes: ['cenc'],
|
||||
videoCapabilities: [{contentType: 'video/mp4; codecs="avc1.42E01E,mp4a.40.2"'}],
|
||||
}
|
||||
],
|
||||
shouldPass: false,
|
||||
@ -261,11 +376,18 @@ var tests = [
|
||||
keySystem: CLEARKEY_ID,
|
||||
options: [
|
||||
{
|
||||
initDataType: 'cenc',
|
||||
videoType: 'video/mp4; codecs="avc1.42E01E"',
|
||||
audioType: 'audio/mp4; codecs="mp4a.40.2"',
|
||||
label: SUPPORTED_LABEL,
|
||||
initDataTypes: ['cenc'],
|
||||
videoCapabilities: [{contentType: 'video/mp4; codecs="avc1.42E01E"'}],
|
||||
audioCapabilities: [{contentType: 'audio/mp4; codecs="mp4a.40.2"'}],
|
||||
}
|
||||
],
|
||||
expectedConfig: {
|
||||
label: SUPPORTED_LABEL,
|
||||
initDataTypes: ['cenc'],
|
||||
videoCapabilities: [{contentType: 'video/mp4; codecs="avc1.42E01E"'}],
|
||||
audioCapabilities: [{contentType: 'audio/mp4; codecs="mp4a.40.2"'}],
|
||||
},
|
||||
shouldPass: true,
|
||||
},
|
||||
{
|
||||
@ -273,8 +395,8 @@ var tests = [
|
||||
keySystem: CLEARKEY_ID,
|
||||
options: [
|
||||
{
|
||||
initDataType: 'webm',
|
||||
videoType: 'video/webm',
|
||||
initDataTypes: ['webm'],
|
||||
videoCapabilities: [{contentType: 'video/webm'}],
|
||||
}
|
||||
],
|
||||
shouldPass: false,
|
||||
@ -282,23 +404,103 @@ var tests = [
|
||||
{
|
||||
name: "CDM version less than",
|
||||
keySystem: CLEARKEY_ID + ".0",
|
||||
options: [
|
||||
{
|
||||
label: SUPPORTED_LABEL,
|
||||
initDataTypes: ['cenc'],
|
||||
videoCapabilities: [{contentType: 'video/mp4'}],
|
||||
}
|
||||
],
|
||||
expectedConfig: {
|
||||
label: SUPPORTED_LABEL,
|
||||
initDataTypes: ['cenc'],
|
||||
videoCapabilities: [{contentType: 'video/mp4'}],
|
||||
},
|
||||
shouldPass: true
|
||||
},
|
||||
{
|
||||
name: "CDM version equal to",
|
||||
keySystem: CLEARKEY_ID + ".1",
|
||||
options: [
|
||||
{
|
||||
label: SUPPORTED_LABEL,
|
||||
initDataTypes: ['cenc'],
|
||||
videoCapabilities: [{contentType: 'video/mp4'}],
|
||||
}
|
||||
],
|
||||
expectedConfig: {
|
||||
label: SUPPORTED_LABEL,
|
||||
initDataTypes: ['cenc'],
|
||||
videoCapabilities: [{contentType: 'video/mp4'}],
|
||||
},
|
||||
shouldPass: true
|
||||
},
|
||||
{
|
||||
name: "CDM version greater than",
|
||||
keySystem: CLEARKEY_ID + ".2",
|
||||
options: [
|
||||
{
|
||||
initDataTypes: ['cenc'],
|
||||
videoCapabilities: [{contentType: 'video/mp4'}],
|
||||
}
|
||||
],
|
||||
shouldPass: false
|
||||
},
|
||||
{
|
||||
name: "Non-whole number CDM version",
|
||||
keySystem: CLEARKEY_ID + ".0.1",
|
||||
options: [
|
||||
{
|
||||
initDataTypes: ['cenc'],
|
||||
videoCapabilities: [{contentType: 'video/mp4'}],
|
||||
}
|
||||
],
|
||||
shouldPass: false
|
||||
},
|
||||
|
||||
// Test legacy support. Remove when we remove backwards compatibility.
|
||||
{
|
||||
name: 'Legacy CENC',
|
||||
keySystem: CLEARKEY_ID,
|
||||
options: [
|
||||
{
|
||||
initDataType: 'cenc',
|
||||
}
|
||||
],
|
||||
expectedConfig: {
|
||||
label: ''
|
||||
},
|
||||
shouldPass: true,
|
||||
},
|
||||
{
|
||||
name: 'Legacy CENC + MP4 video',
|
||||
keySystem: CLEARKEY_ID,
|
||||
options: [
|
||||
{
|
||||
initDataType: 'cenc',
|
||||
videoType: 'video/mp4; codecs="avc1.42E01E"',
|
||||
}
|
||||
],
|
||||
expectedConfig: {
|
||||
label: ''
|
||||
},
|
||||
shouldPass: true,
|
||||
},
|
||||
{
|
||||
name: 'Legacy CENC + MP4 video + MP4 audio',
|
||||
keySystem: CLEARKEY_ID,
|
||||
options: [
|
||||
{
|
||||
initDataType: 'cenc',
|
||||
videoType: 'video/mp4; codecs="avc1.42E01E"',
|
||||
audioType: 'audio/mp4; codecs="mp4a.40.2"',
|
||||
}
|
||||
],
|
||||
expectedConfig: {
|
||||
label: ''
|
||||
},
|
||||
shouldPass: true,
|
||||
},
|
||||
];
|
||||
|
||||
function beginTest() {
|
||||
|
@ -1,109 +1,109 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test Encrypted Media Extensions</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
<script type="text/javascript" src="eme.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
var manager = new MediaTestManager;
|
||||
|
||||
var observedStatus = "nothing";
|
||||
|
||||
var observer = function(subject, topic, data) {
|
||||
observedStatus = JSON.parse(data).status;
|
||||
info("Observed: " + observedStatus);
|
||||
};
|
||||
SpecialPowers.Services.obs.addObserver(observer, "mediakeys-request", false);
|
||||
|
||||
SimpleTest.registerCleanupFunction(function() {
|
||||
SpecialPowers.Services.obs.removeObserver(observer, "mediakeys-request");
|
||||
});
|
||||
|
||||
function SetPrefs(prefs) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
SpecialPowers.pushPrefEnv({"set": prefs}, function() { resolve(); });
|
||||
});
|
||||
}
|
||||
|
||||
function Test(test) {
|
||||
var p = test.prefs ? SetPrefs(test.prefs) : Promise.resolve();
|
||||
observedStatus = "nothing";
|
||||
var name = "'" + test.keySystem + "'";
|
||||
return p.then(function() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
navigator.requestMediaKeySystemAccess(test.keySystem)
|
||||
.then(
|
||||
function(keySystemAccess) {
|
||||
return keySystemAccess.createMediaKeys();
|
||||
})
|
||||
.then(
|
||||
function(mediaKeys) {
|
||||
ok(test.shouldPass, name + " passed and was expected to " + (test.shouldPass ? "pass" : "fail"));
|
||||
is(observedStatus, test.expectedStatus, name + " observer service result");
|
||||
resolve();
|
||||
}
|
||||
)
|
||||
.catch(
|
||||
function() {
|
||||
ok(!test.shouldPass, name + " failed and was expected to " + (test.shouldPass ? "pass" : "fail"));
|
||||
is(observedStatus, test.expectedStatus, name + " observer service result");
|
||||
resolve();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const CLEARKEY_ID = 'org.w3.clearkey';
|
||||
|
||||
var tests = [
|
||||
{
|
||||
keySystem: CLEARKEY_ID,
|
||||
shouldPass: false,
|
||||
expectedStatus: 'api-disabled',
|
||||
prefs: [["media.eme.enabled", false], ["media.eme.clearkey.enabled", true]]
|
||||
},
|
||||
{
|
||||
keySystem: CLEARKEY_ID,
|
||||
shouldPass: false,
|
||||
expectedStatus: 'cdm-disabled',
|
||||
prefs: [["media.eme.enabled", true], ["media.eme.clearkey.enabled", false]]
|
||||
},
|
||||
{
|
||||
keySystem: 'unsupported-keysystem',
|
||||
shouldPass: false,
|
||||
expectedStatus: 'cdm-not-supported'
|
||||
},
|
||||
{
|
||||
keySystem: CLEARKEY_ID + '.10000' , // A stupendously high min CDM version, presumably not installed.
|
||||
shouldPass: false,
|
||||
expectedStatus: 'cdm-insufficient-version',
|
||||
prefs: [["media.eme.enabled", true], ["media.eme.clearkey.enabled", true]]
|
||||
},
|
||||
{
|
||||
keySystem: CLEARKEY_ID,
|
||||
shouldPass: true,
|
||||
expectedStatus: 'cdm-created',
|
||||
prefs: [["media.eme.enabled", true], ["media.eme.clearkey.enabled", true]]
|
||||
},
|
||||
];
|
||||
|
||||
SetupEMEPref(function() {
|
||||
tests.reduce(function(p,c,i,array) {
|
||||
return p.then(function() { return Test(c); });
|
||||
}, Promise.resolve()).then(SimpleTest.finish);
|
||||
});
|
||||
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test Encrypted Media Extensions</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
<script type="text/javascript" src="eme.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
var manager = new MediaTestManager;
|
||||
|
||||
var observedStatus = "nothing";
|
||||
|
||||
var observer = function(subject, topic, data) {
|
||||
observedStatus = JSON.parse(data).status;
|
||||
info("Observed: " + observedStatus);
|
||||
};
|
||||
SpecialPowers.Services.obs.addObserver(observer, "mediakeys-request", false);
|
||||
|
||||
SimpleTest.registerCleanupFunction(function() {
|
||||
SpecialPowers.Services.obs.removeObserver(observer, "mediakeys-request");
|
||||
});
|
||||
|
||||
function SetPrefs(prefs) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
SpecialPowers.pushPrefEnv({"set": prefs}, function() { resolve(); });
|
||||
});
|
||||
}
|
||||
|
||||
function Test(test) {
|
||||
var p = test.prefs ? SetPrefs(test.prefs) : Promise.resolve();
|
||||
observedStatus = "nothing";
|
||||
var name = "'" + test.keySystem + "'";
|
||||
return p.then(function() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
navigator.requestMediaKeySystemAccess(test.keySystem, [{initDataTypes:["cenc"]}])
|
||||
.then(
|
||||
function(keySystemAccess) {
|
||||
return keySystemAccess.createMediaKeys();
|
||||
})
|
||||
.then(
|
||||
function(mediaKeys) {
|
||||
ok(test.shouldPass, name + " passed and was expected to " + (test.shouldPass ? "pass" : "fail"));
|
||||
is(observedStatus, test.expectedStatus, name + " observer service result");
|
||||
resolve();
|
||||
}
|
||||
)
|
||||
.catch(
|
||||
function() {
|
||||
ok(!test.shouldPass, name + " failed and was expected to " + (test.shouldPass ? "pass" : "fail"));
|
||||
is(observedStatus, test.expectedStatus, name + " observer service result");
|
||||
resolve();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const CLEARKEY_ID = 'org.w3.clearkey';
|
||||
|
||||
var tests = [
|
||||
{
|
||||
keySystem: CLEARKEY_ID,
|
||||
shouldPass: false,
|
||||
expectedStatus: 'api-disabled',
|
||||
prefs: [["media.eme.enabled", false], ["media.eme.clearkey.enabled", true]]
|
||||
},
|
||||
{
|
||||
keySystem: CLEARKEY_ID,
|
||||
shouldPass: false,
|
||||
expectedStatus: 'cdm-disabled',
|
||||
prefs: [["media.eme.enabled", true], ["media.eme.clearkey.enabled", false]]
|
||||
},
|
||||
{
|
||||
keySystem: 'unsupported-keysystem',
|
||||
shouldPass: false,
|
||||
expectedStatus: 'cdm-not-supported'
|
||||
},
|
||||
{
|
||||
keySystem: CLEARKEY_ID + '.10000' , // A stupendously high min CDM version, presumably not installed.
|
||||
shouldPass: false,
|
||||
expectedStatus: 'cdm-insufficient-version',
|
||||
prefs: [["media.eme.enabled", true], ["media.eme.clearkey.enabled", true]]
|
||||
},
|
||||
{
|
||||
keySystem: CLEARKEY_ID,
|
||||
shouldPass: true,
|
||||
expectedStatus: 'cdm-created',
|
||||
prefs: [["media.eme.enabled", true], ["media.eme.clearkey.enabled", true]]
|
||||
},
|
||||
];
|
||||
|
||||
SetupEMEPref(function() {
|
||||
tests.reduce(function(p,c,i,array) {
|
||||
return p.then(function() { return Test(c); });
|
||||
}, Promise.resolve()).then(SimpleTest.finish);
|
||||
});
|
||||
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user