зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1391666 - P1. Mochitest to verify correct behavior. r=gerald
We load 10s of encrypted video, which should trigger readyState being HAVE_ENOUGH_DATA MozReview-Commit-ID: 4VRLFHSFlDs --HG-- extra : rebase_source : 919310b00f0ec271a73e149992696bc1eec8cd5f
This commit is contained in:
Родитель
f1083dd2b4
Коммит
aefd5c8c8a
Двоичный файл не отображается.
|
@ -0,0 +1 @@
|
|||
Cache-Control: no-store
|
|
@ -222,7 +222,7 @@ function AppendTrack(test, ms, track, token)
|
|||
|
||||
//Returns a promise that is resolved when the media element is ready to have
|
||||
//its play() function called; when it's loaded MSE fragments.
|
||||
function LoadTest(test, elem, token)
|
||||
function LoadTest(test, elem, token, endOfStream = true)
|
||||
{
|
||||
if (!test.tracks) {
|
||||
ok(false, token + " test does not have a tracks list");
|
||||
|
@ -240,7 +240,9 @@ function LoadTest(test, elem, token)
|
|||
return AppendTrack(test, ms, track, token);
|
||||
})).then(function() {
|
||||
Log(token, "Tracks loaded, calling MediaSource.endOfStream()");
|
||||
ms.endOfStream();
|
||||
if (endOfStream) {
|
||||
ms.endOfStream();
|
||||
}
|
||||
resolve();
|
||||
}).catch(reject);
|
||||
}, {once: true});
|
||||
|
|
|
@ -72,6 +72,8 @@ support-files =
|
|||
bipbop-cenc-video2.m4s^headers^
|
||||
bipbop-cenc-videoinit.mp4
|
||||
bipbop-cenc-videoinit.mp4^headers^
|
||||
bipbop-cenc-video-10s.mp4
|
||||
bipbop-cenc-video-10s.mp4^headers^
|
||||
bipbop_225w_175kbps-cenc-audio-key1-1.m4s
|
||||
bipbop_225w_175kbps-cenc-audio-key1-1.m4s^headers^
|
||||
bipbop_225w_175kbps-cenc-audio-key1-2.m4s
|
||||
|
@ -747,6 +749,8 @@ skip-if = toolkit == 'android' # bug 1336166
|
|||
[test_delay_load.html]
|
||||
skip-if = android_version == '17' # android(bug 1232305)
|
||||
[test_duration_after_error.html]
|
||||
[test_eme_autoplay.html]
|
||||
skip-if = toolkit == 'android' # bug 1149374
|
||||
[test_eme_pssh_in_moof.html]
|
||||
skip-if = toolkit == 'android' # bug 1149374
|
||||
[test_eme_session_callable_value.html]
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
<!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="http://test1.mochi.test:8888/tests/dom/media/test/eme.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
var manager = new MediaTestManager;
|
||||
|
||||
var EMEmanifest = [
|
||||
{
|
||||
name:"bipbop 10s",
|
||||
tracks: [
|
||||
{
|
||||
name:"video",
|
||||
type:"video/mp4; codecs=\"avc1.4d4015\"",
|
||||
fragments:[ "bipbop-cenc-video-10s.mp4",
|
||||
]
|
||||
}
|
||||
],
|
||||
keys: {
|
||||
"7e571d037e571d037e571d037e571d11" : "7e5733337e5733337e5733337e573311",
|
||||
},
|
||||
sessionType:"temporary",
|
||||
sessionCount:1,
|
||||
duration:10.01
|
||||
},
|
||||
];
|
||||
|
||||
function startTest(test, token)
|
||||
{
|
||||
manager.started(token);
|
||||
|
||||
let v = document.createElement("video");
|
||||
v.controls = true;
|
||||
v.autoplay = true;
|
||||
|
||||
document.body.appendChild(v);
|
||||
|
||||
var eventCounts = { play: 0, playing: 0};
|
||||
function ForbiddenEvents(e) {
|
||||
var v = e.target;
|
||||
ok(v.readyState >= v.HAVE_FUTURE_DATA, "Must not have received event too early");
|
||||
is(eventCounts[e.type], 0, "event should have only be fired once");
|
||||
eventCounts[e.type]++;
|
||||
}
|
||||
// Log events for debugging.
|
||||
var events = ["suspend", "play", "canplay", "canplaythrough", "loadstart", "loadedmetadata",
|
||||
"loadeddata", "playing", "ended", "error", "stalled", "emptied", "abort",
|
||||
"waiting", "pause", "durationchange", "seeking", "seeked"];
|
||||
function logEvent(e) {
|
||||
info("got " + e.type + " event");
|
||||
}
|
||||
events.forEach(function(e) {
|
||||
v.addEventListener(e, logEvent);
|
||||
});
|
||||
v.addEventListener("play", ForbiddenEvents);
|
||||
v.addEventListener("playing", ForbiddenEvents);
|
||||
|
||||
var gotWaitingForKey = 0;
|
||||
|
||||
let waitForKey = new EMEPromise;
|
||||
v.addEventListener("waitingforkey", function() {
|
||||
gotWaitingForKey += 1;
|
||||
waitForKey.resolve();
|
||||
});
|
||||
|
||||
v.addEventListener("loadedmetadata", function() {
|
||||
ok(SpecialPowers.do_lookupGetter(v, "isEncrypted").apply(v),
|
||||
TimeStamp(token) + " isEncrypted should be true");
|
||||
is(v.isEncrypted, undefined, "isEncrypted should not be accessible from content");
|
||||
});
|
||||
|
||||
let finish = new EMEPromise;
|
||||
v.addEventListener("playing", function() {
|
||||
ok(true, TimeStamp(token) + " got playing event");
|
||||
// We expect only one waitingForKey as we delay until all sessions are ready.
|
||||
// I.e. one waitingForKey should be fired, after which, we process all sessions,
|
||||
// so it should not be possible to be blocked by a key after that point.
|
||||
ok(gotWaitingForKey == 1, "Expected number 1 wait, got: " + gotWaitingForKey);
|
||||
|
||||
finish.resolve();
|
||||
});
|
||||
|
||||
Promise.all([
|
||||
LoadInitData(v, test, token),
|
||||
CreateAndSetMediaKeys(v, test, token),
|
||||
LoadTest(test, v, token, false /* do not call endOfStream */),
|
||||
waitForKey.promise])
|
||||
.then(values => {
|
||||
let initData = values[0];
|
||||
return ProcessInitData(v, test, token, initData);
|
||||
})
|
||||
.then(sessions => {
|
||||
Log(token, "Updated all sessions, loading complete");
|
||||
finish.promise.then(() => CloseSessions(v, sessions));
|
||||
return finish.promise;
|
||||
})
|
||||
.catch(reason => ok(false, reason))
|
||||
.then(() => manager.finished(token));
|
||||
}
|
||||
|
||||
function beginTest() {
|
||||
manager.runTests(EMEmanifest, startTest);
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SetupEMEPref(beginTest);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче