Skip to content

Commit c8eb682

Browse files
committed
test: ensure CSP header in stream response
1 parent fce240d commit c8eb682

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export function load() {
2+
return {
3+
lazy: new Promise((resolve) => setTimeout(() => resolve(), 1000)).then(() => 'Moo Deng!')
4+
};
5+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<script>
2+
export let data;
3+
</script>
4+
5+
{#await data.lazy}
6+
Loading...
7+
{:then value}
8+
<h2>{value}</h2>
9+
{/await}

packages/kit/test/apps/options/test/test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,15 @@ test.describe('CSP', () => {
130130
expect(await page.evaluate('window.pwned')).toBe(undefined);
131131
});
132132

133+
test('ensure CSP header in stream response', async ({ page, javaScriptEnabled }) => {
134+
if (!javaScriptEnabled) return;
135+
const response = await page.goto('/path-base/csp-with-stream');
136+
expect(response.headers()['content-security-policy']).toMatch(
137+
/require-trusted-types-for 'script'/
138+
);
139+
expect(await page.textContent('h2')).toBe('Moo Deng!');
140+
});
141+
133142
test("quotes 'script'", async ({ page }) => {
134143
const response = await page.goto('/path-base');
135144
expect(response.headers()['content-security-policy']).toMatch(

0 commit comments

Comments
 (0)