navigated-away.html (1233B)
1 <!DOCTYPE html> 2 <head> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 </head> 6 <body> 7 <iframe id="if" src="about:blank"></iframe> 8 <script> 9 var t = async_test("document.cookie behavior on documents without browser context"); 10 t.add_cleanup(function() { 11 document.cookie = "nav_away_test=yes;max-age=0"; 12 }); 13 14 function step2() { 15 t.step(function() { 16 // Get from saved doc should fail. 17 assert_equals(window.iframeDoc.cookie, ""); 18 19 // Try set from saved doc, should do nothing. 20 window.iframeDoc.cookie = "nav_away_test=second"; 21 assert_equals(window.iframeDoc.cookie, ""); 22 assert_not_equals(document.cookie.indexOf("nav_away_test=yes"), -1); 23 }); 24 t.done(); 25 } 26 27 t.step(function() { 28 document.cookie = "nav_away_test=yes"; 29 var iframe = document.getElementById("if"); 30 // Save original document. 31 window.iframeDoc = iframe.contentDocument; 32 assert_not_equals(window.iframeDoc.cookie.indexOf("nav_away_test=yes"), -1); 33 34 // Navigate away. 35 iframe.onload = step2; 36 iframe.contentWindow.location = "/common/blank.html"; 37 }) 38 </script> 39 </body>