Commit 85e02f50 authored by Stefano Sanfilippo's avatar Stefano Sanfilippo Committed by Commit Bot

[Trusted Types] Test that a policy rejection blocks eval.

Change-Id: I20ce9961645deb44bab857d69a1c641600646d65
Bug: 940927
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1911206
Commit-Queue: Stefano Sanfilippo <ssanfilippo@chromium.org>
Reviewed-by: default avatarDaniel Vogelheim <vogelheim@chromium.org>
Auto-Submit: Stefano Sanfilippo <ssanfilippo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#715230}
parent 19d249f4
...@@ -10,11 +10,12 @@ ...@@ -10,11 +10,12 @@
</head> </head>
<body> <body>
<script nonce="abc"> <script nonce="abc">
let p = createScript_policy(window, 1); const p = createScript_policy(window, 1);
test(t => { test(t => {
let a = 0; let a = 0;
assert_throws(new EvalError(), _ => { assert_throws(new EvalError(), _ => {
eval('a="hello there"') eval('a="hello there"');
}); });
assert_equals(a, 0); assert_equals(a, 0);
}, "eval with plain string throws (both block)."); }, "eval with plain string throws (both block).");
......
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<meta http-equiv="Content-Security-Policy" content="trusted-types *">
</head>
<body>
<script>
trustedTypes.createPolicy("default", {createScript: _ => null});
test(t => {
let a = 0;
assert_throws(new EvalError(), _ => {
eval('a="hello there"');
});
assert_equals(a, 0);
}, "eval blocks if the default policy rejects a value.");
</script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment