3 <script src=
"../resources/testharness.js"></script>
4 <script src=
"../resources/testharnessreport.js"></script>
6 var t
= async_test("Preflight request must not contain any cookie header");
7 var runTest
= t
.step_func(function()
9 var resolveSetCookiePromise
= null;
10 var setCookiePromise
= new Promise(function(resolve
, reject
)
12 resolveSetCookiePromise
= resolve
;
15 var resolveClearCookiesPromise
= null;
16 var clearCookiesPromise
= new Promise(function(resolve
, reject
)
18 resolveClearCookiesPromise
= resolve
;
21 var cookieSet
= false;
23 window
.onmessage
= t
.step_func(function(evt
)
25 assert_equals(evt
.data
, "done");
28 resolveSetCookiePromise();
31 resolveClearCookiesPromise();
35 // Set a cookie for localhost:8000.
36 window
.frames
[0].postMessage("sendXHR setFooCookie", "*");
38 setCookiePromise
.then(t
.step_func(function()
40 var xhr
= new XMLHttpRequest
;
41 xhr
.open("GET", "http://localhost:8000/xmlhttprequest/resources/access-control-preflight-request-must-not-contain-cookie.php");
42 xhr
.setRequestHeader("X-Proprietary-Header", "foo")
43 xhr
.withCredentials
= true;
44 xhr
.onerror
= t
.step_func(function (e
) {
47 var doneXHRPromise
= new Promise(function(resolve
, reject
)
49 xhr
.onreadystatechange
= t
.step_func(function () {
50 if (xhr
.readyState
!= xhr
.DONE
)
52 assert_equals(xhr
.status
, 200);
53 assert_equals(xhr
.responseText
, "awesomevalue");
58 return doneXHRPromise
;
59 })).then(t
.step_func(function()
61 // Clean up all cookies for localhost:8000.
62 window
.frames
[0].postMessage("resetCookiesAndNotifyDone", "*");
63 return resolveClearCookiesPromise
;
64 })).then(t
.step_func(function()
67 })).catch(t
.step_func(function(e
)
74 <body onload=
"runTest()">
75 <iframe src=
"http://localhost:8000/cookies/resources/third-party-cookie-relaxing-iframe.html"></iframe>