summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/ajax/offline/test_bug460353.html
diff options
context:
space:
mode:
Diffstat (limited to 'dom/tests/mochitest/ajax/offline/test_bug460353.html')
-rw-r--r--dom/tests/mochitest/ajax/offline/test_bug460353.html100
1 files changed, 100 insertions, 0 deletions
diff --git a/dom/tests/mochitest/ajax/offline/test_bug460353.html b/dom/tests/mochitest/ajax/offline/test_bug460353.html
new file mode 100644
index 000000000..683d53d6a
--- /dev/null
+++ b/dom/tests/mochitest/ajax/offline/test_bug460353.html
@@ -0,0 +1,100 @@
+<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest">
+<head>
+<title>Bug 460353</title>
+
+<!--
+ This test checks that each iframe creates its own
+ scope. Actually, we just check that it loads and updates
+ its associated cache. There is no check that the cache is the
+ expected one, there is no API to gain that information.
+-->
+
+<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+<script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
+
+<script class="testbody" type="text/javascript">
+
+var result = new Array();
+var expectedUpdates = 3; // 2 iframes and our self
+
+applicationCache.oncached = onUpdatePassed;
+applicationCache.onnoupdate = onUpdatePassed;
+
+SpecialPowers.pushPermissions([{'type': 'offline-app', 'allow': true, 'context': document}], init);
+
+function onUpdatePassed()
+{
+ if (!(--expectedUpdates))
+ SimpleTest.executeSoon(finish);
+}
+
+function init()
+{
+ var iframes = document.getElementsByTagName('iframe');
+ iframes[0].src = "460353_iframe_nomanifest.html";
+ iframes[1].src = "460353_iframe_ownmanifest.html";
+ iframes[2].src = "460353_iframe_samemanifest.html";
+}
+
+function frameOnLoad(frameid, status)
+{
+ var obj = new Object();
+ result[frameid] = obj;
+
+ result[frameid].load = true;
+ result[frameid].cacheStatus = status;
+}
+
+function frameOnUpdate(frameid, ok, status)
+{
+ result[frameid].update = true;
+ result[frameid].updateOK = ok;
+ result[frameid].cacheStatus = status;
+
+ onUpdatePassed();
+}
+
+function finish()
+{
+ SimpleTest.ok(result["same"].load || false, "Frame with the same manifest loads");
+ SimpleTest.ok(result["same"].update || false, "Frame with the same manifest cache update notification");
+ SimpleTest.ok(result["same"].updateOK || false, "Frame with the same manifest cache update passed OK");
+ SimpleTest.is(result["same"].cacheStatus || -1, 1, "Frame with the same manifest cache status was IDLE");
+
+ SimpleTest.ok(result["diff"].load || false, "Frame with different manifest loads");
+ SimpleTest.ok(result["diff"].update || false, "Frame with different manifest cache update notification");
+ SimpleTest.ok(result["diff"].updateOK || false, "Frame with different manifest cache update passed OK");
+ SimpleTest.is(result["diff"].cacheStatus || -1, 1, "Frame with different manifest cache status was IDLE");
+
+ SimpleTest.ok(result["noman"].load || false, "Frame with no manifest loads");
+ SimpleTest.ok(result["noman"].update == undefined, "Frame with no manifest cache update didn't notify");
+ SimpleTest.ok(result["noman"].updateOK == undefined, "Frame with no manifest cache update didn't pass");
+ SimpleTest.is(result["noman"].cacheStatus || -1, -1, "Frame with no manifest cache status was undefined");
+
+ OfflineTest.waitForUpdates(function() {
+ cleanCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest");
+ cleanCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingManifest.sjs");
+
+ SimpleTest.finish();
+ });
+}
+
+function cleanCache(manifestURL)
+{
+ var cache = OfflineTest.getActiveCache(manifestURL);
+ dump("Discarding cache for " + manifestURL + " cache=" + cache + "\n");
+ if (cache)
+ cache.discard();
+}
+
+SimpleTest.waitForExplicitFinish();
+
+</script>
+
+<body>
+ <iframe></iframe>
+ <iframe></iframe>
+ <iframe></iframe>
+</body>
+</html>