OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>setMediaKeys() on multiple video elements.</title> | 4 <title>setMediaKeys() on multiple video elements.</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="video1"></video> | 10 <video id="video1"></video> |
11 <video id="video2"></video> | 11 <video id="video2"></video> |
12 <div id="log"></div> | 12 <div id="log"></div> |
13 <script> | 13 <script> |
14 promise_test(function(test) | 14 promise_test(function(test) |
15 { | 15 { |
16 var video1 = document.getElementById('video1'); | 16 var video1 = document.getElementById('video1'); |
17 var video2 = document.getElementById('video2'); | 17 var video2 = document.getElementById('video2'); |
18 var mediaKeys; | 18 var mediaKeys; |
19 | 19 |
20 return navigator.requestMediaKeySystemAccess('org.w3.clearkey',
[{}]).then(function(access) { | 20 return navigator.requestMediaKeySystemAccess('org.w3.clearkey',
getSimpleConfiguration()).then(function(access) { |
21 return access.createMediaKeys(); | 21 return access.createMediaKeys(); |
22 }).then(function(result) { | 22 }).then(function(result) { |
23 mediaKeys = result; | 23 mediaKeys = result; |
24 // Assignment to video1 should work. | 24 // Assignment to video1 should work. |
25 return video1.setMediaKeys(mediaKeys); | 25 return video1.setMediaKeys(mediaKeys); |
26 }).then(function() { | 26 }).then(function() { |
27 // Assignment to video2 should fail. | 27 // Assignment to video2 should fail. |
28 return video2.setMediaKeys(mediaKeys); | 28 return video2.setMediaKeys(mediaKeys); |
29 }).then(function() { | 29 }).then(function() { |
30 assert_unreached('Second setMediaKeys should have failed.'); | 30 assert_unreached('Second setMediaKeys should have failed.'); |
31 }, function(error) { | 31 }, function(error) { |
32 assert_equals(error.name, 'QuotaExceededError'); | 32 assert_equals(error.name, 'QuotaExceededError'); |
33 assert_not_equals(error.message, ''); | 33 assert_not_equals(error.message, ''); |
34 // Return something so the promise resolves properly. | 34 // Return something so the promise resolves properly. |
35 return Promise.resolve(); | 35 return Promise.resolve(); |
36 }).then(function() { | 36 }).then(function() { |
37 // Now clear it from video1. | 37 // Now clear it from video1. |
38 return video1.setMediaKeys(null); | 38 return video1.setMediaKeys(null); |
39 }).then(function() { | 39 }).then(function() { |
40 // Should be assignable to video2. | 40 // Should be assignable to video2. |
41 return video2.setMediaKeys(mediaKeys); | 41 return video2.setMediaKeys(mediaKeys); |
42 }); | 42 }); |
43 }, 'setMediaKeys() on multiple video elements.'); | 43 }, 'setMediaKeys() on multiple video elements.'); |
44 </script> | 44 </script> |
45 </body> | 45 </body> |
46 </html> | 46 </html> |
OLD | NEW |