OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <head> |
| 3 <script src="../resources/testharness.js"></script> |
| 4 <script src="../resources/testharnessreport.js"></script> |
| 5 <script> |
| 6 var t = async_test("Preflight request must not contain any cookie header"); |
| 7 var runTest = t.step_func(function() |
| 8 { |
| 9 var resolveSetCookiePromise = null; |
| 10 var setCookiePromise = new Promise(function(resolve, reject) |
| 11 { |
| 12 resolveSetCookiePromise = resolve; |
| 13 }); |
| 14 |
| 15 var resolveClearCookiesPromise = null; |
| 16 var clearCookiesPromise = new Promise(function(resolve, reject) |
| 17 { |
| 18 resolveClearCookiesPromise = resolve; |
| 19 }); |
| 20 |
| 21 var cookieSet = false; |
| 22 |
| 23 window.onmessage = t.step_func(function(evt) |
| 24 { |
| 25 assert_equals(evt.data, "done"); |
| 26 |
| 27 if (!cookieSet) { |
| 28 resolveSetCookiePromise(); |
| 29 cookieSet = true; |
| 30 } else { |
| 31 resolveClearCookiesPromise(); |
| 32 } |
| 33 }); |
| 34 |
| 35 // Set a cookie for localhost:8000. |
| 36 window.frames[0].postMessage("sendXHR setFooCookie", "*"); |
| 37 |
| 38 setCookiePromise.then(t.step_func(function() |
| 39 { |
| 40 var xhr = new XMLHttpRequest; |
| 41 xhr.open("GET", "http://localhost:8000/xmlhttprequest/resources/access-c
ontrol-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) { |
| 45 assert_unreached(e); |
| 46 }); |
| 47 var doneXHRPromise = new Promise(function(resolve, reject) |
| 48 { |
| 49 xhr.onreadystatechange = t.step_func(function () { |
| 50 if (xhr.readyState != xhr.DONE) |
| 51 return; |
| 52 assert_equals(xhr.status, 200); |
| 53 assert_equals(xhr.responseText, "awesomevalue"); |
| 54 resolve(); |
| 55 }); |
| 56 }); |
| 57 xhr.send(); |
| 58 return doneXHRPromise; |
| 59 })).then(t.step_func(function() |
| 60 { |
| 61 // Clean up all cookies for localhost:8000. |
| 62 window.frames[0].postMessage("resetCookiesAndNotifyDone", "*"); |
| 63 return resolveClearCookiesPromise; |
| 64 })).then(t.step_func(function() |
| 65 { |
| 66 t.done(); |
| 67 })).catch(t.step_func(function(e) |
| 68 { |
| 69 assert_unreached(e); |
| 70 })); |
| 71 }); |
| 72 </script> |
| 73 </head> |
| 74 <body onload="runTest()"> |
| 75 <iframe src="http://localhost:8000/cookies/resources/third-party-cookie-relaxing
-iframe.html"></iframe> |
| 76 </body> |
| 77 </html> |
OLD | NEW |