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

82 строки
2.3 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;
var videos = new Set();
var observedVideos = new Set();
var observer = function(subject) {
ok(videos.has(subject), "Video should be known to us");
videos.delete(subject);
observedVideos.add(subject);
};
SpecialPowers.Services.obs.addObserver(observer, "media-eme-metadataloaded", false);
// When the test manager finishes, these sets should all be empty again:
manager.onFinished = function() {
is(videos.size, 0, "video set should be empty");
is(observedVideos.size, 0, "observed video set should be empty");
};
// ... but even if they're not, we should clear them out when we finish:
SimpleTest.registerCleanupFunction(function() {
SpecialPowers.Services.obs.removeObserver(observer, "media-eme-metadataloaded");
videos.clear();
observedVideos.clear();
});
function startTest(test, token)
{
manager.started(token);
var sessions = [];
var v = SetupEME(test, token);
videos.add(v);
v.preload = "auto"; // Required due to "canplay" not firing for MSE unless we do this.
v.addEventListener("loadeddata", function(ev) {
ok(observedVideos.has(ev.target), "Should have been told about eme video through observer as well.");
observedVideos.delete(ev.target);
manager.finished(token);
});
LoadTest(test, v, token);
}
function beginTest() {
manager.runTests(gEMETests, startTest);
}
var prefs = [
[ "media.mediasource.enabled", true ],
[ "media.mediasource.whitelist", false ],
[ "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>