OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE HTML> | |
2 <meta http-equiv="Content-Security-Policy" content="img-src 'self' {{domains[www ]}}:{{ports[http][0]}}"> | |
3 <html> | |
4 <head> | |
5 <title>img element src attribute must match src list.</title> | |
6 <script src='/resources/testharness.js'></script> | |
7 <script src='/resources/testharnessreport.js'></script> | |
8 </head> | |
9 <body> | |
10 <div id='log'/> | |
11 | |
12 <script> | |
13 async_test(function(t) { | |
14 i = new Image(); | |
15 i.onload = t.step_func_done(function() { | |
16 assert_equals(168, i.naturalWidth); | |
17 assert_equals(64, i.naturalHeight); | |
18 }); | |
19 i.onerror = t.unreached_func("The img should have loaded"); | |
20 i.src = '/content-security-policy/support/pass.png'; | |
21 }, "img-src for relative path should load"); | |
22 | |
23 async_test(function(t) { | |
24 i = new Image(); | |
25 i.onload = t.unreached_func("Image from unapproved domain was loaded."); | |
26 i.onerror = t.step_func_done(); | |
27 i.src = 'http://www1.web-platform.test/content-security-policy/support/f ail.png'; | |
Mike West
2017/03/23 10:19:35
{{domains[www1]}}
| |
28 }, "img-src from unapproved domains should not load"); | |
29 | |
30 async_test(function(t) { | |
31 i = new Image(); | |
32 i.onload = t.step_func_done(function() { | |
33 assert_equals(168, i.naturalWidth); | |
34 assert_equals(64, i.naturalHeight); | |
35 }); | |
36 i.onerror = t.unreached_func("The img should have loaded"); | |
37 i.src = location.protocol + '//www.' + location.hostname + ':' + locatio n.port + | |
Mike West
2017/03/23 10:19:36
{{domains[www]}}
| |
38 '/content-security-policy/support/pass.png'; | |
39 }, "img-src from approved domains should load"); | |
40 </script> | |
41 </body> | |
42 </html> | |
OLD | NEW |