summaryrefslogtreecommitdiffstats
path: root/dom/media/test/test_eme_getstatusforpolicy.html
blob: 2993dac7a6f73a076eb88b3859add93deb12772b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!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">
<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() {
  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>