| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <!-- | 2 <!-- |
| 3 Prefetch page which fetches a script. It includes some javascript that can be | 3 A page that fetches only "prefetch.js" when scanned by NoStatePrefetch, and |
| 4 used to test whether execution occurred. | 4 fetches "prefetch2.js" in addition to that if javascript execution is preformed |
| 5 on the page. In all cases the scripts are executed in a blocking manner. |
| 6 |
| 7 By prefetching this page a browsertest can verify that javascript was not |
| 8 executed (prefetch2.js should not be requested to load even after the page has |
| 9 been fully prefetched (or loaded)). |
| 10 |
| 11 Note: there is no way to ensure that the script loaded via .appendChild() or a |
| 12 sync XHR happens before a preload-scannable request because preload scanner is |
| 13 racy and often fetches resources it sees before the inline script has a chance |
| 14 to execute. |
| 5 --> | 15 --> |
| 6 <head> | |
| 7 <title>Prefetch Page</title> | |
| 8 <script src="prefetch.js" type="text/javascript"></script> | |
| 9 | |
| 10 <script> | |
| 11 // Variables to test if javascript is executed. | |
| 12 var pageBool = true; | |
| 13 var pageAntiBool = false; | |
| 14 </script> | |
| 15 | |
| 16 </head> | |
| 17 <body> | 16 <body> |
| 18 Page content that is necessary for first contentful paint metrics | 17 <script src="prefetch.js"></script> |
| 18 <script> |
| 19 var s = document.createElement("script"); |
| 20 s.src = "prefetch2.js"; |
| 21 document.body.appendChild(s); |
| 22 </script> |
| 23 Some content that is necessary for registering paint metrics. |
| 19 </body> | 24 </body> |
| 20 </html> | 25 </html> |
| OLD | NEW |