Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1636)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/import-enforce-allowed.php

Issue 2147853003: Teach 'LinkRequestBuilder' about the 'nonce' attribute. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@preload
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/import-enforce-blocked.php » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/import-enforce-allowed.php
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/import-enforce-allowed.php b/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/import-enforce-allowed.php
new file mode 100644
index 0000000000000000000000000000000000000000..e1f91e9f8cece2406297b467cd470722c004ea26
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/import-enforce-allowed.php
@@ -0,0 +1,24 @@
+<?php
+ header("Content-Security-Policy: script-src 'nonce-abc'");
+?>
+<!doctype html>
+<script nonce="abc" src="/resources/testharness.js"></script>
+<script nonce="abc" src="/resources/testharnessreport.js"></script>
+<script nonce="abc">
+ async_test(t => {
+ document.addEventListener('securitypolicyviolation', t.unreached_func("No report should be generated"));
+ window.onload = t.step_func(_ => {
+ var link = document.createElement('link');
+ link.setAttribute("rel", "import");
+ link.setAttribute("nonce", "abc");
+ link.setAttribute("href", "/security/resources/blank.html");
+
+ link.onerror = t.unreached_func("The import should load.");
+ link.onload = t.step_func_done(_ => {
+ assert_true(!!link.import);
+ });
+
+ document.body.appendChild(link);
+ });
+ }, "Nonced imports load, and do not trigger reports.");
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/import-enforce-blocked.php » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698