summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/trusted-types/trusted-types-tojson.tentative.html
blob: 72c538309941389b1fad9a24d7db75f55138d855 (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
<!DOCTYPE html>
<head>
  <script src="/resources/testharness.js"></script>
  <script src="/resources/testharnessreport.js"></script>
  <meta http-equiv="Content-Security-Policy" content="trusted-types foo">
</head>
<body>
<script>
test(t => {
  let policy = trustedTypes.createPolicy("foo", {
    createHTML: h => h,
    createScript: s => s,
    createScriptURL: u => u,
   });

  assert_equals(JSON.stringify({"x": policy.createHTML("<p>foo</p>")}),
                "{\"x\":\"<p>foo</p>\"}");
  assert_equals(JSON.stringify({"x": policy.createScript("foo(bar)")}),
                "{\"x\":\"foo(bar)\"}");
  assert_equals(JSON.stringify({"x": policy.createScriptURL("https://foo.example.com/bar")}),
                "{\"x\":\"https://foo.example.com/bar\"}");
}, "toJSON");
</script>
</body>