blob: e18d31a36f32db0369da6a674e67219cbc4ae470 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
<!DOCTYPE HTML>
<html>
<head>
<title>Test generating encrypted request in Widevine privacy mode</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">
function Test() {
return new Promise(function(resolve) {
var configs = [{
initDataTypes: ['keyids'],
videoCapabilities: [{contentType: 'video/mp4' }],
}];
navigator.requestMediaKeySystemAccess('com.widevine.alpha', configs)
.then((access) => access.createMediaKeys(),
(e) => { throw e; })
.then((mediaKeys) => {
var session = mediaKeys.createSession('temporary');
session.addEventListener('message', event => {
is(event.messageType, 'license-request',
'MediaKeyMessage type should be license-request.');
const request = new Uint8Array(event.message);
info('request generated[' + request.length + ']: [' + request + ']');
ok(request.length == 2 && request[0] == 0x08 && request[1] == 0x04,
'Widevine license request should be [0x08, 0x04] in privacy mode');
session.close().then(() => { resolve(); });
});
return session.generateRequest('keyids',
new TextEncoder().encode('{"kids":["MDAwMDAwMDAwMDAwMDAwMQ=="]}'));
},
(e) => { throw e; })
.catch((e) => {
is(e.name, 'NotSupportedError',
'Should only be rejected when "not supported"');
resolve();
});
});
}
SimpleTest.waitForExplicitFinish();
Test().then(function() {
SimpleTest.finish();
});
</script>
</pre>
</body>
</html>
|