-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Andrew <[email protected]> Co-authored-by: Justin Tay <[email protected]>
- Loading branch information
1 parent
f377a84
commit 1d5eec4
Showing
19 changed files
with
273 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { expect, test } from 'vitest' | ||
import { expectWithRetry, getColor, page } from '~utils' | ||
|
||
test('linked css', async () => { | ||
expect(await getColor('.linked')).toBe('blue') | ||
}) | ||
|
||
test('inline style tag', async () => { | ||
expect(await getColor('.inline')).toBe('green') | ||
}) | ||
|
||
test('imported css', async () => { | ||
expect(await getColor('.from-js')).toBe('blue') | ||
}) | ||
|
||
test('dynamic css', async () => { | ||
expect(await getColor('.dynamic')).toBe('red') | ||
}) | ||
|
||
test('script tag', async () => { | ||
await expectWithRetry(() => page.textContent('.js')).toBe('js: ok') | ||
}) | ||
|
||
test('dynamic js', async () => { | ||
await expectWithRetry(() => page.textContent('.dynamic-js')).toBe( | ||
'dynamic-js: ok', | ||
) | ||
}) | ||
|
||
test('meta[property=csp-nonce] is injected', async () => { | ||
const meta = await page.$('meta[property=csp-nonce]') | ||
expect(await (await meta.getProperty('nonce')).jsonValue()).not.toBe('') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.dynamic { | ||
color: red; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import './dynamic.css' | ||
|
||
document.querySelector('.dynamic-js').textContent = 'dynamic-js: ok' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.from-js { | ||
color: blue; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<link rel="stylesheet" href="./linked.css" /> | ||
<style nonce="#$NONCE$#"> | ||
.inline { | ||
color: green; | ||
} | ||
</style> | ||
<script type="module" src="./index.js"></script> | ||
<p class="linked">direct</p> | ||
<p class="inline">inline</p> | ||
<p class="from-js">from-js</p> | ||
<p class="dynamic">dynamic</p> | ||
<p class="js">js: error</p> | ||
<p class="dynamic-js">dynamic-js: error</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import './from-js.css' | ||
|
||
document.querySelector('.js').textContent = 'js: ok' | ||
|
||
import('./dynamic.js') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.linked { | ||
color: blue; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "@vitejs/test-csp", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"debug": "node --inspect-brk ../../packages/vite/bin/vite", | ||
"dev": "vite", | ||
"build": "vite build", | ||
"preview": "vite preview" | ||
} | ||
} |
Oops, something went wrong.