summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fenced-frame/picture-in-picture.https.html
blob: 9665f88b9c045ffac8a6ca49280d3bceb5efea5a (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
<!DOCTYPE html>
<title>Test of picture-in-picture</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/utils.js"></script>
<script src="/common/dispatcher/dispatcher.js"></script>
<script src="resources/utils.js"></script>

<body>
<script>
promise_test(async () => {
  const frame = attachFencedFrameContext();
  const result = await frame.execute(async () => {
    const video = document.body.appendChild(document.createElement("video"));
    try {
      await video.requestPictureInPicture();
      return 'PIP request succeeded.';
    } catch (e) {
      if (e.name == 'SecurityError') {
        return 'PIP request failed';
      } else {
        return `PIP request failed but not with SecurityError - ${e.name}: ${e.message}`;
      }
    }
  });
  assert_equals(
      result, 'PIP request failed',
      'PIP request must fail in a fenced frame by permissions policy.');
}, 'Test HTMLVideoElement.requestPictureInPicture');
</script>
</body>