2016-08-21 23:52:45 +03:00
|
|
|
<!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>
|
2017-11-03 07:30:58 +03:00
|
|
|
<script type="text/javascript" src="https://example.com:443/tests/dom/media/test/eme.js"></script>
|
2016-08-21 23:52:45 +03:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
var manager = new MediaTestManager;
|
|
|
|
|
|
|
|
function startTest(test, token)
|
|
|
|
{
|
|
|
|
manager.started(token);
|
|
|
|
|
2017-04-21 12:10:13 +03:00
|
|
|
let v = document.createElement("video");
|
2016-08-21 23:52:45 +03:00
|
|
|
document.body.appendChild(v);
|
|
|
|
|
|
|
|
var gotWaitingForKey = 0;
|
2016-09-21 05:10:26 +03:00
|
|
|
var gotOnwaitingforkey = 0;
|
2016-08-21 23:52:45 +03:00
|
|
|
|
2017-04-21 12:10:13 +03:00
|
|
|
let waitForKey = new EMEPromise;
|
2016-08-21 23:52:45 +03:00
|
|
|
v.addEventListener("waitingforkey", function() {
|
|
|
|
gotWaitingForKey += 1;
|
2017-04-21 12:10:13 +03:00
|
|
|
waitForKey.resolve();
|
2016-08-21 23:52:45 +03:00
|
|
|
});
|
|
|
|
|
2016-09-21 05:10:26 +03:00
|
|
|
v.onwaitingforkey = function() {
|
|
|
|
gotOnwaitingforkey += 1;
|
|
|
|
};
|
|
|
|
|
2016-08-21 23:52:45 +03:00
|
|
|
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");
|
|
|
|
});
|
|
|
|
|
2017-04-21 12:10:13 +03:00
|
|
|
let finish = new EMEPromise;
|
2016-08-21 23:52:45 +03:00
|
|
|
v.addEventListener("ended", function() {
|
|
|
|
ok(true, TimeStamp(token) + " got ended 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);
|
2016-09-21 05:10:26 +03:00
|
|
|
ok(gotOnwaitingforkey == gotWaitingForKey, "Should have as many event listener calls as event handler calls, got: " + gotOnwaitingforkey);
|
2016-08-21 23:52:45 +03:00
|
|
|
|
2017-04-21 12:10:13 +03:00
|
|
|
finish.resolve();
|
2016-08-21 23:52:45 +03:00
|
|
|
});
|
|
|
|
|
2017-04-21 12:10:13 +03:00
|
|
|
Promise.all([
|
|
|
|
LoadInitData(v, test, token),
|
|
|
|
CreateAndSetMediaKeys(v, test, token),
|
|
|
|
LoadTest(test, v, token),
|
|
|
|
waitForKey.promise])
|
|
|
|
.then(values => {
|
|
|
|
let initData = values[0];
|
|
|
|
return ProcessInitData(v, test, token, initData);
|
|
|
|
})
|
|
|
|
.then(sessions => {
|
|
|
|
Log(token, "Updated all sessions, loading complete -> Play");
|
|
|
|
v.play();
|
|
|
|
finish.promise.then(() => CloseSessions(v, sessions));
|
|
|
|
return finish.promise;
|
|
|
|
})
|
|
|
|
.catch(reason => ok(false, reason))
|
|
|
|
.then(() => manager.finished(token));
|
2016-08-21 23:52:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function beginTest() {
|
|
|
|
manager.runTests(gEMETests, startTest);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!IsMacOSSnowLeopardOrEarlier()) {
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
SetupEMEPref(beginTest);
|
|
|
|
} else {
|
|
|
|
todo(false, "Test disabled on this platform.");
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|