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

Side by Side Diff: LayoutTests/http/tests/security/contentSecurityPolicy/resources/child-src-test.js

Issue 131103010: CSP 1.1: Introduce the 'child-src' directive. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Tests. Created 6 years, 11 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 var EXPECT_BLOCK = true;
2 var EXPECT_LOAD = false;
3
4 window.jsTestIsAsync = true;
5 window.wasPostTestScriptParsed = true;
6
7 var iframe;
8 function injectFrame(url, shouldBlock) {
9 window.onload = function () {
10 iframe = document.createElement('iframe');
11 iframe.onload = iframeLoaded(shouldBlock);
12 iframe.src = url;
13 document.body.appendChild(iframe);
14 };
15 }
16
17 function iframeLoaded(expectBlock) {
18 return function(ev) {
19 var failed = true;
20 try {
21 console.log("IFrame load event fired: the IFrame's location is '" + ev.target.contentWindow.location.href + "'.");
22 if (expectBlock) {
23 testFailed("The IFrame should have been blocked (or cross-origin ). It wasn't.");
24 failed = true;
25 } else {
26 testPassed("The IFrame should not have been blocked. It wasn't." );
27 failed = false;
28 }
29 } catch (ex) {
30 debug("IFrame load event fired: the IFrame is cross-origin (or was b locked).");
31 if (expectBlock) {
32 testPassed("The IFrame should have been blocked (or cross-origin ). It was.");
33 failed = false;
34 } else {
35 testFailed("The IFrame should not have been blocked. It was.");
36 failed = true;
37 }
38 }
39 finishJSTest();
40 };
41 }
42
43 function injectFrameRedirectingTo(url, shouldBlock) {
44 injectFrame("/security/contentSecurityPolicy/resources/redir.php?url=" + url , shouldBlock);
45 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698