Skip to content

Commit 12c5b8a

Browse files
committed
added optionalDependencies: fsevents to package.json + readded tests
1 parent 25543aa commit 12c5b8a

File tree

13 files changed

+257
-0
lines changed

13 files changed

+257
-0
lines changed

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,5 +149,8 @@
149149
],
150150
"sourceMap": true,
151151
"instrument": true
152+
},
153+
"optionalDependencies": {
154+
"fsevents": "^2.1.3"
152155
}
153156
}

test/svelte-styles-csp/index.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
const puppeteer = require("puppeteer");
2+
import * as assert from "assert";
3+
const path = require("path");
4+
5+
// set to false to view transitions tested in Chromium
6+
const headless_browser = true;
7+
8+
describe("svelte-style-csp", async () => {
9+
describe("test transitions with svelte-styles-csp & strict-CSP", async () => {
10+
it("svelte-stylesheet loaded and transitions work", async () => {
11+
const absolutePath = path.join(
12+
__dirname,
13+
"svelte-test-transitions-styles-csp/index.html"
14+
);
15+
const browser = await puppeteer.launch({ headless: headless_browser });
16+
const page = await browser.newPage();
17+
try {
18+
await page.goto("file://" + absolutePath);
19+
await page.waitFor(1000);
20+
let linkTitle: string;
21+
// look for title attribute in link tags to
22+
const linkTitles = await page.evaluateHandle(() => {
23+
return Array.from(document.getElementsByTagName("link")).map(
24+
(a) => a.title
25+
);
26+
});
27+
const linkList = await linkTitles.jsonValue();
28+
29+
for (const item of linkList) {
30+
if (item == "svelte-stylesheet") linkTitle = item;
31+
}
32+
33+
await page.click("input");
34+
await page.waitFor(1000);
35+
await page.click("input");
36+
await page.waitFor(1000);
37+
await browser.close();
38+
assert.equal(linkTitle, "svelte-stylesheet");
39+
} catch (err) {
40+
throw new Error(err);
41+
}
42+
}).timeout(10000);
43+
});
44+
45+
describe("test transitions without svelte-styles-csp & strict CSP", async () => {
46+
it("transitions fail with strict CSP and no stylesrc: unsafe-iline", async () => {
47+
const absolutePath = path.join(
48+
__dirname,
49+
"svelte-test-transitions-no-styles-csp/index.html"
50+
);
51+
const browser = await puppeteer.launch({ headless: headless_browser });
52+
const page = await browser.newPage();
53+
try {
54+
await page.goto("file://" + absolutePath);
55+
await page.waitFor(1000);
56+
await page.click("input");
57+
await page.waitFor(1000);
58+
await page.click("input");
59+
await page.waitFor(1000);
60+
await browser.close();
61+
} catch (err) {
62+
// Transitions should fail with strict CSP
63+
assert.throws(err);
64+
}
65+
}).timeout(10000);
66+
});
67+
});

test/svelte-styles-csp/svelte-test-transitions-no-styles-csp/build/bundle.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/svelte-styles-csp/svelte-test-transitions-no-styles-csp/build/bundle.js

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Loading
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
html, body {
2+
position: relative;
3+
width: 100%;
4+
height: 100%;
5+
}
6+
7+
body {
8+
color: #333;
9+
margin: 0;
10+
padding: 8px;
11+
box-sizing: border-box;
12+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
13+
}
14+
15+
a {
16+
color: rgb(0,100,200);
17+
text-decoration: none;
18+
}
19+
20+
a:hover {
21+
text-decoration: underline;
22+
}
23+
24+
a:visited {
25+
color: rgb(0,80,160);
26+
}
27+
28+
label {
29+
display: block;
30+
}
31+
32+
input, button, select, textarea {
33+
font-family: inherit;
34+
font-size: inherit;
35+
-webkit-padding: 0.4em 0;
36+
padding: 0.4em;
37+
margin: 0 0 0.5em 0;
38+
box-sizing: border-box;
39+
border: 1px solid #ccc;
40+
border-radius: 2px;
41+
}
42+
43+
input:disabled {
44+
color: #ccc;
45+
}
46+
47+
button {
48+
color: #333;
49+
background-color: #f4f4f4;
50+
outline: none;
51+
}
52+
53+
button:disabled {
54+
color: #999;
55+
}
56+
57+
button:not(:disabled):active {
58+
background-color: #ddd;
59+
}
60+
61+
button:focus {
62+
border-color: #666;
63+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset='utf-8'>
5+
<meta name='viewport' content='width=device-width,initial-scale=1'>
6+
<meta http-equiv="Content-Security-Policy" content="default-src 'self';
7+
img-src 'self' data: https:; script-src 'self';
8+
style-src 'self'">
9+
<title>Svelte app</title>
10+
11+
<link rel='icon' type='image/png' href='favicon.png'>
12+
<link rel='stylesheet' href='global.css'>
13+
<link rel='stylesheet' href='build/bundle.css'>
14+
15+
<script defer src='build/bundle.js'></script>
16+
</head>
17+
18+
<body>
19+
</body>
20+
</html>

test/svelte-styles-csp/svelte-test-transitions-styles-csp/build/bundle.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)