| Index: third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/script-reportonly-allowed.php
|
| diff --git a/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/script-reportonly-allowed.php b/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/script-reportonly-allowed.php
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ac240665920af87ac61a996a6d024f245c56b15d
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/script-reportonly-allowed.php
|
| @@ -0,0 +1,49 @@
|
| +<?php
|
| + header("Content-Security-Policy-Report-Only: script-src 'self' 'nonce-abc'");
|
| +?>
|
| +<!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, 29);
|
| + return watcher.wait_for('securitypolicyviolation');
|
| + }))
|
| + .then(t.step_func_done(e => {
|
| + assert_equals(e.blockedURI, "inline");
|
| + assert_equals(e.lineNumber, 32);
|
| + }));
|
| + }, "Unnonced script blocks generate reports.");
|
| +
|
| + var testList = [
|
| + async_test("Script without nonce executes"),
|
| + async_test("Script with incorrect nonce executes")
|
| + ];
|
| + var executed = [
|
| + false,
|
| + false
|
| + ];
|
| +</script>
|
| +<script>
|
| + executed[0] = true;
|
| +</script>
|
| +<script nonce="xyz">
|
| + executed[1] = true;
|
| +</script>
|
| +<script nonce="abc">
|
| + testList[0].step(_ => {
|
| + assert_true(executed[0]);
|
| + testList[0].done();
|
| + });
|
| +
|
| + testList[1].step(_ => {
|
| + assert_true(executed[1]);
|
| + testList[1].done();
|
| + });
|
| +
|
| +</script>
|
|
|