OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>setMediaKeys() multiple times with the same MediaKeys.</title> | 4 <title>setMediaKeys() multiple times with the same 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 mediaKeys; | 17 var mediaKeys; |
17 | 18 |
18 assert_equals(video.mediaKeys, null); | 19 assert_equals(video.mediaKeys, null); |
19 | 20 |
20 return navigator.requestMediaKeySystemAccess('org.w3.clearkey',
[{}]).then(function(access) { | 21 return navigator.requestMediaKeySystemAccess('org.w3.clearkey',
getConfigurationForFile(content)).then(function(access) { |
21 return access.createMediaKeys(); | 22 return access.createMediaKeys(); |
22 }).then(function(result) { | 23 }).then(function(result) { |
23 mediaKeys = result; | 24 mediaKeys = result; |
24 assert_not_equals(mediaKeys, null); | 25 assert_not_equals(mediaKeys, null); |
25 // Set mediaKeys on video should work. | 26 // Set mediaKeys on video should work. |
26 return video.setMediaKeys(mediaKeys); | 27 return video.setMediaKeys(mediaKeys); |
27 }).then(function() { | 28 }).then(function() { |
28 assert_true(video.mediaKeys === mediaKeys); | 29 assert_true(video.mediaKeys === mediaKeys); |
29 // Set mediaKeys on video again should return a resolved | 30 // Set mediaKeys on video again should return a resolved |
30 // promise. | 31 // promise. |
31 return video.setMediaKeys(mediaKeys); | 32 return video.setMediaKeys(mediaKeys); |
32 }).then(function() { | 33 }).then(function() { |
33 assert_true(video.mediaKeys === mediaKeys); | 34 assert_true(video.mediaKeys === mediaKeys); |
34 // Load the media element to create the WebMediaPlayer. | 35 // Load the media element to create the WebMediaPlayer. |
35 video.src = '../content/test-encrypted.webm'; | 36 video.src = content; |
36 // Set mediaKeys again on video should still return a | 37 // Set mediaKeys again on video should still return a |
37 // resolved promise. | 38 // resolved promise. |
38 return video.setMediaKeys(mediaKeys); | 39 return video.setMediaKeys(mediaKeys); |
39 }).then(function() { | 40 }).then(function() { |
40 assert_true(video.mediaKeys === mediaKeys); | 41 assert_true(video.mediaKeys === mediaKeys); |
41 }); | 42 }); |
42 }, 'setMediaKeys() multiple times with the same MediaKeys.'); | 43 }, 'setMediaKeys() multiple times with the same MediaKeys.'); |
43 </script> | 44 </script> |
44 </body> | 45 </body> |
45 </html> | 46 </html> |
OLD | NEW |