dom/tests/mochitest/ajax/offline/test_cancelOfflineCache.html

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:a672d9376d81
1 <html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest">
2 <head>
3 <title>Cancel offline cache</title>
4
5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
6 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
8
9 <script type="text/javascript">
10
11 var manifest = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest";
12 var manifestURI = Cc["@mozilla.org/network/io-service;1"]
13 .getService(Ci.nsIIOService)
14 .newURI(manifest, null, null);
15 var updateService = Cc['@mozilla.org/offlinecacheupdate-service;1']
16 .getService(Ci.nsIOfflineCacheUpdateService);
17
18 function manifestCached () {
19 OfflineTest.ok(false, "The update was supposed to be canceled");
20
21 OfflineTest.teardownAndFinish();
22 }
23
24 function onError () {
25 OfflineTest.ok(true, "Expected error: Update canceled");
26
27 OfflineTest.teardownAndFinish();
28 }
29
30 function onProgress () {
31 var i = 0;
32 while (i < updateService.numUpdates) {
33 var update = updateService.getUpdate(i);
34 if (update.manifestURI.spec == manifestURI.spec) {
35 update.cancel();
36 return;
37 }
38 i++;
39 }
40 }
41
42 if (OfflineTest.setup()) {
43 applicationCache.onerror = OfflineTest.priv(onError);
44 applicationCache.onnoupdate = OfflineTest.failEvent;
45 applicationCache.onprogress = OfflineTest.priv(onProgress);
46 applicationCache.oncached = OfflineTest.priv(manifestCached);
47 }
48
49 SimpleTest.waitForExplicitFinish();
50
51 </script>
52
53 </head>
54
55 <body>
56
57 </body>
58 </html>

mercurial