tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_eme_non_mse_fails.html (2292B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>Bug 1131392 - Test that EME does not work for non-MSE media</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 /* import-globals-from eme.js */
     14 var manager = new MediaTestManager;
     15 
     16 function DoSetMediaKeys(v, test, token)
     17 {
     18  var options = [{
     19    initDataTypes: ["cenc"],
     20    audioCapabilities: [{contentType: test.audioType}],
     21    videoCapabilities: [{contentType: test.videoType}],
     22  }];
     23 
     24  return navigator.requestMediaKeySystemAccess(CLEARKEY_KEYSYSTEM, options)
     25 
     26  .then(function(keySystemAccess) {
     27    return keySystemAccess.createMediaKeys();
     28  })
     29 
     30  .catch(function() {
     31    ok(false, token + " was not expecting failure (yet)");
     32  })
     33 
     34  .then(function(mediaKeys) {
     35    return v.setMediaKeys(mediaKeys);
     36  });
     37 }
     38 
     39 function TestSetMediaKeys(test, token)
     40 {
     41  manager.started(token);
     42 
     43  var v = document.createElement("video");
     44 
     45  v.addEventListener("encrypted", function() {
     46    ok(false, token + " should not fire encrypted event");
     47  });
     48 
     49  var loadedMetadata = false;
     50  v.addEventListener("loadedmetadata", function() {
     51    loadedMetadata = true;
     52  });
     53 
     54  v.addEventListener("error", function() {
     55    ok(true, token + " expected error event");
     56    ok(loadedMetadata, token + " expected loadedmetadata to have fired");
     57    manager.finished(token);
     58  });
     59 
     60  v.src = test.name;
     61 }
     62 
     63 function TestSetSrc(test, token)
     64 {
     65  manager.started(token);
     66 
     67  var v = document.createElement("video");
     68  v.addEventListener("error", function() {
     69    ok(true, token + " got error setting src on video element, as expected");
     70    manager.finished(token);
     71  });
     72 
     73  DoSetMediaKeys(v, test, token)
     74 
     75  .then(function() {
     76    v.src = test.name;
     77  })
     78 
     79  .catch(function() {
     80    ok(false, token + " got error setting media keys");
     81  });
     82 }
     83 
     84 function startTest(test, token)
     85 {
     86  TestSetMediaKeys(test, token + "_setMediaKeys");
     87  TestSetSrc(test, token + "_setSrc");
     88 }
     89 
     90 SimpleTest.waitForExplicitFinish();
     91 manager.runTests(gEMENonMSEFailTests, startTest);
     92 </script>
     93 </pre>
     94 </body>
     95 </html>