test_eme_session_callable_value.html (1305B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title>Test Encrypted Media Extensions</title> 5 <script src="/tests/SimpleTest/SimpleTest.js"></script> 6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 7 <script type="text/javascript" src="manifest.js"></script> 8 <script type="text/javascript" src="eme.js"></script> 9 </head> 10 <body> 11 <pre id="test"> 12 <script class="testbody" type="text/javascript"> 13 14 function Test() { 15 navigator.requestMediaKeySystemAccess(CLEARKEY_KEYSYSTEM, gCencMediaKeySystemConfig) 16 .then(access => access.createMediaKeys()) 17 .then(mediaKeys => { 18 var initData = (new TextEncoder()).encode( 'this is an invalid license, and that is ok'); 19 var s = mediaKeys.createSession("temporary"); 20 s.generateRequest("cenc", initData); // ignore result. 21 // "update()" call should fail, because MediaKeySession is "not callable" 22 // yet, since CDM won't have had a chance to set the sessionId on MediaKeySession. 23 return s.update(initData); 24 }) 25 .then(()=>{ok(false, "An exception should be thrown; MediaKeySession should be not callable."); SimpleTest.finish();}, 26 ()=>{ok(true, "We expect this to fail; MediaKeySession should be not callable."); SimpleTest.finish();}); 27 } 28 29 SimpleTest.waitForExplicitFinish(); 30 Test(); 31 </script> 32 </pre> 33 </body> 34 </html>