gecko-dev/dom/media/test/test_eme_canvas_blocked.html

64 строки
1.6 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>Test Encrypted Media Extensions</title>
<script 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)
{
manager.started(token);
let v = document.createElement("video");
v.preload = "auto"; // Required due to "canplay" not firing for MSE unless we do this.
var p1 = new EMEPromise;
v.addEventListener("loadeddata", function(ev) {
var video = ev.target;
var canvas = document.createElement("canvas");
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
document.body.appendChild(canvas);
var ctx = canvas.getContext("2d");
var threwError = false;
try {
ctx.drawImage(video, 0, 0);
} catch (ex) {
threwError = true;
}
ok(threwError, TimeStamp(token) + " - Should throw an error when trying to draw EME video to canvas.");
p1.resolve();
});
let p2 = SetupEME(v, test, token);
Promise.all([p1.promise, p2])
.catch(reason => ok(false, reason))
.then(() => {
CleanUpMedia(v);
manager.finished(token);
});
}
function beginTest() {
manager.runTests(gEMETests, startTest);
}
if (!IsMacOSSnowLeopardOrEarlier()) {
SimpleTest.waitForExplicitFinish();
SetupEMEPref(beginTest);
} else {
todo(false, "Test disabled on this platform.");
}
</script>
</pre>
</body>
</html>