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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/resources/child-src-test.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/resources/child-src-test.js b/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/resources/child-src-test.js
index 83b58852ae8a8f389c0eee611c4cb76113f797d7..4168dcdf682edd4cad86eda7609fd016749fc607 100644
--- a/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/resources/child-src-test.js
+++ b/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/resources/child-src-test.js
@@ -1,6 +1,9 @@
var EXPECT_BLOCK = true;
var EXPECT_LOAD = false;
+var SAME_ORIGIN = true;
+var CROSS_ORIGIN = false;
+
window.jsTestIsAsync = true;
window.wasPostTestScriptParsed = true;
@@ -63,3 +66,27 @@ function injectSharedWorker(url, expectBlock) {
finishJSTest();
};
}
+
+function injectFrameWithCSP(url, csp, shouldBlock, sameOrigin) {
+ window.onload = function () {
+ iframe = document.createElement('iframe');
+ if (shouldBlock == EXPECT_LOAD && sameOrigin == CROSS_ORIGIN) {
+ window.addEventListener("message", function (e) {
+ if (e.source != iframe.contentWindow) {
+ return;
+ }
+ if (e.data != 'loaded')
+ testFailed("The inner IFrame failed.");
+ else
+ testPassed("The inner IFrame passed.");
+
+ finishJSTest();
+ });
+ } else {
+ iframe.onload = iframeLoaded(shouldBlock);
+ }
+ iframe.src = url;
+ iframe.csp = csp;
+ document.body.appendChild(iframe);
+ };
+}

Powered by Google App Engine
This is Rietveld 408576698