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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/script-multiple-blocked.php

Issue 2020223002: Refactor nonce support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@inline
Patch Set: Rebase. Created 4 years, 6 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
Index: third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/script-multiple-blocked.php
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/script-multiple-blocked.php b/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/script-multiple-blocked.php
new file mode 100644
index 0000000000000000000000000000000000000000..e57d1ee0a067408afbe446c1f258b8137b454c11
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/script-multiple-blocked.php
@@ -0,0 +1,36 @@
+<?php
+ header("Content-Security-Policy: script-src 'self' 'nonce-abc'");
+ header("Content-Security-Policy-Report-Only: script-src 'unsafe-inline' 'self'");
+?>
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script nonce="abc">
+ async_test(t => {
+ var watcher = new EventWatcher(t, document, ['securitypolicyviolation','securitypolicyviolation']);
+ watcher
+ .wait_for('securitypolicyviolation')
+ .then(t.step_func(e => {
+ assert_equals(e.blockedURI, "inline");
+ assert_equals(e.lineNumber, 23);
+ return watcher.wait_for('securitypolicyviolation');
+ }))
+ .then(t.step_func_done(e => {
+ assert_equals(e.blockedURI, "inline");
+ assert_equals(e.lineNumber, 26);
+ }));
+ }, "Unnonced script blocks generate reports.");
+
+ var executed_test = async_test("Nonced script executes, and does not generate a violation report.");
+ var unexecuted_test = async_test("Blocks without correct nonce do not execute, and generate violation reports");
+</script>
+<script>
+ unexecuted_test.assert_unreached("This code block should not execute.");
+</script>
+<script nonce="xyz">
+ unexecuted_test.assert_unreached("This code block should not execute.");
+</script>
+<script nonce="abc">
+ executed_test.done();
+ unexecuted_test.done();
+</script>

Powered by Google App Engine
This is Rietveld 408576698