Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / media / encrypted-media / encrypted-media-playback-setmediakeys-after-src.html
blobdbf9e5b3bd4ab662efc7f62dd38f701e84764ef2
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Clear Key Playback</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 <video id="testVideo"></video>
11 <div id="log"></div>
12 <script>
13 async_test(function(test)
15 var video = document.getElementById('testVideo');
16 var isUpdatePromiseResolved = false;
17 var encryptedEventCount = 0;
19 var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b,
20 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c]);
22 function onEncrypted(event)
24 assert_equals(event.target, video);
25 assert_true(event instanceof window.MediaEncryptedEvent);
26 assert_equals(event.type, 'encrypted');
28 // The same decryption key is used by both the audio and
29 // the video streams so only create a session once. To
30 // avoid issues when comparing the expected.txt file
31 // (which logs the events in the order they occur), create
32 // the session on the second event. This also ensures we
33 // see both events.
34 if (++encryptedEventCount != 2)
35 return;
37 var mediaKeySession = video.mediaKeys.createSession();
38 waitForEventAndRunStep('message', mediaKeySession, onMessage, test);
39 mediaKeySession.generateRequest(event.initDataType, event.initData).catch(function(error) {
40 forceTestFailureFromPromise(test, error);
41 });
44 function onMessage(event)
46 assert_true(event instanceof window.MediaKeyMessageEvent);
47 assert_equals(event.type, 'message');
48 assert_equals(event.messageType, 'license-request');
50 var keyId = extractSingleKeyIdFromMessage(event.message);
51 var jwkSet = stringToUint8Array(createJWKSet(createJWK(keyId, rawKey)));
52 event.target.update(jwkSet).then(function(result) {
53 isUpdatePromiseResolved = true;
54 }).catch(function(error) {
55 forceTestFailureFromPromise(test, error);
56 });
59 function onPlaying(event)
61 // Not using waitForEventAndRunStep() to avoid too many
62 // EVENT(onTimeUpdate) logs.
63 video.addEventListener('timeupdate', onTimeUpdate, true);
66 function onTimeUpdate(event)
68 if (event.target.currentTime < 0.2 || !isUpdatePromiseResolved)
69 return;
71 test.done();
74 navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).then(function(access) {
75 return access.createMediaKeys();
76 }).then(function(mediaKeys) {
78 waitForEventAndRunStep('encrypted', video, onEncrypted, test);
79 waitForEventAndRunStep('playing', video, onPlaying, test);
81 video.src = '../content/test-encrypted.webm';
82 return video.setMediaKeys(mediaKeys);
83 }).then(function(result) {
84 video.play();
85 }).catch(function(error) {
86 forceTestFailureFromPromise(test, error);
87 });
88 }, 'Playback using Clear Key key system, calling setMediaKeys() after setting src attribute.');
89 </script>
90 </body>
91 </html>