Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1001)

Side by Side Diff: LayoutTests/media/encrypted-media/encrypted-media-playback-multiple-sessions.html

Issue 658633002: Update EME playback-multiple-sessions test to avoid flakiness (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: comments Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Clear Key Playback with Multiple Sessions</title> 4 <title>Clear Key Playback with Multiple Sessions</title>
5 <script src="encrypted-media-utils.js"></script> 5 <script src="encrypted-media-utils.js"></script>
6 <script src="../../resources/testharness.js"></script> 6 <script src="../../resources/testharness.js"></script>
7 <script src="../../resources/testharnessreport.js"></script> 7 <script src="../../resources/testharnessreport.js"></script>
8 </head> 8 </head>
9 <body> 9 <body>
10 <video id="testVideo"></video> 10 <video id="testVideo"></video>
11 <div id="log"></div> 11 <div id="log"></div>
12 <p>Test playback of encrypted media using Clear Key key system with mult iple sessions.</p> 12 <p>Test playback of encrypted media using Clear Key key system with mult iple sessions.</p>
13 <script> 13 <script>
14 async_test(function(test) 14 async_test(function(test)
15 { 15 {
16 var video = document.getElementById('testVideo'); 16 var video = document.getElementById('testVideo');
17 var audioMediaKeySession = null; 17 var audioMediaKeySession = null;
18 var videoMediaKeySession = null; 18 var videoMediaKeySession = null;
19 var audioInitDataType = null;
20 var videoInitDataType = null;
21 var audioInitData = null;
22 var videoInitData = null;
19 var audioKeyProvided = false; 23 var audioKeyProvided = false;
20 var videoKeyProvided = false; 24 var videoKeyProvided = false;
21 25
22 // The 2 streams use different key ids and different keys. 26 // The 2 streams use different key ids and different keys.
23 var audioKeyId = '1234567890123456'; 27 var audioKeyId = '1234567890123456';
24 var audioKey = new Uint8Array([0x30, 0x30, 0x62, 0xF1, 0x68, 0x1 4, 0xD2, 0x7B, 28 var audioKey = new Uint8Array([0x30, 0x30, 0x62, 0xF1, 0x68, 0x1 4, 0xD2, 0x7B,
25 0x68, 0xEF, 0x12, 0x2A, 0xFC, 0xE 4, 0xAE, 0x0A]); 29 0x68, 0xEF, 0x12, 0x2A, 0xFC, 0xE 4, 0xAE, 0x0A]);
26 var videoKeyId = '0123456789012345'; 30 var videoKeyId = '0123456789012345';
27 var videoKey = new Uint8Array([0x7A, 0x7A, 0x62, 0xF1, 0x68, 0x1 4, 0xD2, 0x7B, 31 var videoKey = new Uint8Array([0x7A, 0x7A, 0x62, 0xF1, 0x68, 0x1 4, 0xD2, 0x7B,
28 0x68, 0xEF, 0x12, 0x2A, 0xFC, 0xE 4, 0xAE, 0x0A]); 32 0x68, 0xEF, 0x12, 0x2A, 0xFC, 0xE 4, 0xAE, 0x0A]);
29 33
30 function onEncrypted(event) 34 function onEncrypted(event)
31 { 35 {
32 var keyId = String.fromCharCode.apply(null, new Uint8Array(e vent.initData)); 36 var keyId = String.fromCharCode.apply(null, new Uint8Array(e vent.initData));
33 37
38 // To avoid issues when comparing the expected.txt file
39 // (which logs the events in the order they occur), save
40 // the initData and make the calls to generateRequest()
41 // only after both "onencrypted" events are received.
42 // This prevents a "message" event from occurring before
43 // both "onencrypted" events are received.
34 var mediaKeySession = video.mediaKeys.createSession(); 44 var mediaKeySession = video.mediaKeys.createSession();
35 waitForEventAndRunStep('message', mediaKeySession, onMessage , test); 45 if (keyId == videoKeyId) {
36 mediaKeySession.generateRequest(event.initDataType, event.in itData).then(function() { 46 assert_equals(videoMediaKeySession, null);
37 if (keyId == videoKeyId) { 47 videoMediaKeySession = mediaKeySession;
38 assert_equals(videoMediaKeySession, null); 48 videoInitDataType = event.initDataType;
39 videoMediaKeySession = mediaKeySession; 49 videoInitData = event.initData;
40 } else { 50 // Return if audio "onencrypted" event not yet received.
41 assert_equals(keyId, audioKeyId); 51 if (audioMediaKeySession == null)
42 assert_equals(audioMediaKeySession, null); 52 return;
43 audioMediaKeySession = mediaKeySession; 53 } else {
44 } 54 assert_equals(keyId, audioKeyId);
45 }).catch(function(error) { 55 assert_equals(audioMediaKeySession, null);
56 audioMediaKeySession = mediaKeySession;
57 audioInitDataType = event.initDataType;
58 audioInitData = event.initData;
59 // Return if video "onencrypted" event not yet received.
60 if (videoMediaKeySession == null)
61 return;
62 }
63
64 // Both sessions have been created.
65 assert_not_equals(videoMediaKeySession, null);
66 assert_not_equals(audioMediaKeySession, null);
67
68 var promises = [];
69 waitForEventAndRunStep('message', videoMediaKeySession, onMe ssage, test);
70 promises.push(videoMediaKeySession.generateRequest(videoInit DataType, videoInitData));
71
72 waitForEventAndRunStep('message', audioMediaKeySession, onMe ssage, test);
73 promises.push(audioMediaKeySession.generateRequest(audioInit DataType, audioInitData));
74
75 Promise.all(promises).catch(function(error) {
46 forceTestFailureFromPromise(test, error); 76 forceTestFailureFromPromise(test, error);
47 }); 77 });
48 } 78 }
49 79
50 function onMessage(event) 80 function onMessage(event)
51 { 81 {
52 var keyId = extractSingleKeyIdFromMessage(event.message); 82 var keyId = extractSingleKeyIdFromMessage(event.message);
53 if (event.target == videoMediaKeySession) { 83 if (event.target == videoMediaKeySession) {
54 assert_equals(String.fromCharCode.apply(null, keyId), vi deoKeyId); 84 assert_equals(String.fromCharCode.apply(null, keyId), vi deoKeyId);
55 var jwkSet = stringToUint8Array(createJWKSet(createJWK(k eyId, videoKey))); 85 var jwkSet = stringToUint8Array(createJWKSet(createJWK(k eyId, videoKey)));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 return video.setMediaKeys(mediaKeys); 127 return video.setMediaKeys(mediaKeys);
98 }).then(function(result) { 128 }).then(function(result) {
99 video.play(); 129 video.play();
100 }).catch(function(error) { 130 }).catch(function(error) {
101 forceTestFailureFromPromise(test, error); 131 forceTestFailureFromPromise(test, error);
102 }); 132 });
103 }, 'Playback using Clear Key key system with multiple sessions.'); 133 }, 'Playback using Clear Key key system with multiple sessions.');
104 </script> 134 </script>
105 </body> 135 </body>
106 </html> 136 </html>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698