summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fenced-frame/resources/csp-inner.html
blob: 99df39fdc51f2a89f2059ac47d425419cbbbc74a (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
<!DOCTYPE html>
  <script src="utils.js"></script>

  <style>
    body {background-color: red;}
  </style>

  <title>Fenced frame content to test Content Security Policies</title>

  <body>
    <script>
      const [csp_key] = parseKeylist();

      function fail() {
        writeValueToServer(csp_key,
          "FAIL: img-src policy was not honored in fenced frame");
      }

      function pass() {
        // The parent page is going to attempt to pass a
        // style-src: 'none' CSP to the fenced frame. Make sure that
        // the header is not honored.
        const bgcolor = window.getComputedStyle(document.body, null)
                        .getPropertyValue('background-color');

        if (bgcolor != "rgb(255, 0, 0)") {
          writeValueToServer(csp_key,
            "FAIL: style-src policy was passed to fenced frame");
          return;
        }

        writeValueToServer(csp_key, "pass");
      }
    </script>
    <img src="csp.png" id="my_img" onload="fail();" onerror="pass();">
  </body>
</html>