1 <html> 2 <script src="resetCookies.js"></script> 3 <script> 4 resetCookies(); 5 6 if (window.layoutTestController) 7 layoutTestController.dumpAsText(); 8 9 window.onmessage = function(evt) 10 { 11 if (evt.data == "showCookies") { 12 showCookies(); 13 return; 14 } else if (evt.data.split(" ")[0] == "sendXHR") { 15 sendXHR(evt.data.split(" ")[1]); 16 return; 17 } else if (evt.data == "resetCookiesAndNotifyDone") { 18 resetCookiesAndNotifyDone(); 19 return; 20 } else 21 alert("Unknown message."); 22 } 23 24 var stage = 1; 25 function showCookies() 26 { 27 alert("Test stage " + stage++ + " document.cookie is: " + document.cookie); 28 parent.window.postMessage("done", "*"); 29 } 30 31 function sendXHR(queryCommand) 32 { 33 var baseurl = "http://localhost:8000/cookies/resources/cookie-utility.php"; 34 var url = queryCommand ? baseurl + "?queryfunction=" + queryCommand : baseurl; 35 alert(url); 36 var req = new XMLHttpRequest(); 37 req.open('GET', url, false); 38 req.send(); 39 40 if (req.status == 200) 41 alert("XHR response - " + req.responseText); 42 else 43 alert("xhr error"); 44 45 parent.window.postMessage("done", "*"); 46 } 47 48 function resetCookiesAndNotifyDone() 49 { 50 resetCookies(); 51 if (window.layoutTestController) 52 layoutTestController.notifyDone(); 53 } 54 55 </script> 56 <body> 57 HELLO THERE 58 </body> 59 </html> 60