| Kunihiko Sakamoto | 1a4049a | 2017-09-27 09:54:31 | [diff] [blame] | 1 | <!DOCTYPE html> | 
| Rob Buis | 7f72c4e | 2019-05-15 09:54:19 | [diff] [blame^] | 2 | <title>Makes sure that Link headers preload resources with CSP nonce</title> | 
| Kunihiko Sakamoto | 1a4049a | 2017-09-27 09:54:31 | [diff] [blame] | 3 | <script nonce="abc" src="/resources/testharness.js"></script> | 
|  | 4 | <script nonce="abc" src="/resources/testharnessreport.js"></script> | 
|  | 5 | <script nonce="abc" src="/preload/resources/preload_helper.js"></script> | 
| Rob Buis | 7f72c4e | 2019-05-15 09:54:19 | [diff] [blame^] | 6 | <body> | 
| Kunihiko Sakamoto | 1a4049a | 2017-09-27 09:54:31 | [diff] [blame] | 7 | <script nonce="abc"> | 
| Rob Buis | 7f72c4e | 2019-05-15 09:54:19 | [diff] [blame^] | 8 | setup({explicit_done: true}); | 
|  | 9 |  | 
|  | 10 | var iterations = 0; | 
|  | 11 |  | 
|  | 12 | function check_finished() { | 
|  | 13 | if (numberOfResourceTimingEntries("resources/dummy.js?from-header&without-nonce") == 0 && | 
|  | 14 | numberOfResourceTimingEntries("resources/dummy.js?from-header&with-nonce") == 1) { | 
|  | 15 | done(); | 
|  | 16 | } | 
|  | 17 | iterations++; | 
|  | 18 | if (iterations == 10) { | 
|  | 19 | // At least one is expected to fail, but this should give details to the exact failure(s). | 
|  | 20 | verifyNumberOfResourceTimingEntries("resources/dummy.js?from-header&without-nonce", 0); | 
|  | 21 | verifyNumberOfResourceTimingEntries("resources/dummy.js?from-header&with-nonce", 1); | 
|  | 22 | done(); | 
|  | 23 | } else { | 
|  | 24 | step_timeout(check_finished, 500); | 
|  | 25 | } | 
|  | 26 | } | 
|  | 27 |  | 
|  | 28 | window.addEventListener("load", function() { | 
|  | 29 | verifyPreloadAndRTSupport(); | 
|  | 30 | step_timeout(check_finished, 0); | 
|  | 31 | }); | 
| Kunihiko Sakamoto | 1a4049a | 2017-09-27 09:54:31 | [diff] [blame] | 32 | </script> | 
| Rob Buis | 7f72c4e | 2019-05-15 09:54:19 | [diff] [blame^] | 33 | </body> |