1 <html> 2 <body> 3 <p>Test that offline applications work when there is no network access (simulated).</p> 4 <p>Should say SUCCESS:</p> 5 <div id=result></div> 6 7 <script> 8 if (window.layoutTestController) { 9 layoutTestController.dumpAsText(); 10 layoutTestController.waitUntilDone(); 11 } 12 13 function log(message) 14 { 15 document.getElementById("result").innerHTML += message + "<br>"; 16 } 17 18 function setNetworkEnabled(state) 19 { 20 var req = new XMLHttpRequest; 21 req.open("GET", "/resources/network-simulator.php?command=" + (state ? "connect" : "disconnect"), false); 22 req.send(""); 23 } 24 25 function createFrame() 26 { 27 var ifr = document.createElement("iframe"); 28 ifr.setAttribute("src", "/resources/network-simulator.php?path=/appcache/resources/offline-access-frame.html"); 29 document.body.appendChild(ifr); 30 } 31 32 function frameCreated() 33 { 34 if (stage == 0) { 35 stage = 1; 36 setNetworkEnabled(false); 37 createFrame(); 38 } else if (stage == 1) { 39 stage = 2; 40 setNetworkEnabled(true); 41 createFrame(); 42 } else { 43 log("SUCCESS"); 44 if (window.layoutTestController) 45 layoutTestController.notifyDone() 46 } 47 } 48 49 window.addEventListener("message", frameCreated, false); 50 51 var stage = 0; 52 setNetworkEnabled(true); 53 createFrame(); 54 55 </script> 56 </body> 57 </html> 58