Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/cascade/cross-origin.html |
| diff --git a/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/cascade/cross-origin.html b/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/cascade/cross-origin.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6e43fd44f04c72e9ce4421a8f391769fbb5544d9 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/cascade/cross-origin.html |
| @@ -0,0 +1,36 @@ |
| +<!DOCTYPE html> |
| +<html> |
| +<head> |
| + <script src="/resources/testharness.js"></script> |
| + <script src="/resources/testharnessreport.js"></script> |
| + <script src="/security/contentSecurityPolicy/resources/cascade-helper.js"></script> |
| + <meta http-equiv="content-security-policy" content="img-src 'none'"> |
| +</head> |
| +<body> |
| +<script> |
| + async_test(t => { |
| + assert_blocked_image_in_document(t, document, "http://example.test:8000/resources/square.png?img-in-top-level"); |
| + }, "Image loaded in top-level blocked."); |
| + |
| + async_test(t => { |
| + var frame = document.createElement("iframe"); |
| + |
| + window.addEventListener("message", t.step_func(e => { |
| + if (e.source != frame.contentWindow) |
| + return; |
| + |
| + assert_equals(e.data, "blocked"); |
| + t.done(); |
| + })); |
| + |
| + frame.src = "data:text/html,<script>" + |
| + " var i = document.createElement('img');" + |
|
dcheng
2016/11/21 10:14:24
A fun hack I've seen is to define the JS as a func
Mike West
2016/11/29 10:16:28
*sigh* JavaScript is SO WEIRD.
|
| + " i.onload = _ => top.postMessage('loaded', '*');" + |
| + " i.onerror = _ => top.postMessage('blocked', '*');" + |
| + " i.src = 'http://example.test:8000/resources/square.png?data-frame'" + |
| + "</scr" + "ipt>"; |
| + document.body.appendChild(frame); |
| + }, "Image loaded via data: frame blocked."); |
| +</script> |
| +</body> |
| +</html> |