Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / media / encrypted-media / encrypted-media-keystatuses-multiple-updates.html
blobe29c5ab957947ee7a10e1d416e2a3e5a466d8eda
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Verify MediaKeySession.keyStatuses with multiple updates</title>
5 <script src="encrypted-media-utils.js"></script>
6 <script src="../../resources/testharness.js"></script>
7 <script src="../../resources/testharnessreport.js"></script>
8 </head>
9 <body>
10 <div id="log"></div>
11 <script>
12 async_test(function(test)
14 var initDataType;
15 var initData;
16 var mediaKeySession;
17 var firstEvent;
19 // Even though key ids are uint8, using printable values so that
20 // they can be verified easily.
21 var key1 = stringToUint8Array('123');
22 var key2 = stringToUint8Array('4567890');
23 var rawKey1 = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b,
24 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c]);
25 var rawKey2 = new Uint8Array([0x3c, 0xae, 0xe4, 0xfc, 0x2a, 0x12, 0xef, 0x68,
26 0x7b, 0xd2, 0x14, 0x68, 0xf1, 0x62, 0xdd, 0xeb]);
28 function processMessage(event)
30 // No keys added yet.
31 verifyKeyStatuses(mediaKeySession.keyStatuses, { expected: [], unexpected: [key1, key2] });
33 // Add key1 to the session.
34 firstEvent = true;
35 var jwkSet = stringToUint8Array(createJWKSet(createJWK(key1, rawKey1)));
36 mediaKeySession.update(jwkSet).catch(function(error) {
37 forceTestFailureFromPromise(test, error);
38 });
41 function processKeyStatusesChange(event)
43 if (firstEvent) {
44 // Verify that the session only contains key1.
45 dumpKeyStatuses(mediaKeySession.keyStatuses);
46 verifyKeyStatuses(mediaKeySession.keyStatuses, { expected: [key1], unexpected: [key2] });
48 // Now add key2 to the session.
49 firstEvent = false;
50 var jwkSet = stringToUint8Array(createJWKSet(createJWK(key2, rawKey2)));
51 mediaKeySession.update(jwkSet).catch(function(error) {
52 forceTestFailureFromPromise(test, error);
53 });
54 } else {
55 // Verify that the session now contains key1 and key2.
56 dumpKeyStatuses(mediaKeySession.keyStatuses);
57 verifyKeyStatuses(mediaKeySession.keyStatuses, { expected: [key1, key2] });
59 test.done();
63 getSupportedInitDataType().then(function(type) {
64 initDataType = type;
65 initData = getInitData(initDataType);
66 return navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{}]);
67 }).then(function(access) {
68 return access.createMediaKeys();
69 }).then(function(mediaKeys) {
70 mediaKeySession = mediaKeys.createSession();
72 // There should be no keys defined yet.
73 assert_equals(mediaKeySession.keyStatuses.size, 0);
75 waitForEventAndRunStep('message', mediaKeySession, processMessage, test);
76 waitForEventAndRunStep('keystatuseschange', mediaKeySession, processKeyStatusesChange, test);
78 return mediaKeySession.generateRequest(initDataType, initData);
79 }).catch(function(error) {
80 forceTestFailureFromPromise(test, error);
81 });
82 }, 'Verify MediaKeySession.keyStatuses with multiple updates.');
83 </script>
84 </body>
85 </html>