summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/permissions-policy/permissions-policy-opaque-origin-history.https.html
blob: 969ca369e1bcbd211b31e19519a20398c1c32e6b (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
<!DOCTYPE html>
<body>
  <script src=/resources/testharness.js></script>
  <script src=/resources/testharnessreport.js></script>
  <script>

    function get_response() {
      return new Promise(resolve => {
        window.addEventListener('message', e => {
          resolve(e.data);
        }, { once: true });
      });
    }

    promise_test(async () => {
      // - opaque-origin-history1.html navigates itself to opaque-origin-history2.html.
      // - opaque-origin-history2.html call window.history.back() to navigate
      // back to opaque-origin-history1.html
      // - opaque-origin-history1.html should still be able to access fullscreen
      // feature after the history.back() navigation.
      const iframe = document.createElement('iframe');
      // sandbox iframe so that it has opaque origin.
      iframe.sandbox = 'allow-scripts';
      iframe.src = 'resources/opaque-origin-history1.sub.https.html';
      iframe.allow = "fullscreen 'src'";
      document.body.appendChild(iframe);


      assert_equals(
        await get_response(),
        'fullscreen enabled in opaque-origin-history1.html',
        'iframe should be able to access fullscreen.'
      );

      iframe.contentWindow.postMessage('redirect', '*');

      assert_equals(
        await get_response(),
        'fullscreen enabled in opaque-origin-history1.html',
        'iframe should still be able to access fullscreen after history.back() navigation.'
      );
    });
  </script>
</body>