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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/security/cors-rfc1918/internal-to-internal-xhr.html

Issue 1745083002: CORS-RFC1918: Force preflights for external requests in DocumentThreadableLoader. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test. Created 4 years, 8 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/cors-rfc1918/internal-to-internal-xhr.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/cors-rfc1918/internal-to-internal-xhr.html b/third_party/WebKit/LayoutTests/http/tests/security/cors-rfc1918/internal-to-internal-xhr.html
new file mode 100644
index 0000000000000000000000000000000000000000..0df845f7411980448b0a3d149254d2092e1b7d06
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/security/cors-rfc1918/internal-to-internal-xhr.html
@@ -0,0 +1,49 @@
+<!doctype html>
+<html>
+<head>
+ <!-- No 'treat-as-public-address' CSP directive, so we count as internal. -->
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="./resources/preflight.js"></script>
+</head>
+<body>
+ <script>
+ async_test(function (t) {
+ var xhr = new XMLHttpRequest;
+ xhr.responseType = "json";
+ xhr.onload = t.step_func_done(function (e) {
+ assert_equals('success', xhr.response.jsonpResult);
+ });
+ xhr.onerror = t.unreached_func("The load should not fail.");
+
+ xhr.open("GET", preflightURL('fail-with-500', 'json'), true);
+ xhr.send();
+ }, "XHR should pass on failed preflight (because no preflight is sent)");
+
+ async_test(function (t) {
+ var xhr = new XMLHttpRequest;
+ xhr.responseType = "json";
+ xhr.onload = t.step_func_done(function (e) {
+ assert_equals('success', xhr.response.jsonpResult);
+ });
+ xhr.onerror = t.unreached_func("The load should not fail.");
+
+ xhr.open("GET", preflightURL('fail-without-allow', 'json'), true);
+ xhr.send();
+ }, "XHR should pass on failed preflight (because no preflight is sent)");
+
+
+ async_test(function (t) {
+ var xhr = new XMLHttpRequest;
+ xhr.responseType = "json";
+ xhr.onload = t.step_func_done(function (e) {
+ assert_equals('success', xhr.response.jsonpResult);
+ });
+ xhr.onerror = t.unreached_func("The load should not fail.");
+
+ xhr.open("GET", preflightURL('pass', 'json'), true);
+ xhr.send();
+ }, "XHR should pass on successful preflight");
+ </script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698