dom/media/test/test_eme_getstatusforpolicy.html
author Dorel Luca <dluca@mozilla.com>
Sat, 12 Jan 2019 01:28:30 +0200
changeset 453595 c45da646fc6140bd59a36bda18f6cecde6163feb
parent 391787 bbcf8cb962bb430608fac3974f739fabc5bc5aab
child 469641 ba6f655fd68963530c866d0d4a48c3db3d307777
permissions -rw-r--r--
Backed out changeset 24243f13c895 (bug 1519308) for build bustage in mozbuild/mozbuild/test/configure/test_checks_configure.py. CLOSED TREE

<!DOCTYPE HTML>
<html>
<head>
  <title>Test Encrypted Media Extensions</title>
  <script type="text/javascript" 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">
<video id="v" controls></video>
<script class="testbody" type="text/javascript">

SimpleTest.waitForExplicitFinish();

function createMediaKeysAndSet() {
  return navigator.requestMediaKeySystemAccess(CLEARKEY_KEYSYSTEM, gCencMediaKeySystemConfig)
  .then(function (access) {
    return access.createMediaKeys();
  })
  .then(function (mediaKeys) {
    document.getElementById("v").setMediaKeys(mediaKeys);
    return mediaKeys;
  });
}

function test() {
  SetupEMEPref(() => {
    createMediaKeysAndSet()
      .then((m) => {
        let video = document.getElementById("v");
        is(video.mediaKeys, m, "Should have set MediaKeys on media element");
        // getStatusForPolicy() is not suppored by ClearKey key system.
        // The promise will always be rejected with NotSupportedError.
        return video.mediaKeys.getStatusForPolicy({minHdcpVersion: "hdcp-2.0"});
      })
      .then((mediaKeyStatus) => {
        ok(false, "Promise of getStatusForPolicy should not be resolved with clearkey key system");
      })
      // Promise rejected with NotSupportedError as expected.
      .catch(reason => is("NotSupportedError", reason.name,
                          "Promise should be rejected with NotSupportedError."))
      .then(() => SimpleTest.finish());
  });
}

SpecialPowers.pushPrefEnv({"set":
    [
      ["media.eme.hdcp-policy-check.enabled", true],
    ]
  }, test);

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