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

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

Issue 2404373003: Experimental Feature: Allow-CSP-From header (Closed)
Patch Set: Without all those style changes Created 4 years, 2 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
1 var EXPECT_BLOCK = true; 1 var EXPECT_BLOCK = true;
2 var EXPECT_LOAD = false; 2 var EXPECT_LOAD = false;
3 3
4 var SAME_ORIGIN = true;
5 var CROSS_ORIGIN = false;
6
4 window.jsTestIsAsync = true; 7 window.jsTestIsAsync = true;
5 window.wasPostTestScriptParsed = true; 8 window.wasPostTestScriptParsed = true;
6 9
7 var iframe; 10 var iframe;
8 function injectFrame(url, shouldBlock) { 11 function injectFrame(url, shouldBlock) {
9 window.onload = function () { 12 window.onload = function () {
10 iframe = document.createElement('iframe'); 13 iframe = document.createElement('iframe');
11 iframe.onload = iframeLoaded(shouldBlock); 14 iframe.onload = iframeLoaded(shouldBlock);
12 iframe.src = url; 15 iframe.src = url;
13 document.body.appendChild(iframe); 16 document.body.appendChild(iframe);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 59
57 function injectSharedWorker(url, expectBlock) { 60 function injectSharedWorker(url, expectBlock) {
58 window.onload = function() { 61 window.onload = function() {
59 if (expectBlock == EXPECT_BLOCK) 62 if (expectBlock == EXPECT_BLOCK)
60 shouldThrow("var w = new SharedWorker('" + url + "');"); 63 shouldThrow("var w = new SharedWorker('" + url + "');");
61 else 64 else
62 shouldNotThrow("var w = new SharedWorker('" + url + "');"); 65 shouldNotThrow("var w = new SharedWorker('" + url + "');");
63 finishJSTest(); 66 finishJSTest();
64 }; 67 };
65 } 68 }
69
70 function injectFrameWithCSP(url, csp, shouldBlock, sameOrigin) {
71 window.onload = function () {
72 iframe = document.createElement('iframe');
73 if (shouldBlock == EXPECT_LOAD && sameOrigin == CROSS_ORIGIN) {
74 window.addEventListener("message", function (e) {
75 if (e.source != iframe.contentWindow) {
76 return;
77 }
78 if (e.data != 'loaded')
79 testFailed("The inner IFrame failed.");
80 else
81 testPassed("The inner IFrame passed.");
82
83 finishJSTest();
84 });
85 } else {
86 iframe.onload = iframeLoaded(shouldBlock);
87 }
88 iframe.src = url;
89 iframe.csp = csp;
90 document.body.appendChild(iframe);
91 };
92 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698