1 <html manifest="resources/versioned-manifest.php"> 2 <body> 3 <p>Test a simple offline application self-update process. Should print a series of messages followed with DONE:</p> 4 <div id=result></div> 5 6 <script> 7 if (window.layoutTestController) { 8 layoutTestController.dumpAsText(); 9 layoutTestController.waitUntilDone(); 10 } 11 12 function log(message) 13 { 14 document.getElementById("result").innerHTML += message + "<br>"; 15 } 16 17 function modifyManifest() 18 { 19 var req = new XMLHttpRequest; 20 req.open("GET", "resources/versioned-manifest.php?command=step", false); 21 req.send(false); 22 } 23 24 function test() 25 { 26 modifyManifest(); 27 28 applicationCache.oncached = function() { log("FAIL: Unexpected cached event") } 29 applicationCache.onnoupdate = function() { log("FAIL: Unexpected noupdate event") } 30 applicationCache.onupdateready = function() { setTimeout(test2, 0) } 31 32 log("Updating cache group..."); 33 setTimeout("applicationCache.update()", 0); 34 } 35 36 function test2() 37 { 38 log((applicationCache.status == applicationCache.UPDATEREADY) ? "Cache status is UPDATEREADY" : ("FAIL: Incorrect cache status, " + applicationCache.status)); 39 40 modifyManifest(); 41 applicationCache.onupdateready = function() { setTimeout(test3, 0) } 42 43 log("Updating cache group once more..."); 44 setTimeout("applicationCache.update()", 0); 45 } 46 47 function test3() 48 { 49 log((applicationCache.status == applicationCache.UPDATEREADY) ? "Cache status is UPDATEREADY" : ("FAIL: Incorrect cache status, " + applicationCache.status)); 50 51 log("Associating document with the newest cache version..."); 52 applicationCache.swapCache(); 53 54 log((applicationCache.status == applicationCache.IDLE) ? "Cache status is IDLE" : ("FAIL: Incorrect cache status, " + applicationCache.status)); 55 56 log("DONE"); 57 if (window.layoutTestController) 58 layoutTestController.notifyDone(); 59 } 60 61 applicationCache.oncached = test; 62 applicationCache.onnoupdate = test; 63 applicationCache.onupdateready = function() { log("FAIL: Unexpected updateready event") } 64 applicationCache.onerror = function() { log("FAIL: Unexpected error event") } 65 applicationCache.onobsolete = function() { log("FAIL: Unexpected obsolete event") } 66 67 </script> 68 </body> 69 </html> 70