mirror of https://github.com/sveltejs/svelte
parent
817cf28040
commit
1a200ca0e6
@ -0,0 +1,70 @@
|
||||
const puppeteer = require('puppeteer');
|
||||
import * as assert from 'assert';
|
||||
const path = require('path');
|
||||
|
||||
// set to false to view transitions tested in Chromium
|
||||
const headless_browser = true;
|
||||
|
||||
// set to true to allow 1000ms delay between transition start and finish
|
||||
// (gives time to view transitions when not in headless mode)
|
||||
const transition_delay = false;
|
||||
|
||||
describe('svelte-style-csp', async () => {
|
||||
describe('test transitions with svelte-styles-csp & strict-CSP', async () => {
|
||||
it('svelte-stylesheet loaded and transitions work', async () => {
|
||||
const absolutePath = path.join(
|
||||
__dirname,
|
||||
'svelte-test-transitions-styles-csp/index.html'
|
||||
);
|
||||
const browser = await puppeteer.launch({ headless: headless_browser });
|
||||
const page = await browser.newPage();
|
||||
try {
|
||||
await page.goto('file://' + absolutePath);
|
||||
let linkTitle: string;
|
||||
const linkTitles = await page.evaluateHandle(() => {
|
||||
return Array.from(document.getElementsByTagName('link')).map(
|
||||
(a) => a.title
|
||||
);
|
||||
});
|
||||
const linkList = await linkTitles.jsonValue();
|
||||
|
||||
for (const item of linkList) {
|
||||
if (item == 'svelte-stylesheet') linkTitle = item;
|
||||
}
|
||||
|
||||
await page.click('input');
|
||||
if (transition_delay) {
|
||||
await page.waitFor(1000);
|
||||
}
|
||||
await page.click('input');
|
||||
await browser.close();
|
||||
assert.equal(linkTitle, 'svelte-stylesheet');
|
||||
} catch (err) {
|
||||
throw new Error(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('test transitions without svelte-styles-csp & strict CSP', async () => {
|
||||
it('transitions fail with strict CSP and no style-src: unsafe-inline', async () => {
|
||||
const absolutePath = path.join(
|
||||
__dirname,
|
||||
'svelte-test-transitions-no-styles-csp/index.html'
|
||||
);
|
||||
const browser = await puppeteer.launch({ headless: headless_browser });
|
||||
const page = await browser.newPage();
|
||||
try {
|
||||
await page.goto('file://' + absolutePath);
|
||||
await page.click('input');
|
||||
if (transition_delay) {
|
||||
await page.waitFor(1000);
|
||||
}
|
||||
await page.click('input');
|
||||
await browser.close();
|
||||
} catch (err) {
|
||||
// Transitions should fail with strict CSP
|
||||
assert.throws(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -0,0 +1 @@
|
||||
h1.svelte-i7qo5m{color:purple}.contact-card.svelte-vatk6b{box-shadow:0 2px 8px rgba(0, 0, 0, 0.26);max-width:30rem;border-radius:5px;margin:1rem 0}header.svelte-vatk6b{display:flex;justify-content:space-between;align-items:center;height:7rem}.thumb.svelte-vatk6b{width:33%;height:100%}.thumb-placeholder.svelte-vatk6b{background-color:grey}img.svelte-vatk6b{width:100%;height:100%;object-fit:cover}.user-data.svelte-vatk6b{width:67%;display:flex;flex-direction:column;justify-content:center}h1.svelte-vatk6b{font-size:1.25rem;font-family:"Roboto Slab", sans-serif;margin:0.5rem 0}h2.svelte-vatk6b{font-size:1rem;font-weight:normal;color:#5a5a5a;margin:0;margin-bottom:0.5rem}.description.svelte-vatk6b{border-top:1px solid #ccc;padding:1rem}
|
||||
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 3.1 KiB |
@ -0,0 +1,63 @@
|
||||
html, body {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
color: #333;
|
||||
margin: 0;
|
||||
padding: 8px;
|
||||
box-sizing: border-box;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
||||
}
|
||||
|
||||
a {
|
||||
color: rgb(0,100,200);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: rgb(0,80,160);
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
}
|
||||
|
||||
input, button, select, textarea {
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
-webkit-padding: 0.4em 0;
|
||||
padding: 0.4em;
|
||||
margin: 0 0 0.5em 0;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
input:disabled {
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
button {
|
||||
color: #333;
|
||||
background-color: #f4f4f4;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
button:disabled {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
button:not(:disabled):active {
|
||||
background-color: #ddd;
|
||||
}
|
||||
|
||||
button:focus {
|
||||
border-color: #666;
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<meta name='viewport' content='width=device-width,initial-scale=1'>
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self';
|
||||
img-src 'self' data: https:; script-src 'self';
|
||||
style-src 'self'">
|
||||
<title>Svelte app</title>
|
||||
|
||||
<link rel='icon' type='image/png' href='favicon.png'>
|
||||
<link rel='stylesheet' href='global.css'>
|
||||
<link rel='stylesheet' href='build/bundle.css'>
|
||||
|
||||
<script defer src='build/bundle.js'></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1 @@
|
||||
h1.svelte-i7qo5m{color:purple}.contact-card.svelte-vatk6b{box-shadow:0 2px 8px rgba(0, 0, 0, 0.26);max-width:30rem;border-radius:5px;margin:1rem 0}header.svelte-vatk6b{display:flex;justify-content:space-between;align-items:center;height:7rem}.thumb.svelte-vatk6b{width:33%;height:100%}.thumb-placeholder.svelte-vatk6b{background-color:grey}img.svelte-vatk6b{width:100%;height:100%;object-fit:cover}.user-data.svelte-vatk6b{width:67%;display:flex;flex-direction:column;justify-content:center}h1.svelte-vatk6b{font-size:1.25rem;font-family:"Roboto Slab", sans-serif;margin:0.5rem 0}h2.svelte-vatk6b{font-size:1rem;font-weight:normal;color:#5a5a5a;margin:0;margin-bottom:0.5rem}.description.svelte-vatk6b{border-top:1px solid #ccc;padding:1rem}
|
||||
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 3.1 KiB |
@ -0,0 +1,63 @@
|
||||
html, body {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
color: #333;
|
||||
margin: 0;
|
||||
padding: 8px;
|
||||
box-sizing: border-box;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
||||
}
|
||||
|
||||
a {
|
||||
color: rgb(0,100,200);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: rgb(0,80,160);
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
}
|
||||
|
||||
input, button, select, textarea {
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
-webkit-padding: 0.4em 0;
|
||||
padding: 0.4em;
|
||||
margin: 0 0 0.5em 0;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
input:disabled {
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
button {
|
||||
color: #333;
|
||||
background-color: #f4f4f4;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
button:disabled {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
button:not(:disabled):active {
|
||||
background-color: #ddd;
|
||||
}
|
||||
|
||||
button:focus {
|
||||
border-color: #666;
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<meta name='viewport' content='width=device-width,initial-scale=1'>
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src;
|
||||
img-src 'self' data: https:; script-src 'self';
|
||||
style-src 'self'">
|
||||
<title>Svelte app</title>
|
||||
|
||||
<link rel='icon' type='image/png' href='favicon.png'>
|
||||
<link rel='stylesheet' href='global.css'>
|
||||
<link rel='stylesheet' href='build/bundle.css'>
|
||||
<link rel='stylesheet' title='svelte-stylesheet' href='svelte-stylesheet.css'>
|
||||
|
||||
<script defer src='build/bundle.js'></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in new issue