summaryrefslogtreecommitdiffstats
path: root/LayoutTests/http/tests/appcache/update-cache.html
diff options
context:
space:
mode:
Diffstat (limited to 'LayoutTests/http/tests/appcache/update-cache.html')
-rw-r--r--LayoutTests/http/tests/appcache/update-cache.html69
1 files changed, 69 insertions, 0 deletions
diff --git a/LayoutTests/http/tests/appcache/update-cache.html b/LayoutTests/http/tests/appcache/update-cache.html
new file mode 100644
index 0000000..dd48b01
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/update-cache.html
@@ -0,0 +1,69 @@
+<html manifest="resources/versioned-manifest.php">
+<body>
+<p>Test a simple offline application self-update process. Should print a series of messages followed with DONE:</p>
+<div id=result></div>
+
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function modifyManifest()
+{
+ var req = new XMLHttpRequest;
+ req.open("GET", "resources/versioned-manifest.php?command=step", false);
+ req.send(false);
+}
+
+function test()
+{
+ modifyManifest();
+
+ applicationCache.oncached = function() { log("FAIL: Unexpected cached event") }
+ applicationCache.onnoupdate = function() { log("FAIL: Unexpected noupdate event") }
+ applicationCache.onupdateready = function() { setTimeout(test2, 0) }
+
+ log("Updating cache group...");
+ setTimeout("applicationCache.update()", 0);
+}
+
+function test2()
+{
+ log((applicationCache.status == applicationCache.UPDATEREADY) ? "Cache status is UPDATEREADY" : ("FAIL: Incorrect cache status, " + applicationCache.status));
+
+ modifyManifest();
+ applicationCache.onupdateready = function() { setTimeout(test3, 0) }
+
+ log("Updating cache group once more...");
+ setTimeout("applicationCache.update()", 0);
+}
+
+function test3()
+{
+ log((applicationCache.status == applicationCache.UPDATEREADY) ? "Cache status is UPDATEREADY" : ("FAIL: Incorrect cache status, " + applicationCache.status));
+
+ log("Associating document with the newest cache version...");
+ applicationCache.swapCache();
+
+ log((applicationCache.status == applicationCache.IDLE) ? "Cache status is IDLE" : ("FAIL: Incorrect cache status, " + applicationCache.status));
+
+ log("DONE");
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+applicationCache.oncached = test;
+applicationCache.onnoupdate = test;
+applicationCache.onupdateready = function() { log("FAIL: Unexpected updateready event") }
+applicationCache.onerror = function() { log("FAIL: Unexpected error event") }
+applicationCache.onobsolete = function() { log("FAIL: Unexpected obsolete event") }
+
+</script>
+</body>
+</html>