зеркало из https://github.com/mozilla/gecko-dev.git
100 строки
3.5 KiB
HTML
100 строки
3.5 KiB
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;
|
|
|
|
function startTest(test, token)
|
|
{
|
|
// Three cases:
|
|
// 1. setting MediaKeys on an element captured by MediaElementSource should fail, and
|
|
// 2. creating a MediaElementSource on a media element with a MediaKeys should fail, and
|
|
// 3. capturing a media element with mozCaptureStream that has a MediaKeys should fail.
|
|
|
|
// Case 1. setting MediaKeys on an element captured by MediaElementSource should fail.
|
|
var case1token = token + "_case1";
|
|
var setKeysFailed = function() {
|
|
ok(true, TimeStamp(case1token) + " setMediaKeys failed as expected.");
|
|
manager.finished(case1token);
|
|
};
|
|
var v1 = SetupEME(test, case1token, { onSetKeysFail: setKeysFailed });
|
|
var context = new AudioContext();
|
|
var node = context.createMediaElementSource(v1);
|
|
v1.addEventListener("error", bail(case1token + " got error event"));
|
|
v1.addEventListener("loadeddata", function(ev) {
|
|
ok(false, TimeStamp(case1token) + " should never reach loadeddata, as setMediaKeys should fail");
|
|
});
|
|
manager.started(case1token);
|
|
LoadTest(test, v1, case1token);
|
|
|
|
|
|
// Case 2. creating a MediaElementSource on a media element with a MediaKeys should fail.
|
|
var case2token = token + "_case2";
|
|
var v2 = SetupEME(test, case2token);
|
|
v2.addEventListener("error", bail(case2token + " got error event"));
|
|
v2.addEventListener("loadeddata", function(ev) {
|
|
ok(true, case2token + " should reach loadeddata");
|
|
var threw = false;
|
|
try {
|
|
var context = new AudioContext();
|
|
var node = context.createMediaElementSource(v2);
|
|
} catch (e) {
|
|
threw = true;
|
|
}
|
|
ok(threw, "Should throw an error creating a MediaElementSource on an EME video.");
|
|
manager.finished(case2token);
|
|
});
|
|
manager.started(case2token);
|
|
LoadTest(test, v2, case2token);
|
|
|
|
|
|
// Case 3. capturing a media element with mozCaptureStream that has a MediaKeys should fail.
|
|
var case3token = token + "_case3";
|
|
var v3 = SetupEME(test, case3token);
|
|
v3.addEventListener("error", bail(case3token + " got error event"));
|
|
v3.addEventListener("loadeddata", function(ev) {
|
|
ok(true, TimeStamp(case3token) + " should reach loadeddata");
|
|
var threw = false;
|
|
try {
|
|
var stream = v3.mozCaptureStreamUntilEnded();
|
|
} catch (e) {
|
|
threw = true;
|
|
}
|
|
ok(threw, TimeStamp(case3token) + " Should throw an error calling mozCaptureStreamUntilEnded an EME video.");
|
|
manager.finished(case3token);
|
|
});
|
|
manager.started(case3token);
|
|
LoadTest(test, v3, case3token);
|
|
}
|
|
|
|
function beginTest() {
|
|
manager.runTests(gEMETests, startTest);
|
|
}
|
|
|
|
var prefs = [
|
|
[ "media.mediasource.enabled", true ],
|
|
[ "media.mediasource.mp4.enabled", true ],
|
|
];
|
|
|
|
if (/Linux/.test(navigator.userAgent) ||
|
|
!document.createElement('video').canPlayType("video/mp4")) {
|
|
// XXX remove once we have mp4 PlatformDecoderModules on all platforms.
|
|
prefs.push([ "media.fragmented-mp4.exposed", true ]);
|
|
prefs.push([ "media.fragmented-mp4.use-blank-decoder", true ]);
|
|
}
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
SpecialPowers.pushPrefEnv({ "set" : prefs }, beginTest);
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|