summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/ajax/offline/test_simpleManifest.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/tests/mochitest/ajax/offline/test_simpleManifest.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/tests/mochitest/ajax/offline/test_simpleManifest.html')
-rw-r--r--dom/tests/mochitest/ajax/offline/test_simpleManifest.html130
1 files changed, 130 insertions, 0 deletions
diff --git a/dom/tests/mochitest/ajax/offline/test_simpleManifest.html b/dom/tests/mochitest/ajax/offline/test_simpleManifest.html
new file mode 100644
index 000000000..508bcb516
--- /dev/null
+++ b/dom/tests/mochitest/ajax/offline/test_simpleManifest.html
@@ -0,0 +1,130 @@
+<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest">
+<head>
+<title>simple manifest test</title>
+
+<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+<script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
+<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+
+<script type="text/javascript">
+
+var gGotChecking = false;
+var gGotDownloading = false;
+
+ok(applicationCache.mozItems.length == 0,
+ "applicationCache.mozItems should be available and empty before associating with a cache.");
+
+function addFinished()
+{
+ OfflineTest.ok(applicationCache.mozLength == 1, "applicationCache should have one dynamic entry (deprecated API)");
+ OfflineTest.ok(applicationCache.mozItem(0) == "http://mochi.test:8888/tests/SimpleTest/EventUtils.js",
+ "applicationCache's dynamic entry should be the one we expect (deprecated API)");
+
+ OfflineTest.ok(applicationCache.mozItems.length == 1, "applicationCache should have one dynamic entry");
+ OfflineTest.ok(applicationCache.mozItems[0] == "http://mochi.test:8888/tests/SimpleTest/EventUtils.js",
+ "applicationCache's dynamic entry should be the one we expect");
+
+ OfflineTest.ok(applicationCache.mozHasItem("http://mochi.test:8888/tests/SimpleTest/EventUtils.js"),
+ "applicationCache.mozHasItem() should see the dynamic entry");
+
+ // Check that the entry was added successfully
+ OfflineTest.checkCache("http://mochi.test:8888/tests/SimpleTest/EventUtils.js",
+ true,
+ removeItem);
+}
+
+function removeItem()
+{
+ // Now test that removes work
+ applicationCache.mozRemove("http://mochi.test:8888/tests/SimpleTest/EventUtils.js");
+
+ OfflineTest.ok(applicationCache.mozLength == 0,
+ "applicationCache should have no dynamic entries (deprecated API)");
+ OfflineTest.ok(applicationCache.mozItems.length == 0,
+ "applicationCache should have no dynamic entries");
+ OfflineTest.ok(!applicationCache.mozHasItem("http://mochi.test:8888/tests/SimpleTest/EventUtils.js"),
+ "applicationCache.mozHasItem() should not see the removed dynamic entry");
+
+ OfflineTest.checkCache("http://mochi.test:8888/tests/SimpleTest/EventUtils.js",
+ false,
+ function() {
+ // We're done
+ OfflineTest.teardownAndFinish();
+ });
+}
+
+function manifestUpdated()
+{
+ OfflineTest.ok(gGotChecking, "Should get a checking event");
+ OfflineTest.ok(gGotDownloading, "Should get a downloading event");
+
+ OfflineTest.is(applicationCache.status, 1, "Cache status should be 1 (CACHED)");
+
+ var entries = [
+ // The manifest itself should be in the cache
+ ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest", true],
+
+ // The document that requested the manifest should be in the cache
+ [window.location.href, true],
+
+ // The entries from the manifest should be in the cache
+ ["http://mochi.test:8888/tests/SimpleTest/SimpleTest.js", true],
+ ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", true],
+
+ // The bad entries from the manifest should not be in the cache
+ ["bad:/uri/invalid", false]
+ ];
+ OfflineTest.checkCacheEntries(
+ entries,
+ function() {
+ try {
+ applicationCache.swapCache();
+ OfflineTest.ok(false, "application.swapCache() should fail after initial update.");
+ } catch(ex) {
+ OfflineTest.ok(true, "application.swapCache() should fail after initial update.");
+ }
+
+ // XXX: make sure that the previous version went away after the swapCache().
+
+ // Now add a file using the applicationCache API
+ applicationCache.mozAdd("http://mochi.test:8888/tests/SimpleTest/EventUtils.js");
+
+ // Wait for the add() to be downloaded
+ OfflineTest.waitForAdd("http://mochi.test:8888/tests/SimpleTest/EventUtils.js",
+ OfflineTest.priv(addFinished));
+ });
+}
+
+if (OfflineTest.setup()) {
+ OfflineTest.ok(applicationCache instanceof EventTarget,
+ "applicationCache should be an event target");
+
+ applicationCache.onerror = OfflineTest.failEvent;
+
+ applicationCache.addEventListener("checking", function() {
+ // We should get the "checking" event during an initial update,
+ // but until we are associated it will not affect applicationCache.status
+ OfflineTest.is(applicationCache.status, applicationCache.UNCACHED,
+ "CHECKING state during initial update");
+ gGotChecking = true;
+ }, true);
+ applicationCache.ondownloading = function() {
+ // We should get the "downloading" event during an initial update,
+ // but until we are associated it will not affect applicationCache.status
+ OfflineTest.is(applicationCache.status, applicationCache.UNCACHED,
+ "DOWNLOADING state during initial update")
+ gGotDownloading = true; };
+ applicationCache.oncached = OfflineTest.priv(manifestUpdated);
+}
+
+SimpleTest.waitForExplicitFinish();
+SimpleTest.requestFlakyTimeout("untriaged");
+
+</script>
+
+</head>
+
+<body>
+
+</body>
+</html>