Skip to content

Commit

Permalink
Merge pull request #1578 from cramforce/csp-test
Browse files Browse the repository at this point in the history
Add example page for testing the CDN CSP.
  • Loading branch information
cramforce committed Jan 26, 2016
2 parents 00bffe0 + c7a99de commit 179835b
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
57 changes: 57 additions & 0 deletions examples/csp.amp.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<!doctype html>
<html >
<head>
<meta charset="utf-8">
<title>AMP Analytics</title>
<link rel="canonical" href="analytics.amp.html" >
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">

<meta http-equiv="Content-Security-Policy" content="default-src * data:; script-src https://cdn.ampproject.org/v0.js https://cdn.ampproject.org/v0/ https://cdn.ampproject.org/viewer/; object-src 'none'; style-src 'unsafe-inline' https://fast.fonts.net https://fonts.googleapis.com; report-uri https://csp-collector.appspot.com/csp/amp">
<link href='https://fonts.googleapis.com/css?family=Questrial' rel='stylesheet' type='text/css'>
<script async custom-element="amp-iframe" src="https://cdn.ampproject.org/v0/amp-iframe-0.1.js"></script>
<script async custom-element="amp-youtube" src="https://cdn.ampproject.org/v0/amp-youtube-0.1.js"></script>
<style>body {opacity: 0}</style><noscript><style>body {opacity: 1}</style></noscript>
<script async src="https://cdn.ampproject.org/v0.js"></script>

<style amp-custom>
#data-svg {
width: 100px;
height: 100px;
background-color: red;
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="#fff" viewBox="0 0 18 18"><path d="M15 8.25H5.87l4.19-4.19L9 3 3 9l6 6 1.06-1.06-4.19-4.19H15v-1.5z" /></svg>')
}
.font {
font-family: 'Questrial'
}
</style>
</head>
<body>

To update, copy current Proxy CSP into meta tag. This file intentionally does not validate, because it uses an inline CSP. Note also, that one CSP error related to the "livereload" script injected by our test server is expected.

<h2>Should show red with arrows</h2>
<div id="data-svg"></div>

<h2 id="iframe">Should say hello world</h2>
<amp-iframe width="300" height="50" src="data:text/html;charset=utf-8;base64,PGgxPmhlbGxvIHdvcmxkPC9oMT4=">
<amp-img placeholder src="img/hero@1x.jpg" width="300" height="50">
</amp-iframe>

<h2>Should show ad<h2>
<amp-ad width=300 height=250
type="a9"
data-aax_size="300x250"
data-aax_pubname="test123"
data-aax_src="302">
</amp-ad>
<h2>Should show YT video</h2>
<amp-youtube
data-videoid="mGENRKrdoGY"
width="240" height="135"></amp-youtube>
<h2>Should show image</h2>
<amp-img src="https://cdn.ampproject.org/i/s/i.guim.co.uk/img/media/dc4d6f2e1198a804b9c9d4b70515a8f7915e1943/0_0_6144_3688/master/6144.jpg?w=700&q=85&auto=format&sharp=10&s=e13bbb3b723ce2d831869edc96ec4b96" width=50 height=50></amp-img>

<h2 class="font">Different font</h2>
</body>
</html>

1 change: 1 addition & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ function buildExamples(watch) {
buildExample('analytics.amp.html');
buildExample('article.amp.html');
buildExample('article-access.amp.html');
buildExample('csp.amp.html');
buildExample('metadata-examples/article-json-ld.amp.html');
buildExample('metadata-examples/article-microdata.amp.html');
buildExample('metadata-examples/recipe-json-ld.amp.html');
Expand Down

0 comments on commit 179835b

Please sign in to comment.