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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/content-security-policy/script-src/script-src-strict_dynamic_double_policy_different_nonce.html

Issue 2695813009: Import wpt@503f5b5f78ec4e87d144f78609f363f0ed0ea8db (Closed)
Patch Set: Skip some tests Created 3 years, 10 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE HTML>
2 <html>
3
4 <head>
5 <title>A separate policy with more nonces works correctly with `strict-dynam ic` in the script-src directive.</title>
6 <script src='/resources/testharness.js' nonce='dummy'></script>
7 <script src='/resources/testharnessreport.js' nonce='dummy'></script>
8
9 <!-- CSP served:
10 1) Content-Security-Policy: script-src 'strict-dynamic' 'nonce-dummy'
11 2) Content-Security-Policy: script-src 'nonce-dummy' 'nonce-dummy2'
12 -->
13 </head>
14
15 <body>
16 <h1>A separate policy with more nonces works correctly with `strict-dynamic` in the script-src directive.</h1>
17 <div id='log'></div>
18
19 <script nonce='dummy'>
20 async_test(function(t) {
21 window.addEventListener('message', t.step_func(function(e) {
22 if (e.data === 'unNonced-appendChild') {
23 assert_unreached('Unnonced script injected via `appendChild` is not allowed with `strict-dynamic` + a nonce-only double policy.');
24 }
25 }));
26
27 window.addEventListener('securitypolicyviolation', t.step_func(funct ion(violation) {
28 if (violation.blockedURI.split('?')[1] !== 'unNonced-appendChild ') {
29 return;
30 }
31 assert_equals(violation.effectiveDirective, 'script-src');
32 t.done();
33 }));
34
35 var e = document.createElement('script');
36 e.id = 'unNonced-appendChild';
37 e.src = 'simpleSourcedScript.js?' + e.id;
38 e.onload = t.unreached_func('OnLoad should not be triggered.');
39 document.body.appendChild(e);
40 }, 'Unnonced script injected via `appendChild` is not allowed with `stri ct-dynamic` + a nonce-only double policy.');
41 </script>
42
43 <script nonce='dummy'>
44 async_test(function(t) {
45 window.addEventListener('message', t.step_func(function(e) {
46 if (e.data === 'nonced-appendChild') {
47 t.done();
48 }
49 }));
50
51 window.addEventListener('securitypolicyviolation', t.step_func(funct ion(violation) {
52 if (violation.blockedURI.split('?')[1] !== 'nonced-appendChild') {
53 return;
54 }
55 assert_unreached('No CSP violation report has fired.');
56 }));
57
58 var e = document.createElement('script');
59 e.setAttribute('nonce', 'dummy2');
60 e.id = 'nonced-appendChild';
61 e.src = 'simpleSourcedScript.js?' + e.id;
62 e.onerror = t.unreached_func('Error should not be triggered.');
63 document.body.appendChild(e);
64 }, 'Script injected via `appendChild` with a correct nonce is allowed wi th `strict-dynamic` + a nonce-only double policy.');
65 </script>
66 </body>
67
68 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698