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

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:2c32445a8692
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>Low device storage during update</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 /**
12 * This test checks that an offline cache update is canceled when a low device
13 * storage condition is detected during the update.
14 */
15
16 var updateService = Cc['@mozilla.org/offlinecacheupdate-service;1']
17 .getService(Ci.nsIOfflineCacheUpdateService);
18
19 var obs = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
20 .getService(SpecialPowers.Ci.nsIObserverService);
21
22 function finish() {
23 obs.notifyObservers(updateService, "disk-space-watcher", "free");
24
25 OfflineTest.teardownAndFinish();
26 }
27
28 function onError() {
29 OfflineTest.ok(true, "Expected error: Update canceled");
30 finish();
31 }
32
33 function onUnexpectedEvent() {
34 OfflineTest.ok(false, "The update was supposed to be canceled");
35 finish();
36 }
37
38 function onChecking() {
39 obs.notifyObservers(updateService, "disk-space-watcher", "full");
40 }
41
42 if (OfflineTest.setup()) {
43 applicationCache.onerror = OfflineTest.priv(onError);
44 applicationCache.onprogress = OfflineTest.priv(onUnexpectedEvent);
45 applicationCache.oncached = OfflineTest.priv(onUnexpectedEvent);
46 applicationCache.onchecking = OfflineTest.priv(onChecking);
47 }
48
49 SimpleTest.waitForExplicitFinish();
50
51 </script>
52
53 </head>
54
55 <body>
56
57 </body>
58 </html>

mercurial