Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/content-security-policy/img-src/img-src-self-unique-origin.html

Issue 2937503002: CSP, PlzNavigate: make clear what happens with unique origins. (Closed)
Patch Set: Add web platform tests. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3
4 <head>
5 <title>img-src-self-unique-origin</title>
6 <script src="/resources/testharness.js"></script>
7 <script src="/resources/testharnessreport.js"></script>
8 </head>
9
10 <body>
11 <p>
12 The origin of an URL is called "unique" when it is considered to be
13 different from every origin, including itself. The origin of a
14 data-url is unique. When the current origin is unique, the CSP source
15 'self' must not match any URL.
16 </p>
17 <script>
18 var iframe = document.createElement("iframe");
19 iframe.src = encodeURI(`data:text/html,
20 <script>
21 /* Add the CSP: frame-src: 'self'. */
22 var meta = document.createElement('meta');
23 meta.httpEquiv = 'Content-Security-Policy';
24 meta.content = "img-src 'self'";
25 document.getElementsByTagName('head')[0].appendChild(meta);
26
27 /* Notify the parent the image has been blocked. */
28 window.addEventListener('securitypolicyviolation', e => {
29 if (e.originalPolicy == "img-src 'self'")
30 window.parent.postMessage('Test PASS', '*');
31 });
32 </scr`+`ipt>
33
34 This image should be blocked by CSP:
35 <img src='data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WO yDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNK ToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBM QiB0UjIQA7'></img>
36 `);
37 if (window.async_test) {
38 async_test(t => {
39 window.addEventListener("message", e => {
40 if (e.data == "Test PASS")
41 t.done();
42 });
43 }, "Image's url must not match with 'self'. Image must be blocked.") ;
44 }
45 document.body.appendChild(iframe);
46 </script>
47 </body>
48
49 </html>
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/external/wpt/content-security-policy/frame-src/frame-src-self-unique-origin.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698