| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <body> | 2 <body> |
| 3 <script type="text/javascript"> | 3 <script type="text/javascript"> |
| 4 // Since promises run asynchronously, use the pages title to keep track | 4 // Since promises run asynchronously, use the pages title to keep track |
| 5 // of the result. | 5 // of the result. |
| 6 function setResultInTitle(title) { | 6 function setResultInTitle(title) { |
| 7 if (title == "" || title == "success" || | 7 if (title == "" || title == "success" || |
| 8 title == "Unsupported keySystem" || | 8 title == "Unsupported keySystem" || |
| 9 title == "None of the requested configurations were supported.") { | 9 title == "None of the requested configurations were supported.") { |
| 10 document.title = title; | 10 document.title = title; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 return actual[i].contentType + " does not match " + | 26 return actual[i].contentType + " does not match " + |
| 27 expected[i].contentType + " at index " + i; | 27 expected[i].contentType + " at index " + i; |
| 28 } | 28 } |
| 29 return "success"; | 29 return "success"; |
| 30 } | 30 } |
| 31 | 31 |
| 32 // Calls navigator.requestMediaKeySystemAccess() using the supplied codec | 32 // Calls navigator.requestMediaKeySystemAccess() using the supplied codec |
| 33 // lists, and then verifies the result. Sets page title when done. | 33 // lists, and then verifies the result. Sets page title when done. |
| 34 function requestMediaKeySystemAccessAndVerifyConfiguration( | 34 function requestMediaKeySystemAccessAndVerifyConfiguration( |
| 35 keySystem, initDataType, audioCodecList, videoCodecList) { | 35 keySystem, initDataType, audioCodecList, videoCodecList) { |
| 36 var configuration = {initDataTypes: [initDataType]}; | 36 var configuration = { |
| 37 initDataTypes: [initDataType], |
| 38 audioCapabilities: [], |
| 39 videoCapabilities: [] |
| 40 }; |
| 37 if (audioCodecList !== null) { | 41 if (audioCodecList !== null) { |
| 38 configuration.audioCapabilities = []; | |
| 39 for (entry of audioCodecList) { | 42 for (entry of audioCodecList) { |
| 40 configuration.audioCapabilities.push({contentType: entry}); | 43 configuration.audioCapabilities.push({contentType: entry}); |
| 41 }; | 44 }; |
| 42 } | 45 } |
| 43 if (videoCodecList !== null) { | 46 if (videoCodecList !== null) { |
| 44 configuration.videoCapabilities = []; | |
| 45 for (entry of videoCodecList) { | 47 for (entry of videoCodecList) { |
| 46 configuration.videoCapabilities.push({contentType: entry}); | 48 configuration.videoCapabilities.push({contentType: entry}); |
| 47 }; | 49 }; |
| 48 } | 50 } |
| 49 // This is using promises which will run asynchronously. | 51 // This is using promises which will run asynchronously. |
| 50 navigator.requestMediaKeySystemAccess(keySystem, [configuration]) | 52 navigator.requestMediaKeySystemAccess(keySystem, [configuration]) |
| 51 .then(function(response) { | 53 .then(function(response) { |
| 52 var allowedConfig = response.getConfiguration(); | 54 var allowedConfig = response.getConfiguration(); |
| 53 if (allowedConfig.initDataTypes.length !== 1) { | 55 if (allowedConfig.initDataTypes.length !== 1) { |
| 54 setResultInTitle("initDataType length mismatch"); | 56 setResultInTitle("initDataType length mismatch"); |
| 55 return; | 57 return; |
| 56 } | 58 } |
| 57 if (allowedConfig.initDataTypes[0] !== initDataType) { | 59 if (allowedConfig.initDataTypes[0] !== initDataType) { |
| 58 setResultInTitle("initDataType returned " + | 60 setResultInTitle("initDataType returned " + |
| 59 allowedConfig.initDataTypes[0] + | 61 allowedConfig.initDataTypes[0] + |
| 60 ", expected " + initDataType); | 62 ", expected " + initDataType); |
| 61 return; | 63 return; |
| 62 } | 64 } |
| 63 if (audioCodecList !== null) { | 65 if (audioCodecList !== null) { |
| 64 var result = | 66 var result = |
| 65 verifyCapabilitiesAreEqual(allowedConfig.audioCapabilities, | 67 verifyCapabilitiesAreEqual(allowedConfig.audioCapabilities, |
| 66 configuration.audioCapabilities); | 68 configuration.audioCapabilities); |
| 67 if (result !== "success") { | 69 if (result !== "success") { |
| 68 setResultInTitle(result); | 70 setResultInTitle(result); |
| 69 return; | 71 return; |
| 70 } | 72 } |
| 71 } else if (allowedConfig.audioCapabilities) { | 73 } else if (allowedConfig.audioCapabilities.length > 0) { |
| 72 setResultInTitle("audioCapabilities set when none expected"); | 74 setResultInTitle("audioCapabilities set when none expected"); |
| 73 return; | 75 return; |
| 74 } | 76 } |
| 75 if (videoCodecList !== null) { | 77 if (videoCodecList !== null) { |
| 76 setResultInTitle( | 78 setResultInTitle( |
| 77 verifyCapabilitiesAreEqual(allowedConfig.videoCapabilities, | 79 verifyCapabilitiesAreEqual(allowedConfig.videoCapabilities, |
| 78 configuration.videoCapabilities)); | 80 configuration.videoCapabilities)); |
| 79 return; | 81 return; |
| 80 } else if (allowedConfig.videoCapabilities) { | 82 } else if (allowedConfig.videoCapabilities.length > 0) { |
| 81 setResultInTitle("videoCapabilities set when none expected"); | 83 setResultInTitle("videoCapabilities set when none expected"); |
| 82 return; | 84 return; |
| 83 } | 85 } |
| 84 setResultInTitle("success"); | 86 setResultInTitle("success"); |
| 85 }) | 87 }) |
| 86 .catch(function(err) { setResultInTitle(err.message); }); | 88 .catch(function(err) { setResultInTitle(err.message); }); |
| 87 }; | 89 }; |
| 88 | 90 |
| 89 function checkKeySystemWithMediaMimeType(keySystem, initDataType, | 91 function checkKeySystemWithMediaMimeType(keySystem, initDataType, |
| 90 audioCodecList, videoCodecList) { | 92 audioCodecList, videoCodecList) { |
| 91 setResultInTitle(""); | 93 setResultInTitle(""); |
| 92 requestMediaKeySystemAccessAndVerifyConfiguration( | 94 requestMediaKeySystemAccessAndVerifyConfiguration( |
| 93 keySystem, initDataType, audioCodecList, videoCodecList); | 95 keySystem, initDataType, audioCodecList, videoCodecList); |
| 94 }; | 96 }; |
| 95 </script> | 97 </script> |
| 96 </body> | 98 </body> |
| 97 </html> | 99 </html> |
| OLD | NEW |