summaryrefslogtreecommitdiffstats
path: root/dom/media/test/crashtests/1608286.html
blob: 9f52605be668aa88f7b8cefa9c18c94335ed5cf1 (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
<html class="reftest-wait">
<head>
  <script>
    function test() {
      function checkResolve(value) {
        // Let the test timeout and fail
        throw new Error("This promise should not resolve");
      }

      function checkReject(reason) {
        if (reason.message !== "Browsing context is no longer available") {
          // Let the test timeout and fail
          throw new Error("Unexpected rejected promise reason");          
        }
        // Otherwise, successfully rejected a request not attached to a
        // window without crashing
      }

      var i = document.querySelector("iframe");
      var nav = i.contentWindow.navigator;
      i.remove();

      // First, check with valid args
      nav.requestMediaKeySystemAccess(
        "com.widevine.alpha",
        [{
            initDataTypes: ["webm"],
            videoCapabilities: [{ contentType: 'video/webm; codecs="vp9"' }]
        }]
      ).then(
        checkResolve,
        (reason) => {
          checkReject(reason);

          // Then, check with invalid args
          nav.requestMediaKeySystemAccess("", []).then(
            checkResolve,
            (reason) => {
              checkReject(reason);
              document.documentElement.removeAttribute("class");
            }
          );
        });
    }
  </script>
</head>
<body onload="test()">
  <iframe></iframe>
</body>
</html>