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

Side by Side Diff: third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-setmediakeys-multiple-times-with-different-mediakeys.html

Issue 2084053002: EME: Update tests so 'audioCapabilities' always provided (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changes (+rebase) Created 4 years, 5 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>setMediaKeys() multiple times with different MediaKeys.</title> 4 <title>setMediaKeys() multiple times with different MediaKeys.</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="video"></video> 10 <video id="video"></video>
11 <div id="log"></div> 11 <div id="log"></div>
12 <script> 12 <script>
13 promise_test(function(test) 13 promise_test(function(test)
14 { 14 {
15 var video = document.getElementById('video'); 15 var video = document.getElementById('video');
16 var content = '../content/test-encrypted.webm';
16 var keySystemAccess; 17 var keySystemAccess;
17 var mediaKeys1; 18 var mediaKeys1;
18 var mediaKeys2; 19 var mediaKeys2;
19 20
20 assert_equals(video.mediaKeys, null); 21 assert_equals(video.mediaKeys, null);
21 22
22 return navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).then(function(access) { 23 return navigator.requestMediaKeySystemAccess('org.w3.clearkey', getConfigurationForFile(content)).then(function(access) {
23 keySystemAccess = access; 24 keySystemAccess = access;
24 // Create a mediaKeys. 25 // Create a mediaKeys.
25 return keySystemAccess.createMediaKeys(); 26 return keySystemAccess.createMediaKeys();
26 }).then(function(result) { 27 }).then(function(result) {
27 mediaKeys1 = result; 28 mediaKeys1 = result;
28 assert_not_equals(mediaKeys1, null); 29 assert_not_equals(mediaKeys1, null);
29 // Create a second mediaKeys. 30 // Create a second mediaKeys.
30 return keySystemAccess.createMediaKeys(); 31 return keySystemAccess.createMediaKeys();
31 }).then(function(result) { 32 }).then(function(result) {
32 mediaKeys2 = result; 33 mediaKeys2 = result;
33 assert_not_equals(mediaKeys2, null); 34 assert_not_equals(mediaKeys2, null);
34 // Set mediaKeys1 on video. 35 // Set mediaKeys1 on video.
35 return video.setMediaKeys(mediaKeys1); 36 return video.setMediaKeys(mediaKeys1);
36 }).then(function() { 37 }).then(function() {
37 assert_true(video.mediaKeys === mediaKeys1); 38 assert_true(video.mediaKeys === mediaKeys1);
38 // Set mediaKeys2 on video (switching MediaKeys). 39 // Set mediaKeys2 on video (switching MediaKeys).
39 return video.setMediaKeys(mediaKeys2); 40 return video.setMediaKeys(mediaKeys2);
40 }).then(function() { 41 }).then(function() {
41 assert_true(video.mediaKeys === mediaKeys2); 42 assert_true(video.mediaKeys === mediaKeys2);
42 // Clear mediaKeys from video. 43 // Clear mediaKeys from video.
43 return video.setMediaKeys(null); 44 return video.setMediaKeys(null);
44 }).then(function() { 45 }).then(function() {
45 assert_equals(video.mediaKeys, null); 46 assert_equals(video.mediaKeys, null);
46 // Set mediaKeys1 on video again. 47 // Set mediaKeys1 on video again.
47 return video.setMediaKeys(mediaKeys1); 48 return video.setMediaKeys(mediaKeys1);
48 }).then(function() { 49 }).then(function() {
49 assert_true(video.mediaKeys === mediaKeys1); 50 assert_true(video.mediaKeys === mediaKeys1);
50 // Load the media element to create the WebMediaPlayer. 51 // Load the media element to create the WebMediaPlayer.
51 video.src = '../content/test-encrypted.webm'; 52 video.src = content;
52 // Set mediaKeys2 on video (switching MediaKeys) not 53 // Set mediaKeys2 on video (switching MediaKeys) not
53 // supported after WebMediaPlayer is created. 54 // supported after WebMediaPlayer is created.
54 return video.setMediaKeys(mediaKeys2); 55 return video.setMediaKeys(mediaKeys2);
55 }).then(function() { 56 }).then(function() {
56 assert_unreached('Switching mediaKeys after setting src shou ld have failed.'); 57 assert_unreached('Switching mediaKeys after setting src shou ld have failed.');
57 }, function(error) { 58 }, function(error) {
58 assert_true(video.mediaKeys === mediaKeys1); 59 assert_true(video.mediaKeys === mediaKeys1);
59 assert_equals(error.name, 'InvalidStateError'); 60 assert_equals(error.name, 'InvalidStateError');
60 assert_not_equals(error.message, ''); 61 assert_not_equals(error.message, '');
61 // Return something so the promise resolves properly. 62 // Return something so the promise resolves properly.
62 return Promise.resolve(); 63 return Promise.resolve();
63 }).then(function() { 64 }).then(function() {
64 // Set null mediaKeys on video (clearing MediaKeys) not 65 // Set null mediaKeys on video (clearing MediaKeys) not
65 // supported after WebMediaPlayer is created. 66 // supported after WebMediaPlayer is created.
66 return video.setMediaKeys(null); 67 return video.setMediaKeys(null);
67 }).then(function() { 68 }).then(function() {
68 assert_unreached('Clearing mediaKeys after setting src shoul d have failed.'); 69 assert_unreached('Clearing mediaKeys after setting src shoul d have failed.');
69 }, function(error) { 70 }, function(error) {
70 assert_true(video.mediaKeys === mediaKeys1); 71 assert_true(video.mediaKeys === mediaKeys1);
71 assert_equals(error.name, 'InvalidStateError'); 72 assert_equals(error.name, 'InvalidStateError');
72 assert_not_equals(error.message, ''); 73 assert_not_equals(error.message, '');
73 return Promise.resolve(); 74 return Promise.resolve();
74 }); 75 });
75 }, 'setMediaKeys() multiple times with different MediaKeys.'); 76 }, 'setMediaKeys() multiple times with different MediaKeys.');
76 </script> 77 </script>
77 </body> 78 </body>
78 </html> 79 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698