dom/media/test/test_eme_stream_capture_blocked_case1.html
author R. Martinho Fernandes <bugs@rmf.io>
Sat, 12 Jun 2021 23:42:37 +0000
changeset 582910 f092d76bde6ed523386f39c7ef340be72e06a0ff
parent 554878 6ef23a073f1cb1be8f52ca501c50504e7b644210
permissions -rw-r--r--
Bug 1694639 - Add DOM:Web Authentication tests for sameOriginWithAncestors false r=dveditz Differential Revision: https://phabricator.services.mozilla.com/D105315

<!DOCTYPE HTML>
<html>
<head>
  <title>Test Encrypted Media Extensions</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
  <script type="text/javascript" src="manifest.js"></script>
  <script type="text/javascript" src="eme.js"></script>
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
var manager = new MediaTestManager;

function startTest(test, token)
{
  // Case 1. setting MediaKeys on an element captured by MediaElementSource should fail.
  var case1token = token + "_case1";
  let v1 = document.createElement("video");

  function setMediaKeys() {
    let p = new EMEPromise;
    CreateMediaKeys(v1, test, case1token)
    .then(mediaKeys => {
      v1.setMediaKeys(mediaKeys)
      .then(() => {
        p.reject(`${case1token} setMediaKeys shouldn't succeed.`);
      }, () => {
        ok(true, TimeStamp(case1token) + " setMediaKeys failed as expected.");
        p.resolve();
      })
    }, p.reject);
    return p.promise;
  }

  var context = new AudioContext();
  context.createMediaElementSource(v1);
  v1.addEventListener("loadeddata", function(ev) {
    ok(false, TimeStamp(case1token) + " should never reach loadeddata, as setMediaKeys should fail");
  });

  manager.started(case1token);

  Promise.all([
    LoadTest(test, v1, case1token),
    setMediaKeys()])
  .catch(reason => ok(false, reason))
  .then(() => {
    CleanUpMedia(v1);
    manager.finished(case1token);
  });
}

function beginTest() {
  manager.runTests(gEMETests, startTest);
}

SimpleTest.waitForExplicitFinish();
SetupEMEPref(beginTest);

</script>
</pre>
</body>
</html>