summaryrefslogtreecommitdiffstats
path: root/LayoutTests/http/tests/appcache/offline-access.html
diff options
context:
space:
mode:
Diffstat (limited to 'LayoutTests/http/tests/appcache/offline-access.html')
-rw-r--r--LayoutTests/http/tests/appcache/offline-access.html57
1 files changed, 57 insertions, 0 deletions
diff --git a/LayoutTests/http/tests/appcache/offline-access.html b/LayoutTests/http/tests/appcache/offline-access.html
new file mode 100644
index 0000000..45e9d4e
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/offline-access.html
@@ -0,0 +1,57 @@
+<html>
+<body>
+<p>Test that offline applications work when there is no network access (simulated).</p>
+<p>Should say SUCCESS:</p>
+<div id=result></div>
+
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function setNetworkEnabled(state)
+{
+ var req = new XMLHttpRequest;
+ req.open("GET", "/resources/network-simulator.php?command=" + (state ? "connect" : "disconnect"), false);
+ req.send("");
+}
+
+function createFrame()
+{
+ var ifr = document.createElement("iframe");
+ ifr.setAttribute("src", "/resources/network-simulator.php?path=/appcache/resources/offline-access-frame.html");
+ document.body.appendChild(ifr);
+}
+
+function frameCreated()
+{
+ if (stage == 0) {
+ stage = 1;
+ setNetworkEnabled(false);
+ createFrame();
+ } else if (stage == 1) {
+ stage = 2;
+ setNetworkEnabled(true);
+ createFrame();
+ } else {
+ log("SUCCESS");
+ if (window.layoutTestController)
+ layoutTestController.notifyDone()
+ }
+}
+
+window.addEventListener("message", frameCreated, false);
+
+var stage = 0;
+setNetworkEnabled(true);
+createFrame();
+
+</script>
+</body>
+</html>