set-from-dom.https.sub.html (1581B)
1 <!doctype html> 2 <html> 3 <head> 4 <meta charset=utf-8> 5 <title>Set 'secure' cookie from `document.cookie` on a secure page</title> 6 <meta name=help href="https://tools.ietf.org/html/draft-west-leave-secure-cookies-alone"> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="/cookies/resources/testharness-helpers.js"></script> 10 </head> 11 <body> 12 <div id=log></div> 13 <script> 14 var tests = [ 15 [ 16 "'secure' cookie visible in `document.cookie`", 17 function () { 18 document.cookie = "secure_from_secure_dom=1; secure; path=/"; 19 assert_not_equals(document.cookie.match(/secure_from_secure_dom=1/), null); 20 this.done(); 21 } 22 ], 23 [ 24 "'secure' cookie visible in HTTP request", 25 function () { 26 document.cookie = "secure_from_secure_dom=1; secure; path=/"; 27 assert_not_equals(document.cookie.match(/secure_from_secure_dom=1/), null); 28 fetch("https://{{host}}:{{ports[https][0]}}/cookies/resources/echo-json.py", 29 { "credentials": "include" }) 30 .then(this.step_func(function (r) { 31 return r.json(); 32 })) 33 .then(this.step_func_done(function (j) { 34 assert_equals(j["secure_from_secure_dom"], "secure_from_secure_dom=1"); 35 })); 36 } 37 ] 38 ]; 39 40 function clearKnownCookie() { 41 document.cookie = "secure_from_secure_dom=0; Secure; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/"; 42 } 43 44 executeTestsSerially(tests, clearKnownCookie, clearKnownCookie); 45 </script> 46 </body> 47 </html>