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

Unified Diff: LayoutTests/http/tests/xmlhttprequest/access-control-preflight-request-must-not-contain-cookie.html

Issue 312653002: ResourceLoaderOptions also must be updated by updateRequestForAccessControl() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed #5 Created 6 years, 6 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: LayoutTests/http/tests/xmlhttprequest/access-control-preflight-request-must-not-contain-cookie.html
diff --git a/LayoutTests/http/tests/xmlhttprequest/access-control-preflight-request-must-not-contain-cookie.html b/LayoutTests/http/tests/xmlhttprequest/access-control-preflight-request-must-not-contain-cookie.html
new file mode 100644
index 0000000000000000000000000000000000000000..d1be954674d558e5919b5582ce54365eb894816c
--- /dev/null
+++ b/LayoutTests/http/tests/xmlhttprequest/access-control-preflight-request-must-not-contain-cookie.html
@@ -0,0 +1,77 @@
+<html>
+<head>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script>
+var t = async_test("Preflight request must not contain any cookie header");
+var runTest = t.step_func(function()
+{
+ var resolveSetCookiePromise = null;
+ var setCookiePromise = new Promise(function(resolve, reject)
+ {
+ resolveSetCookiePromise = resolve;
+ });
+
+ var resolveClearCookiesPromise = null;
+ var clearCookiesPromise = new Promise(function(resolve, reject)
+ {
+ resolveClearCookiesPromise = resolve;
+ });
+
+ var cookieSet = false;
+
+ window.onmessage = t.step_func(function(evt)
+ {
+ assert_equals(evt.data, "done");
+
+ if (!cookieSet) {
+ resolveSetCookiePromise();
+ cookieSet = true;
+ } else {
+ resolveClearCookiesPromise();
+ }
+ });
+
+ // Set a cookie for localhost:8000.
+ window.frames[0].postMessage("sendXHR setFooCookie", "*");
+
+ setCookiePromise.then(t.step_func(function()
+ {
+ var xhr = new XMLHttpRequest;
+ xhr.open("GET", "http://localhost:8000/xmlhttprequest/resources/access-control-preflight-request-must-not-contain-cookie.php");
+ xhr.setRequestHeader("X-Proprietary-Header", "foo")
+ xhr.withCredentials = true;
+ xhr.onerror = t.step_func(function (e) {
+ assert_unreached(e);
+ });
+ var doneXHRPromise = new Promise(function(resolve, reject)
+ {
+ xhr.onreadystatechange = t.step_func(function () {
+ if (xhr.readyState != xhr.DONE)
+ return;
+ assert_equals(xhr.status, 200);
+ assert_equals(xhr.responseText, "awesomevalue");
+ resolve();
+ });
+ });
+ xhr.send();
+ return doneXHRPromise;
+ })).then(t.step_func(function()
+ {
+ // Clean up all cookies for localhost:8000.
+ window.frames[0].postMessage("resetCookiesAndNotifyDone", "*");
+ return resolveClearCookiesPromise;
+ })).then(t.step_func(function()
+ {
+ t.done();
+ })).catch(t.step_func(function(e)
+ {
+ assert_unreached(e);
+ }));
+});
+</script>
+</head>
+<body onload="runTest()">
+<iframe src="http://localhost:8000/cookies/resources/third-party-cookie-relaxing-iframe.html"></iframe>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698