@@ -1827,7 +1827,10 @@ createNextDescribe(
1827
1827
expect ( $ ( 'body' ) . find ( 'script[async]' ) . length ) . toBe ( 1 )
1828
1828
} )
1829
1829
1830
- if ( ! isDev ) {
1830
+ // Turbopack doesn't use eval by default, so we can check strict CSP.
1831
+ if ( ! isDev || isTurbopack ) {
1832
+ // This test is here to ensure that we don't accidentally turn CSP off
1833
+ // for the prod version.
1831
1834
it ( 'should successfully bootstrap even when using CSP' , async ( ) => {
1832
1835
// This path has a nonce applied in middleware
1833
1836
const browser = await next . browser ( '/bootstrap/with-nonce' )
@@ -1844,19 +1847,18 @@ createNextDescribe(
1844
1847
} )
1845
1848
} else {
1846
1849
it ( 'should fail to bootstrap when using CSP in Dev due to eval' , async ( ) => {
1847
- // This test is here to ensure that we don't accidentally turn CSP off
1848
- // for the prod version.
1849
1850
const browser = await next . browser ( '/bootstrap/with-nonce' )
1850
- const response = await next . fetch ( '/bootstrap/with-nonce' )
1851
- // We expect this page to response with CSP headers requiring a nonce for scripts
1852
- expect ( response . headers . get ( 'content-security-policy' ) ) . toContain (
1853
- "script-src 'nonce"
1854
- )
1855
1851
// We expect our app to fail to bootstrap due to invalid eval use in Dev.
1856
1852
// We assert the html is in it's SSR'd state.
1857
1853
expect (
1858
1854
await browser . eval ( 'document.getElementById("val").textContent' )
1859
1855
) . toBe ( 'initial' )
1856
+
1857
+ const response = await next . fetch ( '/bootstrap/with-nonce' )
1858
+ // We expect this page to response with CSP headers requiring a nonce for scripts
1859
+ expect ( response . headers . get ( 'content-security-policy' ) ) . toContain (
1860
+ "script-src 'nonce"
1861
+ )
1860
1862
} )
1861
1863
}
1862
1864
} )
0 commit comments