summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/trusted-types/tt-block-eval.tentative.html
blob: 13178bd44bf17f06c6d6d46433dcad273367a364 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<!DOCTYPE html>
<html>
<head>
  <script src="/resources/testharness.js"></script>
  <script src="/resources/testharnessreport.js"></script>
  <meta http-equiv="Content-Security-Policy" content="require-trusted-types-for 'script'">
</head>
<body>
<script>
  trustedTypes.createPolicy("default", {createScript: _ => null});

  test(t => {
    let a = 0;
    assert_throws_js(EvalError, _ => {
      eval('a="hello there"');
    });
    assert_equals(a, 0);
  }, "eval blocks if the default policy rejects a value.");
</script>