OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Test handling of invalid initData for generateRequest().</title> | 4 <title>Test handling of invalid initData for generateRequest().</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 <div id="log"></div> | 10 <div id="log"></div> |
11 <script> | 11 <script> |
12 // Create a session and call generateRequest() with |initDataType| | 12 // Create a session and call generateRequest() with |initDataType| |
13 // and |initData|. generateRequest() should fail with an | 13 // and |initData|. generateRequest() should fail with an |
14 // InvalidAccessError. Returns a promise that resolves successfully | 14 // InvalidAccessError. Returns a promise that resolves successfully |
15 // if the error happened, rejects otherwise. | 15 // if the error happened, rejects otherwise. |
16 function test_session(initDataType, initData) | 16 function test_session(initDataType, initData) |
17 { | 17 { |
18 return isInitDataTypeSupported(initDataType).then(function(resul
t) { | 18 return isInitDataTypeSupported(initDataType).then(function(resul
t) { |
19 // If |initDataType| is not supported, simply succeed. | 19 // If |initDataType| is not supported, simply succeed. |
20 if (!result) | 20 if (!result) |
21 return Promise.resolve('Not supported'); | 21 return Promise.resolve('Not supported'); |
22 | 22 |
23 return navigator.requestMediaKeySystemAccess('org.w3.clearke
y', [{}]).then(function(access) { | 23 return navigator.requestMediaKeySystemAccess('org.w3.clearke
y', getSimpleConfigurationForInitDataType(initDataType)).then(function(access) { |
24 return access.createMediaKeys(); | 24 return access.createMediaKeys(); |
25 }).then(function(mediaKeys) { | 25 }).then(function(mediaKeys) { |
26 var mediaKeySession = mediaKeys.createSession(); | 26 var mediaKeySession = mediaKeys.createSession(); |
27 return mediaKeySession.generateRequest(initDataType, ini
tData); | 27 return mediaKeySession.generateRequest(initDataType, ini
tData); |
28 }).then(function() { | 28 }).then(function() { |
29 assert_unreached('generateRequest() succeeded'); | 29 assert_unreached('generateRequest() succeeded'); |
30 }, function(error) { | 30 }, function(error) { |
31 assert_equals(error.name, 'InvalidAccessError'); | 31 assert_equals(error.name, 'InvalidAccessError'); |
32 return Promise.resolve('success'); | 32 return Promise.resolve('success'); |
33 }); | 33 }); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 promise_test(function() | 94 promise_test(function() |
95 { | 95 { |
96 // Valid key ID size must be less than 512 characters for keyids
. | 96 // Valid key ID size must be less than 512 characters for keyids
. |
97 var keyId = new Uint8Array(600); | 97 var keyId = new Uint8Array(600); |
98 var initData = stringToUint8Array(createKeyIDs(keyId)); | 98 var initData = stringToUint8Array(createKeyIDs(keyId)); |
99 return test_session('keyids', initData); | 99 return test_session('keyids', initData); |
100 }, 'generateRequest() with too long key ID.'); | 100 }, 'generateRequest() with too long key ID.'); |
101 </script> | 101 </script> |
102 </body> | 102 </body> |
103 </html> | 103 </html> |
OLD | NEW |