Bug 1690477 [wpt PR 27455] - [Trusted Types] Add toJSON to the trusted type interfaces., a=testonly

Automatic update from web-platform-tests
[Trusted Types] Add toJSON to the trusted type interfaces.

Addresses https://github.com/w3c/webappsec-trusted-types/issues/306

Change-Id: I595fd60ba68bfe0b5f0122873616e525943f51a5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2665936
Commit-Queue: Stefano Sanfilippo <ssanfilippo@chromium.org>
Reviewed-by: Daniel Vogelheim <vogelheim@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Cr-Commit-Position: refs/heads/master@{#851153}

--

wpt-commits: 4e70b1a4cb822274621d4ce9620bd396e1cc93f5
wpt-pr: 27455
This commit is contained in:
Stefano Sanfilippo 2021-02-09 04:38:38 +00:00 коммит произвёл moz-wptsync-bot
Родитель a667408f33
Коммит 864ca8dffd
1 изменённых файлов: 24 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,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>